Tag Functions
Navigation: PGMs ➔ Functions ➔ Tag Functions
Functions | Subroutines | Classes | |||||
---|---|---|---|---|---|---|---|
Defining a Function | Predefined Functions | Tag Functions | Mathematical Functions | String Functions | Defining a Subroutine | Trigger Subroutines | Defining a Class |
GetTag Functions
Function | Function Syntax | Data Type | Description / Examples / Notes |
---|---|---|---|
Getting Tag or Value from SysCAD Recommended Syntax |
variable = ["full tag"]
variable = [str "full tag"]
variable = [string]
|
|
|
Getting Value from SysCAD Alternative Syntax |
variable = GetTag("full tag")
variable = GetTag(string)
|
|
|
variable = GetDynTag("full tag")
variable = GetDynTag(string)
| |||
Getting Tag from SysCAD Alternative Syntax |
variable = GetDynStrTag(string)
|
|
SetTag Functions
Function | Function Syntax | Data Type | Description / Examples / Notes |
---|---|---|---|
Setting Tag or Value to SysCAD Recommended Syntax |
["full tag"] = variable
|
|
["X_001.GM.IOs.[P_001].Split (%)"] = 10
["XPG_001.P_Reqd (kPag)"] = HP_Steam_P
|
[StringVariable] = variable
|
MyTag = "X_001.GM.IOs.[P_001].Split (%)"
[MyTag] = 10
| ||
[str "full tag"] = StringVariable
|
CtrlOutputTag = "FUEL.QmReqd (t/h)"
[str "FUEL_ADDITION_PID.Cfg.[0].Output_Tag"] = CtrlOutputTag
| ||
Setting Value from SysCAD Alternative Syntax |
SetTag("full tag", value)
|
|
|
SetDynTag(string, value)
SetDynTag("full tag", value)
|
|
| |
SetDynStrTag(String1, String2)
|
The SetDynStrTag function assigns a String to the parameter, referred to by the tag contained in string1.
|
DynTagExists
Function | Function Syntax | Data Type | Description |
---|---|---|---|
Dynamic Tag Exists |
variable = DynTagExists(string)
|
|
|
Examples
Example 1
Real Flow_Split
Real Pressure_1@("P", "kPag")
Real Pressure_2@("P", "kPag")
String MyTag, UnitTag{Tag}, Condition@
Flow_Split = ["X_001.GM.IOs.[P_001].Split (%)"]
Pressure_1 = ["XPG_001.P_Reqd (kPag)"]
MyTag = "X_001.GM.IOs.[P_001].Split (%)"
Flow_Split = [MyTag]
UnitTag = "X_001"
Pressure_2 = [Concatenate(UnitTag, ".OperatingP.Result (kPag)")]
Condition = ["PlantModel.StateDesc"] ;Use the same syntax when the tag being fetched is a string variable
$
Example 2
[string] or GetDynStrTag is useful for users wanting to dynamically build up some control logic either in PGM or through Excel. For instance, a tank may have many inputs and outputs, users can use this function to get the input stream name for IO point 1. This can be done as follows:
String InputStream01
;InputStream01 = GetDynStrTag("TNK_001.Links.[0].DstTag")
InputStream01 = ["TNK_001.Links.[0].DstTag"]
When SysCAD is solved, InputStream01 will return the Tag name of the pipe that is connected to IO point input 1.
Example 3
String MyTag, CtrlOutputTag
Real HP_Steam_P
["X_001.GM.IOs.[P_001].Split (%)"] = 10
["XPG_001.P_Reqd (kPag)"] = HP_Steam_P
CtrlOutputTag = "FUEL.QmReqd (t/h)"
[str "FUEL_ADDITION_PID.Cfg.[0].Output_Tag"] = CtrlOutputTag
MyTag = "X_001.GM.IOs.[P_001].Split (%)"
[MyTag] = 10
Example 4
Setting Dynamic String Tag is useful for users wanting to dynamically build up some control logic either in PGM or through Excel. For instance, the user may want to dynamically change the controller output tag based on some predefined conditions. This can be done as follows:
String SelectControllerOutput*
Integer TestCond*
Sub InitialiseSolution()
If TestCond == 1
SelectControllerOutput = "MudLiqByPass.GM.IOs.[P_094].Splt.Liquids (%)"
Else
SelectControllerOutput = "TNK_002.GM.Recovery.Composition (%)"
Endif
[Str "PID_002.Cfg.[1].Output_Tag"] = SelectControllerOutput
EndSub
Notes
- A conversion is NOT checked to see if it exists or is valid when the PGM code is loaded and compiled, but is checked when the PGM code is executed for the first time. If no conversion is assigned or the specified conversion unit is invalid, the SysCAD SI unit will be used.
- The difference between (GetTag and SetTag) and (GetDynTag and SetDynTag) is subtle. It is NOT related to dynamic solver mode, but has to do with how SysCAD uses and checks the tags when used by these functions within the PGM code.
- GetTag and SetTag (and ["FullTag"]): At PGM load time SysCAD builds up a list of all tags referenced in GetTag and SetTag calls, but ignores tags in GetDynTag and SetDynTag. Then when you press solve, SysCAD checks this list of tags to see if they exist and can be set/read. SysCAD solver expects that these are ALWAYS accessible, regardless of whether they are actually accessed within PGM execution during an iteration. This implementation is for efficiency of retrieving and setting the tags, and tracking tag dependencies/references between models. For example, all the "get" tags are retrieved before execution of the PGM each iteration. For GetTag and SetTag you have to explicitly reference the full tag, for example GetTag("P_001.Qm (t/h)"), and you cannot use String variables, for example GetTag(s) is illegal.
- GetDynTag and SetDynTag: These functions have a number of differences and uses:
- The tag can be "dynamically" built or referenced when required. This can also be a string based on logic using strcat that you want to set/get. For example GetDynTag(s) or GetDynTag(strcat(PipeTag, ".Qm (t/h)")).
- For SetDynTag() and GetDynTag() the checking of the tag validity is done at runtime when the command is actually called. Therefore these are ideal for when a tag may not always be writeable or exist (for example, within if blocks and in Trigger Subroutines sections).
- In the Trigger Subroutines sections of a PGM (i.e. when the PGM is called at startup before the first iteration) GetDynTag and SetDynTag are commonly used, especially to set tags once off, such us switching models on/off (or setting any tags that can't be set while solving).