var SOC1, SOC2, Battery100Cap, CellMaxTemp, CellMinTemp, BatteryVolts, CellMaxVolt, CellMinVolt, ChargeAmpsAC, ChargeAmpsDC, ChargeVoltsAC, ChargeVoltsDC, ChargerTemperature1, ChargerTemperature2, Odometer, OutdoorAirTemperature;
for (let i = 0; i < msg.payload.frame.length; i++) {
let frame = msg.payload.frame[i];
let id = frame.id;
let data = frame.data;
switch (id) {
case 884:
SOC1 = { payload: (data[0] - 10) / 2 };
SOC2 = { payload: (data[1] - 10) / 2 };
Battery100Cap = { payload: data[6] / 2 };
CellMaxTemp = { payload: data[4] - 50 };
CellMinTemp = { payload: data[5] - 50 };
break;
case 883:
BatteryVolts = { payload: (data[4] * 256 + data[5]) / 10 };
CellMaxVolt = { payload: (data[0] + 210) / 100 };
CellMinVolt = { payload: (data[1] + 210) / 100 };
break;
case 905:
ChargeAmpsAC = { payload: data[6] / 10 };
ChargeAmpsDC = { payload: data[2] / 10 };
ChargeVoltsAC = { payload: data[1] };
ChargeVoltsDC = { payload: 2 * data[0] + 0.5 };
ChargerTemperature1 = { payload: data[3] - 50 };
ChargerTemperature2 = { payload: data[4] - 50 };
break;
case 1042:
Odometer = { payload: data[2] * 65536 + data[3] * 256 + data[4] };
break;
case 646:
OutdoorAirTemperature = { payload: data[3] - 50 };
break;
default:
break;
}
}
return [SOC1, SOC2, Battery100Cap, CellMaxTemp, CellMinTemp, BatteryVolts, CellMaxVolt, CellMinVolt, ChargeAmpsAC, ChargeAmpsDC, ChargeVoltsAC, ChargeVoltsDC, ChargerTemperature1, ChargerTemperature2, Odometer, OutdoorAirTemperature];