Skip to content

Commit

Permalink
imp/state info (#243)
Browse files Browse the repository at this point in the history
* set_present_protocol_state parameter is updated
  • Loading branch information
ikaratass authored Jun 14, 2023
1 parent 8141abe commit f7df0d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion iso15118/secc/controller/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
DynamicDCChargeLoopRes,
ScheduledDCChargeLoopResParams,
)
from iso15118.shared.states import State


@dataclass
Expand Down Expand Up @@ -480,7 +481,7 @@ async def get_evse_status(self) -> Optional[EVSEStatus]:
raise NotImplementedError

@abstractmethod
async def set_present_protocol_state(self, state_name: str):
async def set_present_protocol_state(self, state: State):
"""
This method sets the present state of the charging protocol.
Expand Down
5 changes: 3 additions & 2 deletions iso15118/secc/controller/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
load_priv_key,
)
from iso15118.shared.settings import V20_EVSE_SERVICES_CONFIG
from iso15118.shared.states import State

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -604,8 +605,8 @@ async def get_evse_status(self) -> Optional[EVSEStatus]:
# )
return None

async def set_present_protocol_state(self, state_name: str):
pass
async def set_present_protocol_state(self, state: State):
logger.info(f"iso15118 state: {str(state)}")

async def send_charging_power_limits(
self,
Expand Down
12 changes: 6 additions & 6 deletions iso15118/shared/comm_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ async def start(self, timeout: float):
def save_session_info(self):
raise NotImplementedError

async def _update_state_info(self, state: State):
if hasattr(self.comm_session, "evse_controller"):
await self.comm_session.evse_controller.set_present_protocol_state(state)

async def stop(self, reason: str):
"""
Closes the TCP connection after 5 seconds and terminates or pauses the
Expand Down Expand Up @@ -482,22 +486,18 @@ async def rcv_loop(self, timeout: float):
# This will create the values needed for the next state, such as
# next_state, next_v2gtp_message, next_message_payload_type etc.
await self.process_message(message)
if hasattr(self.comm_session, "evse_controller"):
await self.comm_session.evse_controller.set_present_protocol_state(
str(self.current_state)
)
if self.current_state.next_v2gtp_msg:
# next_v2gtp_msg would not be set only if the next state is either
# Terminate or Pause on the EVCC side
await self.send(self.current_state.next_v2gtp_msg)

await self._update_state_info(self.current_state)
if self.current_state.next_state in (Terminate, Pause):
await self.stop(reason=self.comm_session.stop_reason.reason)
self.comm_session.session_handler_queue.put_nowait(
self.comm_session.stop_reason
)
await self._update_state_info(self.current_state.next_state)
return

timeout = self.current_state.next_msg_timeout
self.go_to_next_state()
except (
Expand Down

0 comments on commit f7df0d2

Please sign in to comment.