Class: Substance

Substance(name, charges, limits, changes, equals, recharges, recycles, replaces, retire, setVals, enables, isMod, compat, assumeMode)

Substance configuration including consumption patterns and lifecycle. Represents a single substance (e.g., HFC-134a, R-410A) used within an application. Contains GWP values, initial charges, consumption/sales streams (domestic, import, export), retirement rates, recharge schedules, and sales assumptions for bank tracking. Sales assumptions control carryover behavior: - "continued": Sales continue from previous year (default, no-op) - "only recharge": New sales limited to servicing existing equipment - "no": All sales reset to zero UI editor supports max 1 assume command for sales stream without duration. Advanced editor supports multiple assumes, durations, and other streams (domestic, import, bank).

Constructor

new Substance(name, charges, limits, changes, equals, recharges, recycles, replaces, retire, setVals, enables, isMod, compat, assumeMode)

Create a new Substance.
Parameters:
Name Type Description
name string Name of the substance.
charges Array.<Command> Initial charge commands.
limits Array.<LimitCommand> Limit commands.
changes Array.<Command> Change commands.
equals Command Equals command.
recharges Array.<Command> Recharge commands.
recycles Array.<Command> Recycle commands.
replaces Array.<ReplaceCommand> Replace commands.
retire Command Retire command.
setVals Array.<Command> Set value commands.
enables Array.<Command> Enable commands.
isMod boolean Whether this modifies existing substance.
compat boolean Whether substance is UI-compatible.
assumeMode string | null Sales assumption mode.
Source:

Methods

getAssumeMode() → {string|null}

Get the sales assumption mode for this substance.
Source:
Returns:
The assumption mode: "continued", "only recharge", "no", or null for default.
Type
string | null

getChanges() → {Array.<Command>}

Get all change commands for this substance.
Source:
Returns:
Array of change commands.
Type
Array.<Command>

getEnables() → {Array.<Command>}

Get all enable commands for this substance.
Source:
Returns:
Array of enable commands.
Type
Array.<Command>

getEqualsGhg() → {Command|null}

Get the GHG equals command for this substance.
Source:
Returns:
The GHG equals command or null if not set.
Type
Command | null

getEqualsKwh() → {Command|null}

Get the energy consumption equals command for this substance.
Source:
Returns:
The energy equals command or null if not set.
Type
Command | null

getInitialCharge(stream) → {Command|null}

Get the initial charge command for a specific stream.
Parameters:
Name Type Description
stream string The stream to get initial charge for.
Source:
Returns:
The initial charge command or null if not found.
Type
Command | null

getInitialCharges() → {Array.<Command>}

Get all initial charge commands for this substance.
Source:
Returns:
Array of initial charge commands.
Type
Array.<Command>

getIsCompatible() → {boolean}

Check if this substance is compatible with UI editing.
Source:
Returns:
True if substance can be edited in UI.
Type
boolean

getIsModification() → {boolean}

Check if this substance modifies an existing one.
Source:
Returns:
True if this modifies an existing substance.
Type
boolean

getLimits() → {Array.<LimitCommand>}

Get all limit commands for this substance.
Source:
Returns:
Array of limit commands.
Type
Array.<LimitCommand>

getMeta(applicationName) → {SubstanceMetadata}

Get metadata representation of this substance for CSV export/import. This method extracts metadata from the current substance structure and creates a SubstanceMetadata instance. The application name is provided as a parameter since it's not stored within the substance itself.
Parameters:
Name Type Description
applicationName string Name of the application this substance belongs to.
Source:
Returns:
Metadata representation of the substance.
Type
SubstanceMetadata

getName() → {string}

Get the name of this substance.
Source:
Returns:
The substance name like HFC-134a.
Type
string

getRecharges() → {Array.<Command>}

Get all recharge commands for this substance.
Source:
Returns:
Array of recharge commands.
Type
Array.<Command>

getRecycles() → {Array.<Command>}

Get all recycle commands for this substance.
Source:
Returns:
Array of recycle commands.
Type
Array.<Command>

getReplaces() → {Array.<ReplaceCommand>}

Get all replace commands for this substance.
Source:
Returns:
Array of replace commands.
Type
Array.<ReplaceCommand>

getRetire() → {Command|null}

Get the retire command for this substance.
Source:
Returns:
The retire command or null if not set.
Type
Command | null

getSetVals() → {Array.<Command>}

Get all set value commands for this substance.
Source:
Returns:
Array of set value commands.
Type
Array.<Command>

rename(newName)

Rename this substance.
Parameters:
Name Type Description
newName string New name for the substance.
Source:

toCode(spaces) → {string}

Generate the code representation of the substance. Translate the substance's properties and commands into their code representation based on the number of spaces specified for the indentation.
Parameters:
Name Type Description
spaces number Number of spaces to use for indentation.
Source:
Returns:
The code representation of the substance.
Type
string

updateMetadata(newMetadata, applicationName)

Update all metadata for this substance using a SubstanceMetadata object.
Parameters:
Name Type Description
newMetadata SubstanceMetadata New metadata to apply to this substance.
applicationName string Name of the application this substance belongs to.
Source: