getWriteRequest method

  1. @override
ModbusWriteRequest getWriteRequest(
  1. dynamic value, {
  2. bool rawValue = false,
  3. int? unitId,
  4. Duration? responseTimeout,
  5. ModbusEndianness? endianness,
})
override

Gets a write request from this register element. value is set to the element once request is successfully completed. If rawValue is true then the integer value is written as it is without any value or type conversion.

Implementation

@override
ModbusWriteRequest getWriteRequest(dynamic value,
    {bool rawValue = false,
    int? unitId,
    Duration? responseTimeout,
    ModbusEndianness? endianness}) {
  if (byteCount == 2) {
    return super.getWriteRequest(value,
        rawValue: rawValue,
        unitId: unitId,
        responseTimeout: responseTimeout,
        endianness: endianness ?? this.endianness);
  } else {
    var numValue = rawValue ? value : _getRawValue(value);
    return getMultipleWriteRequest(_toBytes(numValue),
        unitId: unitId,
        responseTimeout: responseTimeout,
        endianness: endianness ?? this.endianness);
  }
}