diff --git a/dependencies.yaml b/dependencies.yaml index 68a8cbf874..c895a8db0d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -35,7 +35,7 @@ libcurl: # Josev Josev: git: https://github.com/EVerest/ext-switchev-iso15118.git - git_tag: ec48efc4034a5e52139f05b88ac1dcdd61583639 + git_tag: 6099df7283a00cde3178401fb1655a533dc213ce cmake_condition: "EVEREST_ENABLE_PY_SUPPORT AND EVEREST_DEPENDENCY_ENABLED_JOSEV" # linux_libnfc-nci for RFID libnfc-nci: diff --git a/interfaces/ISO15118_ev.yaml b/interfaces/ISO15118_ev.yaml index a060145c97..ca2c2eceff 100644 --- a/interfaces/ISO15118_ev.yaml +++ b/interfaces/ISO15118_ev.yaml @@ -44,6 +44,13 @@ cmds: $ref: /iso15118#/DcEvBPTParameters enable_sae_j2847_v2g_v2h: description: Enable the SAE J2847 2 V2H V2G + update_soc: + description: Updating the EV SoC state + arguments: + SoC: + description: The actual State of Charge from the EV + type: number + minimum: 0 vars: v2g_session_finished: description: The v2g session between the charger and the car is finished diff --git a/modules/EV/EvManager/main/car_simulation.cpp b/modules/EV/EvManager/main/car_simulation.cpp index b5b72e1b3c..86406d6e9a 100644 --- a/modules/EV/EvManager/main/car_simulation.cpp +++ b/modules/EV/EvManager/main/car_simulation.cpp @@ -138,10 +138,20 @@ void CarSimulation::simulate_soc() { sim_data.battery_charge_wh += power * factor; } - ev_info.soc = (sim_data.battery_charge_wh / sim_data.battery_capacity_wh) * 100.0; - if (ev_info.soc > 100.0) { - ev_info.soc = 100.0; + auto soc = (sim_data.battery_charge_wh / sim_data.battery_capacity_wh) * 100.0; + + if (soc > 100.0) { + soc = 100.0; + } else if (soc <= 0.0) { + soc = 0.0; + } + + if (latest_soc != soc) { + latest_soc = soc; + r_ev[0]->call_update_soc(soc); } + + ev_info.soc = soc; ev_info.battery_capacity = sim_data.battery_capacity_wh; ev_info.battery_full_soc = 100; diff --git a/modules/EV/EvManager/main/car_simulation.hpp b/modules/EV/EvManager/main/car_simulation.hpp index bd633d4e6c..8fc5a965e9 100644 --- a/modules/EV/EvManager/main/car_simulation.hpp +++ b/modules/EV/EvManager/main/car_simulation.hpp @@ -132,6 +132,8 @@ class CarSimulation { std::chrono::time_point timepoint_last_update; double charge_current_a{0}; + double latest_soc{0}; + enum class ChargeMode { None, AC, diff --git a/modules/EV/PyEvJosev/module.py b/modules/EV/PyEvJosev/module.py index eec896a0ca..5b3e666d1a 100644 --- a/modules/EV/PyEvJosev/module.py +++ b/modules/EV/PyEvJosev/module.py @@ -4,6 +4,7 @@ import sys from pathlib import Path import threading +import math from everest.framework import Module, RuntimeSession, log @@ -138,5 +139,8 @@ def _handler_set_bpt_dc_params(self, args): def _handler_enable_sae_j2847_v2g_v2h(self, args): self._es.SAEJ2847_V2H_V2G_Active = True + def _handler_update_soc(self, args): + self._es.actual_soc = math.floor(args['SoC']) + py_ev_josev = PyEVJosevModule() py_ev_josev.start_evcc_handler()