mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
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:
parent
7b3594c248
commit
adf8185d33
7 changed files with 30 additions and 27 deletions
|
@ -353,17 +353,17 @@ void init_stored_settings() {
|
|||
static uint32_t temp = 0;
|
||||
settings.begin("batterySettings", false);
|
||||
|
||||
// Always get the emergency stop status
|
||||
datalayer.system.settings.equipment_stop_active = settings.getBool("EMERGENCY_STOP", false);
|
||||
// Always get the equipment stop status
|
||||
datalayer.system.settings.equipment_stop_active = settings.getBool("EQUIPMENT_STOP", false);
|
||||
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
|
||||
settings.clear(); // If this clear function is executed, no settings will be read from storage
|
||||
|
||||
//always save the emergency stop status
|
||||
settings.putBool("EMERGENCY_STOP", datalayer.system.settings.equipment_stop_active);
|
||||
//always save the equipment stop status
|
||||
settings.putBool("EQUIPMENT_STOP", datalayer.system.settings.equipment_stop_active);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -585,7 +585,7 @@ void monitor_equipment_stop_button() {
|
|||
long pressDuration = equipment_button_releasedTime - equipment_button_pressedTime;
|
||||
|
||||
if (pressDuration < equipment_button_long_press_duration) {
|
||||
// Short press detected, trigger emergency stop
|
||||
// Short press detected, trigger equipment stop
|
||||
setBatteryPause(true, true, true);
|
||||
} else {
|
||||
// Long press detected, reset equipment stop state
|
||||
|
@ -913,9 +913,9 @@ void init_serialDataLink() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void store_settings_emergency_stop() {
|
||||
void store_settings_equipment_stop() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 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 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 */
|
||||
// #define MQTT // Enable this line to enable MQTT
|
||||
|
|
|
@ -196,22 +196,22 @@ void update_machineryprotection() {
|
|||
}
|
||||
|
||||
//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
|
||||
if (emergency_stop && !datalayer.system.settings.equipment_stop_active) {
|
||||
// First handle equipment stop / resume
|
||||
if (equipment_stop && !datalayer.system.settings.equipment_stop_active) {
|
||||
datalayer.system.settings.equipment_stop_active = true;
|
||||
if (store_settings) {
|
||||
store_settings_emergency_stop();
|
||||
store_settings_equipment_stop();
|
||||
}
|
||||
|
||||
set_event(EVENT_EMERGENCY_STOP, 1);
|
||||
} else if (!emergency_stop && datalayer.system.settings.equipment_stop_active) {
|
||||
set_event(EVENT_EQUIPMENT_STOP, 1);
|
||||
} else if (!equipment_stop && datalayer.system.settings.equipment_stop_active) {
|
||||
datalayer.system.settings.equipment_stop_active = false;
|
||||
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;
|
||||
|
|
|
@ -16,12 +16,12 @@ extern battery_pause_status emulator_pause_status;
|
|||
extern bool allowed_to_send_CAN;
|
||||
//battery pause status end
|
||||
|
||||
extern void store_settings_emergency_stop();
|
||||
extern void store_settings_equipment_stop();
|
||||
|
||||
void update_machineryprotection();
|
||||
|
||||
//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();
|
||||
std::string get_emulator_pause_status();
|
||||
//battery pause status end
|
||||
|
|
|
@ -213,7 +213,7 @@ void init_events(void) {
|
|||
events.entries[EVENT_WIFI_DISCONNECT].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_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...
|
||||
|
||||
|
@ -412,8 +412,8 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
|
|||
return "Info: MQTT connected.";
|
||||
case EVENT_MQTT_DISCONNECT:
|
||||
return "Info: MQTT disconnected.";
|
||||
case EVENT_EMERGENCY_STOP:
|
||||
return "ERROR: EMERGENCY STOP ACTIVATED!!!";
|
||||
case EVENT_EQUIPMENT_STOP:
|
||||
return "ERROR: EQUIPMENT STOP ACTIVATED!!!";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
XX(EVENT_WIFI_DISCONNECT) \
|
||||
XX(EVENT_MQTT_CONNECT) \
|
||||
XX(EVENT_MQTT_DISCONNECT) \
|
||||
XX(EVENT_EMERGENCY_STOP) \
|
||||
XX(EVENT_EQUIPMENT_STOP) \
|
||||
XX(EVENT_NOF_EVENTS)
|
||||
|
||||
typedef enum { EVENTS_ENUM_TYPE(GENERATE_ENUM) } EVENTS_ENUM_TYPE;
|
||||
|
|
|
@ -166,8 +166,8 @@ void init_webserver() {
|
|||
}
|
||||
});
|
||||
|
||||
// Route for emergency stop/resume
|
||||
server.on("/emergencyStop", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
// Route for equipment stop/resume
|
||||
server.on("/equipmentStop", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||
return request->requestAuthentication();
|
||||
if (request->hasParam("stop")) {
|
||||
|
@ -345,7 +345,7 @@ void init_webserver() {
|
|||
return request->requestAuthentication();
|
||||
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
|
||||
setBatteryPause(true, true, true, false);
|
||||
delay(1000);
|
||||
|
@ -911,7 +911,7 @@ String processor(const String& var) {
|
|||
content +=
|
||||
"var xhr=new "
|
||||
"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 += "</script>";
|
||||
|
||||
|
@ -958,6 +958,9 @@ void onOTAEnd(bool success) {
|
|||
|
||||
// Log when OTA has finished
|
||||
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
|
||||
#ifdef DEBUG_VIA_USB
|
||||
Serial.println("OTA update finished successfully!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue