ihost: Logic Points In addition to displaying values reported by a unit, ihost supports adding additional logic points to a unit and calculating the value based on a custom logic expression. On calculation of a new value, an event will be created (routine host datalogging must be enabled for analogues) that may be plotted on Interactive Trends and notified to users just the same as regular points. This feature is currently supported for binary inputs, counter inputs and analogue inputs. Roles and Privileges As you should know not all Users can see all pages, links and menu items. It might be that some of the screen shots shown below do not match with what you see this is nothing to worry about. If you are not able to access some of the pages you would like too then please contact your ihost administration team. Adding and removing logic points Logic points can be added via the UI from 2.38 onwards. This is available via a link on the point settings page. Note, there is currently no support for removing logic points once added. Existing logic points can be enabled / disabled via the settings pages. If additional logic points are required for an ihost on version less than 2.38 then please contact technical support. Accessing and using the Logic Editor The logic expression associated with a logic point may be modified using the built-in Logic Editor. The Logic Editor can be accessed for a single point via the Unit Overview or the input settings page. On the Unit Overview, click the calculator icon shown next to the trend graph icon: On the binary input settings page click the Edit link: The logic expression is always validated on saving changes. Also the interval can be updated which is the period between evaluating a logic expression. The interval must be a minimum of 60 seconds. Nortech Management Ltd, United Kingdom Page 1 of 13
For Nexus and Bowden P360 units, the logic evaluation can be triggered on a call. This expression will run independent of whether the call failed or was successful as long as the logs were processed and points were updated. Nortech Management Ltd, United Kingdom Page 2 of 13
Logic point types The following point types can be logic points: Type Counter Input Expected Return Type Boolean Unsigned Integer Logic points of one type can reference a logic point of a different type as long as the final return type is correct. Logic symbols A logic point is referenced by its symbol and number. Type Symbol Minimum Point Number Maximum Point Number Example BI 0 1000 BI16 Counter Input CI 0 1000 CI16 AI 0 1000 AI16 Binary Output BO 0 1000 BO16 Analogue Output AO 0 1000 AO16 Logic syntax Logic expressions are case insensitive. Spaces are required between operators and functions. There are no line delimiters and the expression must be evaluated as a single line. Custom functions are not supported i.e. only functions listed in this FAQ may be used. Boolean values can be written as True or False. Real and integral numbers can be used. Hex values can be written using the standard hex notation 0xFF12. Some functions may return Null when a value does not apply or has not yet been recorded. Nortech Management Ltd, United Kingdom Page 3 of 13
Arithmetic Operators Operator Description + Addition. Example: LastValue(CI0) + LastValue(CI1) - Subtraction. Example: LastValue(CI0) - LastValue(CI1) * Multiplication. Example: LastValue(CI0) * LastValue(CI1) / Division. Example: LastValue(CI0) / LastValue(CI1) % Modulo. Example: LastValue(CI0) % LastValue(CI1) ^ Power. Example: LastValue(AI0) ^ 2 Comparison Operators Operator Description = Equal to. Example: LastValue(CI0) = LastValue(CI1) <> Not equal to. Example: LastValue(CI0) <> LastValue(CI1) > Greater than. Example: LastValue(AI0) > LastValue(AI1) < Less than. Example: LastValue(AI0) < LastValue(AI1) >= Greater than or equal to. Example: LastValue(AI0) >= LastValue(AI1) <= Less than or equal to. Example: LastValue(AI0) <= LastValue(AI1) Logical Operators If both operands of an expression are boolean, then it is a logical operation. Operator And Or Xor Not Description Returns True if both its operands are True. Example: LastValue(BI0) And LastValue(BI1) Returns True if any of its operands are True. Example: LastValue(BI0) Or LastValue(BI1) Otherwise known as Exclusive Or. Returns True if and only if exactly one of its operands are True. Example: LastValue(BI0) Xor LastValue(BI1) Returns True if operand is False and vice-versa. Example: Not LastValue(BI0) Logical Not operator must always be surrounded in parenthesis where it follows a preceding logical Not operator. Example: False Or Not (Not True) Nortech Management Ltd, United Kingdom Page 4 of 13
Bitwise Operators Bitwise operations should only be performed on integers such as Counter Input values or numeric values that have been cast to an integer. Bitwise operations are useful where bit flags are encoded in an integer value. Operator Description And Performs logical And operation on each pair of corresponding bits by multiplying them. Result is 1 if both bits are 1, otherwise it is 0. Example: LastValue(CI0) And LastValue(CI1) will return 4 if first value is 5 and the second value is 6. 0101 (decimal 5) And 0110 (decimal 6) = 0100 (decimal 4) Or Performs logical Or operation on each pair of corresponding bits. Result is 1 if either bits are 1, otherwise it is 0. Example: LastValue(CI0) Or LastValue(CI1) will return 7 if first value is 5 and the second value is 6. 0101 (decimal 5) Or 0110 (decimal 6) = 0111 (decimal 7) Xor Otherwise known as Exclusive Or. Performs logical exclusive Or on each pair of corresponding bits. Result is 1 if only one bit is 1, otherwise it is 0. Example: LastValue(CI0) Xor LastValue(CI1) will return 3 if first value is 5 and the second value is 6. 0101 (decimal 5) Xor 0110 (decimal 6) = 0011 (decimal 3) Not Performs logical negation on each bit. Bits that are 0 become 1 and bits that are 1 become 0. Example: Not LastValue(CI0) for a Counter Input (32-bit Unsigned Integer) will return 4294967294 if value is 1. NOT 00000000000000000000000000000001 (decimal 1) = 11111111111111111111111111111110 (decimal 4294967294) Bitwise Not operator must always be surrounded in parenthesis where it follows another operator. For example: 1 - (Not(LastValue(CI0))) For further information, see https://en.wikipedia.org/wiki/bitwise_operation Nortech Management Ltd, United Kingdom Page 5 of 13
Bitwise Shift Operators Bitwise shift operators should only be used on integers such as Counter Input values or numeric values that have been cast to an integer. A binary shift operator shifts all of the bits by moving every bit a specified number of places and the vacant bit positions are filled in. Operator Description << Shifts its first operand left by the number of bits specified by its second operand. Example: LastValue(CI0) << 1 if counter input value is 1 then this will shift the counter input value one bit to the left and the empty position in the least significant bit (most-right bit) is filled with a zero, 1 << 1 = 2. 00000000000000000000000000000001 (decimal 1) = 00000000000000000000000000000010 (decimal 2) >> Shifts its first operand right by the number of bits specified by its second operand. Example: LastValue(CI0) >> 1 if counter input value is 2 then this will shift the counter input value one bit to the right and the empty position in the most significant bit (most-left bit) is filled with a zero, 2 >> 1 = 1. 00000000000000000000000000000010 (decimal 2) = 00000000000000000000000000000001 (decimal 1) For further information, see https://en.wikipedia.org/wiki/arithmetic_shift In Operator The In operator returns True if a value exists within an array. Example: LastValue(AI0) In (0, 100) If Last Value of AI0 is either 0 or 100 then return True, otherwise return False. Order of Operations When a logic expression contains multiple operators, the precedence of the operators controls the order in which they are evaluated. The list below summarises the operators in order of precedence from highest to lowest: 1. Power ^ 2. Multiplication, Division and Modulo * / % 3. Addition and Subtraction + - 4. Bit shift << >> 5. Comparison = <> < > >= <= 6. In 7. Logical and Bitwise Not 8. Logical and Bitwise And 9. Logical and Bitwise Or 10. Logical and Bitwise Xor Precedence can also be controlled by using parenthesis. For example, when writing an expression to calculate the average of 3 values, the expression 1 + 2 + 3 / 3 would produce an incorrect result of 4. This is due to the higher precedence for the division operator resulting in 3 / 3 being evaluated first. The correct way to write this expression would be (1 + 2 + 3) / 3 using the parenthesis to control the evaluation order and providing the correct result of 2. Nortech Management Ltd, United Kingdom Page 6 of 13
Where two operators have the same precedence, the operations are evaluated left to right, so 15 / 3 * 4 would be evaluated as (15 / 3) * 4. Examples of evaluation order: Expression Evaluation Order Result 25-4 * 5 25 - (4 * 5) 5 15 * 4-1 (15 * 4) - 1 59 15 % 5 + 3 (15 % 5) + 3 3 15 + 5 % 3 15 + (5 % 3) 17 15 / 3 * 4 (15 / 3) * 4 20 15 * 3 / 4 (15 * 3) / 4 11 1 + 5 ^ 2 * 2 1 + ((5 ^ 2) * 2) 51 1 ^ 5 + 2 * 2 (1 ^ 5) + (2 * 2) 5 1 + 5 * 2 ^ 2 1 + (5 * (2 ^ 2)) 21 True And Not False True And (Not False) True Not False And True (Not False) And True True 2 > 1 And Not False (2 > 1) And (Not False) True 1 + 1 < 3 + 2 (1 + 1) < (3 + 2) True 2 + 3 In (5) (2 + 3) In (5) True 3 In (6) and True (3 In (6)) And True False True And 3 In (6) True And (3 In (6)) False True Or False In (False) True Or (False In (False)) True 2 > 1 And 2 < 3 (2 > 1) And (2 < 3) True True And 2 < 1 And Not False (True And (2 < 1)) And (Not False) False Nortech Management Ltd, United Kingdom Page 7 of 13
Logic functions Basic functions Function If(condition, return this value when True, otherwise return this value) Cast(value, type) Date and Time functions Function Days(days) Hours(hours) Minutes(minutes) Seconds(seconds) Milliseconds(milliseconds) Data functions Description A conditional operator chooses a result based on a boolean condition. Example: If(LastValue(AI0) > 90, 100, LastValue(AI0)) If Last Value of AI0 is greater than 90 then return 100, else return the Last Value of AI0. Used to convert a value from one type to another. Example: Cast(LastValue(AI1), uint) This would cast a double to an unsigned integer. Target types supported by this function are: boolean byte sbyte short ushort int uint long ulong single double Description Number of days. Number of hours. Number of minutes. Number of seconds. Number of milliseconds. Function Description Supported Point Types IsAlarm(pointReference) Returns True if point is in an alarm state. Example: IsAlarm(BI0) IsReset(pointReference) Returns True if point is healthy. Example: IsReset(BI0) HasUpdated(pointReference, timespan) Returns True if a point has been updated with in the given time frame. Example: HasUpdated(BI0, Minutes(10)) will Counter Input return True if BI0 has been updated with in the last 10 minutes. HasChanged(pointReference, timespan) Returns True if a point value has changed with in the given time frame. Example: HasChanged(BI0, Minutes(10)) will return True if BI0 has changed with in the last 10 minutes. LastValue(pointReference) Nortech Management Ltd, United Kingdom Page 8 of 13 Returns the current value of an input point. Example: LastValue(AI0) Counter Input
Function Description Supported Point Types LastReadValue(pointReference) Returns the current value of an output point. Example: LastReadValue(BO0) Binary Output Analogue Output LastSetValue(pointReference) HasAlarmed(pointReference, timespan) HasReset(pointReference, timespan) Low(pointReference) LowLow(pointReference) High(pointReference) HighHigh(pointReference) MinValue(pointReference, timespan) MaxValue(pointReference, timespan) AvgValue(pointReference, timespan) Returns the last set value of an output point. Example: LastSetValue(BO0) Returns True if a point has changed to an alarm state within the given time frame. Example: HasAlarmed(BI0, Minutes(10)) will return True if BI0 has changed to an alarm state with in the last 10 minutes. Returns True if a point has changed to a reset state within the given time frame. Example: HasReset(BI0, Minutes(10)) will return True if BI0 has changed to a reset state with in the last 10 minutes. Low Threshold. Example: LastValue(AI0) < Low(AI0) will return True if the current value has crossed the L threshold. Low Low Threshold. Example: LastValue(AI0) < LowLow(AI0) will return True if the current value has crossed the LL threshold. High Threshold. Example: LastValue(AI0) > High(AI0) will return True if the current value has crossed the H threshold. High High Threshold. Example: LastValue(AI0) > HighHigh(AI0) will return True if the current value has crossed the HH threshold. Returns the smallest value of all analogue input readings reported within the given time frame. Example: MinValue(AI0, Days(7)) will return 1 if AI0 has reported readings of 1 and 10 with in the last 7 days. Returns the largest value of all analogue input readings reported within the given time frame. Example: MaxValue(AI0, Days(7)) will return 10 if AI0 has reported readings of 1 and 10 with in the last 7 days. Returns the average of all analogue input readings reported within the given time frame. Example: AvgValue(AI0, Days(7)) will return 5.5 if AI0 has reported readings of 1 and 10 with in the last 7 days. Binary Output Analogue Output Nortech Management Ltd, United Kingdom Page 9 of 13
Function Description Supported Point Types SumValue(pointReference, timespan) Returns the sum of all analogue input readings reported within the given time frame. Example: SumValue(AI0, Days(7)) will return 11 if AI0 has reported readings of 1 and 10 with in the last 7 days. HasValueAbove(pointReference, limit, timespan) Returns True if an analogue input reading reported within the given time frame is above the given limit. Example: HasValueAbove(AI0, 5.0, Days(7)) will return True if AI0 has reported readings of 1 and 10 with in the last 7 days. HasValueBelow(pointReference, limit, timespan) Mathematical functions Returns True if an analogue input reading reported within the given time frame is below the given limit. Example: HasValueBelow(AI0, 5.0, Days(7)) will return True if AI0 has reported readings of 1 and 10 with in the last 7 days. All double values in the examples shown below have been rounded to 3 decimal places. Function Description Supported Parameter Types Abs(value) Returns the absolute value of a given number. Example: Abs(LastValue(AI0)) will return 5 if AI0 value is -5. Integer Acos(d) The inverse of cosine. Returns the angle in radians of the given cosine. Convert radians to degrees by multiplying by 180/PI Example: Acos(LastValue(AI0)) will return 0 if AI0 value is 1. Asin(d) The inverse of sine. Returns an angle in radians of the given sine. Convert radians to degrees by multiplying by 180/PI. Example: Asin(LastValue(AI0)) will return 1.571 if AI0 value is 1. Atan(d) The inverse of tangent. Returns an angle in radians of the given tangent. Convert radians to degrees by multiplying by 180/PI Example: Atan(LastValue(AI0)) will return 0.785 if AI0 value is 1. Atan2(y, x) Returns an angle in radians of the given tangent. This tangent is a quotient of 2 numbers. Convert radians to degrees by multiplying by 180/PI Example: Atan2(LastValue(AI0), LastValue(AI1)) will return 1.373 if AI0 value is 5 and AI1 value is 1. Ceiling(d) Rounds the given value up to the nearest whole number. Example: Ceiling(LastValue(AI0)) returns 2 if value is 1.5 Cos(d) Returns the cosine of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Cos(LastValue(AI0)) will return -0.839 if AI0 value is 10. Nortech Management Ltd, United Kingdom Page 10 of 13
Function Description Supported Parameter Types Cosh(value) Returns the hyperbolic cosine of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Cosh(LastValue(AI0)) will return 1.543 if AI0 value is 1. Exp(d) Computes values of the exponential function. Returns 2.71828 raised to the given power. Example: Exp(LastValue(CI0)) returns 7.389 if value is 2. Floor(d) Rounds the given value down to the nearest whole number. Example: Floor(LastValue(AI0)) returns 1 if value is 1.5 IEEERemainder(x, y) Returns the remainder of x divided by y. Example: IEEERemainder(LastValue(CI0), 2) returns 1 if first value is 5. Log(d) Returns the logarithm of the given value. Example: Log(LastValue(CI0)) returns 0.693 if value is 2. Log10(d) Returns the base 10 logarithm of the given value. Example: Log10(LastValue(CI0)) returns 0.301 if value is 2. Max(val1, val2) Returns the largest value of the 2 given values. Example: Max(LastValue(AI0), LastValue(AI1)) returns 5 if first value is 1 and second value is 5. Min(val1, val2) Returns the smallest value of the 2 given values. Example: Min(LastValue(AI0), LastValue(AI1)) returns 1 if first value is 1 and second value is 5. Pow(x, y) Returns x raised to the power of y. Example: Pow(LastValue(AI0), 2) returns 100 if value is 10. Round(a) Rounds a given value to the nearest whole number. Example: Round(LastValue(AI0)) returns 2 if value is 1.5 Sign(value) Returns -1 if the given value is negative, 1 if positive and 0 if value is zero. Example: Sign(LastValue(AI0)) returns 1 if value is 20 Sin(a) Returns the sine of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Sin(LastValue(AI0)) will return -0.544 if AI0 value is 10. Sinh(value) Returns the hyperbolic sine of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Sinh(LastValue(AI0)) will return 1.175 if AI0 value is 1. Sqrt(d) Returns the square root of the given value. Example: Sqrt(LastValue(AI0)) returns 12 if value is 144. Tan(a) Returns the tangent of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Tan(LastValue(AI0)) will return 0.648 if AI0 value is 10. Tanh(value) Returns the hyperbolic tangent of the given angle (in radians). Convert degrees to radians by dividing by 180/PI Example: Tanh(LastValue(AI0)) will return 0.762 if AI0 value is 1. Integer Integer Integer Nortech Management Ltd, United Kingdom Page 11 of 13
Array functions Function Description Supported Parameter Types Array(value1, value2, ) Count(values) Round(values, digits) First(values) Last(values) Average(values) Min(values) Max(values) Between(values, lower, upper) Creates an array from the passed values. Example: Array(LastValue(AI0), LastValue(AI1)) Returns the number of items in the given array. Example: Count(Array(LastValue(AI0), LastValue(AI1))) will return 2. Rounds all values in the given array to the nearest decimal place. Number of decimal places is represented by digits. Example: Round(Array(LastValue(AI0), LastValue(AI1)), 2) will round each value in the array to 2 decimal places. Returns the first item in the given array. Example: First(Array(LastValue(AI0), LastValue(AI1))) will return the value for AI0. Returns the last item in the given array. Example: Last(Array(LastValue(AI0), LastValue(AI1))) will return the value for AI1. Returns the average of all values in the given array. Example: Average(Array(LastValue(AI0), LastValue(AI1))) will return 3 if AI0 value is 1 and AI1 value is 5. Returns the smallest value in the given array. Example: Min(Array(LastValue(AI0), LastValue(AI1))) will return 1 if AI0 value is 1 and AI1 value is 5. Returns the largest value in the given array. Example: Max(Array(LastValue(AI0), LastValue(AI1))) will return 5 if AI0 value is 1 and AI1 value is 5. Returns all values between the lower and upper values. Example: Between(Array(LastValue(AI0), LastValue(AI1)), 4.0, 20.0) will return one value of 4 if AI0 value is 1 and AI1 value is 4. Boolean Integer (all parameters must be of the same type) Array Array of or Integer, Integer Array Array Array of or Integer Array of or Integer Array of or Integer Array Lower/Upper must be of same type as Array. Outside(values, lower, upper) Returns all values outside of the lower and upper values. Example: Outside(Array(LastValue(AI0), LastValue(AI1)), 4.0, 20.0) will return one value of 1 if AI0 value is 1 and AI1 value is 4. Array Lower/Upper must be of same type as Array. Nortech Management Ltd, United Kingdom Page 12 of 13
Examples Input aggregation Average 3 phase voltage: (LastValue(AI0) + LastValue(AI1) + LastValue(AI2)) / 3 HV voltage using tapping ratio of 4.5: (LastValue(AI0) + LastValue(AI1) + LastValue(AI2)) / 3 * 4.5 Alarm if analogue over threshold Alarm if analogue over HH threshold: LastValue(AI0) > HighHigh(AI0) Combinational binary logic (e.g. Any Alarm point) IsAlarm (BI0) Or IsAlarm (BI1) Or IsAlarm(BI2) Bitwise operator on analogue value (truncating to unsigned integer value) Cast(LastValue(AI0), uint) And 2 Nortech Management Ltd, United Kingdom Page 13 of 13