getNext method

num? getNext(
  1. ModbusRecordType type
)

Implementation

num? getNext(ModbusRecordType type) {
  if (_endOfRecord(_currentBytePos + (type.recordLength * 2))) {
    return null;
  }
  var dataView = ByteData.view(recordBuffer);
  var pos = _currentBytePos;
  _currentBytePos += type.recordLength * 2;
  switch (type) {
    case ModbusRecordType.int16:
      return dataView.getInt16(pos);
    case ModbusRecordType.uint16:
      return dataView.getUint16(pos);
    case ModbusRecordType.int32:
      return dataView.getInt32(pos);
    case ModbusRecordType.uint32:
      return dataView.getUint32(pos);
    case ModbusRecordType.float:
      return dataView.getFloat32(pos);
    case ModbusRecordType.double:
      return dataView.getFloat64(pos);
  }
}