From c9995c03739f695a1fc7add863f3cbf90707f731 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:55:24 +0000 Subject: [PATCH 01/10] voltage and current is same as ev in precharge --- iso15118/secc/controller/simulator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index 4beac94e..e469cd9f 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1082,11 +1082,12 @@ async def get_cable_check_status(self) -> Union[IsolationLevel, None]: return IsolationLevel.VALID async def set_precharge( - self, - voltage: Union[PVEVTargetVoltage, RationalNumber], - current: Union[PVEVTargetCurrent, RationalNumber], + self, + voltage: Union[PVEVTargetVoltage, RationalNumber], + current: Union[PVEVTargetCurrent, RationalNumber], ): - pass + self.evse_data_context.session_context.evse_present_voltage = voltage + self.evse_data_context.session_context.evse_present_current = current async def send_charging_command( self, From fa1e3f1d390f25f77917f377aa5b5bef604cf068 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:42:15 +0000 Subject: [PATCH 02/10] log is added for debug --- iso15118/secc/controller/simulator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index e469cd9f..4b6bce6d 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1086,6 +1086,8 @@ async def set_precharge( voltage: Union[PVEVTargetVoltage, RationalNumber], current: Union[PVEVTargetCurrent, RationalNumber], ): + print(f"KARATAS {voltage.value}") + print(f"KARATAS {current.value}") self.evse_data_context.session_context.evse_present_voltage = voltage self.evse_data_context.session_context.evse_present_current = current From ff4c97b32b7f3e38a2f774ba65b377ba6a6ced04 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:44:53 +0000 Subject: [PATCH 03/10] log is added for debug --- iso15118/secc/states/iso15118_2_states.py | 1 + 1 file changed, 1 insertion(+) diff --git a/iso15118/secc/states/iso15118_2_states.py b/iso15118/secc/states/iso15118_2_states.py index a4012575..4ccc6454 100644 --- a/iso15118/secc/states/iso15118_2_states.py +++ b/iso15118/secc/states/iso15118_2_states.py @@ -2359,6 +2359,7 @@ async def process_message( # Set precharge voltage in every loop. # Because there are EVs that send a wrong Precharge-Voltage # in the first message (example: BMW i3 Rex 2018) + print(f"KARATASSSS -> {precharge_req.ev_target_voltage}") await self.comm_session.evse_controller.set_precharge( precharge_req.ev_target_voltage, precharge_req.ev_target_current ) From a2f79012ce16ef7522facdf002b89640716dfb45 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:02:12 +0000 Subject: [PATCH 04/10] EV and EVSE voltage equal in precharge state --- iso15118/secc/controller/simulator.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index 4b6bce6d..633e7df1 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1086,11 +1086,8 @@ async def set_precharge( voltage: Union[PVEVTargetVoltage, RationalNumber], current: Union[PVEVTargetCurrent, RationalNumber], ): - print(f"KARATAS {voltage.value}") - print(f"KARATAS {current.value}") - self.evse_data_context.session_context.evse_present_voltage = voltage - self.evse_data_context.session_context.evse_present_current = current - + self.evse_data_context.session_context.evse_present_voltage = voltage.value * 10**voltage.multiplier + self.evse_data_context.session_context.evse_present_current = 1 async def send_charging_command( self, voltage: Union[PVEVTargetVoltage, RationalNumber], From 2cfe5a20e30fde14b331315c3f3fbddd11b4d904 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:00:11 +0000 Subject: [PATCH 05/10] more logs are added --- iso15118/evcc/controller/simulator.py | 2 ++ iso15118/secc/controller/simulator.py | 1 + poetry.lock | 8 ++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/iso15118/evcc/controller/simulator.py b/iso15118/evcc/controller/simulator.py index 24ff21eb..26d7e0d2 100644 --- a/iso15118/evcc/controller/simulator.py +++ b/iso15118/evcc/controller/simulator.py @@ -552,6 +552,8 @@ async def ready_to_charge(self) -> bool: async def is_precharged( self, present_voltage_evse: Union[PVEVSEPresentVoltage, RationalNumber] ) -> bool: + print(f"KARATAS {(await self.get_present_voltage()).get_decimal_value()}") + print(f"KARATAS {present_voltage_evse.get_decimal_value()}") if ( self.precharge_loop_cycles == 5 or present_voltage_evse.get_decimal_value() diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index 633e7df1..22492874 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1086,6 +1086,7 @@ async def set_precharge( voltage: Union[PVEVTargetVoltage, RationalNumber], current: Union[PVEVTargetCurrent, RationalNumber], ): + print(f"KARATAS set precharge: {voltage} - {current}") self.evse_data_context.session_context.evse_present_voltage = voltage.value * 10**voltage.multiplier self.evse_data_context.session_context.evse_present_current = 1 async def send_charging_command( diff --git a/poetry.lock b/poetry.lock index f6876045..9aee178e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -348,13 +348,13 @@ pyflakes = ">=3.1.0,<3.2.0" [[package]] name = "freezegun" -version = "1.2.2" +version = "1.3.0" description = "Let your Python tests travel through time" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "freezegun-1.2.2-py3-none-any.whl", hash = "sha256:ea1b963b993cb9ea195adbd893a48d573fda951b0da64f60883d7e988b606c9f"}, - {file = "freezegun-1.2.2.tar.gz", hash = "sha256:cd22d1ba06941384410cd967d8a99d5ae2442f57dfafeff2fda5de8dc5c05446"}, + {file = "freezegun-1.3.0-py3-none-any.whl", hash = "sha256:fc21de00b8e7f3dfb91414f876afe7f74b2f29ce9907bd81013bdbc7e8a632d0"}, + {file = "freezegun-1.3.0.tar.gz", hash = "sha256:56cc5dc34de38fe28a4d19bea65bbd3af6fd66020df8141b92bdb45c9be9f503"}, ] [package.dependencies] From 8a72b74988d4c43a0783947544a3d043f9a7144f Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:56:03 +0000 Subject: [PATCH 06/10] get_exponent_value_repr --- iso15118/evcc/controller/simulator.py | 2 +- iso15118/secc/controller/simulator.py | 7 ++++++- iso15118/secc/states/iso15118_2_states.py | 2 +- iso15118/shared/messages/datatypes.py | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/iso15118/evcc/controller/simulator.py b/iso15118/evcc/controller/simulator.py index 26d7e0d2..6ea84e32 100644 --- a/iso15118/evcc/controller/simulator.py +++ b/iso15118/evcc/controller/simulator.py @@ -136,7 +136,7 @@ def __init__(self, evcc_config: EVCCConfig): multiplier=0, value=1, unit=UnitSymbol.AMPERE ), dc_target_voltage=PVEVTargetVoltage( - multiplier=0, value=400, unit=UnitSymbol.VOLTAGE + multiplier=3, value=20, unit=UnitSymbol.VOLTAGE ), ) diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index 22492874..b5f46cac 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1038,9 +1038,11 @@ async def get_evse_present_voltage( ) -> Union[PVEVSEPresentVoltage, RationalNumber]: """Overrides EVSEControllerInterface.get_evse_present_voltage().""" if protocol in [Protocol.DIN_SPEC_70121, Protocol.ISO_15118_2]: + print(f"protocol -> {protocol}") value, exponent = PhysicalValue.get_exponent_value_repr( cast(int, self.evse_data_context.session_context.evse_present_voltage) ) + print(f"value -> {value}, exponent {exponent}") try: pv_evse_present_voltage = PVEVSEPresentVoltage( multiplier=exponent, value=value, unit="V" @@ -1086,8 +1088,11 @@ async def set_precharge( voltage: Union[PVEVTargetVoltage, RationalNumber], current: Union[PVEVTargetCurrent, RationalNumber], ): + + self.evse_data_context.session_context.evse_present_voltage = voltage.get_decimal_value() print(f"KARATAS set precharge: {voltage} - {current}") - self.evse_data_context.session_context.evse_present_voltage = voltage.value * 10**voltage.multiplier + print(f"KARATAS get decimal: {voltage.get_decimal_value()}") + # evse_present_voltagevoltage.value * 10**voltage.multiplier self.evse_data_context.session_context.evse_present_current = 1 async def send_charging_command( self, diff --git a/iso15118/secc/states/iso15118_2_states.py b/iso15118/secc/states/iso15118_2_states.py index 4ccc6454..9056c74b 100644 --- a/iso15118/secc/states/iso15118_2_states.py +++ b/iso15118/secc/states/iso15118_2_states.py @@ -2370,7 +2370,7 @@ async def process_message( Protocol.ISO_15118_2 ) ) - + print(f"evse_present_voltage {evse_present_voltage}") precharge_res = PreChargeRes( response_code=ResponseCode.OK, dc_evse_status=dc_charger_state, diff --git a/iso15118/shared/messages/datatypes.py b/iso15118/shared/messages/datatypes.py index 72294303..fa76082c 100644 --- a/iso15118/shared/messages/datatypes.py +++ b/iso15118/shared/messages/datatypes.py @@ -75,6 +75,9 @@ def get_exponent_value_repr(cls, value: int) -> Tuple[int, int]: while abs(calculated_value) < 1: calculated_value *= 10 exponent -= 1 + while exponent > 3: + exponent -= 1 + calculated_value *= 10 return cast(int, calculated_value), exponent From 7d0c30d8e27f743b548fad5717cd1a2eecfef365 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:18:49 +0000 Subject: [PATCH 07/10] cleared logs --- iso15118/secc/controller/simulator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index b5f46cac..3af8a0ce 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1090,10 +1090,7 @@ async def set_precharge( ): self.evse_data_context.session_context.evse_present_voltage = voltage.get_decimal_value() - print(f"KARATAS set precharge: {voltage} - {current}") - print(f"KARATAS get decimal: {voltage.get_decimal_value()}") - # evse_present_voltagevoltage.value * 10**voltage.multiplier - self.evse_data_context.session_context.evse_present_current = 1 + self.evse_data_context.session_context.evse_present_current = current.get_decimal_value() async def send_charging_command( self, voltage: Union[PVEVTargetVoltage, RationalNumber], From cd53e830720fd3bae407c05017ab9f299677242b Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:22:20 +0000 Subject: [PATCH 08/10] code quality --- iso15118/evcc/controller/simulator.py | 2 -- iso15118/secc/controller/simulator.py | 16 +++++++++------- iso15118/secc/states/iso15118_2_states.py | 2 -- poetry.lock | 8 ++++---- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/iso15118/evcc/controller/simulator.py b/iso15118/evcc/controller/simulator.py index 6ea84e32..6f3f4899 100644 --- a/iso15118/evcc/controller/simulator.py +++ b/iso15118/evcc/controller/simulator.py @@ -552,8 +552,6 @@ async def ready_to_charge(self) -> bool: async def is_precharged( self, present_voltage_evse: Union[PVEVSEPresentVoltage, RationalNumber] ) -> bool: - print(f"KARATAS {(await self.get_present_voltage()).get_decimal_value()}") - print(f"KARATAS {present_voltage_evse.get_decimal_value()}") if ( self.precharge_loop_cycles == 5 or present_voltage_evse.get_decimal_value() diff --git a/iso15118/secc/controller/simulator.py b/iso15118/secc/controller/simulator.py index 3af8a0ce..81225950 100644 --- a/iso15118/secc/controller/simulator.py +++ b/iso15118/secc/controller/simulator.py @@ -1038,11 +1038,9 @@ async def get_evse_present_voltage( ) -> Union[PVEVSEPresentVoltage, RationalNumber]: """Overrides EVSEControllerInterface.get_evse_present_voltage().""" if protocol in [Protocol.DIN_SPEC_70121, Protocol.ISO_15118_2]: - print(f"protocol -> {protocol}") value, exponent = PhysicalValue.get_exponent_value_repr( cast(int, self.evse_data_context.session_context.evse_present_voltage) ) - print(f"value -> {value}, exponent {exponent}") try: pv_evse_present_voltage = PVEVSEPresentVoltage( multiplier=exponent, value=value, unit="V" @@ -1084,13 +1082,17 @@ async def get_cable_check_status(self) -> Union[IsolationLevel, None]: return IsolationLevel.VALID async def set_precharge( - self, - voltage: Union[PVEVTargetVoltage, RationalNumber], - current: Union[PVEVTargetCurrent, RationalNumber], + self, + voltage: Union[PVEVTargetVoltage, RationalNumber], + current: Union[PVEVTargetCurrent, RationalNumber], ): + self.evse_data_context.session_context.evse_present_voltage = ( + voltage.get_decimal_value() + ) + self.evse_data_context.session_context.evse_present_current = ( + current.get_decimal_value() + ) - self.evse_data_context.session_context.evse_present_voltage = voltage.get_decimal_value() - self.evse_data_context.session_context.evse_present_current = current.get_decimal_value() async def send_charging_command( self, voltage: Union[PVEVTargetVoltage, RationalNumber], diff --git a/iso15118/secc/states/iso15118_2_states.py b/iso15118/secc/states/iso15118_2_states.py index 9056c74b..75ca3801 100644 --- a/iso15118/secc/states/iso15118_2_states.py +++ b/iso15118/secc/states/iso15118_2_states.py @@ -2359,7 +2359,6 @@ async def process_message( # Set precharge voltage in every loop. # Because there are EVs that send a wrong Precharge-Voltage # in the first message (example: BMW i3 Rex 2018) - print(f"KARATASSSS -> {precharge_req.ev_target_voltage}") await self.comm_session.evse_controller.set_precharge( precharge_req.ev_target_voltage, precharge_req.ev_target_current ) @@ -2370,7 +2369,6 @@ async def process_message( Protocol.ISO_15118_2 ) ) - print(f"evse_present_voltage {evse_present_voltage}") precharge_res = PreChargeRes( response_code=ResponseCode.OK, dc_evse_status=dc_charger_state, diff --git a/poetry.lock b/poetry.lock index 9aee178e..578bcf69 100644 --- a/poetry.lock +++ b/poetry.lock @@ -501,13 +501,13 @@ files = [ [[package]] name = "platformdirs" -version = "4.0.0" +version = "4.1.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "platformdirs-4.0.0-py3-none-any.whl", hash = "sha256:118c954d7e949b35437270383a3f2531e99dd93cf7ce4dc8340d3356d30f173b"}, - {file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"}, + {file = "platformdirs-4.1.0-py3-none-any.whl", hash = "sha256:11c8f37bcca40db96d8144522d925583bdb7a31f7b0e37e3ed4318400a8e2380"}, + {file = "platformdirs-4.1.0.tar.gz", hash = "sha256:906d548203468492d432bcb294d4bc2fff751bf84971fbb2c10918cc206ee420"}, ] [package.extras] From bbe747ceb63723aae7e0e9017429cbb0567f31b7 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:24:27 +0000 Subject: [PATCH 09/10] code quality --- iso15118/secc/states/iso15118_2_states.py | 1 + 1 file changed, 1 insertion(+) diff --git a/iso15118/secc/states/iso15118_2_states.py b/iso15118/secc/states/iso15118_2_states.py index 75ca3801..a4012575 100644 --- a/iso15118/secc/states/iso15118_2_states.py +++ b/iso15118/secc/states/iso15118_2_states.py @@ -2369,6 +2369,7 @@ async def process_message( Protocol.ISO_15118_2 ) ) + precharge_res = PreChargeRes( response_code=ResponseCode.OK, dc_evse_status=dc_charger_state, From 5a91445b54d0e825c986c2c0fff4869405a24016 Mon Sep 17 00:00:00 2001 From: ikaratass <89934937+ikaratass@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:00:59 +0000 Subject: [PATCH 10/10] dc_max_voltage_limit is updated --- iso15118/evcc/controller/simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iso15118/evcc/controller/simulator.py b/iso15118/evcc/controller/simulator.py index 6f3f4899..d094186b 100644 --- a/iso15118/evcc/controller/simulator.py +++ b/iso15118/evcc/controller/simulator.py @@ -127,7 +127,7 @@ def __init__(self, evcc_config: EVCCConfig): multiplier=1, value=8000, unit=UnitSymbol.WATT ), dc_max_voltage_limit=PVEVMaxVoltageLimit( - multiplier=1, value=40, unit=UnitSymbol.VOLTAGE + multiplier=3, value=20, unit=UnitSymbol.VOLTAGE ), dc_energy_capacity=PVEVEnergyCapacity( multiplier=1, value=7000, unit=UnitSymbol.WATT_HOURS