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

Fix of the several messages that misuse the List type #4

Merged
merged 27 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c300c6d
Fixed ServiceDiscoveryRes message datatypes
tropxy Dec 10, 2021
0b29bca
fix typo in ServiceList and started fixing ChargeParametersDiscovery
tropxy Dec 13, 2021
0a0759e
fixed service_list incorrect attribute
tropxy Dec 13, 2021
2f01505
fixed the list of cert ids
tropxy Dec 13, 2021
1a06c21
Fixed certificate List issues
tropxy Dec 14, 2021
f1e3293
fixed sub certificate handling for the PaymentDetailsReq and fixed th…
tropxy Dec 14, 2021
135f4f6
improved a bit the handling of the stop error messages
tropxy Dec 21, 2021
656b4ea
Fixed ChargeParameterDiscoveryRes - Converted PMaxSchedule from a lis…
tropxy Dec 21, 2021
d03fa12
Fixed PowerDeliveryReq by Changing the ChargeProfile type from a list…
tropxy Dec 21, 2021
33228f2
Refactored the Certificates datatypes and some attributes names
tropxy Dec 29, 2021
9ec6250
Removed the unnedded overriding of the init from the base Exception c…
tropxy Dec 29, 2021
15f16b2
Renamed ProfileEntry to ChargingProfile
tropxy Dec 29, 2021
6201c99
Renamed AuthOptionsList, added TODOs for exi_codec.py, refactored sig…
tropxy Dec 29, 2021
af3c938
added comment to the xmldsig file
tropxy Dec 29, 2021
c279ccf
added more info to the simple types
tropxy Dec 29, 2021
b25f034
Applied requested changes to xmldsig.py, added a HTTPURL type for the…
tropxy Dec 30, 2021
769b57a
Fixed Subcertificates for V20 and the usage of the Certificate type; …
tropxy Dec 30, 2021
0558f24
reformatted the code and security.py
tropxy Dec 30, 2021
045f7ac
refactored call for create_sign
tropxy Dec 30, 2021
e20c353
reformatted code
tropxy Dec 30, 2021
3a92637
renamed RootCertificateID to RootCertificateIDList; added more docstr…
tropxy Jan 4, 2022
4cb82ea
reformatted the code using black
tropxy Jan 4, 2022
7bc622f
Flaked8 and reformatted the code; included flake8 into the code quali…
tropxy Jan 4, 2022
14248bf
addresed comments
tropxy Jan 4, 2022
0c3fcf5
reformat
tropxy Jan 4, 2022
4203685
refactored EMAID in ISO15118-20
tropxy Jan 4, 2022
4cc15e1
fixed imports in evcc interface and simulator
tropxy Jan 4, 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ run-secc:


mypy:
mypy --config-file ../mypy.ini iso15118 tests
mypy --config-file mypy.ini iso15118 tests

reformat:
isort iso15118 tests && black --line-length=88 iso15118 tests
Expand All @@ -88,7 +88,7 @@ black:
black --check --diff --line-length=88 iso15118 tests

flake8:
flake8 --config ../.flake8 iso15118 tests
flake8 --config .flake8 iso15118 tests

code-quality: reformat mypy black flake8

Expand Down
15 changes: 7 additions & 8 deletions iso15118/evcc/controller/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@

from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Optional, Tuple, Union
from typing import List, Optional, Tuple

from iso15118.shared.messages.enums import Protocol
from iso15118.shared.messages.iso15118_2.datatypes import (
ACEVChargeParameter,
ChargeProgress,
ChargingProfile,
DCEVChargeParameter,
EnergyTransferMode,
EnergyTransferModeEnum,
ProfileEntry,
SAScheduleTuple,
SAScheduleTupleEntry,
)
from iso15118.shared.messages.iso15118_20.ac import (
ACChargeParameterDiscoveryReqParams,
BPTACChargeParameterDiscoveryReqParams,
)
from iso15118.shared.messages.iso15118_20.common_messages import EMAID
from iso15118.shared.messages.iso15118_20.common_messages import EMAIDList


@dataclass
Expand Down Expand Up @@ -127,8 +126,8 @@ def is_cert_install_needed(self) -> bool:

@abstractmethod
def process_sa_schedules(
self, sa_schedules: List[SAScheduleTuple]
) -> Tuple[ChargeProgress, int, List[ProfileEntry]]:
self, sa_schedules: List[SAScheduleTupleEntry]
) -> Tuple[ChargeProgress, int, ChargingProfile]:
"""
Processes the SAScheduleList provided with the ChargeParameterDiscoveryRes
to decide which of the offered schedules to choose and whether or not to
Expand Down Expand Up @@ -184,7 +183,7 @@ def store_contract_cert_and_priv_key(self, contract_cert: bytes, priv_key: bytes
raise NotImplementedError

@abstractmethod
def get_prioritised_emaids(self) -> Optional[List[EMAID]]:
def get_prioritised_emaids(self) -> Optional[EMAIDList]:
"""
Indicates the list of EMAIDs (E-Mobility Account IDs) referencing contract
certificates that shall be installed into the EV. The EMAIDs are given in
Expand Down
27 changes: 12 additions & 15 deletions iso15118/evcc/controller/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
from iso15118.shared.messages.iso15118_2.datatypes import (
ACEVChargeParameter,
ChargeProgress,
ChargingProfile,
EnergyTransferModeEnum,
ProfileEntry,
ProfileEntryDetails,
PVEAmount,
PVEVMaxCurrent,
PVEVMaxVoltage,
PVEVMinCurrent,
PVPMax,
SAScheduleTuple,
SAScheduleTupleEntry,
UnitSymbol,
)
from iso15118.shared.messages.iso15118_20.ac import (
ACChargeParameterDiscoveryReqParams,
BPTACChargeParameterDiscoveryReqParams,
)
from iso15118.shared.messages.iso15118_20.common_messages import EMAID
from iso15118.shared.messages.iso15118_20.common_messages import EMAIDList
from iso15118.shared.messages.iso15118_20.common_types import RationalNumber
from iso15118.shared.network import get_nic_mac_address

Expand Down Expand Up @@ -114,23 +114,22 @@ def is_cert_install_needed(self) -> bool:
return True

def process_sa_schedules(
self, sa_schedules: List[SAScheduleTuple]
) -> Tuple[ChargeProgress, int, List[ProfileEntry]]:
self, sa_schedules: List[SAScheduleTupleEntry]
) -> Tuple[ChargeProgress, int, ChargingProfile]:
"""Overrides EVControllerInterface.process_sa_schedules()."""
schedule = sa_schedules.pop()
profile_entry_list: List[ProfileEntry] = []
profile_entry_list: List[ProfileEntryDetails] = []

# The charging schedule coming from the SECC is called 'schedule', the
# pendant coming from the EVCC (after having processed the offered
# schedule(s)) is called 'profile'. Therefore, we use the prefix
# 'schedule_' for data from the SECC, and 'profile_' for data from the EVCC.
tropxy marked this conversation as resolved.
Show resolved Hide resolved
for p_max_schedule_entry in schedule.tuple.p_max_schedule:
schedule_entry_details = p_max_schedule_entry.entry_details
for schedule_entry_details in schedule.p_max_schedule.entry_details:
profile_entry_details = ProfileEntryDetails(
start=schedule_entry_details.time_interval.start,
max_power=schedule_entry_details.p_max,
)
profile_entry_list.append(ProfileEntry(entry_details=profile_entry_details))
profile_entry_list.append(profile_entry_details)

# The last PMaxSchedule element has an optional 'duration' field. if
# 'duration' is present, then there'll be no more PMaxSchedule element
Expand All @@ -145,17 +144,15 @@ def process_sa_schedules(
),
max_power=zero_power,
)
profile_entry_list.append(
ProfileEntry(entry_details=last_profile_entry_details)
)
profile_entry_list.append(last_profile_entry_details)

# TODO If a SalesTariff is present and digitally signed (and TLS is used),
# verify each sales tariff with the mobility operator sub 2 certificate

return (
ChargeProgress.START,
schedule.tuple.sa_schedule_tuple_id,
profile_entry_list,
schedule.sa_schedule_tuple_id,
ChargingProfile(profile_entries=profile_entry_list),
)

def continue_charging(self) -> bool:
Expand All @@ -175,5 +172,5 @@ def store_contract_cert_and_priv_key(self, contract_cert: bytes, priv_key: bytes
# TODO Need to store the contract cert and private key
pass

def get_prioritised_emaids(self) -> Optional[List[EMAID]]:
def get_prioritised_emaids(self) -> Optional[EMAIDList]:
return None
16 changes: 9 additions & 7 deletions iso15118/evcc/evcc_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def load_envs(self, env_path: Optional[str] = None) -> None:

self.log_level = env.str("LOG_LEVEL", default="INFO")

# Choose the EVController implementation. Must be the class name of the controller
# that implements the EVControllerInterface
# Choose the EVController implementation. Must be the class name of the
# controller that implements the EVControllerInterface
self.ev_controller = EVControllerInterface
if env.bool("EVCC_CONTROLLER_SIM", default=False):
self.ev_controller = SimEVController
Expand All @@ -70,13 +70,15 @@ def load_envs(self, env_path: Optional[str] = None) -> None:
"MAX_CONTRACT_CERTS", default=3, validate=Range(min=1, max=65535)
)

# Indicates the security level (either TCP (unencrypted) or TLS (encrypted)) the EVCC
# shall send in the SDP request
# Indicates the security level (either TCP (unencrypted) or TLS (encrypted))
# the EVCC shall send in the SDP request
self.use_tls = env.bool("EVCC_USE_TLS", default=True)

# Indicates whether or not the EVCC should always enforce a TLS-secured communication
# session. If True, the EVCC will only continue setting up a communication session if
# the SECC's SDP response has the Security field set to the enum value Security.TLS.
# Indicates whether or not the EVCC should always enforce a TLS-secured
# communication session.
# If True, the EVCC will only continue setting up a communication session if
# the SECC's SDP response has the Security field set
# to the enum value Security.TLS.
# If the USE_TLS setting is set to False and ENFORCE_TLS is set to True, then
# ENFORCE_TLS overrules USE_TLS.
self.enforce_tls = env.bool("EVCC_ENFORCE_TLS", default=False)
Expand Down
7 changes: 0 additions & 7 deletions iso15118/evcc/states/evcc_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
from typing import Optional, Type, TypeVar, Union

from iso15118.evcc.comm_session_handler import EVCCCommunicationSession
from iso15118.shared.exceptions import FaultyStateImplementationError
from iso15118.shared.messages.app_protocol import (
SupportedAppProtocolReq,
SupportedAppProtocolRes,
)
from iso15118.shared.messages.iso15118_2.body import BodyBase, Response
from iso15118.shared.messages.iso15118_2.body import (
SessionSetupReq as SessionSetupReqV2,
)
from iso15118.shared.messages.iso15118_2.body import (
SessionSetupRes as SessionSetupResV2,
)
from iso15118.shared.messages.iso15118_2.msgdef import V2GMessage as V2GMessageV2
from iso15118.shared.messages.iso15118_20.common_messages import (
SessionSetupReq as SessionSetupReqV20,
)
from iso15118.shared.messages.iso15118_20.common_messages import (
SessionSetupRes as SessionSetupResV20,
)
Expand Down
8 changes: 4 additions & 4 deletions iso15118/evcc/states/iso15118_20_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def process_message(
)
)
],
max_contract_cert_chains=self.comm_session.config.max_contract_certs,
prioritized_emaids=self.comm_session.ev_controller.get_prioritised_emaids(),
max_contract_cert_chains=self.comm_session.config.max_contract_certs, # noqa: E501
prioritized_emaids=self.comm_session.ev_controller.get_prioritised_emaids(), # noqa: E501
)

self.create_next_message(
Expand All @@ -178,7 +178,7 @@ def process_message(
except PrivateKeyReadError as exc:
self.stop_state_machine(
"Can't read private key necessary to sign "
f"CertificateInstallationReq: {exc.error}"
f"CertificateInstallationReq: {exc}"
)
return

Expand Down Expand Up @@ -213,7 +213,7 @@ def process_message(
except PrivateKeyReadError as exc:
self.stop_state_machine(
"Can't read private key necessary to sign "
f"AuthorizationReq: {exc.error}"
f"AuthorizationReq: {exc}"
)
return
else:
Expand Down
Loading