Simple Control Functions
These functions are used for working with simple conditional controls.
| Function | Versions | Description |
|---|---|---|
addControl | 2.2+ | Adds a new simple control to a project. |
deleteControl | 2.2+ | Deletes an existing simple control. |
getControl | 2.2+ | Retrieves the properties of a simple control. |
setControl | 2.2+ | Sets the properties of an existing simple control. |
getControlEnabled | 2.3+ | Checks whether a simple control is enabled. |
setControlEnabled | 2.3+ | Enables or disables a simple control. |
addControl 2.2+
Section titled “addControl ”Adds a new simple control to a project.
addControl(type: ControlType, linkIndex: number, setting: number, nodeIndex: number, level: number): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| type | ControlType | the type of control to add (see ControlType). |
| linkIndex | number | the index of a link to control (starting from 1). |
| setting | number | control setting applied to the link. |
| nodeIndex | number | index of the node used to control the link (0 for ControlType.Timer and ControlType.TimeOfDay controls). |
| level | number | action level (tank level, junction pressure, or time in seconds) that triggers the control. |
Returns
Number
index of the new control.
deleteControl 2.2+
Section titled “deleteControl ”Deletes an existing simple control.
deleteControl(index: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the index of the control to delete (starting from 1). |
getControl 2.2+
Section titled “getControl ”Retrieves the properties of a simple control.
getControl(index: number): { type: ControlType; linkIndex: number; setting: number; nodeIndex: number; level: number;};Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the control’s index (starting from 1). |
Returns
Object
{ type: ControlType; linkIndex: number; setting: number; nodeIndex: number; level: number;}| Property | Type | Description |
|---|---|---|
| type | ControlType | the type of control to add (see ControlType). |
| linkIndex | number | the index of a link to control (starting from 1). |
| setting | number | control setting applied to the link. |
| nodeIndex | number | index of the node used to control the link (0 for ControlType.Timer and ControlType.TimeOfDay controls). |
| level | number | action level (tank level, junction pressure, or time in seconds) that triggers the control. |
setControl 2.2+
Section titled “setControl ”Sets the properties of an existing simple control.
setControl(index: number, type: ControlType, linkIndex: number, setting: number, nodeIndex: number, level: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the control’s index (starting from 1). |
| type | ControlType | the type of control to add (see ControlType). |
| linkIndex | number | the index of a link to control (starting from 1). |
| setting | number | control setting applied to the link. |
| nodeIndex | number | index of the node used to control the link (0 for ControlType.Timer and ControlType.TimeOfDay controls). |
| level | number | action level (tank level, junction pressure, or time in seconds) that triggers the control. |
getControlEnabled 2.3+
Section titled “getControlEnabled ”Checks whether a simple control is enabled. Disabled controls are kept in the project but skipped during simulation.
getControlEnabled(index: number): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the control’s index (starting from 1). |
Returns
Number
1 if the control is enabled, 0 if disabled.
setControlEnabled 2.3+
Section titled “setControlEnabled ”Enables or disables a simple control without deleting it.
setControlEnabled(index: number, enabled: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the control’s index (starting from 1). |
| enabled | number | 1 to enable the control, 0 to disable it. |