Variable Status and Conversion Functions

From SysCAD Documentation
Jump to: navigation, search

Navigation: PGMs - Predefined Functions

Watch Keywords

Watch

Syntax:

Watch variable
Watch Class instance
Watch Class instance.data Member 

The Watch function allows any variable to be displayed in the permanent PGM data watch window. This is equivalent to appending a ' * ' to the end of the variable in the Variable declaration.

Similarly, the Watch function allows any instance of a class to be displayed in the permanent PGM data watch window. This will add all the data members for the class to the permanent PGM data watch window.

The Watch function also allows one to selectively add data members of an instance of a class to the permanent PGM data watch window. The Dot Notation would be used to access the required data member.

Any number of variables, class instances or class data members can be watched using a single watch command if each one is separated by a comma.

Examples:
  REAL    a
  Noise   b, c
  WATCH   a, b, c.GetVal

ExcludeWatch

Syntax:

ExcludeWatch UserClass[index]

This is used to make variables of a class not visible in the access window.

For Example: ExcludeWatch C[0]

SetConcealedState

Syntax:
SetConcealedState(Variable, bit value)

Variable : a valid variable or class for which the Concealed state must be set.

bit value : this may be either be a single bit value (true or false) or an expression which resolves into a single true or false result.

The SetConcealedState function is used to change the Concealed state of data variables based on the specified bit value. By changing the Concealed state the variables become visible or concealed on the Access window. Concealed variables are still accessible as tags in the flowsheet (for example from Excel, etc). The Variable can be a data variable or a class. If it is a class, all the variables for that class will have the state changed.

Only watched variables that are defined as inputs or outputs can have the state set. It is meaningless to use SetConcealedState on variables that are not declared as input or output to make them visible as tags.

Example:

Bit    UseSetSplit{i,s}
Real   RequiredSplit{i,Cnv("Frac","%"),Range(0,100)}

if (OnInitialise)
  SetConcealedState(RequiredSplit, (UseSetSplit==false))  ;Only want variable visible if option is chosen where this is used
else
  if (UseSetSplit)
    SetTag("X_001.GM.IOs.[P_002].Split (%)", RequiredSplit)
  endif
endif


Using SetConcealedState with Classes:

  1. It is possible to set the concealed state of a variable in a class, for example SetConcealedState(T.d1, true).
  2. It is also possible to set the concealed state of a variable in an array of classes as long as the index is specified directly, for example SetConcealedState(T[3].d1, true).
  3. It is NOT possible to specify the index pragmatically, for example SetConcealedState(T[i].d1, true).
  4. When writing a function within a class definition, it is possible to use SetConcealedState to change the concealed status of variables within the class. This is useful for a class to adjust visible variables as a function of it's parameters. You can set the concealed state of all variables within the class by specifying this as the Variable parameter.

For example, include these functions in the class to show/hide all variables in the class.

;Show all variables in the class
Function ShowAll()
   SetConcealedState(this, false))
Return 0
EndFunct
;Show hide variables in the class
Function HideAll()
   SetConcealedState(this, True)
Return 0
EndFunct

For more information on how to apply this to a PGM class, please see Aqueous Feed Concentration Calculator example PGM file.

Conversion Functions

Cnv

Syntax:
variable = Cnv(variable1, unit)

The Cnv function converts variable1 to the conversion units specified by unit and returns the result. Conversion information must have been specified for variable1. An expression cannot be used instead of supplying variable1. The unit must be a valid conversion unit belonging to the conversion family for variable1. The conversion units ARE case sensitive.

Example:

Double  len("L","m")*, d*, r1*, r2*
CnvInfo(d, "Qm","kg/s")

d  = GetTag("P_11.Qm kg/s")
r1 = Cnv(len, "ft")
r2 = Cnv(d, "t/h")

CnvVal

Syntax:
variable = CnvVal(variable1, family, unit, ReqdUnit)

The CnvVal function converts variable1 from the conversion units specified by unit to the conversion units specified by ReqdUnit for the specified conversion family and returns the result. The unit and ReqdUnit must be a valid conversion units belonging to the specified conversion family. The conversion family and conversion units ARE case sensitive.

Example:

Double  len, d1, d2, r1*, r2*

d1 = GetTag("P_11.Qm kg/s")
d2 = GetTag("P_12.Qm kg/s")
r1 = CnvVal(len, "L", "m", "ft")
r2 = CnvVal(d1 + d2, "Qm", "kg/s", "t/h")

CnvInfo

Syntax:
CnvInfo(variable, family, unit)

The CnvInfo function allows conversions (engineering units) to be assigned to a variable. Conversion information can only be assigned to double and long variable types. This conversion information can also be supplied when a variable is declared. See Variable declaration. The conversion family and conversion units ARE case sensitive.

The variable is the PGM variable that has already been declared for which you wish to specify conversion information. The family is the name of the conversion family or group. The unit is the conversion (or engineering) unit the variable represents.

This conversion information is especially useful if the variable is watched. When it is accessed in a trend or in an access window, the number is more meaningful because it has an engineering unit and the user can change the conversion unit as required for display purposes. This conversion information is also used by the Cnv function.

Example:

Double  len*, d*, c3b* 

Cnvinfo(len,"L",   "km")          ;family length, unit km
CnvInfo(c3b,"Time","h" )          ;family time, unit h
CnvInfo(d,   M,    kg  )          ;family mass, unit kg