Skip to content

Commit

Permalink
internal cp: don't set heartbeat if one cp is in error state (openWB#…
Browse files Browse the repository at this point in the history
…1982)

* internal cp: don't set heartbeat if one cp is in error state

* fix non-duo

* fix 5 min handler
  • Loading branch information
LKuemmel authored Oct 30, 2024
1 parent 0b39104 commit 56492b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def handler5Min(self):
if sub.internal_chargepoint_data["global_data"].configured:
if not general_internal_chargepoint_handler.internal_chargepoint_handler.heartbeat:
log.error("Heartbeat für Internen Ladepunkt nicht zurückgesetzt.")
general_internal_chargepoint_handler.event_stop.set()
general_internal_chargepoint_handler.event_start.set()
else:
general_internal_chargepoint_handler.internal_chargepoint_handler.heartbeat = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,18 @@ def init_gpio(self) -> None:
def loop(self) -> None:
def _loop():
while True:
self.heartbeat = True
if self.event_stop.is_set():
break
log.debug("***Start***")
data = copy.deepcopy(SubData.internal_chargepoint_data)
log.debug(data)
log.setLevel(SubData.system_data["system"].data["debug_level"])
heartbeat_cp0, heartbeat_cp1 = None, None
if self.cp0:
self.cp0.update(data["global_data"], data["cp0"].data, data["rfid_data"])
heartbeat_cp0 = self.cp0.update(data["global_data"], data["cp0"].data, data["rfid_data"])
if self.cp1:
self.cp1.update(data["global_data"], data["cp1"].data, data["rfid_data"])
heartbeat_cp1 = self.cp1.update(data["global_data"], data["cp1"].data, data["rfid_data"])
self.heartbeat = True if heartbeat_cp0 and heartbeat_cp1 else False
time.sleep(1.1)
with SingleComponentUpdateContext(self.fault_state_info_cp0, update_always=False):
# Allgemeine Fehlermeldungen an LP 1
Expand Down Expand Up @@ -250,7 +251,7 @@ def __init__(self,
self.update_state = UpdateState(self.module, hierarchy_id)
self.old_plug_state = False

def update(self, global_data: GlobalHandlerData, data: InternalChargepointData, rfid_data: RfidData) -> None:
def update(self, global_data: GlobalHandlerData, data: InternalChargepointData, rfid_data: RfidData) -> bool:
def __thread_active(thread: Optional[threading.Thread]) -> bool:
if thread:
return thread.is_alive()
Expand All @@ -267,6 +268,8 @@ def __thread_active(thread: Optional[threading.Thread]) -> bool:
if global_data.parent_ip is not None:
self.update_values.update_values(state, heartbeat_expired)
self.update_state.update_state(data, heartbeat_expired)
return True
return False

def _check_heartbeat_expired(self, heartbeat) -> bool:
if heartbeat+80 < timecheck.create_timestamp():
Expand Down

0 comments on commit 56492b0

Please sign in to comment.