BatteryInfo.parse constructor

BatteryInfo.parse(
  1. ByteData data_
)

Implementation

factory BatteryInfo.parse(ByteData data_) {
  if (data_.lengthInBytes < BatteryInfo.mavlinkEncodedLength) {
    var len = BatteryInfo.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var dischargeMinimumVoltage = data_.getFloat32(0, Endian.little);
  var chargingMinimumVoltage = data_.getFloat32(4, Endian.little);
  var restingMinimumVoltage = data_.getFloat32(8, Endian.little);
  var chargingMaximumVoltage = data_.getFloat32(12, Endian.little);
  var chargingMaximumCurrent = data_.getFloat32(16, Endian.little);
  var nominalVoltage = data_.getFloat32(20, Endian.little);
  var dischargeMaximumCurrent = data_.getFloat32(24, Endian.little);
  var dischargeMaximumBurstCurrent = data_.getFloat32(28, Endian.little);
  var designCapacity = data_.getFloat32(32, Endian.little);
  var fullChargeCapacity = data_.getFloat32(36, Endian.little);
  var cycleCount = data_.getUint16(40, Endian.little);
  var weight = data_.getUint16(42, Endian.little);
  var id = data_.getUint8(44);
  var batteryFunction = data_.getUint8(45);
  var type = data_.getUint8(46);
  var stateOfHealth = data_.getUint8(47);
  var cellsInSeries = data_.getUint8(48);
  var manufactureDate = MavlinkMessage.asInt8List(data_, 49, 9);
  var serialNumber = MavlinkMessage.asInt8List(data_, 58, 32);
  var name = MavlinkMessage.asInt8List(data_, 90, 50);

  return BatteryInfo(
      dischargeMinimumVoltage: dischargeMinimumVoltage,
      chargingMinimumVoltage: chargingMinimumVoltage,
      restingMinimumVoltage: restingMinimumVoltage,
      chargingMaximumVoltage: chargingMaximumVoltage,
      chargingMaximumCurrent: chargingMaximumCurrent,
      nominalVoltage: nominalVoltage,
      dischargeMaximumCurrent: dischargeMaximumCurrent,
      dischargeMaximumBurstCurrent: dischargeMaximumBurstCurrent,
      designCapacity: designCapacity,
      fullChargeCapacity: fullChargeCapacity,
      cycleCount: cycleCount,
      weight: weight,
      id: id,
      batteryFunction: batteryFunction,
      type: type,
      stateOfHealth: stateOfHealth,
      cellsInSeries: cellsInSeries,
      manufactureDate: manufactureDate,
      serialNumber: serialNumber,
      name: name);
}