Within your If -Then-Else expressions, you can compare values and perform mathematical operations on values. For example, suppose you want to run an action only when the alarm "Critical_Alarm" is generated and has a severity of 100 or higher. You would create the If expression using a comparison operator, as follows:
If: Alarm.name == "Critical_Alarm" && Alarm.severity>=100
Then:
Consider another example where you want to create a data item (Tank_Total) and set its value to the sum of two other data items (tank1 and tank2):
If:
Then: SendDataItem("TankTotal", tank1+tank2)
The following tables show the logical operations you can perform on Numbers and on Strings. Make sure the operation you select matches the data type of the related object(s).
Operator name |
Key(s) |
Example |
Power |
^ |
DataItem.temp.value^2 squares the value of temp |
Not |
! |
Use this operator to test a Boolean symbol for the value, false: !User.isfirstlogin !User.isadmin !DataItem.temp.changed !Registration.first !State.isentry For example, !State.isentry tests if the state machine is leaving the current state (isentry is false if the state machine is leaving the current state). |
Unary plus and minus |
+x, -x |
|
Modulus |
% |
18%4 is 2 |
Division |
/ |
8/2 is 4 |
Multiplication |
* |
8*2 is 16 |
Addition, Subtraction |
+, - |
8+2 is 10 |
Less than or equal to, More than or equal to |
<=, >= |
DataItem.temp.value <=100 |
Less than, Greater than |
< , > |
DataItem.temp.value > 80 |
Not equal to, equal to |
!=, == |
DataItem.Switch.value!=0 |
Boolean AND |
&& |
Use between multiple data item values in an If expression: DataItem.temp.value > 33 && DataItem.temp.value < 57 or use between multiple functions or actions in a Then or Else expression when you want them all to run: SetAlarmState="ESCALATED" && SetAlarmSeverity=100 |
Boolean OR |
|| |
Use between multiple data item values in an If expression: DataItem.temp.value > 33 || DataItem.temp.value < 22 |
Assignment |
= |
DataItem.machineFan.value = 1 |
Mathematical and Comparison Operators Supported for Strings
Operator name |
Key(s) |
Example |
Addition |
+ |
"Jan"+"uary" is "January" |
Less than or equal to, More than or equal to |
<=, >= |
|
Less than, Greater than |
< , > |
|
Not equal to, equal to |
!=, == |
OS == "Linux" |