Network Node Functions
These functions are used for working with network nodes.
| Function | Description |
|---|---|
addNode | Adds a new node to a project. |
deleteNode | Deletes a node from a project. |
getNodeIndex | Gets the index of a node given its ID name. |
getNodeId | Gets the ID name of a node given its index. |
setNodeId | Changes the ID name of a node. |
getNodeType | Retrieves a node’s type given its index. |
getNodeValue | Retrieves a property value for a node. |
setNodeValue | Sets a property value for a node. |
setJunctionData | Sets a group of properties for a junction node. |
setTankData | Sets a group of properties for a tank node. |
getCoordinates | Gets the (x,y) coordinates of a node. |
setCoordinates | Sets the (x,y) coordinates of a node. |
addNode
Section titled “addNode”Adds a new node to a project.
addNode(id: string, nodeType: NodeType): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | the ID name of the node to be added. |
| nodeType | NodeType | the type of node being added (see NodeType) |
Returns
Number
the index of the newly added node
When a new node is created all of its properties (see NodeProperty) are set to 0.
deleteNode
Section titled “deleteNode”Deletes a node from a project.
deleteNode(index: number, actionCode: ActionCodeType): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the index of the node to be deleted. |
| actionCode | ActionCodeType | the action taken if any control contains the node and its links. |
If actionCode is ActionCodeType.Unconditional then the node, its incident links and all simple and rule-based controls that contain them are deleted. If set to ActionCodeType.Conditional then the node is not deleted if it or its incident links appear in any controls and error code 261 is returned.
getNodeIndex
Section titled “getNodeIndex”Gets the index of a node given its ID name.
getNodeIndex(id: string): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | a node ID name. |
Returns
Number
the node’s index (starting from 1).
getNodeId
Section titled “getNodeId”Gets the ID name of a node given its index.
getNodeId(index: number): string;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node’s index (starting from 1). |
Returns
String
the node’s ID name.
setNodeId
Section titled “setNodeId”Changes the ID name of a node.
setNodeId(index: number, newid: string): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node’s index (starting from 1). |
| newid | string | the new ID name for the node. |
getNodeType
Section titled “getNodeType”Retrieves a node’s type given its index.
getNodeType(index: number): NodeType;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node’s index (starting from 1). |
Returns
NodeType
the node’s type (see NodeType).
getNodeValue
Section titled “getNodeValue”Retrieves a property value for a node.
getNodeValue(index: number, property: NodeProperty): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node’s index. |
| property | NodeProperty | the property to retrieve (see NodeProperty). |
Returns
Number
the current value of the property.
Values are returned in units that depend on the units used for flow rate (see Measurement Units).
setNodeValue
Section titled “setNodeValue”Sets a property value for a node.
setNodeValue(index: number, property: NodeProperty, value: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node’s index (starting from 1). |
| property | NodeProperty | the property to set (see NodeProperty). |
| value | number | the new value for the property. |
Values are in units that depend on the units used for flow rate (see Measurement Units).
setJunctionData
Section titled “setJunctionData”Sets a group of properties for a junction node.
setJunctionData(index: number, elev: number, dmnd: number, dmndpat: string): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a junction node’s index (starting from 1). |
| elev | number | the value of the junction’s elevation. |
| dmnd | number | the value of the junction’s primary base demand. |
| dmndpat | string | the ID name of the demand’s time pattern ("" for no pattern) |
These properties have units that depend on the units used for flow rate (see Measurement Units).
setTankData
Section titled “setTankData”Sets a group of properties for a tank node.
setTankData(index: number, elev: number, initlvl: number, minlvl: number, maxlvl: number, diam: number, minvol: number, volcurve: string): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a tank node’s index (starting from 1). |
| elev | number | the tank’s bottom elevation. |
| initlvl | number | the initial water level in the tank. |
| minlvl | number | the minimum water level for the tank. |
| maxlvl | number | the maximum water level for the tank. |
| diam | number | the tank’s diameter (0 if a volume curve is supplied). |
| minvol | number | the volume of the tank at its minimum water level. |
| volcurve | string | the name of the tank’s volume curve ("" for no curve) |
These properties have units that depend on the units used for flow rate (see Measurement Units).
getCoordinates
Section titled “getCoordinates”Gets the (x,y) coordinates of a node.
getCoordinates(index: number): {x: number;y: number;};Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node index (starting from 1). |
Returns
Object
{ x: number; y: number;}| Property | Type | Description |
|---|---|---|
| x | number | the node’s X-coordinate value. |
| y | number | the node’s Y-coordinate value. |
setCoordinates
Section titled “setCoordinates”Sets the (x,y) coordinates of a node.
setCoordinates(index: number, x: number, y: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a node index (starting from 1). |
| x | number | the node’s X-coordinate value. |
| y | number | the node’s Y-coordinate value. |