GeneratorStatus.parse constructor

GeneratorStatus.parse(
  1. ByteData data_
)

Implementation

factory GeneratorStatus.parse(ByteData data_) {
  if (data_.lengthInBytes < GeneratorStatus.mavlinkEncodedLength) {
    var len = GeneratorStatus.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var status = data_.getUint64(0, Endian.little);
  var batteryCurrent = data_.getFloat32(8, Endian.little);
  var loadCurrent = data_.getFloat32(12, Endian.little);
  var powerGenerated = data_.getFloat32(16, Endian.little);
  var busVoltage = data_.getFloat32(20, Endian.little);
  var batCurrentSetpoint = data_.getFloat32(24, Endian.little);
  var runtime = data_.getUint32(28, Endian.little);
  var timeUntilMaintenance = data_.getInt32(32, Endian.little);
  var generatorSpeed = data_.getUint16(36, Endian.little);
  var rectifierTemperature = data_.getInt16(38, Endian.little);
  var generatorTemperature = data_.getInt16(40, Endian.little);

  return GeneratorStatus(
      status: status,
      batteryCurrent: batteryCurrent,
      loadCurrent: loadCurrent,
      powerGenerated: powerGenerated,
      busVoltage: busVoltage,
      batCurrentSetpoint: batCurrentSetpoint,
      runtime: runtime,
      timeUntilMaintenance: timeUntilMaintenance,
      generatorSpeed: generatorSpeed,
      rectifierTemperature: rectifierTemperature,
      generatorTemperature: generatorTemperature);
}