public ChargeDischargeTotalMessage(byte[] payload) { payload.RequireBytes(8); ChargeTotal = new KiloWattHour((payload[0] + (payload[1] << 8) + (payload[2] << 16) + (payload[3] << 24)) / 1000.0m); DischargeTotal = new KiloWattHour((payload[4] + (payload[5] << 8) + (payload[6] << 16) + (payload[7] << 24)) / 1000.0m); }
public ChargeDischargeMessage(byte[] payload) { payload.RequireBytes(RequireBytes); TotalDischarge = new KiloWattHour(BitArrayConverter.ToUInt32(payload, 0, 32) * 0.001m); TotalCharge = new KiloWattHour(BitArrayConverter.ToUInt32(payload, 32, 32) * 0.001m); }
public StateOfChargeMessage(byte[] payload) { payload.RequireBytes(RequireBytes); DetermineChargeTotalType(payload); ChargeTotal = new KiloWattHour((payload[4] + (payload[5] << 8) + (payload[6] << 16) + (payload[7] << 24)) / 1000.0m); StateOfChargeMin = new Percent((payload[0] + ((payload[1] & 0x3) << 8)) / 10m); StateOfChargeDisplayed = new Percent((payload[1] >> 2) + ((payload[2] & 0xF) << 6) / 10.0m); }
public BatteryCapacityMessage(byte[] payload) { payload.RequireBytes(RequireBytes); FullBatteryCapacity = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 0, 10) * 0.1m); RemainingBatteryCapacity = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 10, 10) * 0.1m); ExpectedRemainingCapacity = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 20, 10) * 0.1m); IdealRemaining = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 30, 10) * 0.1m); ToCompleteCharge = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 40, 10) * 0.1m); EnergyBuffer = new KiloWattHour(BitArrayConverter.ToUInt16(payload, 50, 10) * 0.1m); }
public PackInfoMessage(byte[] payload) { payload.RequireBytes(RequireBytes); EnergyBuffer = new KiloWattHour(((payload[6] >> 2) + (payload[7] & 0x03) * 64) * 0.1m); ExpectedRemaining = new KiloWattHour(((payload[2] >> 4) + (payload[3] & 0x3F) << 4) * 0.1m); IdealRemaining = new KiloWattHour(((payload[3] >> 6) + (payload[4] & 0xFF) << 2) * 0.1m); NominalFullPack = new KiloWattHour((payload[0] + ((payload[1] & 0x03) << 8)) * 0.1m); NominalRemaining = new KiloWattHour(((payload[1] >> 2) + ((payload[2] & 0x0F) << 6)) * 0.1m); ToChargeComplete = new KiloWattHour((payload[5] + ((payload[6] & 0x03) << 8)) * 0.1); }