Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions interfaces/ISO15118_ev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions modules/EV/EvManager/main/car_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions modules/EV/EvManager/main/car_simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
std::chrono::time_point<std::chrono::steady_clock> timepoint_last_update;
double charge_current_a{0};

double latest_soc{0};

Check warning on line 135 in modules/EV/EvManager/main/car_simulation.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EV/EvManager/main/car_simulation.hpp#L135

class member 'CarSimulation::latest_soc' is never used.

enum class ChargeMode {
None,
AC,
Expand Down
4 changes: 4 additions & 0 deletions modules/EV/PyEvJosev/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
from pathlib import Path
import threading
import math

from everest.framework import Module, RuntimeSession, log

Expand Down Expand Up @@ -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()
Loading