vValue | (Variant) Value that is transformed |
---|---|
nType | (Long) Type of transformation
1 - 12 -> 21 - Swaps 1st<->2nd byte in the value of the Integer type (see Example1). It is so-called 2-byte value transfomation from Little-endian to Big-endian (or backwards).
2 - 1234 -> 4321 - Swaps 1st<->4th byte and 2nd<->3rd byte in the value of the Long type. It is so-called 4-byte value transfomation from Little-endian to Big-endian (or backwards).
20 - Long -> BCD - Transforms a value of the Long type (range 0-99999999) to the value of the Long type in BCD format (see Example2).
21 - BCD -> Long - Transforms a value of the Long type in BCD format to the value of the Long type.
40 - ElementArray -> Array - Transforming an array where the array items are of a real elementary data type (i.e. instead of being Variant type) into the standard (VBScript) form, where each array item is of the Variant type of specified subtype. This kind of conversion may be handy, for example, if the array is gained from the communication or from a DLL library function.
41 - Array -> ElementArray - Transforming the standard VBScript array, where each the array item is of the Variant type, into the array where each array item is represented by the same elementary data type (i.e. instead of being Variant type). This kind of conversion can be handy, for example, if the array is being sent into a communication (for OPC see Data vector transmission) or into a DLL library function.
50 - Matrix -> TranspMatrix - In a value of the array type (2-dimensional array) the mutual counterchange of rows and of columns is performed (transposed array).
100 - Simatic -> Single - Transforms a value of the Single type from the real number format PLC SIMATIC S5.
101 - Single -> Simatic - Transforms a value of the Single type into the real number format PLC SIMATIC S5.
120 - Real -> "99x9" - The value will be converted to string, where for real numbers (Single, Double or Date) the decimal separator will be used according to the Windows OS settings.
This and the following two transformations are suitable, for example, for storing the values into text files, see Data sharing by files. 121 - Real -> "99.9" - The value will be converted to string, where for real numbers (Single, Double or Date) the period (".") will be used as decimal separator regardless to Windows OS setting.
122 - Real -> "99,9" - The value will be converted to string, where for real numbers (Single, Double or Date) the comma character (",") will be used as decimal separator regardless to Windows OS setting.
200 - Value -> Array of Boolean - Creates the array (Array) with values of the Boolean type (see Example3). Each value of the array has one bit value of the vValue parameter. The vValue parameter can be:
- Byte data type: 8 values in the array (opposite to the transformation type 221)
- Integer data type: 16 values in the array (opposite to the transformation type 222)
- Long data type: 32 values in the array (opposite to the transformation type 223)
- Single data type: 32 values in the array (opposite to the transformation type 224)
- Double data type: 64 values in the array (opposite to the transformation type 225) 201 - Value -> Array of Byte - Creates the array (Array) with values of the Byte type. Each value of the array has one byte value of the vValue parameter. The vValue parameter can be:
- Byte data type: 1 value in the array (opposite to the transformation type 221)
- Integer data type: 2 values in the array (opposite to the transformation type 222)
- Long data type: 4 values in the array (opposite to the transformation type 223)
- Single data type: 4 values in the array (opposite to the transformation type 224)
- Double data type: 8 values in the array (opposite to the transformation type 225) 202 - Value -> Array of Integer - Creates the array (Array) with values of the Integer type. Each value of the array has two bytes value of the vValue parameter. The vValue parameter can be:
- Integer data type: 1 value in the array (opposite to the transformation type 222)
- Long data type: 2 values in the array (opposite to the transformation type 223)
- Single data type: 2 values in the array (opposite to the transformation type 224)
- Double data type: 4 values in the array (opposite to the transformation type 225) 203 - Value -> Array of Long - Creates the array (Array) with values of the Long type. Each value of the array has four bytes value of the vValue parameter. The vValue parameter can be:
- Long data type: 1 value in the array (opposite to the transformation type 223)
- Single data type: 1 value in the array (opposite to the transformation type 224)
- Double data type: 2 values in the array (opposite to the transformation type 225) 221 - Array -> Byte - Creates the value of the Byte type. The vValue parameter can be:
- Array: 8 values of the Boolean type (opposite to the transformation type 200)
- Array: 1 value of the Byte type (opposite to the transformation type 201) 222 - Array -> Integer - Creates the value of the Integer type (see Example3). The vValue parameter can be:
- Array: 16 values of the Boolean type (opposite to the transformation type 200)
- Array: 2 values of the Byte type (opposite to the transformation type 201)
- Array: 1 value of the Integer type (opposite to the transformation type 202) 223 - Array -> Long - Creates the value of the Long type. The vValue parameter can be:
- Array: 32 values of the Boolean type (opposite to the transformation type 200)
- Array: 4 values of the Byte type (opposite to the transformation type 201)
- Array: 2 values of the Integer type (opposite to the transformation type 202)
- Array: 1 value of the Long type (opposite to the transformation type 203)
- value of the Single type (opposite to the transformation type 204) 224 - Array -> Single - Creates the value of the Single type. The vValue parameter can be:
- Array: 32 values of the Boolean type (opposite to the transformation type 200)
- Array: 4 values of the Byte type (opposite to the transformation type 201)
- Array: 2 values of the Integer type (opposite to the transformation type 202)
- Array: 1 value of the Long type (opposite to the transformation type 203)
- value of the Long type (opposite to the transformation type 223) 225 - Array -> Double - Creates the value of the Double type. The vValue parameter can be:
- Array: 64 values of the Boolean type (opposite to the transformation type 200)
- Array: 8 values of the Byte type (opposite to the transformation type 201)
- Array: 4 values of the Integer type (opposite to the transformation type 202)
- Array: 2 values of the Long type (opposite to the transformation type 203) 240 - Array -> HexaString - The input is value of the Array type with all items of the Byte type. The output is value of the String type with so-called HexaString content.
Example: If the input value of the Array type contains three values of the Byte type, for example 1A 00 B8 (in hexadecimal), then the output would be a String containing six "1A00B8" characters. This is handy if you need to save binary data into the text. For this transformation type it is better to use the PmBuffer.GetHexaString method. 241 - HexaString -> Array - The opposite of previous transformation, i.e. from HexaString it creates value of the Array type with all items of the Byte type
For this transformation type it is better to use the PmBuffer.SetHexaString method. |
var Val = 3;
var ValNew = Pm.TransformValue(Val, 1);
var nVal = 99;
var nBcd = Pm.TransformValue(nVal, 20);
if (Pm.IsValid(nBcd))
{
Pm.Debug("Val=" + nVal + "-> BCD=" + nBcd);
// Val=99 -> BCD=153
Pm.Debug(0x99);
// Writing the same value in the form of a constant (in hexadecimal).
}
var Val1 = CInt(-2);
var Arr = Pm.TransformValue(Val1, 200);
var Val2 = Pm.TransformValue(Arr, 222);
Pm.Debug(Arr, 1);
Pm.Debug(Val2, 1);