Total Active Systems: 1379
 

ITU G2 Expressions

The ITU_G2 introduces a powerful system of expressions to go along with the flexibility of the new log map. Commonly used expressions will tend to be fairly simple, but to meet specific requirements some quite complex expressions can be devised.

Expressions are used to define the ^HIMG, ^HLOP, ^HSCO, and relay control settings, but, in addition, a set of user expressions can be defined. User expressions can be used to define terms that can then be used in other expressions. This allows complex expressions to be created without them having to become incomprehensible.

The syntax of an expression can be defined as follows:

expression ::= expression_term { boolean_operator expression_term }
expression_term ::= data_identifier_term | [ ! ] defined_term
data_identifier_term ::= log_field_number [ bit_mask ] [ ! ] comparison_operator
defined_term ::= expression_identifier | expression_name | forward_referenced_expression
expression_identifier ::= X expression_number
boolean_operator ::= + | .
bit_mask ::= [ bit_range { , bit_range } ]
bit_range ::= bit_number [ - bit_number ]
comparison_operator ::= L | H | C
forward_referenced_expression ::= { expression_identifier : user_expression_name }
expression_name ::= standard_expression_name | user_expression_name
standard_expression_name ::= FALSE | TRUE | RST | TEST | T_5 | T_10 | T_15 | T_30 | T1 | T5 | T10 | T15 | T30 | T60 | SCT | ICT1 | ICT2 | TCP | SCO | LOP | ROFF1 | ROFF2 | ROFF3 | ROFF4 | RON1 | RON2 | RON3 | RON4 | ROT1 | ROT2 | ROT3 | ROT4 | TOD1 | TOD2 | TOY1 | TOY2 | SUN | MON | TUE | WED | THU | FRI | SAT | LIGHT | IMG | NI | SUNRISE | SUNSET
user_expression_name ::= letter { letter | digit }
log_field_number ::= 0 .. 63
bit_number ::= 0 .. 22
expression_number ::= 1 .. 8
letter ::= A .. Z | a .. z | _
digit ::= 0 .. 9

Data Terms

A data_identifier_term contains a reference to one of the 64 value fields in the log record (the log_field_number). If an optionally bit_mask is specified then the comparisons applied to this term will be based on bit-wise Boolean logic, otherwise numeric comparisons will be used. When a bit_mask is used only those bits inclued in the mask are used in the comparison.

ComparisonNumeric valueBit field
L<Low thresholdAll bits 0
!L>Low thresholdOne or more 1 bits
H>High thresholdAll bits 1
!H<High thresholdOne or more 0 bits
C>Change thresholdAny bits different
!C<Change thresholdAll bits the same

Change comparisons are based on the absolute difference from the matching log field in the last log record. It is therefore necessary to write log records at suitable times to have values to compare against. If a change comparison is used to trigger a call then it is generally necessary to write a log record at the time of the call so that the comparison does not remain true following the call.

Level comparisons are based on the current level of the input. Since a level comparison can remain true for some time it is generally necessary to combine level comparison terms with time based terms.

Thresholds are defined using the ^HATH command and are associated with a log record entry using the ^HLM command.

Standard Terms

TermSet True
FALSENever
TRUEAlways
RSTAt reset
TESTWhen test button pressed
T_5Every 5 seconds
T_10Every 10 seconds
T_15Every 15 seconds
T_30Every 30 seconds
T1Every minute
T5Every 5 minutes
T10Every 10 minutes
T15Every 15 minutes
T30Every 30 minutes
T60Every hour
SCTAt a scheduled call time
ICT1ICT1 minutes after a call
ICT2ICT2 minutes after a call
TCPWhen a TCP connection is established
SCOWhen the SCO expression evalutes true
LOPWhen the LOP expression evalutes true
ROFF1When the ROFF1 expression evalutes true
ROFF2When the ROFF2 expression evalutes true
ROFF3When the ROFF3 expression evalutes true
ROFF4When the ROFF4 expression evalutes true
RON1When the RON1 expression evalutes true
RON2When the RON2 expression evalutes true
RON3When the RON3 expression evalutes true
RON4When the RON4 expression evalutes true
ROT1When the relay 1 timer expires
ROT2When the relay 2 timer expires
ROT3When the relay 3 timer expires
ROT4When the relay 4 timer expires
TOD1When the time of day is within defined range
TOD2When the time of day is within defined range
TOY1When the time of year is within defined range
TOY2When the time of year is within defined range
SUNWhen it's a Sunday
MONWhen it's a Monday
TUEWhen it's a Tuesday
WEDWhen it's a Wednesday
THUWhen it's a Thursday
FRIWhen it's a Friday
SATWhen it's a Saturday
LIGHTWhen the time of day is between sunrise and sunset
IMGWhen the IMG expression evaluates true
NIWhen a new image becomes available
SUNRISEWhen the time matches the current sunrise time
SUNSETWhen the time matches the current sunset time

