Skip to content

Commit

Permalink
Squashed all 39 commits of this branch into one. This branch continue…
Browse files Browse the repository at this point in the history
…s to implement the -20 states until ScheduleExchange.

Update README.md (#1)

* Update README.md

Corrected a few typos and added a sentence explaining why JRE is needed

* Update README.md

* Update README.md

* Update README.md

Removed mqtt api as dependency (#3)

Fix compatibility with linux (#2)

* Added ipv6 support in docker world; fixed compatibility issue with sed between BSD and Linux systems

* improved readme

* renamed the .env files to be more intuitive in regards to their purpose; Updated Readme, adding a more detailed explanation of how to handle IPv6 communication within docker; fixed a bug on handling the configuration of the NIC interface

* fixed bug in the host mode compose file

* Added a few more clarification in the build Makefile recipe

* Fixed language typos in the README and removed references to the MQTT api

* Refactored network tools methods and general handling of it, to be more consise and close to the use case we have. For example, as the NETWORK_INTERFACE is always present, there is no need to scan for all the available interfaces to find one that contains a link-local address.

* Removed references ot the PYPI credentials in the Dockerfile

* Fixed bug on printing the interface used

* addressed editorial comments and renamed exception to be consistent

* Fixed docstring typo

* Due to the changes regarding the handling of the exceptions of the code, I did some reworking on the UDP client and server services, as in some occasions (e.g. when the interface configured was invalid) the application would throw the error 'evcc_1   | sys:1: RuntimeWarning: coroutine 'CommunicationSessionHandler.get_from_rcv_queue' was never awaited
evcc_1   | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
evcc_1   | sys:1: RuntimeWarning: coroutine 'CommunicationSessionHandler.restart_sdp' was never awaited
evcc_1   | RuntimeWarning: Enable tracemalloc to get the object allocation traceback'

* improved docs

* fixed grammar and context

* removed more PYPI references

* fixed bug on EVCC side when requesting to stop charging

Simplification of the Authorization process_message method (#5)

* Removed explicit call to process CharParameterDiscoveryReq message; instead we can just decide which is the next expected state

* Updated README and Authoruzation docstring

* converted the wanring to a TODO

improved secc and evcc configuration handling and updated readme (#6)

* improved secc configuration handling and updated readme

* Added configuration handling for the evcc

* Refactored the collection of shared settings and log configuration. Also provided a way to select the location of the PKI certificate structure directory

* Added new line at the end

* improved README

* minor editorial change

Fix 1090 physical types validation error (#7)

* Fixed max value validation for the PhysicalValue types

* Changed multiplier to test the changes

* On favour of DRY, I moved the root_validator of the PhysicalTypes to their parent class

* added extra comment related to the private method validation with pydantic

* changed physical value restrictions after comments by Marc

* Revert "changed physical value restrictions after comments by Marc"

This reverts commit cf88330.

* used the enums for a few fields

Github actions workflow and reformat of the code (#8)

* Added github workflows for testing and publish; Reformatted the code using black and updated the CHANGELOG

* Added initial tests

* reformatted tests

* typo

* install with pip

* attempt to run tests without poetry

* added pytest to the workflow

* suspended temporarily the tests run

* fixed typo

* re-added poetry to call black

* added iso15118 for black

* attempt to run tests (using docker)

* copied tests dir to the container

* retry poetry tests

* added init to iso15118 dir

* docker as testing stage

* try to run tests with poetry again

* run tests with docker

* typo on the github action tag

* Editorial change

Added the skeleton for the remaining states (message handling classes) on the SECC side

Added the skeleton for the remaining states (message handling classes) on the EVCC side

Minor editorial edits and deactivating PnC in the settings to test EIM implementation first

Fixed the list issues regarding the EXI codec as raised by Shalin for the AuthorizationReq message and CertificateInstallationReq message

Implemented AuthorizationReq for EVCC and SECC

Modified exi_codec to complete the list of ISO 15118-20 messages that shall be used to parse an object from an incoming decoded EXI stream.

Implemented ServiceDiscoveryReq and -Res

Implemented ServiceDetailReq and -Res

Implemented ServiceSelectionReq and -Res

Changed settings.py in shared directory as ROOT_DIR did not point to the actual root directory but to settings.py in the shared folder, which messed up the path to the pki folder. As a result, the ssl_context could not be created.

Minor editorial edits and bugfix to get the application to run again

Made use of the new enums INT_16_MIN, INT_16_MAX, INT_8_MIN, INT_8_MAX in common_messages.py and common_types.py

Made use of the new enums INT_16_MAX in evcc_settings.py. Plus minor editorial edits to respect column length of 88

Added the specific payload type for each V2GTP message the EVCC and SECC sends in ISO 15118-20. In -20, we have energy mode-specific payload types we need to distinguish so that the EXI decoder gets pointed to the right XSD to decode the message.

Added the failed response for DCChargeParameterDiscoveryReq and modified the failed_responses.py to return also the payload type, which is important for the EXI codec (as in -20, we have energy mode-specific payload types).

Improved implementation of the class ServiceSelection on EVCC and SECC side

Implemented class DCChargeParameterDiscovery on SECC side

Fixed a small bug after changing the signature of the EVCC interface's get_charge_params_v20() function

Improved implementation of ServiceDiscovery and ServiceDetails in order to better handle the offered and selected service and their associated parameter sets. Needed some changes in the comm_session.py and comm_session_handler.py (both EVCC and SECC) as well as the state classes.

Working on finishing the implementation of the class DC_ChargeParameterDiscovery on the EVCC side. Implementing the ScheduleExchangeReq message.

Changed the implementation of the selected energy service and selected value-added services as session variables in the comm_session object. This way, we have easier access to the various service parameters, especially useful for the selected energy service.

Applied ge and le restrictions to departure_time and added the missing fields ev_max_v2x_energy_request and ev_min_v2x_energy_request to the class DynamicScheduleExchangeReqParams

Finished implementing state DCChargeParameterDiscovery on the EVCC side

Improved/fixed the implementation of class ServiceSelection on SECC side to check if the EVCC selected the correct pairs of service ID and parameter set ID per selected service

Introduced NumericID type in common_types.py and replaced simple int types for schedules IDs etc. with that type. Also changed the name of the class ListOfRootCertificateIDs to RootCertificateIDList to be consistent with the latest changes coming with PR#4

Started implememting the class ScheduleExchange on the SECC side, which includes work on the get_scheduled_se_params() and get_dynamic_se_params() functions on the EVCC and SECC side.

Finished implememting the class ScheduleExchange on the SECC side

Ran black on the files in this branch

Ran flake8 on the files in this branch

Forgot to add evcc_state.py to my last commit
  • Loading branch information
tropxy authored and MarcMueltin committed Jan 4, 2022
1 parent 5a6de24 commit aba1bed
Show file tree
Hide file tree
Showing 23 changed files with 3,179 additions and 346 deletions.
4 changes: 2 additions & 2 deletions .env.dev.local
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# General Settings
NETWORK_INTERFACE=eth0
NETWORK_INTERFACE=en0

# Redis
REDIS_PORT=10001
REDIS_HOST=localhost


# SECC Settings
SECC_CONTROLLER_SIM=True
FREE_CHARGING_SERVICE=False
Expand Down
157 changes: 147 additions & 10 deletions iso15118/evcc/controller/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,33 @@
ChargingProfile,
DCEVChargeParameter,
EnergyTransferModeEnum,
SAScheduleTuple,
SAScheduleTupleEntry,
ProfileEntry,
)
from iso15118.shared.messages.iso15118_20.ac import (
ACChargeParameterDiscoveryReqParams,
BPTACChargeParameterDiscoveryReqParams,
)
from iso15118.shared.messages.iso15118_20.common_messages import EMAIDList
from iso15118.shared.messages.enums import Protocol, ServiceV20

from iso15118.shared.messages.iso15118_20.ac import (
ACChargeParameterDiscoveryReqParams,
BPTACChargeParameterDiscoveryReqParams,
)
from iso15118.shared.messages.iso15118_20.common_messages import (
EMAID,
ParameterSet as ParameterSetV20,
ScheduledScheduleExchangeReqParams,
DynamicScheduleExchangeReqParams,
SelectedEnergyService,
SelectedVAS,
)
from iso15118.shared.messages.iso15118_20.dc import (
DCChargeParameterDiscoveryReqParams,
BPTDCChargeParameterDiscoveryReqParams,
)


@dataclass
Expand All @@ -30,6 +50,11 @@ class ChargeParamsV2:


class EVControllerInterface(ABC):

# ============================================================================
# | COMMON FUNCTIONS (FOR ALL ENERGY TRANSFER MODES) |
# ============================================================================

@abstractmethod
def get_evcc_id(self, protocol: Protocol, iface: str) -> str:
"""
Expand Down Expand Up @@ -65,6 +90,63 @@ def get_energy_transfer_mode(self) -> EnergyTransferModeEnum:
"""
raise NotImplementedError

@abstractmethod
def get_energy_service(self) -> ServiceV20:
"""
Gets the energy transfer service requested for the current charging session.
This must be one of the energy related services (services with ID 1 through 7)
Relevant for:
- ISO 15118-20
"""
raise NotImplementedError

@abstractmethod
def select_energy_service_v20(
self, service: ServiceV20, is_free: bool, parameter_sets: List[ParameterSetV20]
) -> SelectedEnergyService:
"""
Selects the energy service and associated parameter set from a given set of
parameters per energy service ID.
Args:
service: The service given as an enum member of ServiceV20
is_free: Whether this is a free or paid service
parameter_sets: The parameter sets, which the SECC offers for that energy
service
Returns:
An instance of SelectedEnergyService, containing the service, whether it's
free or paid, and its chosen parameter set.
Relevant for:
- ISO 15118-20
"""
raise NotImplementedError

@abstractmethod
def select_vas_v20(
self, service: ServiceV20, is_free: bool, parameter_sets: List[ParameterSetV20]
) -> Optional[SelectedVAS]:
"""
Selects a value-added service (VAS) and associated parameter set from a given
set of parameters for that value-added energy. If you don't want to select
the offered VAS, return None.
Args:
service: The value-added service given as an enum member of ServiceV20
is_free: Whether this is a free or paid service
parameter_sets: The parameter sets, which the SECC offers for that VAS
Returns:
An instance of SelectedVAS, containing the service, whether it's free or
paid, and its chosen parameter set.
Relevant for:
- ISO 15118-20
"""
raise NotImplementedError

@abstractmethod
def get_charge_params_v2(self) -> ChargeParamsV2:
"""
Expand All @@ -84,27 +166,74 @@ def get_charge_params_v2(self) -> ChargeParamsV2:

@abstractmethod
def get_charge_params_v20(
self,
) -> Tuple[
self, selected_service: SelectedEnergyService
) -> Union[
ACChargeParameterDiscoveryReqParams,
Optional[BPTACChargeParameterDiscoveryReqParams],
BPTACChargeParameterDiscoveryReqParams,
DCChargeParameterDiscoveryReqParams,
BPTDCChargeParameterDiscoveryReqParams,
]:
"""
Gets the charge parameters needed for a ChargeParameterDiscoveryReq, which is
either an ACChargeParameterDiscoveryReq, or a DCChargeParameterDiscoveryReq,
or a WPTChargeParameterDiscoveryReq from ISO 15118-20, including the optional
optional BPT (bi-directional power flow) paramters.
Gets the charge parameters needed for a ChargeParameterDiscoveryReq.
Args:
selected_service: The energy transfer service, which the EVCC selected, and
for which we need the EVCC's charge parameters. This is
an instance of the custom class SelectedEnergyService.
Returns:
A tuple containing both the non-BPT and BPT charger parameter needed for a
request message of type ChargeParameterDiscoveryReq (AC, DC, or WPT)
Charge parameters for either unidirectional or bi-directional power
transfer needed for a ChargeParameterDiscoveryReq.
Relevant for:
- ISO 15118-20
TODO Add support for DC and WPT in the return type
TODO Add support for WPT and ACDP in the return type
"""
raise NotImplementedError

@abstractmethod
def get_scheduled_se_params(
self, selected_energy_service: SelectedEnergyService
) -> ScheduledScheduleExchangeReqParams:
"""
Gets the parameters for a ScheduleExchangeRequest, which correspond to the
Scheduled control mode.
Args:
selected_energy_service: The energy services, which the EVCC selected.
The selected parameter set, that is associated
with that energy service, influences the
parameters for the ScheduleExchangeReq
Returns:
Parameters for the ScheduleExchangeReq in Scheduled control mode
Relevant for:
- ISO 15118-20
"""

@abstractmethod
def get_dynamic_se_params(
self, selected_energy_service: SelectedEnergyService
) -> DynamicScheduleExchangeReqParams:
"""
Gets the parameters for a ScheduleExchangeRequest, which correspond to the
Dynamic control mode.
Args:
selected_energy_service: The energy services, which the EVCC selected.
The selected parameter set, that is associated
with that energy service, influences the
parameters for the ScheduleExchangeReq
Returns:
Parameters for the ScheduleExchangeReq in Dynamic control mode
Relevant for:
- ISO 15118-20
"""

@abstractmethod
def is_cert_install_needed(self) -> bool:
"""
Expand Down Expand Up @@ -200,3 +329,11 @@ def get_prioritised_emaids(self) -> Optional[EMAIDList]:
- ISO 15118-20
"""
raise NotImplementedError

# ============================================================================
# | AC-SPECIFIC FUNCTIONS |
# ============================================================================

# ============================================================================
# | DC-SPECIFIC FUNCTIONS |
# ============================================================================
Loading

0 comments on commit aba1bed

Please sign in to comment.