Update cookies preferences
Promotic

ArrayOper - method of the Pm object

Description:
Method performs various types of calculations over the array.
Syntax:
Variant ArrayOper(Array aArray, String sType)
Parameters:
aArray(Array) The array over which the operation is performed (PmArray object for JavaScript or Array data type for VBScript).
sType(String) Type name of the performed operation:
"Min" - Minimum value of all array items. The items must be numeric, of the String type or Date type. For the String type, the items are sorted alphabetically.
"Max" - Maximum value of all array items. The items must be numeric, of the String type or Date type. For the String type, the items are sorted alphabetically.
"Sum" - Sum of the array items values. The items must be numeric and the result is a value of the Double type.
"Mean" - Mean value of the array items. The items must be numeric and the result is a value of the Double type.
"StdDeviation" - Standard deviation of the array items values. The items must 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, i.e. 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, i.e. 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, i.e. 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" - Checksum 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 to the value of the Byte type (i.e. sum 256 modulo).
"CSumB2" - the same as CSumB1 but the result sum is converted to the value of the Integer type (i.e. sum modulo 65536).
Note:
- Statistical calculations (average, sum, ...) can also be done by the trend system, see the PmaTrendGroup.GetData method.
- it is better to use the PmBuffer object method CalcCheckSum for computation of checksums.


This method is not functional in Web panels.
Example1:
The example gets the sum of values and minimum value of items from the PmaData object. The result is written into the INFO system.
JavaScriptVBScriptSelect and copy to clipboard

var 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).
JavaScriptVBScriptSelect and copy to clipboard

var arr = Pm.Array1("abc", "xyz", "fgr");
Pm.Debug("Min=" + Pm.ArrayOper(arr, "Min"));
Pm.Debug("Max=" + Pm.ArrayOper(arr, "Max"));
in the "Debug" item of the INFO system there will be then:
  Min = abc
  Max = xyz

History:
Pm8.01.02: added the CRC1 parameter.
PROMOTIC 9.0.29 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- ArrayOper
 
 
- Cos
- E
- Exp
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.