All the, Txx, time expressions are set to true when the real time clock minute reaches a suitable multiple. For example, T5 is set when the real time clock minute field is incremented to 0, 5, 10, 15, etc.

All the, T_xx, time expressions are set to true when the real time clock second reaches a suitable multiple. For example, T_15 is set when the real time clock second field is incremented to 0, 15, 30, or 45.

The ICT timers count down from the time DTR was last de-asserted so the terms will be set true again after their set time intervals regardless of the success or otherwise of the previous call.

The SCT terms is set when the real time clock increments to match any of the defined scheduled call times.

The TCP term is set when a TCP connection is established and cleared when the connection is closed. This allows expressions to be created that can, for example, cause a new connection to be established or take alternative relay control action based on the TCP connection status.

The IMG, SCO, LOP, ROFFn, and RONn terms are set when their expressions evaluate to true. These are special purpose expressions but can be defined and used just like a user expressions with the exceptions that they cannot be named and that they have their own effects.

The ROTn terms are set when their respective relay operate timers expire. These timers are triggered by the RONn expressions (or a ^HSOn=1 command) and can be used as general purpose timers so long as the relay operation, if there is one, is not significant.

The TODn and TOYn terms are true whenever the time or date is within the range defined by the corresponding ^HTOD or ^HTOY command.

The day of week terms, SUN through SAT, are true on there corresponding day of the week. The day of week is calculated by the ITU based on the year, month, and day set in its real time clock.

The LIGHT term is set when the time of day is within the calculated sunrise to sunset time range. This time range is calculated based on the date and location of the ITU.

The NI (New Image) term is set when an image capture sequence is successfully completed. An image capture sequence will be started when the IMG expression evaluated to true and the NI term will indicate completion.

User Expression Terms

Eight user expressions, X1 to X8, can be defined. These provide a way of creating sub-expressions that can then be used in other expressions. This allows for complex expressions to be build from simple, more easily understood, sub-expressions.

Naming of user expressions is recommended to enhance comprehension. User expression can be assigned names of up to seven characters in length. Letters, digits and the underscore character ('_') are permitted in expression names although they may not start with a digit. Letters may be extered in either upper or lower case but are all converted to upper case. Names but not confict with standard expression names. If a expression has a name the expression is redefined, the name will be retained so long as no new name is specified. An empty name string ("") may be specified if the user wishes to delete an existing name without defining a new name.

Names of expressions are stored with the expression that is so named. References to the named expression are stored numerically. This means that should a name be changed then all references to it will also change.

Some Rules Regarding Expressions

Circular references are not permitted. This includes circular references that go via several different expressions.

Only eight terms are permitted in any one expression. If more are needed then user expressions should be used to define suitable sub-expressions.

Named expressions may only be referred to by their names if the names are already defined. If it is necessary to reference a user expression before it is named then the Xn syntax can be used. Optionally, to help clarity of the expressions, the forward reference syntax, {Xn:name}, may be used. When it is, only the Xn part is used by the ITU; the name is documentative only.

Examples

AT^HX1"COLD"=23L+24L+25L+26L+27L+28L+29L+30L
AT^HX4"IDLE"=10[0-8]!L+15[1]H+17[1]H
AT^HLOP=COLD.T1+!IDLE.45[3-4]!H+X7

The user expression X1 is assigned the name COLD and is true if any one of the data values 23 to 30 are below their respective thresholds. Typically a suitable threshold set would be defined and applied to all these data values but this doesn't have to be the case.

The user expression X4 looks more complicated but just states that if any one of 11 different bits is true then it will be true. Typically such an expression would be used to look at digital inputs (which are likely to be bit mapped). It is possible to look at other types of inputs this way but it would generally not be a good idea.

The LOP expression is really just a made up example to show what can be done. The five terms of this expression form three products terms: COLD.T1, !IDLE.45[3-4]!H, and X7. Any one product term true will result in generation of a log record. The first product term will cause one minute logging whenever any of the eight temperature inputs referenced in the X1 expression is below its low threshold. The second product term requires that the IDLE expression is false and data value 45 has a zero bit in position 3 or 4. The final term we know nothing about because the X7 term is not defined here. Note that when listing user expressions, any expression that is defined as FALSE will not be listed. This is how unused expressions can be cleared.