diff --git a/Software/src/battery/BMW-I3-BATTERY.cpp b/Software/src/battery/BMW-I3-BATTERY.cpp index beaaaafe..574a5948 100644 --- a/Software/src/battery/BMW-I3-BATTERY.cpp +++ b/Software/src/battery/BMW-I3-BATTERY.cpp @@ -376,10 +376,7 @@ void update_values_battery2() { //This function maps all the values fetched via datalayer.battery2.status.soh_pptt = battery2_soh * 100; - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { if (battery2_BEV_available_power_longterm_discharge > 65000) { datalayer.battery2.status.max_discharge_power_W = 65000; } else { @@ -421,10 +418,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.soh_pptt = battery_soh * 100; - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = battery_BEV_available_power_longterm_discharge; datalayer.battery.status.max_charge_power_W = battery_BEV_available_power_longterm_charge; } diff --git a/Software/src/battery/BYD-ATTO-3-BATTERY.cpp b/Software/src/battery/BYD-ATTO-3-BATTERY.cpp index 4aba2657..f7f93489 100644 --- a/Software/src/battery/BYD-ATTO-3-BATTERY.cpp +++ b/Software/src/battery/BYD-ATTO-3-BATTERY.cpp @@ -101,10 +101,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = 10000; //TODO: Map from CAN later on datalayer.battery.status.max_charge_power_W = 10000; //TODO: Map from CAN later on } diff --git a/Software/src/battery/CHADEMO-BATTERY.cpp b/Software/src/battery/CHADEMO-BATTERY.cpp index ff9105fb..7e4a4c26 100644 --- a/Software/src/battery/CHADEMO-BATTERY.cpp +++ b/Software/src/battery/CHADEMO-BATTERY.cpp @@ -114,10 +114,7 @@ void update_values_battery() { datalayer.battery.status.real_soc = x102_chg_session.StateOfCharge; - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = 10000; //TODO: Map from CAN later on datalayer.battery.status.max_charge_power_W = 1000; } diff --git a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp index 66136c74..8bba7d8d 100644 --- a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp +++ b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp @@ -48,10 +48,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { //We do not know the max charge/discharge power is sent by the battery. We hardcode value for now. datalayer.battery.status.max_discharge_power_W = 10000; // 10kW //TODO: Fix when CAN is decoded datalayer.battery.status.max_charge_power_W = 10000; // 10kW //TODO: Fix when CAN is decoded diff --git a/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp b/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp index 720864c2..d24a8f3f 100644 --- a/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp +++ b/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp @@ -89,10 +89,7 @@ void update_values_battery() { datalayer.battery.status.temperature_max_dC = HVBattCellTempHottest * 10; // C to dC - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = HVBattDischargeContiniousPowerLimit * 10; // kWh+2 to W datalayer.battery.status.max_charge_power_W = HVBattChargeContiniousPowerLimit * 10; // kWh+2 to W (TODO: Check that scaling is right way) diff --git a/Software/src/battery/KIA-E-GMP-BATTERY.cpp b/Software/src/battery/KIA-E-GMP-BATTERY.cpp index 0994a310..36dac059 100644 --- a/Software/src/battery/KIA-E-GMP-BATTERY.cpp +++ b/Software/src/battery/KIA-E-GMP-BATTERY.cpp @@ -310,10 +310,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { //datalayer.battery.status.max_charge_power_W = (uint16_t)allowedChargePower * 10; //From kW*100 to Watts //The allowed charge power is not available. We hardcode this value for now datalayer.battery.status.max_charge_power_W = MAXCHARGEPOWERALLOWED; diff --git a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp index fbe8eed8..8a531e9d 100644 --- a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp +++ b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp @@ -123,10 +123,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_charge_power_W = allowedChargePower * 10; datalayer.battery.status.max_discharge_power_W = allowedDischargePower * 10; } diff --git a/Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp b/Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp index 664c9c27..a2e9b5f2 100644 --- a/Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp +++ b/Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp @@ -64,10 +64,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = available_discharge_power * 10; datalayer.battery.status.max_charge_power_W = available_charge_power * 10; } diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index a4a47285..70f526e7 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -228,10 +228,7 @@ void update_values_battery() { /* This function maps all the values fetched via } } - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = (battery_Discharge_Power_Limit * 1000); //kW to W datalayer.battery.status.max_charge_power_W = (battery_Charge_Power_Limit * 1000); //kW to W } @@ -383,10 +380,7 @@ void update_values_battery2() { // Handle the values coming in from battery #2 } } - if (emulator_pause_request_ON) { - datalayer.battery2.status.max_discharge_power_W = 0; - datalayer.battery2.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery2.status.max_discharge_power_W = (battery2_Discharge_Power_Limit * 1000); //kW to W datalayer.battery2.status.max_charge_power_W = (battery2_Charge_Power_Limit * 1000); //kW to W } diff --git a/Software/src/battery/PYLON-BATTERY.cpp b/Software/src/battery/PYLON-BATTERY.cpp index 7f053f22..97758eab 100644 --- a/Software/src/battery/PYLON-BATTERY.cpp +++ b/Software/src/battery/PYLON-BATTERY.cpp @@ -63,10 +63,7 @@ void update_values_battery() { datalayer.battery.status.active_power_W = //Power in watts, Negative = charging batt ((datalayer.battery.status.voltage_dV * datalayer.battery.status.current_dA) / 100); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_charge_power_W = (max_charge_current * (voltage_dV / 10)); datalayer.battery.status.max_discharge_power_W = (-max_discharge_current * (voltage_dV / 10)); } diff --git a/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp b/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp index 75a992c4..b25bdb44 100644 --- a/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp +++ b/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp @@ -87,10 +87,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = (LB_Discharge_Power_Limit * 500); //Convert value fetched from battery to watts diff --git a/Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp b/Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp index 126b6b70..5a54fe76 100644 --- a/Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp +++ b/Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp @@ -47,10 +47,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = 5000; //TODO: Take from CAN datalayer.battery.status.max_charge_power_W = LB_Charge_Power_W; } diff --git a/Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp b/Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp index 797b5290..a77ff101 100644 --- a/Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp +++ b/Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp @@ -81,10 +81,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = allowedDischargePower * 10; datalayer.battery.status.max_charge_power_W = allowedChargePower * 10; } diff --git a/Software/src/battery/TESLA-BATTERY.cpp b/Software/src/battery/TESLA-BATTERY.cpp index 5067f971..5f8cd94c 100644 --- a/Software/src/battery/TESLA-BATTERY.cpp +++ b/Software/src/battery/TESLA-BATTERY.cpp @@ -278,10 +278,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.remaining_capacity_Wh = static_cast( (static_cast(datalayer.battery.status.real_soc) / 10000) * datalayer.battery.info.total_capacity_Wh); - if (emulator_pause_request_ON) { - datalayer.battery.status.max_charge_power_W = 0; - datalayer.battery.status.max_discharge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { // Define the allowed discharge power datalayer.battery.status.max_discharge_power_W = (battery_max_discharge_current * battery_volts); // Cap the allowed discharge power if higher than the maximum discharge power allowed diff --git a/Software/src/battery/TEST-FAKE-BATTERY.cpp b/Software/src/battery/TEST-FAKE-BATTERY.cpp index d8963340..f7b1875f 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.cpp +++ b/Software/src/battery/TEST-FAKE-BATTERY.cpp @@ -45,10 +45,7 @@ void update_values_battery() { /* This function puts fake values onto the parame datalayer.battery.status.temperature_max_dC = 60; // 6.0*C - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { datalayer.battery.status.max_discharge_power_W = 5000; // 5kW datalayer.battery.status.max_charge_power_W = 5000; // 5kW } diff --git a/Software/src/battery/VOLVO-SPA-BATTERY.cpp b/Software/src/battery/VOLVO-SPA-BATTERY.cpp index 2c927890..6e876130 100644 --- a/Software/src/battery/VOLVO-SPA-BATTERY.cpp +++ b/Software/src/battery/VOLVO-SPA-BATTERY.cpp @@ -83,10 +83,7 @@ void update_values_battery() { //This function maps all the values fetched via datalayer.battery.status.current_dA = BATT_I * 10; datalayer.battery.status.remaining_capacity_Wh = remaining_capacity; - if (emulator_pause_request_ON) { - datalayer.battery.status.max_discharge_power_W = 0; - datalayer.battery.status.max_charge_power_W = 0; - } else { + if (!emulator_pause_request_ON) { //datalayer.battery.status.max_discharge_power_W = HvBattPwrLimDchaSoft * 1000; // Use power limit reported from BMS, not trusted ATM datalayer.battery.status.max_discharge_power_W = 30000; datalayer.battery.status.max_charge_power_W = 30000; diff --git a/Software/src/devboard/mqtt/mqtt.cpp b/Software/src/devboard/mqtt/mqtt.cpp index a6f3b4bf..921ad6e8 100644 --- a/Software/src/devboard/mqtt/mqtt.cpp +++ b/Software/src/devboard/mqtt/mqtt.cpp @@ -117,7 +117,7 @@ static void publish_common_info(void) { doc["pause_status"] = get_emulator_pause_status(); //only publish these values if BMS is active and we are comunication with the battery (can send CAN messages to the battery) - if (datalayer.battery.status.bms_status == ACTIVE && can_send_CAN) { + if (datalayer.battery.status.bms_status == ACTIVE && can_send_CAN && millis() > BOOTUP_TIME) { doc["SOC"] = ((float)datalayer.battery.status.reported_soc) / 100.0; doc["SOC_real"] = ((float)datalayer.battery.status.real_soc) / 100.0; doc["state_of_health"] = ((float)datalayer.battery.status.soh_pptt) / 100.0; diff --git a/Software/src/devboard/safety/safety.cpp b/Software/src/devboard/safety/safety.cpp index 1987d4ad..d453cbf8 100644 --- a/Software/src/devboard/safety/safety.cpp +++ b/Software/src/devboard/safety/safety.cpp @@ -189,6 +189,7 @@ void setBatteryPause(bool pause_battery, bool pause_CAN) { set_event(EVENT_PAUSE_BEGIN, 1); emulator_pause_request_ON = true; + emulator_pause_status = PAUSING; datalayer.battery.status.max_discharge_power_W = 0; datalayer.battery.status.max_charge_power_W = 0; #ifdef DOUBLE_BATTERY @@ -196,10 +197,9 @@ void setBatteryPause(bool pause_battery, bool pause_CAN) { datalayer.battery2.status.max_charge_power_W = 0; #endif - emulator_pause_status = PAUSING; } else { clear_event(EVENT_PAUSE_BEGIN); - set_event(EVENT_PAUSE_END, 0); + set_event(EVENT_PAUSE_END, 1); emulator_pause_request_ON = false; emulator_pause_CAN_send_ON = false; emulator_pause_status = RESUMING; diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index e2bb79d8..c06298c8 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -942,10 +942,12 @@ void onOTAProgress(size_t current, size_t final) { void onOTAEnd(bool success) { - //try to Resume the battery - setBatteryPause(false, false); + ota_active = false; + clear_event(EVENT_OTA_UPDATE); + // Log when OTA has finished if (success) { + // 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!"); #endif // DEBUG_VIA_USB @@ -953,9 +955,9 @@ void onOTAEnd(bool success) { #ifdef DEBUG_VIA_USB Serial.println("There was an error during OTA update!"); #endif // DEBUG_VIA_USB + //try to Resume the battery pause and CAN communication + setBatteryPause(false, false); } - ota_active = false; - clear_event(EVENT_OTA_UPDATE); } template // This function makes power values appear as W when under 1000, and kW when over