mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
Rename function and simplifying how SOC method is toggled.
This commit is contained in:
parent
de8f5af057
commit
4e00dbb86c
5 changed files with 9 additions and 19 deletions
|
@ -291,12 +291,6 @@ void BydAttoBattery::
|
||||||
stateMachineClearCrash = STARTED;
|
stateMachineClearCrash = STARTED;
|
||||||
datalayer_bydatto->UserRequestCrashReset = false;
|
datalayer_bydatto->UserRequestCrashReset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change SOC method if requested from webserver datalayer
|
|
||||||
if (datalayer_bydatto->ChangeSOCMethod) {
|
|
||||||
SOC_method = !SOC_method; // Toggle the SOC method
|
|
||||||
datalayer_bydatto->ChangeSOCMethod = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,11 @@ class BydAttoBattery : public CanBattery {
|
||||||
void reset_crash() { datalayer_bydatto->UserRequestCrashReset = true; }
|
void reset_crash() { datalayer_bydatto->UserRequestCrashReset = true; }
|
||||||
|
|
||||||
#ifndef USE_ESTIMATED_SOC
|
#ifndef USE_ESTIMATED_SOC
|
||||||
// Changing SOC method in UI is only enabled if we initially use measured SOC
|
// Toggle SOC method in UI is only enabled if we initially use measured SOC
|
||||||
bool supports_change_SOC_method() { return true; }
|
bool supports_toggle_SOC_method() { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void change_SOC_method() { datalayer_bydatto->ChangeSOCMethod = true; }
|
void toggle_SOC_method() { SOC_method = !SOC_method; }
|
||||||
|
|
||||||
BatteryHtmlRenderer& get_status_renderer() { return renderer; }
|
BatteryHtmlRenderer& get_status_renderer() { return renderer; }
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ class BydAttoBattery : public CanBattery {
|
||||||
unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
||||||
unsigned long previousMillis200 = 0; // will store last time a 200ms CAN Message was send
|
unsigned long previousMillis200 = 0; // will store last time a 200ms CAN Message was send
|
||||||
bool SOC_method = false;
|
bool SOC_method = false;
|
||||||
bool ChangeSOCMethod = false;
|
|
||||||
uint8_t counter_50ms = 0;
|
uint8_t counter_50ms = 0;
|
||||||
uint8_t counter_100ms = 0;
|
uint8_t counter_100ms = 0;
|
||||||
uint8_t frame6_counter = 0xB;
|
uint8_t frame6_counter = 0xB;
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Battery {
|
||||||
virtual bool supports_set_fake_voltage() { return false; }
|
virtual bool supports_set_fake_voltage() { return false; }
|
||||||
virtual bool supports_manual_balancing() { return false; }
|
virtual bool supports_manual_balancing() { return false; }
|
||||||
virtual bool supports_real_BMS_status() { return false; }
|
virtual bool supports_real_BMS_status() { return false; }
|
||||||
virtual bool supports_change_SOC_method() { return false; }
|
virtual bool supports_toggle_SOC_method() { return false; }
|
||||||
|
|
||||||
virtual void clear_isolation() {}
|
virtual void clear_isolation() {}
|
||||||
virtual void reset_BMS() {}
|
virtual void reset_BMS() {}
|
||||||
|
@ -41,7 +41,7 @@ class Battery {
|
||||||
virtual void reset_BECM() {}
|
virtual void reset_BECM() {}
|
||||||
virtual void request_open_contactors() {}
|
virtual void request_open_contactors() {}
|
||||||
virtual void request_close_contactors() {}
|
virtual void request_close_contactors() {}
|
||||||
virtual void change_SOC_method() {}
|
virtual void toggle_SOC_method() {}
|
||||||
|
|
||||||
virtual void set_fake_voltage(float v) {}
|
virtual void set_fake_voltage(float v) {}
|
||||||
virtual float get_voltage() { static_cast<float>(datalayer.battery.status.voltage_dV) / 10.0; }
|
virtual float get_voltage() { static_cast<float>(datalayer.battery.status.voltage_dV) / 10.0; }
|
||||||
|
|
|
@ -171,9 +171,6 @@ typedef struct {
|
||||||
/** User requesting crash reset via WebUI*/
|
/** User requesting crash reset via WebUI*/
|
||||||
bool UserRequestCrashReset = false;
|
bool UserRequestCrashReset = false;
|
||||||
/** bool */
|
/** bool */
|
||||||
/** User changing SOC method via WebUI*/
|
|
||||||
bool ChangeSOCMethod = false;
|
|
||||||
/** bool */
|
|
||||||
/** Which SOC method currently used. 0 = Estimated, 1 = Measured */
|
/** Which SOC method currently used. 0 = Estimated, 1 = Measured */
|
||||||
bool SOC_method = 0;
|
bool SOC_method = 0;
|
||||||
/** uint16_t */
|
/** uint16_t */
|
||||||
|
|
|
@ -56,11 +56,11 @@ std::vector<BatteryCommand> battery_commands = {
|
||||||
[](Battery* b) {
|
[](Battery* b) {
|
||||||
b->reset_SOH();
|
b->reset_SOH();
|
||||||
}},
|
}},
|
||||||
{"changeSOC", "Change SOC method",
|
{"toggleSOC", "Toggle SOC method",
|
||||||
"change SOC method? This will toggle between ESTIMATED and MEASURED SOC methods.",
|
"toggle SOC method? This will toggle between ESTIMATED and MEASURED SOC methods.",
|
||||||
[](Battery* b) { return b && b->supports_change_SOC_method(); },
|
[](Battery* b) { return b && b->supports_toggle_SOC_method(); },
|
||||||
[](Battery* b) {
|
[](Battery* b) {
|
||||||
b->change_SOC_method();
|
b->toggle_SOC_method();
|
||||||
}},
|
}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue