mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Merge branch 'main' into feature/event-log
This commit is contained in:
commit
25cdc7a98a
17 changed files with 400 additions and 231 deletions
|
@ -278,6 +278,62 @@ static void set_message(EVENTS_ENUM_TYPE event) {
|
|||
snprintf(events.message, sizeof(events.message), "The dummy event was set!"); // Don't change this event message!
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
const char* get_event_message(EVENTS_ENUM_TYPE event) {
|
||||
switch (event) {
|
||||
case EVENT_CAN_FAILURE:
|
||||
return "No CAN communication detected for 60s. Shutting down battery control.";
|
||||
case EVENT_CAN_WARNING:
|
||||
return "ERROR: High amount of corrupted CAN messages detected. Check CAN wire shielding!";
|
||||
case EVENT_WATER_INGRESS:
|
||||
return "Water leakage inside battery detected. Operation halted. Inspect battery!";
|
||||
case EVENT_12V_LOW:
|
||||
return "12V battery source below required voltage to safely close contactors. Inspect the supply/battery!";
|
||||
case EVENT_SOC_PLAUSIBILITY_ERROR:
|
||||
return "ERROR: SOC% reported by battery not plausible. Restart battery!";
|
||||
case EVENT_KWH_PLAUSIBILITY_ERROR:
|
||||
return "Warning: kWh remaining reported by battery not plausible. Battery needs cycling.";
|
||||
case EVENT_BATTERY_CHG_STOP_REQ:
|
||||
return "ERROR: Battery raised caution indicator AND requested charge stop. Inspect battery status!";
|
||||
case EVENT_BATTERY_DISCHG_STOP_REQ:
|
||||
return "ERROR: Battery raised caution indicator AND requested discharge stop. Inspect battery status!";
|
||||
case EVENT_BATTERY_CHG_DISCHG_STOP_REQ:
|
||||
return "ERROR: Battery raised caution indicator AND requested charge/discharge stop. Inspect battery status!";
|
||||
case EVENT_LOW_SOH:
|
||||
return "ERROR: State of health critically low. Battery internal resistance too high to continue. Recycle "
|
||||
"battery.";
|
||||
case EVENT_HVIL_FAILURE:
|
||||
return "ERROR: Battery interlock loop broken. Check that high voltage connectors are seated. Battery will be "
|
||||
"disabled!";
|
||||
case EVENT_INTERNAL_OPEN_FAULT:
|
||||
return "ERROR: High voltage cable removed while battery running. Opening contactors!";
|
||||
case EVENT_CELL_UNDER_VOLTAGE:
|
||||
return "ERROR: CELL UNDERVOLTAGE!!! Stopping battery charging and discharging. Inspect battery!";
|
||||
case EVENT_CELL_OVER_VOLTAGE:
|
||||
return "ERROR: CELL OVERVOLTAGE!!! Stopping battery charging and discharging. Inspect battery!";
|
||||
case EVENT_CELL_DEVIATION_HIGH:
|
||||
return "ERROR: HIGH CELL DEVIATION!!! Inspect battery!";
|
||||
case EVENT_UNKNOWN_EVENT_SET:
|
||||
return "An unknown event was set! Review your code!";
|
||||
case EVENT_DUMMY:
|
||||
return "The dummy event was set!"; // Don't change this event message!
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const char* get_event_enum_string(EVENTS_ENUM_TYPE event) {
|
||||
const char* fullString = EVENTS_ENUM_TYPE_STRING[event];
|
||||
if (strncmp(fullString, "EVENT_", 6) == 0) {
|
||||
return fullString + 6; // Skip the first 6 characters
|
||||
}
|
||||
return fullString;
|
||||
}
|
||||
|
||||
static void set_event_message(EVENTS_ENUM_TYPE event) {
|
||||
const char* message = get_event_message(event);
|
||||
snprintf(event_message, sizeof(event_message), "%s", message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue