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

selected_energy_mode is a part of evdata #408

Merged
merged 3 commits into from
May 21, 2024
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
4 changes: 3 additions & 1 deletion iso15118/evcc/comm_session_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from iso15118.shared.messages.enums import (
AuthEnum,
DINPayloadTypes,
EnergyTransferModeEnum,
ISOV2PayloadTypes,
ISOV20PayloadTypes,
Namespace,
Expand Down Expand Up @@ -137,7 +138,8 @@ def __init__(
# "Caching" authorization_req. (Required in ISO15118-20)
# Avoids recomputing the signature, eim, pnc params during authorization loop.
self.authorization_req_message: Optional[AuthorizationReq] = None

# The energy mode the EVCC selected (ISO 15118-2)
self.selected_energy_mode: Optional[EnergyTransferModeEnum] = None
self.is_tls = False

def create_sap(self) -> Union[SupportedAppProtocolReq, None]:
Expand Down
9 changes: 8 additions & 1 deletion iso15118/secc/controller/ev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
DCEVChargeParameter as DIN_DCEVChargeParameter,
)
from iso15118.shared.messages.din_spec.body import PreChargeReq as DIN_PreChargeReq
from iso15118.shared.messages.enums import AuthEnum, ControlMode, ServiceV20
from iso15118.shared.messages.enums import (
AuthEnum,
ControlMode,
EnergyTransferModeEnum,
ServiceV20,
)
from iso15118.shared.messages.iso15118_2.body import (
ACEVChargeParameter,
CurrentDemandReq,
Expand Down Expand Up @@ -243,6 +248,8 @@ def __init__(
# Sent in -2,-20 PreChargeReq
# and same as above
self.target_voltage: float = target_voltage
# The energy mode the EVCC selected.
self.selected_energy_mode: Optional[EnergyTransferModeEnum] = None

def update_ac_charge_parameters_v2(
self, ac_ev_charge_parameter: ACEVChargeParameter
Expand Down
3 changes: 1 addition & 2 deletions iso15118/secc/states/din_spec_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ async def process_message(
ResponseCode.FAILED_WRONG_ENERGY_TRANSFER_MODE,
)
return

self.comm_session.selected_energy_mode = (
self.comm_session.evse_controller.ev_data_context.selected_energy_mode = (
charge_parameter_discovery_req.requested_energy_mode
)

Expand Down
6 changes: 3 additions & 3 deletions iso15118/secc/states/iso15118_2_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,9 +1352,9 @@ async def process_message(
evse_data_context = self.comm_session.evse_controller.evse_data_context
ev_data_context = self.comm_session.evse_controller.ev_data_context

self.comm_session.selected_energy_mode = charge_params_req.requested_energy_mode
ev_data_context.selected_energy_mode = charge_params_req.requested_energy_mode
self.comm_session.selected_charging_type_is_ac = (
self.comm_session.selected_energy_mode.value.startswith("AC")
ev_data_context.selected_energy_mode.value.startswith("AC")
)

max_schedule_entries: Optional[
Expand Down Expand Up @@ -1995,7 +1995,7 @@ async def process_message(

evse_controller = self.comm_session.evse_controller
if (
self.comm_session.selected_energy_mode
evse_controller.ev_data_context.selected_energy_mode
and self.comm_session.selected_charging_type_is_ac
):
metering_receipt_res = MeteringReceiptRes(
Expand Down
3 changes: 0 additions & 3 deletions iso15118/shared/comm_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
Protocol,
SessionStopAction,
)
from iso15118.shared.messages.iso15118_2.datatypes import EnergyTransferModeEnum
from iso15118.shared.messages.iso15118_2.msgdef import V2GMessage as V2GMessageV2
from iso15118.shared.messages.iso15118_20.common_messages import (
MatchedService as OfferedServiceV20,
Expand Down Expand Up @@ -328,8 +327,6 @@ def __init__(
self.selected_services: List[SelectedServiceV2_DIN] = []
# The energy service the EVCC selected (ISO 15118-20)
self.selected_energy_service: Optional[SelectedEnergyService] = None
# The energy mode the EVCC selected (ISO 15118-2)
self.selected_energy_mode: Optional[EnergyTransferModeEnum] = None
# Variable selected_charging_type_is_ac set if one of the AC modes is selected
self.selected_charging_type_is_ac: bool = True
# The SAScheduleTuple element the EVCC chose (referenced by ID)
Expand Down
268 changes: 134 additions & 134 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def comm_secc_session_mock():
comm_session_mock.failed_responses_isov2 = init_failed_responses_iso_v2()
comm_session_mock.session_id = MOCK_SESSION_ID
comm_session_mock.offered_schedules = get_sa_schedule_list()
comm_session_mock.selected_energy_mode = EnergyTransferModeEnum.DC_EXTENDED
comm_session_mock.selected_charging_type_is_ac = False
comm_session_mock.stop_reason = StopNotification(False, "pytest")
comm_session_mock.evse_controller = SimEVSEController()
comm_session_mock.protocol = Protocol.UNKNOWN
comm_session_mock.evse_id = "UK123E1234"
comm_session_mock.ev_session_context = EVSessionContext15118()
comm_session_mock.selected_schedule = 1
comm_session_mock.evse_controller.ev_data_context.selected_energy_mode = (
EnergyTransferModeEnum.DC_EXTENDED
)
return comm_session_mock
4 changes: 3 additions & 1 deletion tests/dinspec/secc/test_dinspec_secc_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def _comm_session(self):
self.comm_session = Mock(spec=SECCCommunicationSession)
self.comm_session.session_id = "F9F9EE8505F55838"
# comm_session.offered_schedules = get_sa_schedule_list()
self.comm_session.selected_energy_mode = EnergyTransferModeEnum.DC_EXTENDED
self.comm_session.selected_charging_type_is_ac = False
self.comm_session.stop_reason = StopNotification(False, "pytest")
self.comm_session.evse_controller = SimEVSEController()
Expand All @@ -58,6 +57,9 @@ def _comm_session(self):
self.comm_session.failed_responses_din_spec = (
init_failed_responses_din_spec_70121()
)
self.comm_session.evse_controller.ev_data_context.selected_energy_mode = (
EnergyTransferModeEnum.DC_EXTENDED
)

def get_evse_data(self) -> EVSEDataContext:
dc_limits = EVSEDCCPDLimits(
Expand Down
6 changes: 3 additions & 3 deletions tests/iso15118_20/secc/test_iso15118_20_ac_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ class TestEvScenarios:
def _comm_session(self):
self.comm_session = Mock(spec=SECCCommunicationSession)
self.comm_session.session_id = "F9F9EE8505F55838"
self.comm_session.selected_energy_mode = (
EnergyTransferModeEnum.AC_THREE_PHASE_CORE
)
self.comm_session.selected_charging_type_is_ac = False
self.comm_session.stop_reason = StopNotification(False, "pytest")
self.comm_session.protocol = Protocol.ISO_15118_20_AC
Expand All @@ -99,6 +96,9 @@ def _comm_session(self):
self.comm_session.evse_controller.ev_data_context = EVDataContext(
rated_limits=EVRatedLimits(ac_limits=EVACCPDLimits())
)
self.comm_session.evse_controller.ev_data_context.selected_energy_mode = (
EnergyTransferModeEnum.AC_THREE_PHASE_CORE
)
load_shared_settings()

def get_evse_data(self) -> EVSEDataContext:
Expand Down
4 changes: 3 additions & 1 deletion tests/iso15118_20/secc/test_iso15118_20_dc_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class TestEvScenarios:
def _comm_session(self):
self.comm_session = Mock(spec=SECCCommunicationSession)
self.comm_session.session_id = "F9F9EE8505F55838"
self.comm_session.selected_energy_mode = EnergyTransferModeEnum.DC_EXTENDED
self.comm_session.selected_charging_type_is_ac = False
self.comm_session.stop_reason = StopNotification(False, "pytest")
self.comm_session.protocol = Protocol.ISO_15118_20_DC
Expand All @@ -91,6 +90,9 @@ def _comm_session(self):
self.comm_session.evse_controller.ev_data_context = EVDataContext(
rated_limits=EVRatedLimits(dc_limits=EVDCCPDLimits())
)
self.comm_session.evse_controller.ev_data_context.selected_energy_mode = (
EnergyTransferModeEnum.DC_EXTENDED
)
load_shared_settings()

def get_evse_data(self) -> EVSEDataContext:
Expand Down