Expressions that refer only to the valid current value of a variable cause G2 to perform data seeking to obtain a new current value if the specified variable has never had a value or if its current value has expired.
A reference to a variable or parameter produces the same value everywhere it is used in the same expression. Also, a reference to a variable or parameter produces the same value everywhere it is used within the same transaction scope.
To refer directly to a variable or a parameter:
{quantitative-variable | quantitative-parameter}
-> {integer | float}
{integer-variable | integer-parameter}
-> integer
{float-variable | float-parameter}
-> float
{symbolic-variable | symbolic-parameter}
-> symbol
{text-variable | text-parameter}
-> text
{logical-variable | logical-parameter}
-> truth-value
collect data statement in procedures, G2 performs data seeking to attempt to obtain a new current value. See the discussion of data seeking in Obtaining Values for Variables. for any tank T upon this workspace
if the temperature of T > 100 then
conclude that the latest-temperature of master-display =
the temperature of T
Temperature attribute for the user-defined TANK class is defined as given by a variable. If the Temperature of tank-1 has a current value, the conclude action in the rule's consequent uses that value as the new value of the Latest-temperature attribute of master-display. If the Temperature of tank-1 does not have a current value, referencing it causes G2 to perform data seeking. Since variables do not always have a value, you cannot refer to them directly in procedures as you can a parameter. Attempting to do so causes G2 to signal an error. Instead, you can access the value of a variable within a procedure by using a
collect data statement or within a the current value of expression.A
collect data statement causes data seeking if the variable does not have current value. For more information about how G2 performs a collect data operation, see collect data.
Using the Value of Expression
To refer to the value of a variable:
the value of variable->{integer | float | symbol | text | truth-value}
The expiration time interval of this expression is the expiration time interval of the current value of the specified variable. For example:
the value of the temperature of tank-1
To determine if a variable has a value:
variable has {a | no} value
-> truth-value
the temperature of tank-1 has a value
the temperature of tank-1 has a valid current value, this expression produces the truth-value true. If the temperature of tank-1 has never had a value, or if its current value has expired, this expression causes G2 to perform data seeking to obtain a new current value. If G2 obtains a value from that data seeking, the expression produces the truth-value true, else the expression produces the truth-value false.
When a variable receives a new current value, G2 determines an expiration time for that value based on whether it was explicitly specified (via the
conclude ... with expiration action) or by combining the collection time of the new value and the variable's validity interval.
To obtain a variable's current value:
the current value of variable->{integer | float | symbol | text | truth-value}
the current value of the temperature of tank-1
To determine whether a variable has a current value:
variable has {a | no} current value
-> truth-value
the temperature of tank-1 has a current value
Temperature attribute of tank-1 has a current value, this expression produces the truth-value true. If the Temperature attribute of tank-1 has never had a value, or if its current value has expired, this expression produces the truth-value false. If this expression produces the truth-value
true, the expiration time of this expression is the expiration time of the current value. If this expression produces the truth-value false, the expiration time is indefinite. If a
has a value expression is nested within a has a current value expression, G2 evaluates the nested expression no differently than a has a value expression. G2 performs data seeking, if necessary, to obtain a new current value for the variable referenced in the nested has a value expression.
Obtaining the Collection Time for a Variable or Parameter
To obtain the collection time for a variable or parameter:
the collection time of {variable | parameter}
[as of integer-expression datapoints ago]
-> integer
If you specify this expression without the optional
as of integer-expression datapoints ago phrase, for the expression to produce a value, the specified variable or parameter need not have a current value, but must have received at least one history value. Otherwise, this expression produces a no value condition. For example:
the collection time of custom-variable
custom-variable has received at least one history value, this expression produces an integer value that represents the time in seconds at which the most recent history value was received. If you specify this expression with the optional
as of integer-expression datapoints ago phrase, then for the expression to produce a value, the specified variable or parameter need not have a current value, but must have received at least the specified number of history values plus one. Otherwise, this expression produces a no value condition. The most recently received history value is zero (0) history values ago. For example:
the collection time of custom-variable as of 10 datapoints ago
custom-variable has received at least 11 history values, this expression produces an integer value that represents the time in seconds at which the value 10 history values ago was received.
To obtain a variable's expiration time:
the expiration time of variable->integer
Validity-interval attribute is set to indefinite, this expression produces a no value condition. For example:
the expiration time of custom-variable
custom-variable has received at least one history value, this expression produces an integer value that represents the time in seconds at which the variable's current value expires.
To refer to a variable or parameter giving the value of an attribute:
the {variable | parameter} giving
the attribute-name of {object | connection | message}
-> {variable | parameter}
if the status of the temperature-variable TV
giving the temperature of tank-1 is broken
then inform the operator that
"The temperature sensor [the public-name of TV] is broken." ;
Status attribute of the temperature-variable item that gives the value of the Temperature attribute of tank-1.