Encode Binary Buffer
The Encode Binary Buffer action writes
multiple variable values into a single output binary
buffer. The source variables, data types, offsets into the
destination buffer, counts, intervals, lengths and special
handling options can be specified.
Parameter descriptions
The action provides these parameters:
Parameter | Description |
---|---|
Rules Input Type | The options are:
|
Rules in JSON | When Rules Input
Type is
Manual, this parameter
is used to specify the JSON description
of the variables to encode into a
binary buffer. Each variable is
specified as shown in the example
with:
|
File | When Rules Input
Type is Staging
File, this parameter is used
to specify a file in the Staging
Browser area that contains the JSON
description of the variables to encode
into a binary buffer. This file is read when the trigger is edited. The description of the variables in the file is handled in the same manner as the Rules in JSON parameter. The file is only read when the trigger is edited, so changes to the file's content do not impact a started trigger's definition or function. To change a trigger's function, the trigger must be stopped, edited (the file is read) to make any necessary changes, and then restarted. |
Byte Order | There are two types:
|
Input tab
Parameter | Description |
---|---|
Binary Buffer | Specifies the source binary buffer. This source binary buffer is copied to an internal buffer before the encoding (writing) of the individual source variables. |
Offset | An optional offset used in addition
to each variable's offset value. This can be used, for example, when a variable length header in the destination buffer needs to be accounted for. |
Input map variables | The map variables identified in the
JSON variable description. Each variable in the JSON variable description will be added as a map variable row in the Input tab. In the Value column, specify the source variable. The variable can be a constant, trigger macro, event variable, trigger variable or device variable. |
Output tab
Parameter | Description |
---|---|
Binary Buffer | Specifies the destination binary
buffer that stores the result of the
Encode Binary Buffer action. The result of the Encode Binary Buffer action is copied from the internal replica of the source binary buffer to the destination binary buffer. If you want to update a source binary buffer directly with the variable values specified, then the Output tab Binary Buffer parameter should be set to the same variable as the Input tab Binary Buffer parameter. |
Encode Binary Buffer example
This example shows the JSON description of the variables and the placement of the data as it is written into the output binary buffer.
{
"First" : {"offset":8, "type":"FLOAT4", "count":1 },
"Second" : {"offset": 12, "type":"STRING", "count":2, "length":4 },
"Third" : {"offset":30, "type":"INT4", "count":4, "interval":6 }
}
Encode Binary Buffer example using process.bit and process.all.bits
This example shows the JSON description of the variables and the placement of the data as it is written into the output binary buffer.
{
"First" : {"offset":0, "type":"BOOL", "count":3, "bit_offset":1, "special":"process.bit" },
"Second" : {"offset": 2, "type":"BOOL", "count":10, "bit_offset":2, "special":"process.all.bits" }
}