Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Object PmBuffer (Binary data)

Description:
The object represents binary values in data block. Data block (buffer) is a continuous area in memory. For reading/writing of individual value it is necessary to know its position (offset) in the data block and also the data type (size).
General methods and properties:
AutoOffset Internal automated position in the data block
SetSize Setting the data block size
GetSize Detection of data block size
SetBuffer Writing data block in the form of PmBuffer
GetBuffer Reading the data block in the form of PmBuffer
Methods for writing and reading numeric value:
SetInt8 Writing integer 1 byte value
GetInt8 Reading the integer 1 byte value
SetUint8 Writing integer 1 byte value with no sign
GetUint8 Reading integer 1 byte value with no sign
SetInt16 Writing integer 2 byte value
GetInt16 Reading the integer 2 byte value
SetUint16 Writing integer 2 byte value with no sign
GetUint16 Reading integer 2 byte value with no sign
SetInt32 Writing integer 4 byte value
GetInt32 Reading the integer 4 byte value
SetUint32 Writing integer 4 byte value with no sign
GetUint32 Reading integer 4 byte value with no sign
GetFloat32 Reading the real 4 byte value
SetFloat32 Writing real 4 byte value
GetFloat64 Reading the real 8 byte value
SetFloat64 Writing real 8 byte value
Methods for writing and reading String type value:
SetStringFix Writing the character string with fixed lenght
GetStringFix Reading the character string with fixed lenght
SetStringVar Writing the character string with variable lenght (terminated by the NULL character)
GetStringVar Reading the character string with variable lenght (terminated by the NULL character)
SetHexaString Writing data block in the form of HexaString
GetHexaString Reading the data block in the form of HexaString
SetBase64String Writing data block in the form of Base64String
GetBase64String Reading the data block in the form of Base64String
Note:
- The object can be created by the method Pm.CreatePmBuffer.
- This object is functional also for Web panels.

Comparison of objects used for data storage:

The following object types can be used for holding values (of any data type). Each of these objects has certain advantages and disadvantages and the choice depends on the desired usage.

PmArray: This object contains values that are accessible by index in the array - it is possible to read any value at any time in this object. Reading and setting values is very fast, but adding is slow.

This object is functional only for JavaScript language. For the VBScript language the array is represented by Array data type.

PmMap: This object contains values that are addressed by name (text identifier). Value names represent object properties. The advanatege is the "clarity" of usage in the script code. The disadvantage is the inability to access the values in cycle by index.
PmBuffer: This object contains binary values in data block. For reading/writing of individual value it is necessary to know its position (offset) in the data block and also the data type (size).
Example:
JavaScriptSelect and copy to clipboard

var b = Pm.CreatePmBuffer();
//Setting the whole content of the data block as HexaString and partial reading of its content into 3 variables of different types
var s1 = "40302010605070";  //The HexaString contains 7 bytes with values 0x40 0x30 0x20 0x10 0x60 0x50 0x70
b.SetHexaString(-2, s1);  //Filling the data block with data from HexaString
b.AutoOffset = 0;  //Setting the automatic position back to beginning
var i32 = b.GetInt32(-4);  //Reading the value into variable: 0x10203040
var i16 = b.GetInt16(-4);  //Reading the value into variable: 0x5060
var ui8 = b.GetUint8(-4);  //Reading the value into variable: 0x70
//Continuous creation of data block by writing 3 variables and then obtaining the whole content in the form of HexaString
b.SetSize(0);  //Setting the new size to 0 and deleting (resetting) of existing content of the data block
b.SetInt32(-2, i32);  //Adding the value from variable to the end: 0x10203040
b.SetInt16(-2, i16);  //Adding the value from variable to the end: 0x5060
b.SetUint8(-2, ui8);  //Adding the value from variable to the end: 0x70
var s2 = b.GetHexaString(0);  //Reading the data block in the form of HexaString. The read value s2 is the same as the original input value s1

History:
Pm9.00.04: Created
PROMOTIC 9.0.4 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice