Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dinspec implementation #24

Merged
merged 50 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d7c73da
Updated branch to use jar with DINSpec support
shalinnijel2 Mar 1, 2022
2208228
Updated timeout values for DINSpec. Minor formatting to stop black fr…
shalinnijel2 Mar 1, 2022
422e90c
Added reference schema files.
shalinnijel2 Mar 2, 2022
05ae1b0
DIN SPEC schema representation - first draft
shalinnijel2 Mar 8, 2022
dbea87c
Updated din_spec/datatypes.py
shalinnijel2 Mar 8, 2022
7931f2e
Updated comm_session.py and exi_codec to accept DINSPEC message types.
shalinnijel2 Mar 9, 2022
20b3dee
Updated abstract method definition in states.py and updated associate…
shalinnijel2 Mar 9, 2022
e799c07
Setting preferred protocol to DIN SPEC on evcc side for now (to be ch…
shalinnijel2 Mar 9, 2022
01239e8
Fixed flake8 and black errors. Removed message types not used by DINS…
shalinnijel2 Mar 14, 2022
464e984
Fixed flake8 and black errors. Moved EnergyTransferMode to common enums.
shalinnijel2 Mar 14, 2022
b337a92
Initial checkin - DIN SPEC states for EVCC and SECC.
shalinnijel2 Mar 14, 2022
98d70dd
Code format mods to pass tests on GitHub.
shalinnijel2 Mar 14, 2022
f33ae05
Support for remaining states till SessionStop
shalinnijel2 Mar 17, 2022
f166ff2
Refactoring to move common classes between -2 dc and dinspec messages.
shalinnijel2 Mar 18, 2022
edef98e
Updated EXICodec.jar with fix for WeldingDetectionRes message (#27)
shalinnijel2 Mar 23, 2022
89c9329
feat: Addressed some of the comments on PR(AB#1439)
shalinnijel2 Mar 29, 2022
5ceeb11
feat: DIN SPEC should not be listed in supported protocols if use_tls…
shalinnijel2 Mar 30, 2022
089d67c
feat: Add timeout handling to CableCheck, renamed ServiceAndPaymentSe…
shalinnijel2 Mar 31, 2022
178b4e5
feat: Added tests. Fixed identified issue with CableCheck.
shalinnijel2 Mar 31, 2022
be38593
Feature/dc states till session stop (#21)
lukaslombriserdesignwerk Apr 1, 2022
a805a8e
feat: More fixes. (AB#1439)
shalinnijel2 Apr 1, 2022
aa29088
Updated timeout values for DINSpec. Minor formatting to stop black fr…
shalinnijel2 Mar 1, 2022
bbf0f4e
Added reference schema files.
shalinnijel2 Mar 2, 2022
c01d77c
DIN SPEC schema representation - first draft
shalinnijel2 Mar 8, 2022
6a5e84c
Updated din_spec/datatypes.py
shalinnijel2 Mar 8, 2022
bbf6494
Updated comm_session.py and exi_codec to accept DINSPEC message types.
shalinnijel2 Mar 9, 2022
9fda171
Updated abstract method definition in states.py and updated associate…
shalinnijel2 Mar 9, 2022
a5a1037
Setting preferred protocol to DIN SPEC on evcc side for now (to be ch…
shalinnijel2 Mar 9, 2022
d22af16
Fixed flake8 and black errors. Removed message types not used by DINS…
shalinnijel2 Mar 14, 2022
9ab4aaf
Fixed flake8 and black errors. Moved EnergyTransferMode to common enums.
shalinnijel2 Mar 14, 2022
b380eb2
Initial checkin - DIN SPEC states for EVCC and SECC.
shalinnijel2 Mar 14, 2022
9784da2
Code format mods to pass tests on GitHub.
shalinnijel2 Mar 14, 2022
27631be
Support for remaining states till SessionStop
shalinnijel2 Mar 17, 2022
7eef163
Refactoring to move common classes between -2 dc and dinspec messages.
shalinnijel2 Mar 18, 2022
e524b8e
feat: Addressed some of the comments on PR(AB#1439)
shalinnijel2 Mar 29, 2022
c5f5879
feat: DIN SPEC should not be listed in supported protocols if use_tls…
shalinnijel2 Mar 30, 2022
9f12305
feat: Add timeout handling to CableCheck, renamed ServiceAndPaymentSe…
shalinnijel2 Mar 31, 2022
8af702e
feat: Added tests. Fixed identified issue with CableCheck.
shalinnijel2 Mar 31, 2022
cee777c
feat: More fixes. (AB#1439)
shalinnijel2 Apr 1, 2022
0e6685f
feat: Rebased to master. Re-added missed (AB#1439)
shalinnijel2 Apr 6, 2022
8788a0c
Merge branch 'dinspec_implementation' of https://github.com/SwitchEV/…
shalinnijel2 Apr 6, 2022
0293f5f
feat: Updated failing tests(AB#1439)
shalinnijel2 Apr 6, 2022
3dd1aed
feat: Addressed comments in PR (AB#1439)
shalinnijel2 Apr 7, 2022
b1de09e
feat: Fixed failing tests(AB#1439)
shalinnijel2 Apr 7, 2022
6b277c7
feat: added timeout checkj to CableCheck, WeldingDetection, updated t…
shalinnijel2 Apr 8, 2022
7f30b5b
feat: Addressed comments on PR. Added missing docstrings.(AB#1439)
shalinnijel2 Apr 11, 2022
9892aff
feat: Addressed comments on PR(AB#1439)
shalinnijel2 Apr 12, 2022
6646da8
feat: Renamed shared/messages/datatypes_iso15118_2_dinspec to shared/…
shalinnijel2 Apr 12, 2022
c01d4d5
feat: Fixed flake8 errors
shalinnijel2 Apr 12, 2022
6d7b53a
feat: Updated tests following file rename (AB#1439)
shalinnijel2 Apr 12, 2022
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
40 changes: 37 additions & 3 deletions iso15118/evcc/controller/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
from dataclasses import dataclass
from typing import List, Optional, Tuple

from iso15118.shared.messages.enums import Protocol
from iso15118.shared.messages.datatypes_iso15118_2_dinspec import (
DCEVChargeParams,
)
from iso15118.shared.messages.din_spec.datatypes import (
DCEVStatus,
DCEVPowerDeliveryParameter,
)

from iso15118.shared.messages.enums import Protocol, EnergyTransferModeEnum
from iso15118.shared.messages.iso15118_2.datatypes import (
ACEVChargeParameter,
ChargeProgress,
ChargingProfile,
DCEVChargeParameter,
EnergyTransferModeEnum,
SAScheduleTupleEntry,
)
from iso15118.shared.messages.iso15118_20.ac import (
Expand Down Expand Up @@ -53,7 +60,7 @@ def get_evcc_id(self, protocol: Protocol, iface: str) -> str:
raise NotImplementedError

@abstractmethod
def get_energy_transfer_mode(self) -> EnergyTransferModeEnum:
def get_energy_transfer_mode(self, protocol: Protocol) -> EnergyTransferModeEnum:
"""
Gets the energy transfer mode requested for the current charging session.
This depends on the charging cable being plugged in, which could be a
Expand Down Expand Up @@ -200,3 +207,30 @@ def get_prioritised_emaids(self) -> Optional[EMAIDList]:
- ISO 15118-20
"""
raise NotImplementedError

@abstractmethod
def get_dc_charge_params(self) -> DCEVChargeParams:
"""
This would return an encapsulation of the following parameters:
DC Max Current Limit
DC Max Voltage Limit
DC Target Current
DC Target Voltage
"""
raise NotImplementedError

@abstractmethod
def get_dc_ev_status(self) -> DCEVStatus:
raise NotImplementedError

@abstractmethod
def ready_to_charge(self) -> bool:
raise NotImplementedError

@abstractmethod
def get_dc_ev_power_delivery_parameter(self) -> DCEVPowerDeliveryParameter:
raise NotImplementedError

@abstractmethod
def is_charging_complete(self) -> bool:
raise NotImplementedError
83 changes: 71 additions & 12 deletions iso15118/evcc/controller/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,38 @@
import logging
from typing import List, Optional, Tuple

from iso15118.shared.messages.datatypes_iso15118_2_dinspec import (
PVEVTargetVoltage,
PVEVTargetCurrent,
PVEAmount,
PVEVMaxVoltage,
PVEVMaxCurrent,
PVEVMinCurrent,
PVPMax,
PVEVMaxCurrentLimit,
PVEVMaxVoltageLimit,
DCEVChargeParams,
)
from iso15118.shared.messages.din_spec.datatypes import (
DCEVStatus,
DCEVPowerDeliveryParameter,
)

from iso15118.evcc.controller.interface import ChargeParamsV2, EVControllerInterface
from iso15118.shared.exceptions import InvalidProtocolError, MACAddressNotFound
from iso15118.shared.messages.enums import Namespace, Protocol
from iso15118.shared.messages.enums import (
Namespace,
Protocol,
EnergyTransferModeEnum,
UnitSymbol,
DCEVErrorCode,
)
from iso15118.shared.messages.iso15118_2.datatypes import (
ACEVChargeParameter,
ChargeProgress,
ChargingProfile,
EnergyTransferModeEnum,
ProfileEntryDetails,
PVEAmount,
PVEVMaxCurrent,
PVEVMaxVoltage,
PVEVMinCurrent,
PVPMax,
SAScheduleTupleEntry,
UnitSymbol,
)
from iso15118.shared.messages.iso15118_20.ac import (
ACChargeParameterDiscoveryReqParams,
Expand All @@ -41,11 +57,25 @@ class SimEVController(EVControllerInterface):

def __init__(self):
self.charging_loop_cycles: int = 0
self.dc_ev_charge_params: DCEVChargeParams = DCEVChargeParams(
dc_max_current_limit=PVEVMaxCurrentLimit(
multiplier=1, value=10, unit=UnitSymbol.AMPERE
),
dc_max_voltage_limit=PVEVMaxVoltageLimit(
multiplier=1, value=40, unit=UnitSymbol.VOLTAGE
),
dc_target_current=PVEVTargetCurrent(
multiplier=1, value=10, unit=UnitSymbol.AMPERE
),
dc_target_voltage=PVEVTargetVoltage(
multiplier=1, value=40, unit=UnitSymbol.VOLTAGE
),
)

def get_evcc_id(self, protocol: Protocol, iface: str) -> str:
"""Overrides EVControllerInterface.get_evcc_id()."""

if protocol in (Protocol.ISO_15118_2, Protocol.DIN_SPEC_70121):
if protocol == Protocol.ISO_15118_2:
try:
hex_str = get_nic_mac_address(iface)
return hex_str.replace(":", "").upper()
Expand All @@ -56,18 +86,22 @@ def get_evcc_id(self, protocol: Protocol, iface: str) -> str:
"'000000000000'"
)
return "000000000000"
elif protocol == Protocol.DIN_SPEC_70121:
return "00000000"
shalinnijel2 marked this conversation as resolved.
Show resolved Hide resolved
elif protocol.ns.startswith(Namespace.ISO_V20_BASE):
# The check digit (last character) is not a correctly computed one
return "WMIV1234567890ABCDEX"
else:
logger.error(f"Invalid protocol '{protocol}', can't determine EVCCID")
raise InvalidProtocolError

def get_energy_transfer_mode(self) -> EnergyTransferModeEnum:
def get_energy_transfer_mode(self, protocol: Protocol) -> EnergyTransferModeEnum:
"""Overrides EVControllerInterface.get_energy_transfer_mode()."""
if protocol == Protocol.DIN_SPEC_70121:
return EnergyTransferModeEnum.DC_EXTENDED
return EnergyTransferModeEnum.AC_THREE_PHASE_CORE
tropxy marked this conversation as resolved.
Show resolved Hide resolved

def get_charge_params_v2(self) -> ChargeParamsV2:
def get_charge_params_v2(self, protocol: Protocol) -> ChargeParamsV2:
"""Overrides EVControllerInterface.get_charge_params_v2()."""
# This is for simulating AC only. You can modify to simulate DC charging
e_amount = PVEAmount(multiplier=0, value=60, unit=UnitSymbol.WATT_HOURS)
Expand All @@ -85,7 +119,9 @@ def get_charge_params_v2(self) -> ChargeParamsV2:
ev_max_current=ev_max_current,
ev_min_current=ev_min_current,
)
return ChargeParamsV2(self.get_energy_transfer_mode(), ac_charge_params, None)
return ChargeParamsV2(
self.get_energy_transfer_mode(protocol), ac_charge_params, None
)
shalinnijel2 marked this conversation as resolved.
Show resolved Hide resolved

def get_charge_params_v20(
self,
Expand Down Expand Up @@ -174,3 +210,26 @@ def store_contract_cert_and_priv_key(self, contract_cert: bytes, priv_key: bytes

def get_prioritised_emaids(self) -> Optional[EMAIDList]:
return None

def get_dc_charge_params(self) -> DCEVChargeParams:
return self.dc_ev_charge_params

def get_dc_ev_status(self) -> DCEVStatus:
return DCEVStatus(
ev_ready=True,
ev_error_code=DCEVErrorCode.NO_ERROR,
ev_ress_soc=10,
)

def ready_to_charge(self) -> bool:
return self.continue_charging()

def get_dc_ev_power_delivery_parameter(self) -> DCEVPowerDeliveryParameter:
return DCEVPowerDeliveryParameter(
dc_ev_status=self.get_dc_ev_status(),
bulk_charging_complete=False,
charging_complete=self.continue_charging(),
)

def is_charging_complete(self) -> bool:
return True
6 changes: 5 additions & 1 deletion iso15118/evcc/evcc_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def load_envs(self, env_path: Optional[str] = None) -> None:
# the protocols are listed here determines the priority (i.e. first list entry
# has higher priority than second list entry). A list entry must be a member
# of the Protocol enum
self.supported_protocols = [Protocol.ISO_15118_2, Protocol.ISO_15118_20_AC]
self.supported_protocols = [
Protocol.DIN_SPEC_70121,
Protocol.ISO_15118_2,
Protocol.ISO_15118_20_AC,
]

env.seal() # raise all errors at once, if any

Expand Down
Loading