Class WriteRequestJsonUtilities
java.lang.Object
org.openhab.core.io.transport.modbus.json.WriteRequestJsonUtilities
Utilities for converting JSON to
ModbusWriteRequestBlueprint
- Author:
- Sami Salonen - Initial contribution
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default maxTries when it has not been specifiedstatic final String
Constant for the write address key in the JSONstatic final String
Constant for the function code key in the JSONstatic final String
Constant for the maxTries key in the JSONstatic final String
Constant for the value key in the JSON -
Method Summary
Modifier and TypeMethodDescriptionParse JSON string to collection ofModbusWriteRequestBlueprint
JSON string should represent a JSON array, with JSON objects.
-
Field Details
-
JSON_FUNCTION_CODE
Constant for the function code key in the JSON- See Also:
-
JSON_ADDRESS
Constant for the write address key in the JSON- See Also:
-
JSON_VALUE
Constant for the value key in the JSON- See Also:
-
JSON_MAX_TRIES
Constant for the maxTries key in the JSON- See Also:
-
DEFAULT_MAX_TRIES
public static final int DEFAULT_MAX_TRIESDefault maxTries when it has not been specified- See Also:
-
-
Method Details
-
fromJson
Parse JSON string to collection ofModbusWriteRequestBlueprint
JSON string should represent a JSON array, with JSON objects. Each JSON object represents a write request. The JSON object must have the following keys - functionCode: numeric function code - address: reference or start address of the write - value: array of data to be written. Use zero and one when writing coils. With registers, each number corresponds to register's 16 bit data. - maxTries: number of tries with the write in case of errors- Parameters:
unitId
- unit id for the constructedModbusWriteRequestBlueprint
jsonString
- json to be parsed in string format- Returns:
- collection of
ModbusWriteRequestBlueprint
representing the json - Throws:
IllegalArgumentException
- in case of unexpected function codes, or too large payload exceeding modbus protocol specificationIllegalStateException
- in case of parsing errors and unexpected json structure- See Also:
-