LengthType element
Specifies whether the parameter has a fixed length.
Type
Parent
Attributes
| Name | Type | Required | Description |
|---|---|---|---|
| id | TypeParamId | Specifies the ID of another parameter that contains the parameter length. | |
| times | unsignedInt | Specifies the number of times the next parameter should occur before it is considered to be the next parameter. |
Remarks
Contains one of the following values:
fixed
The parameter has a fixed length, which has to be defined in the Protocol.Params.Param.Interprete.Length tag. During parameter initialization, DataMiner does the following for parameters that have LengthType set to "fixed":
A byte array is created with size equal to the value specified in Interprete.Length. This array is then initialized. The initialization value depends on the RawType value:
- If RawType is set to "text" or "other", the array is initialized with 0x20 bytes.
- If RawType is set to "numeric text", the array is initialized with 0x30 bytes.
- If RawType is set to "signed number", "unsigned number", "double" or "bcd", the array is initialized with 0x00 bytes.
If the parameter specifies a fixed value (Interprete/Value), the byte array is set to the specified value.
For example, executing a GetData (SLProtocol) on a parameter with the following Interprete defined will result in a byte array being returned of size 2, with each byte having a value of 0x20 ([0x20 0x20]).
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>fixed</LengthType>
<Length>2</Length>
</Interprete>
Note
As a result, the IsEmpty (SLProtocol) method will always return false for fixed length parameters, even if these do not have a value specified (Interprete.Value).
last next param
The parameter has a variable length, which depends on the last instance of the next (fixed-length) parameter in the response.
If the expected response will contain a number with a length up to 5 digits (which can have a decimal point), followed by a fixed point, then you can define two parameters:
- A first one with a LengthType equal to "last next param" to catch the number containing the decimal point ("last next param" will make sure the number is not broken off at the first point), and
- A second one with a LengthType equal to "fixed" to catch the point.
Important
Do not use this LengthType if the next parameter is the trailer, and the trailer is not unique within the response sequence.
In this situation, the raw data reader stops at the first occurrence of the trailer. All data received up to that point is immediately forwarded for parameter processing, including any bytes that had already been received as part of the same chunk, even if they logically belong after the first trailer occurrence.
Because incoming data may arrive in arbitrary chunks, this can lead to inconsistent and unpredictable results. For example, if the expected response is abc$def$, and $ is defined as the trailer, the parameter logic might receive this from the raw bytes reader:
abc$abc$dabc$deabc$def$abc$def$
This could cause the current last next param to be filled in with the value abc$ or abc$def$, which is unexpected. To avoid incomplete or incorrectly parsed values, ensure that the trailer is unique within the entire response sequence.
Example
The last next param LengthType determines the length of the current parameter by searching for the last occurrence of the following parameter's value in the incoming data.
For example, assuming the following:
- The current parameter has
LengthType = last next param. - The following parameter is a fixed parameter with the value
$. - The last parameter is a trailer parameter with the fixed value
#.
This is the incoming data:
abc$def$ghi$#
In this case:
- The logic receiving the raw bytes will wait and search until it finds the trailer, after which it forwards all the data it received to the parameter parser.
- The parameter parser searches for the last occurrence of
$in the string it received from the raw bytes receiver (abc$def$ghi$#). - Everything before that last
$is assigned to the current parameter. - The parameter parser matches the last
$to the fixed parameter with value$. - The parameter parser matches the
#to the trailer parameter.
Result:
- Current parameter value:
abc$def$ghi. - Following (fixed) parameter value:
$. - The trailer parameter value:
#and a complete, successful, match.
This behavior differs from the next param LengthType. If next param were used instead, the parser would stop at the first occurrence of $, and the current parameter would receive only the following data:
abc
After that, the parameter match would fail, as the first $ is not followed by the trailer (#).
In summary, last next param ensures that the current parameter includes all content up to the final occurrence of the following parameter, making it useful when the data itself may contain the same delimiter multiple times.
next param
The parameter has a variable length, which depends on the next (fixed-length) parameter in the response.
If the expected response will contain a number with a length up to 5 digits, followed by a point, you can define two parameters:
- A first one with a LengthType equal to "next param" to catch the number, and
- A second one with a LengthType equal to "fixed" to catch the point.
other param
The length of the parameter will be inherited from another parameter.
The ID of that other parameter has to be specified in the id attribute. See id.