Replaced all instances of "emergency" with "equipment" in the code for improved clarity and alignment with the feature's purpose.

This commit is contained in:
amarofarinha 2024-10-03 09:43:41 +01:00
parent 7b3594c248
commit adf8185d33
7 changed files with 30 additions and 27 deletions

View file

@ -353,17 +353,17 @@ void init_stored_settings() {
static uint32_t temp = 0; static uint32_t temp = 0;
settings.begin("batterySettings", false); settings.begin("batterySettings", false);
// Always get the emergency stop status // Always get the equipment stop status
datalayer.system.settings.equipment_stop_active = settings.getBool("EMERGENCY_STOP", false); datalayer.system.settings.equipment_stop_active = settings.getBool("EQUIPMENT_STOP", false);
if (datalayer.system.settings.equipment_stop_active) { if (datalayer.system.settings.equipment_stop_active) {
set_event(EVENT_EMERGENCY_STOP, 1); set_event(EVENT_EQUIPMENT_STOP, 1);
} }
#ifndef LOAD_SAVED_SETTINGS_ON_BOOT #ifndef LOAD_SAVED_SETTINGS_ON_BOOT
settings.clear(); // If this clear function is executed, no settings will be read from storage settings.clear(); // If this clear function is executed, no settings will be read from storage
//always save the emergency stop status //always save the equipment stop status
settings.putBool("EMERGENCY_STOP", datalayer.system.settings.equipment_stop_active); settings.putBool("EQUIPMENT_STOP", datalayer.system.settings.equipment_stop_active);
#endif #endif
@ -585,7 +585,7 @@ void monitor_equipment_stop_button() {
long pressDuration = equipment_button_releasedTime - equipment_button_pressedTime; long pressDuration = equipment_button_releasedTime - equipment_button_pressedTime;
if (pressDuration < equipment_button_long_press_duration) { if (pressDuration < equipment_button_long_press_duration) {
// Short press detected, trigger emergency stop // Short press detected, trigger equipment stop
setBatteryPause(true, true, true); setBatteryPause(true, true, true);
} else { } else {
// Long press detected, reset equipment stop state // Long press detected, reset equipment stop state
@ -913,9 +913,9 @@ void init_serialDataLink() {
#endif #endif
} }
void store_settings_emergency_stop() { void store_settings_equipment_stop() {
settings.begin("batterySettings", false); settings.begin("batterySettings", false);
settings.putBool("EMERGENCY_STOP", datalayer.system.settings.equipment_stop_active); settings.putBool("EQUIPMENT_STOP", datalayer.system.settings.equipment_stop_active);
settings.end(); settings.end();
} }

View file

@ -65,7 +65,7 @@
#define MDNSRESPONDER //Enable this line to enable MDNS, allows battery monitor te be found by .local address. Requires WEBSERVER to be enabled. #define MDNSRESPONDER //Enable this line to enable MDNS, allows battery monitor te be found by .local address. Requires WEBSERVER to be enabled.
#define LOAD_SAVED_SETTINGS_ON_BOOT //Enable this line to read settings stored via the webserver on boot (overrides Wifi/battery settings set below) #define LOAD_SAVED_SETTINGS_ON_BOOT //Enable this line to read settings stored via the webserver on boot (overrides Wifi/battery settings set below)
//#define FUNCTION_TIME_MEASUREMENT // Enable this to record execution times and present them in the web UI (WARNING, raises CPU load, do not use for production) //#define FUNCTION_TIME_MEASUREMENT // Enable this to record execution times and present them in the web UI (WARNING, raises CPU load, do not use for production)
//#define EQUIPMENT_STOP_BUTTON // Enable this to allow an emergency/equipment stop button connected to the Battery-Emulator to disengage the battery //#define EQUIPMENT_STOP_BUTTON // Enable this to allow an equipment stop button connected to the Battery-Emulator to disengage the battery
/* MQTT options */ /* MQTT options */
// #define MQTT // Enable this line to enable MQTT // #define MQTT // Enable this line to enable MQTT

View file

@ -196,22 +196,22 @@ void update_machineryprotection() {
} }
//battery pause status begin //battery pause status begin
void setBatteryPause(bool pause_battery, bool pause_CAN, bool emergency_stop, bool store_settings) { void setBatteryPause(bool pause_battery, bool pause_CAN, bool equipment_stop, bool store_settings) {
// First handle emergency stop / resume // First handle equipment stop / resume
if (emergency_stop && !datalayer.system.settings.equipment_stop_active) { if (equipment_stop && !datalayer.system.settings.equipment_stop_active) {
datalayer.system.settings.equipment_stop_active = true; datalayer.system.settings.equipment_stop_active = true;
if (store_settings) { if (store_settings) {
store_settings_emergency_stop(); store_settings_equipment_stop();
} }
set_event(EVENT_EMERGENCY_STOP, 1); set_event(EVENT_EQUIPMENT_STOP, 1);
} else if (!emergency_stop && datalayer.system.settings.equipment_stop_active) { } else if (!equipment_stop && datalayer.system.settings.equipment_stop_active) {
datalayer.system.settings.equipment_stop_active = false; datalayer.system.settings.equipment_stop_active = false;
if (store_settings) { if (store_settings) {
store_settings_emergency_stop(); store_settings_equipment_stop();
} }
clear_event(EVENT_EMERGENCY_STOP); clear_event(EVENT_EQUIPMENT_STOP);
} }
emulator_pause_CAN_send_ON = pause_CAN; emulator_pause_CAN_send_ON = pause_CAN;

View file

@ -16,12 +16,12 @@ extern battery_pause_status emulator_pause_status;
extern bool allowed_to_send_CAN; extern bool allowed_to_send_CAN;
//battery pause status end //battery pause status end
extern void store_settings_emergency_stop(); extern void store_settings_equipment_stop();
void update_machineryprotection(); void update_machineryprotection();
//battery pause status begin //battery pause status begin
void setBatteryPause(bool pause_battery, bool pause_CAN, bool emergency_stop = false, bool store_settings = true); void setBatteryPause(bool pause_battery, bool pause_CAN, bool equipment_stop = false, bool store_settings = true);
void emulator_pause_state_send_CAN_battery(); void emulator_pause_state_send_CAN_battery();
std::string get_emulator_pause_status(); std::string get_emulator_pause_status();
//battery pause status end //battery pause status end

View file

@ -213,7 +213,7 @@ void init_events(void) {
events.entries[EVENT_WIFI_DISCONNECT].level = EVENT_LEVEL_INFO; events.entries[EVENT_WIFI_DISCONNECT].level = EVENT_LEVEL_INFO;
events.entries[EVENT_MQTT_CONNECT].level = EVENT_LEVEL_INFO; events.entries[EVENT_MQTT_CONNECT].level = EVENT_LEVEL_INFO;
events.entries[EVENT_MQTT_DISCONNECT].level = EVENT_LEVEL_INFO; events.entries[EVENT_MQTT_DISCONNECT].level = EVENT_LEVEL_INFO;
events.entries[EVENT_EMERGENCY_STOP].level = EVENT_LEVEL_ERROR; events.entries[EVENT_EQUIPMENT_STOP].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_EEPROM_WRITE].log = false; // Don't log the logger... events.entries[EVENT_EEPROM_WRITE].log = false; // Don't log the logger...
@ -412,8 +412,8 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
return "Info: MQTT connected."; return "Info: MQTT connected.";
case EVENT_MQTT_DISCONNECT: case EVENT_MQTT_DISCONNECT:
return "Info: MQTT disconnected."; return "Info: MQTT disconnected.";
case EVENT_EMERGENCY_STOP: case EVENT_EQUIPMENT_STOP:
return "ERROR: EMERGENCY STOP ACTIVATED!!!"; return "ERROR: EQUIPMENT STOP ACTIVATED!!!";
default: default:
return ""; return "";
} }

View file

@ -101,7 +101,7 @@
XX(EVENT_WIFI_DISCONNECT) \ XX(EVENT_WIFI_DISCONNECT) \
XX(EVENT_MQTT_CONNECT) \ XX(EVENT_MQTT_CONNECT) \
XX(EVENT_MQTT_DISCONNECT) \ XX(EVENT_MQTT_DISCONNECT) \
XX(EVENT_EMERGENCY_STOP) \ XX(EVENT_EQUIPMENT_STOP) \
XX(EVENT_NOF_EVENTS) XX(EVENT_NOF_EVENTS)
typedef enum { EVENTS_ENUM_TYPE(GENERATE_ENUM) } EVENTS_ENUM_TYPE; typedef enum { EVENTS_ENUM_TYPE(GENERATE_ENUM) } EVENTS_ENUM_TYPE;

View file

@ -166,8 +166,8 @@ void init_webserver() {
} }
}); });
// Route for emergency stop/resume // Route for equipment stop/resume
server.on("/emergencyStop", HTTP_GET, [](AsyncWebServerRequest* request) { server.on("/equipmentStop", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password)) if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
return request->requestAuthentication(); return request->requestAuthentication();
if (request->hasParam("stop")) { if (request->hasParam("stop")) {
@ -345,7 +345,7 @@ void init_webserver() {
return request->requestAuthentication(); return request->requestAuthentication();
request->send(200, "text/plain", "Rebooting server..."); request->send(200, "text/plain", "Rebooting server...");
//Equipment STOP without persisting the emergency state before restart //Equipment STOP without persisting the equipment state before restart
// Max Charge/Discharge = 0; CAN = stop; contactors = open // Max Charge/Discharge = 0; CAN = stop; contactors = open
setBatteryPause(true, true, true, false); setBatteryPause(true, true, true, false);
delay(1000); delay(1000);
@ -911,7 +911,7 @@ String processor(const String& var) {
content += content +=
"var xhr=new " "var xhr=new "
"XMLHttpRequest();xhr.onload=function() { " "XMLHttpRequest();xhr.onload=function() { "
"window.location.reload();};xhr.open('GET','/emergencyStop?stop='+stop,true);xhr.send();"; "window.location.reload();};xhr.open('GET','/equipmentStop?stop='+stop,true);xhr.send();";
content += "}"; content += "}";
content += "</script>"; content += "</script>";
@ -958,6 +958,9 @@ void onOTAEnd(bool success) {
// Log when OTA has finished // Log when OTA has finished
if (success) { if (success) {
//Equipment STOP without persisting the equipment state before restart
// Max Charge/Discharge = 0; CAN = stop; contactors = open
setBatteryPause(true, true, true, false);
// a reboot will be done by the OTA library. no need to do anything here // a reboot will be done by the OTA library. no need to do anything here
#ifdef DEBUG_VIA_USB #ifdef DEBUG_VIA_USB
Serial.println("OTA update finished successfully!"); Serial.println("OTA update finished successfully!");