#ifndef _ECMP_BATTERY_HTML_H
#define _ECMP_BATTERT_HTML_H
#include
#include "../datalayer/datalayer.h"
#include "../datalayer/datalayer_extended.h"
#include "../devboard/webserver/BatteryHtmlRenderer.h"
class EcmpHtmlRenderer : public BatteryHtmlRenderer {
public:
String get_status_html() {
String content;
content += "Main Connector State: ";
if (datalayer_extended.stellantisECMP.MainConnectorState == 0) {
content += "Contactors open
";
} else if (datalayer_extended.stellantisECMP.MainConnectorState == 0x01) {
content += "Precharged";
} else {
content += "Invalid";
}
content +=
"Insulation Resistance: " + String(datalayer_extended.stellantisECMP.InsulationResistance) + "kOhm
";
content += "Interlock: ";
if (datalayer_extended.stellantisECMP.InterlockOpen == true) {
content += "BROKEN!
";
} else {
content += "Seated OK";
}
content += "Insulation Diag: ";
if (datalayer_extended.stellantisECMP.InsulationDiag == 0) {
content += "No failure
";
} else if (datalayer_extended.stellantisECMP.InsulationDiag == 1) {
content += "Symmetric failure";
} else { //4 Invalid, 5-7 illegal, wrap em under one text
content += "N/A";
}
content += "Contactor weld check: ";
if (datalayer_extended.stellantisECMP.pid_welding_detection == 0) {
content += "OK
";
} else if (datalayer_extended.stellantisECMP.pid_welding_detection == 255) {
content += "N/A";
} else { //Problem
content += "WELDED!" + String(datalayer_extended.stellantisECMP.pid_welding_detection) + "";
}
content += "Contactor opening reason: ";
if (datalayer_extended.stellantisECMP.pid_reason_open == 7) {
content += "Invalid Status
";
} else if (datalayer_extended.stellantisECMP.pid_reason_open == 255) {
content += "N/A";
} else { //Problem (Also status 0 might be OK?)
content += "Unknown" + String(datalayer_extended.stellantisECMP.pid_reason_open) + "";
}
content += "Status of power switch: " +
(datalayer_extended.stellantisECMP.pid_contactor_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_contactor_status)) +
"
";
content += "Negative power switch control: " +
(datalayer_extended.stellantisECMP.pid_negative_contactor_control == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_negative_contactor_control)) +
"
";
content += "Negative power switch status: " +
(datalayer_extended.stellantisECMP.pid_negative_contactor_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_negative_contactor_status)) +
"
";
content += "Positive power switch control: " +
(datalayer_extended.stellantisECMP.pid_positive_contactor_control == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_positive_contactor_control)) +
"
";
content += "Positive power switch status: " +
(datalayer_extended.stellantisECMP.pid_positive_contactor_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_positive_contactor_status)) +
"
";
content += "Contactor negative: " +
(datalayer_extended.stellantisECMP.pid_contactor_negative == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_contactor_negative)) +
"
";
content += "Contactor positive: " +
(datalayer_extended.stellantisECMP.pid_contactor_positive == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_contactor_positive)) +
"
";
content += "Precharge control: " +
(datalayer_extended.stellantisECMP.pid_precharge_relay_control == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_precharge_relay_control)) +
"
";
content += "Precharge status: " +
(datalayer_extended.stellantisECMP.pid_precharge_relay_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_precharge_relay_status)) +
"
";
content += "Recharge Status: " +
(datalayer_extended.stellantisECMP.pid_recharge_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_recharge_status)) +
"
";
content += "Delta temperature: " +
(datalayer_extended.stellantisECMP.pid_delta_temperature == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_delta_temperature)) +
"°C
";
content += "Lowest temperature: " +
(datalayer_extended.stellantisECMP.pid_lowest_temperature == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_lowest_temperature)) +
"°C
";
content += "Average temperature: " +
(datalayer_extended.stellantisECMP.pid_average_temperature == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_average_temperature)) +
"°C
";
content += "Highest temperature: " +
(datalayer_extended.stellantisECMP.pid_highest_temperature == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_highest_temperature)) +
"°C
";
content += "Coldest module: " +
(datalayer_extended.stellantisECMP.pid_coldest_module == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_coldest_module)) +
"
";
content += "Hottest module: " +
(datalayer_extended.stellantisECMP.pid_hottest_module == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_hottest_module)) +
"
";
content += "Average cell voltage: " +
(datalayer_extended.stellantisECMP.pid_avg_cell_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_avg_cell_voltage)) +
" mV
";
content +=
"High precision current: " +
(datalayer_extended.stellantisECMP.pid_current == 255 ? "N/A"
: String(datalayer_extended.stellantisECMP.pid_current)) +
" mA
";
content += "Insulation resistance neg-gnd: " +
(datalayer_extended.stellantisECMP.pid_insulation_res_neg == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_insulation_res_neg)) +
" kOhm
";
content += "Insulation resistance pos-gnd: " +
(datalayer_extended.stellantisECMP.pid_insulation_res_pos == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_insulation_res_pos)) +
" kOhm
";
content += "Max current 10s: " +
(datalayer_extended.stellantisECMP.pid_max_current_10s == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_max_current_10s)) +
"
";
content += "Max discharge power 10s: " +
(datalayer_extended.stellantisECMP.pid_max_discharge_10s == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_max_discharge_10s)) +
"
";
content += "Max discharge power 30s: " +
(datalayer_extended.stellantisECMP.pid_max_discharge_30s == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_max_discharge_30s)) +
"
";
content += "Max charge power 10s: " +
(datalayer_extended.stellantisECMP.pid_max_charge_10s == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_max_charge_10s)) +
"
";
content += "Max charge power 30s: " +
(datalayer_extended.stellantisECMP.pid_max_charge_30s == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_max_charge_30s)) +
"
";
content += "Energy capacity: " +
(datalayer_extended.stellantisECMP.pid_energy_capacity == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_energy_capacity)) +
"
";
content += "Highest cell number: " +
(datalayer_extended.stellantisECMP.pid_highest_cell_voltage_num == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_highest_cell_voltage_num)) +
"
";
content += "Lowest cell voltage number: " +
(datalayer_extended.stellantisECMP.pid_lowest_cell_voltage_num == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_lowest_cell_voltage_num)) +
"
";
content += "Sum of all cell voltages: " +
(datalayer_extended.stellantisECMP.pid_sum_of_cells == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_sum_of_cells)) +
" dV
";
content += "Cell min capacity: " +
(datalayer_extended.stellantisECMP.pid_cell_min_capacity == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_cell_min_capacity)) +
"
";
content += "Cell voltage measurement status: " +
(datalayer_extended.stellantisECMP.pid_cell_voltage_measurement_status == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_cell_voltage_measurement_status)) +
"
";
content += "Battery Insulation Resistance: " +
(datalayer_extended.stellantisECMP.pid_insulation_res == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_insulation_res)) +
" kOhm
";
content += "Pack voltage: " +
(datalayer_extended.stellantisECMP.pid_pack_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_pack_voltage)) +
" dV
";
content += "Highest cell voltage: " +
(datalayer_extended.stellantisECMP.pid_high_cell_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_high_cell_voltage)) +
" mV
";
content += "Lowest cell voltage: " +
(datalayer_extended.stellantisECMP.pid_low_cell_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_low_cell_voltage)) +
" mV
";
content += "Battery Energy: " +
(datalayer_extended.stellantisECMP.pid_battery_energy == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_battery_energy)) +
"
";
content += "Collision information Counter: " +
(datalayer_extended.stellantisECMP.pid_crash_counter == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_crash_counter)) +
"
";
content += "Collision Counter recieved by Wire: " +
(datalayer_extended.stellantisECMP.pid_wire_crash == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_wire_crash)) +
"
";
content += "Collision data sent from car to battery: " +
(datalayer_extended.stellantisECMP.pid_CAN_crash == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_CAN_crash)) +
"
";
content += "History data: " +
(datalayer_extended.stellantisECMP.pid_history_data == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_history_data)) +
"
";
content += "Low SOC counter: " +
(datalayer_extended.stellantisECMP.pid_lowsoc_counter == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_lowsoc_counter)) +
"
";
content += "Last CAN failure detail: " +
(datalayer_extended.stellantisECMP.pid_last_can_failure_detail == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_last_can_failure_detail)) +
"
";
content += "HW version number: " +
(datalayer_extended.stellantisECMP.pid_hw_version_num == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_hw_version_num)) +
"
";
content += "SW version number: " +
(datalayer_extended.stellantisECMP.pid_sw_version_num == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_sw_version_num)) +
"
";
content += "Factory mode: " +
(datalayer_extended.stellantisECMP.pid_factory_mode_control == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_factory_mode_control)) +
"
";
char readableSerialNumber[14]; // One extra space for null terminator
memcpy(readableSerialNumber, datalayer_extended.stellantisECMP.pid_battery_serial,
sizeof(datalayer_extended.stellantisECMP.pid_battery_serial));
readableSerialNumber[13] = '\0'; // Null terminate the string
content += "Battery serial: " + String(readableSerialNumber) + "
";
uint8_t day = (datalayer_extended.stellantisECMP.pid_date_of_manufacture >> 16) & 0xFF;
uint8_t month = (datalayer_extended.stellantisECMP.pid_date_of_manufacture >> 8) & 0xFF;
uint8_t year = datalayer_extended.stellantisECMP.pid_date_of_manufacture & 0xFF;
content += "Date of manufacture: " + String(day) + "/" + String(month) + "/" + String(year) + "
";
content += "Aux fuse state: " +
(datalayer_extended.stellantisECMP.pid_aux_fuse_state == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_aux_fuse_state)) +
"
";
content += "Battery state: " +
(datalayer_extended.stellantisECMP.pid_battery_state == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_battery_state)) +
"
";
content += "Precharge short circuit: " +
(datalayer_extended.stellantisECMP.pid_precharge_short_circuit == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_precharge_short_circuit)) +
"
";
content += "Service plug state: " +
(datalayer_extended.stellantisECMP.pid_eservice_plug_state == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_eservice_plug_state)) +
"
";
content += "Main fuse state: " +
(datalayer_extended.stellantisECMP.pid_mainfuse_state == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_mainfuse_state)) +
"
";
content += "Most critical fault: " +
(datalayer_extended.stellantisECMP.pid_most_critical_fault == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_most_critical_fault)) +
"
";
content += "Current time: " +
(datalayer_extended.stellantisECMP.pid_current_time == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_current_time)) +
" ticks
";
content += "Time sent by car: " +
(datalayer_extended.stellantisECMP.pid_time_sent_by_car == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_time_sent_by_car)) +
" ticks
";
content +=
"12V: " +
(datalayer_extended.stellantisECMP.pid_12v == 255 ? "N/A" : String(datalayer_extended.stellantisECMP.pid_12v)) +
"
";
content += "12V abnormal: ";
if (datalayer_extended.stellantisECMP.pid_12v_abnormal == 255) {
content += "N/A
";
} else if (datalayer_extended.stellantisECMP.pid_12v_abnormal == 0) {
content += "No";
} else {
content += "Yes";
}
content += "HVIL IN Voltage: " +
(datalayer_extended.stellantisECMP.pid_hvil_in_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_hvil_in_voltage)) +
"mV
";
content += "HVIL Out Voltage: " +
(datalayer_extended.stellantisECMP.pid_hvil_out_voltage == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_hvil_out_voltage)) +
"mV
";
content += "HVIL State: " +
(datalayer_extended.stellantisECMP.pid_hvil_state == 255
? "N/A"
: (datalayer_extended.stellantisECMP.pid_hvil_state == 0
? "OK"
: String(datalayer_extended.stellantisECMP.pid_hvil_state))) +
"
";
content += "BMS State: " +
(datalayer_extended.stellantisECMP.pid_bms_state == 255
? "N/A"
: (datalayer_extended.stellantisECMP.pid_bms_state == 0
? "OK"
: String(datalayer_extended.stellantisECMP.pid_bms_state))) +
"
";
content += "Vehicle speed: " +
(datalayer_extended.stellantisECMP.pid_vehicle_speed == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_vehicle_speed)) +
" km/h
";
content += "Time spent over 55c: " +
(datalayer_extended.stellantisECMP.pid_time_spent_over_55c == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_time_spent_over_55c)) +
" minutes
";
content += "Contactor lifetime closing counter: " +
(datalayer_extended.stellantisECMP.pid_contactor_closing_counter == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_contactor_closing_counter)) +
" cycles
";
content += "State of Health Cell-1: " +
(datalayer_extended.stellantisECMP.pid_SOH_cell_1 == 255
? "N/A"
: String(datalayer_extended.stellantisECMP.pid_SOH_cell_1)) +
"
";
if (datalayer_extended.stellantisECMP.MysteryVan) {
content += "MysteryVan platform detected:
";
content += "Crash Memorized: ";
if (datalayer_extended.stellantisECMP.CrashMemorized == 255) {
content += "Yes
";
} else {
content += "No";
}
content += "Contactor Opening Reason: ";
if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 0) {
content += "No error";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 1) {
content += "Crash!";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 2) {
content += "12V supply source undervoltage";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 3) {
content += "12V supply source overvoltage";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 4) {
content += "Battery temperature";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 5) {
content += "Interlock line open";
} else if (datalayer_extended.stellantisECMP.CONTACTOR_OPENING_REASON == 6) {
content += "e-Service plug disconnected";
}
content += "
";
content += "Battery fault type: ";
if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 0) {
content += "No fault";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 1) {
content += "FirstLevelFault: Warning Lamp";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 2) {
content += "SecondLevelFault: Stop Lamp";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 3) {
content += "ThirdLevelFault: Stop Lamp + contactor opening (EPS shutdown)";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 4) {
content += "FourthLevelFault: Stop Lamp + Active Discharge";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 5) {
content += "Inhibition of powertrain activation";
} else if (datalayer_extended.stellantisECMP.TBMU_FAULT_TYPE == 6) {
content += "Reserved";
}
content += "
";
content += "FC insulation minus resistance " +
String(datalayer_extended.stellantisECMP.HV_BATT_FC_INSU_MINUS_RES) + " kOhm
";
content += "FC insulation plus resistance " +
String(datalayer_extended.stellantisECMP.HV_BATT_FC_INSU_PLUS_RES) + " kOhm
";
content += "FC vehicle insulation plus resistance " +
String(datalayer_extended.stellantisECMP.HV_BATT_FC_VHL_INSU_PLUS_RES) + " kOhm
";
content += "FC vehicle insulation plus resistance " +
String(datalayer_extended.stellantisECMP.HV_BATT_ONLY_INSU_MINUS_RES) + " kOhm
";
}
return content;
}
};
#endif