Promotic
WikipediaLinkedInYoutubeTwitterFacebook

ArrayOper - method of object Pm

Description:
Method performs various types of calculations over the array.
Syntax:
ArrayOper(aArray As Array, sType As String) As Variant
Calling:
val = Pm.ArrayOper(aArray, sType)
Parameters:
aArray(Array) Array over which the operation is performed
sType(String) Type name of the performed operation:
"Min" - Minimum value of all array items. The items have to be numeric, of the String or Date type. In case of the String type, the items are sorted alphabetically.
"Max" - Maximum value of all array items. The items have to be numeric, of the String or Date type. In case of the String type, the items are sorted alphabetically.
"Sum" - Sum of the array items values. The items have to be numeric and the result is a value of the Double type.
"Mean" - Mean value of the array items. The items have to be numeric and the result is a value of the Double type.
"StdDeviation" - Standard deviation of the array items values. The items have to be numeric and the result is a value of the Double type.
"CRC1" - CRC-16-CCITT, 2 bytes Cyclical Redundancy Check with CCITT polynomial [0x1021 = x16+x12+x5+1]. Cyclical Redundancy Check of the array value bytes. The items can be of any type and the result is the value of the Integer type that is 2 bytes value. This check sum is used, for example, at the PmSBUS communication. It is possible to enter the sub-option: "CRC1,Be" that performs the sum over the values converted into Big-Endian format.
"CRC2" - CRC-16-IBM, 2 bytes Cyclical Redundancy Check with CCITT polynomial [0xA001 = x16+x15+x2+1]. Cyclical Redundancy Check of the array value bytes. The items can be of any type and the result is the value of the Integer type that is 2 bytes value. This check sum is used, for example, at the Modbus communication protocol. It is possible to enter the sub-option: "CRC2,Be" that performs the sum over the values converted into Big-Endian format.
"CRC3" - CRC-16-IBM, 2 bytes Cyclical Redundancy Check with CCITT polynomial [0x8005 = x16+x15+x2+1]. Cyclical Redundancy Check of the array value bytes. The items can be of any type and the result is the value of the Integer type that is 2 bytes value. This check sum is used, for example, at the PmABradleyDF1 communication. It is possible to enter the sub-option: "CRC3,Be" that performs the sum over the values converted into Big-Endian format.
"CSumB1" - Check sum of the "byte values sum" type. The values of the array are stored linear into the memory and then the sum of such stored bytes is performed. The result sum is converted into the Byte data type (i.e. sum 256 modulo).
"CSumB2" - The same as CSumB1 but the result sum is converted into the Integer data type (i.e. sum 65536 modulo).
Note:
Statistical calculations (average, summ, ..) can also be done by the trend system, using, for example, the PmTrend.GetData method.

This method is not so far functional for Web Panels.

Example1:
The example gets the sum of values and minimum value of items from the PmData object. The result is written into the INFO system.
Dim arr
arr = pMe.Pm("/Data").GetVarArray()
Pm.Debug "Sum=" & Pm.ArrayOper(arr, "Sum")
Pm.Debug "Min=" & Pm.ArrayOper(arr, "Min")
Example2:
The example gets the minimum and maximum value from the string array (in alphabetical order).
Dim arr
arr = Array("abc", "xyz", "fgr")
Pm.Debug "Min=" & Pm.ArrayOper(arr, "Min")
Pm.Debug "Max=" & Pm.ArrayOper(arr, "Max")
In the item Debug_info of the INFO system there will be then:
  Min = abc
  Max = xyz
Navigation:
 
- Pm
 
- Abs
- ArrayOper
 
 
- Cos
- E
- Exp
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice