Further improve dialogue boxes and texts

This commit is contained in:
Daniel Öster 2025-08-17 21:24:55 +03:00
parent 8444855f24
commit 1645c5b337
4 changed files with 26 additions and 19 deletions

View file

@ -192,7 +192,7 @@ void handle_contactors() {
set(negPin, OFF, PWM_OFF_DUTY); set(negPin, OFF, PWM_OFF_DUTY);
set(posPin, OFF, PWM_OFF_DUTY); set(posPin, OFF, PWM_OFF_DUTY);
set_event(EVENT_ERROR_OPEN_CONTACTOR, 0); set_event(EVENT_ERROR_OPEN_CONTACTOR, 0);
datalayer.system.status.contactors_engaged = false; datalayer.system.status.contactors_engaged = 2;
return; // A fault scenario latches the contactor control. It is not possible to recover without a powercycle (and investigation why fault occured) return; // A fault scenario latches the contactor control. It is not possible to recover without a powercycle (and investigation why fault occured)
} }
@ -201,10 +201,9 @@ void handle_contactors() {
set(prechargePin, OFF); set(prechargePin, OFF);
set(negPin, OFF, PWM_OFF_DUTY); set(negPin, OFF, PWM_OFF_DUTY);
set(posPin, OFF, PWM_OFF_DUTY); set(posPin, OFF, PWM_OFF_DUTY);
datalayer.system.status.contactors_engaged = false; datalayer.system.status.contactors_engaged = 0;
if (datalayer.system.status.battery_allows_contactor_closing && if (datalayer.system.status.inverter_allows_contactor_closing &&
datalayer.system.status.inverter_allows_contactor_closing &&
!datalayer.system.settings.equipment_stop_active) { !datalayer.system.settings.equipment_stop_active) {
contactorStatus = START_PRECHARGE; contactorStatus = START_PRECHARGE;
} }
@ -263,7 +262,7 @@ void handle_contactors() {
set(posPin, ON, PWM_HOLD_DUTY); set(posPin, ON, PWM_HOLD_DUTY);
dbg_contactors("PRECHARGE_OFF"); dbg_contactors("PRECHARGE_OFF");
contactorStatus = COMPLETED; contactorStatus = COMPLETED;
datalayer.system.status.contactors_engaged = true; datalayer.system.status.contactors_engaged = 1;
} }
break; break;
default: default:

View file

@ -310,8 +310,8 @@ struct DATALAYER_SYSTEM_STATUS_TYPE {
/** True if the inverter allows for the contactors to close */ /** True if the inverter allows for the contactors to close */
bool inverter_allows_contactor_closing = true; bool inverter_allows_contactor_closing = true;
/** True if the contactor controlled by battery-emulator is closed */ /** 0 if starting up, 1 if contactors engaged, 2 if the contactors controlled by battery-emulator is opened */
bool contactors_engaged = false; uint8_t contactors_engaged = 0;
/** True if the contactor controlled by battery-emulator is closed. Determined by check_interconnect_available(); if voltage is OK */ /** True if the contactor controlled by battery-emulator is closed. Determined by check_interconnect_available(); if voltage is OK */
bool contactors_battery2_engaged = false; bool contactors_battery2_engaged = false;

View file

@ -270,8 +270,8 @@ String get_event_message_string(EVENTS_ENUM_TYPE event) {
case EVENT_INTERFACE_MISSING: case EVENT_INTERFACE_MISSING:
return "Configuration trying to use CAN interface not baked into the software. Recompile software!"; return "Configuration trying to use CAN interface not baked into the software. Recompile software!";
case EVENT_ERROR_OPEN_CONTACTOR: case EVENT_ERROR_OPEN_CONTACTOR:
return "Too much time spent in error state. Opening contactors, not safe to continue charging. " return "Too much time spent in error state. Opening contactors, not safe to continue. "
"Check other error code for reason!"; "Check other active ERROR code for reason. Reboot emulator after problem is solved!";
case EVENT_MODBUS_INVERTER_MISSING: case EVENT_MODBUS_INVERTER_MISSING:
return "Modbus inverter has not sent any data. Inspect communication wiring!"; return "Modbus inverter has not sent any data. Inspect communication wiring!";
case EVENT_NO_ENABLE_DETECTED: case EVENT_NO_ENABLE_DETECTED:

View file

@ -1277,7 +1277,7 @@ String processor(const String& var) {
content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>"; content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>";
} }
content += "<h4>Battery allows contactor closing: "; content += "<h4>Emulator allows contactor closing: ";
if (datalayer.battery.status.bms_status == FAULT) { if (datalayer.battery.status.bms_status == FAULT) {
content += "<span style='color: red;'>&#10005;</span>"; content += "<span style='color: red;'>&#10005;</span>";
} else { } else {
@ -1289,11 +1289,13 @@ String processor(const String& var) {
} else { } else {
content += "<span style='color: red;'>&#10005;</span></h4>"; content += "<span style='color: red;'>&#10005;</span></h4>";
} }
content += "<h4>Secondary battery allowed to join "; if (battery2) {
if (datalayer.system.status.battery2_allowed_contactor_closing == true) { content += "<h4>Secondary battery allowed to join ";
content += "<span>&#10003;</span>"; if (datalayer.system.status.battery2_allowed_contactor_closing == true) {
} else { content += "<span>&#10003;</span>";
content += "<span style='color: red;'>&#10005; (voltage mismatch)</span>"; } else {
content += "<span style='color: red;'>&#10005; (voltage mismatch)</span>";
}
} }
if (!contactor_control_enabled) { if (!contactor_control_enabled) {
@ -1304,13 +1306,19 @@ String processor(const String& var) {
"powering the contactors. Battery-Emulator will have limited amount of control over the contactors!</span>"; "powering the contactors. Battery-Emulator will have limited amount of control over the contactors!</span>";
content += "</div>"; content += "</div>";
} else { //contactor_control_enabled TRUE } else { //contactor_control_enabled TRUE
content += "<h4>Contactors controlled by emulator, state: "; content += "<div class=\"tooltip\"><h4>Contactors controlled by emulator, state: ";
if (datalayer.system.status.contactors_engaged) { if (datalayer.system.status.contactors_engaged == 0) {
content += "<span style='color: green;'>PRECHARGE</span>";
} else if (datalayer.system.status.contactors_engaged == 1) {
content += "<span style='color: green;'>ON</span>"; content += "<span style='color: green;'>ON</span>";
} else { } else if (datalayer.system.status.contactors_engaged == 2) {
content += "<span style='color: red;'>OFF</span>"; content += "<span style='color: red;'>OFF</span>";
content += "<span class=\"tooltip-icon\"> [!]</span>";
content +=
"<span class=\"tooltiptext\">Emulator spent too much time in critical FAULT event. Investigate event "
"causing this via Events page. Reboot required to resume operation!</span>";
} }
content += "</h4>"; content += "</h4></div>";
if (contactor_control_enabled_double_battery) { if (contactor_control_enabled_double_battery) {
if (pwm_contactor_control) { if (pwm_contactor_control) {
content += "<h4>Cont. Neg.: "; content += "<h4>Cont. Neg.: ";