Skip to content

Commit

Permalink
clean up sync messaging and set entering flag for state
Browse files Browse the repository at this point in the history
  • Loading branch information
David Conner committed Aug 3, 2024
1 parent 2d37d2e commit 7b25d0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions flexbe_mirror/flexbe_mirror/flexbe_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,23 +511,23 @@ def _onboard_heartbeat_callback(self, msg):
f' Check UI and consider manual re-sync!\n'
' (mismatch may be temporarily understandable for rapidly changing outcomes)'
f' {self._sync_heartbeat_mismatch_counter}')
Logger.localinfo(f'IDs {msg.behavior_id} {self._active_id} : \n'
f' Onboard IDs: {msg.current_state_checksums}\n '
f'Mirror IDs {mirror_status.current_state_checksums}')
Logger.localinfo(f'IDs {msg.behavior_id} {self._active_id} {self._sync_heartbeat_mismatch_counter}: \n'
f' Onboard IDs: {msg.current_state_checksums}\n'
f' Mirror IDs: {mirror_status.current_state_checksums}')

for state_hash in msg.current_state_checksums:
try:
ob_state_id, ob_out = StateMap.unhash(state_hash)
ob_state = self._state_map[ob_state_id]
Logger.localinfo(f" onboard {ob_state_id} : '{ob_state.name}' "
f'out={ob_out} - {ob_state.path}')
Logger.localinfo(f" onboard {ob_state_id} : '{ob_state.name.replace('_mirror', '')}'"
f" out={ob_out} - {ob_state.path.replace('_mirror', '')}")
except Exception as exc: # pylint: disable=W0703
Logger.localinfo(f' error for onboard state hash {state_hash} - {type(exc)} - {exc}')
for state_hash in mirror_status.current_state_checksums:
try:
mr_state_id, mr_out = StateMap.unhash(state_hash)
mr_state = self._state_map[mr_state_id]
Logger.localinfo(f" mirror {mr_state_id} : '{mr_state.name.replace('_mirror', '')}' "
Logger.localinfo(f" mirror {mr_state_id} : '{mr_state.name.replace('_mirror', '')}'"
f" out={mr_out} - {mr_state.path.replace('_mirror', '')}")
except Exception as exc: # pylint: disable=W0703
Logger.localinfo(f' error for mirror state hash {state_hash} - {type(exc)} - {exc}')
Expand Down
1 change: 1 addition & 0 deletions flexbe_mirror/flexbe_mirror/mirror_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def on_enter_mirror(self, userdata):
"""Enter the mirror state."""
self._entering = False
self._last_outcome = None
self._last_execution = None
MirrorState.publish_update(self._target_path)

def on_exit_mirror(self, userdata, desired_outcome):
Expand Down
2 changes: 2 additions & 0 deletions flexbe_mirror/flexbe_mirror/mirror_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ def on_enter_mirror(self, userdata):
self._last_outcome = None
self.assert_consistent_transitions()
self._current_state = self.initial_state
self._last_outcome = None
self._current_state._entering = True # force state to handle enter on first execute
self._userdata = None # not used in mirror
MirrorState.publish_update(self._target_path)

Expand Down

0 comments on commit 7b25d0f

Please sign in to comment.