Skip to content

Commit b1b9fe5

Browse files
committed
feat(EvManager): Reporting simulated SoC to PyEvJosev
Signed-off-by: Sebastian Lukas <sebastian.lukas@pionix.de>
1 parent 1801c65 commit b1b9fe5

5 files changed

Lines changed: 27 additions & 4 deletions

File tree

dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ libcurl:
3535
# Josev
3636
Josev:
3737
git: https://github.com/EVerest/ext-switchev-iso15118.git
38-
git_tag: ec48efc4034a5e52139f05b88ac1dcdd61583639
38+
git_tag: 6099df7283a00cde3178401fb1655a533dc213ce
3939
cmake_condition: "EVEREST_ENABLE_PY_SUPPORT AND EVEREST_DEPENDENCY_ENABLED_JOSEV"
4040
# linux_libnfc-nci for RFID
4141
libnfc-nci:

interfaces/ISO15118_ev.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ cmds:
4444
$ref: /iso15118#/DcEvBPTParameters
4545
enable_sae_j2847_v2g_v2h:
4646
description: Enable the SAE J2847 2 V2H V2G
47+
update_soc:
48+
description: Updating the EV SoC state
49+
arguments:
50+
SoC:
51+
description: The actual State of Charge from the EV
52+
type: number
53+
minimum: 0
4754
vars:
4855
v2g_session_finished:
4956
description: The v2g session between the charger and the car is finished

modules/EV/EvManager/main/car_simulation.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,20 @@ void CarSimulation::simulate_soc() {
138138
sim_data.battery_charge_wh += power * factor;
139139
}
140140

141-
ev_info.soc = (sim_data.battery_charge_wh / sim_data.battery_capacity_wh) * 100.0;
142-
if (ev_info.soc > 100.0) {
143-
ev_info.soc = 100.0;
141+
auto soc = (sim_data.battery_charge_wh / sim_data.battery_capacity_wh) * 100.0;
142+
143+
if (soc > 100.0) {
144+
soc = 100.0;
145+
} else if (soc <= 0.0) {
146+
soc = 0.0;
147+
}
148+
149+
if (latest_soc != soc) {
150+
latest_soc = soc;
151+
r_ev[0]->call_update_soc(soc);
144152
}
153+
154+
ev_info.soc = soc;
145155
ev_info.battery_capacity = sim_data.battery_capacity_wh;
146156
ev_info.battery_full_soc = 100;
147157

modules/EV/EvManager/main/car_simulation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class CarSimulation {
132132
std::chrono::time_point<std::chrono::steady_clock> timepoint_last_update;
133133
double charge_current_a{0};
134134

135+
double latest_soc{0};
136+
135137
enum class ChargeMode {
136138
None,
137139
AC,

modules/EV/PyEvJosev/module.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
from pathlib import Path
66
import threading
7+
import math
78

89
from everest.framework import Module, RuntimeSession, log
910

@@ -138,5 +139,8 @@ def _handler_set_bpt_dc_params(self, args):
138139
def _handler_enable_sae_j2847_v2g_v2h(self, args):
139140
self._es.SAEJ2847_V2H_V2G_Active = True
140141

142+
def _handler_update_soc(self, args):
143+
self._es.actual_soc = math.floor(args['SoC'])
144+
141145
py_ev_josev = PyEVJosevModule()
142146
py_ev_josev.start_evcc_handler()

0 commit comments

Comments
 (0)