Index: leahi_dialin/dd/modules/post_gen_dialysate.py =================================================================== diff -u -r5c1132f5aadff6082afa56588ad1f4a64f828cd9 -r6caa49d072aceb2655d605de5d2eea52ab1a8911 --- leahi_dialin/dd/modules/post_gen_dialysate.py (.../post_gen_dialysate.py) (revision 5c1132f5aadff6082afa56588ad1f4a64f828cd9) +++ leahi_dialin/dd/modules/post_gen_dialysate.py (.../post_gen_dialysate.py) (revision 6caa49d072aceb2655d605de5d2eea52ab1a8911) @@ -17,9 +17,11 @@ # Module imports from logging import Logger import time +from typing import Union # Project imports from leahi_dialin.common.constants import NO_RESET +from leahi_dialin.common.dd_defs import DDPostGenDialysateStates from leahi_dialin.common.generic_defs import DataTypes from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_broadcast_interval_override @@ -50,10 +52,28 @@ function = self._handler_post_gen_dialysate_sync) self.post_gen_state_timestamp = 0 #: The timestamp of the latest message - self.execution_state = 0 #: The execution state + self.execution_state = DDPostGenDialysateStates.NUM_OF_DD_POST_GEN_DIALYSATE_STATES self.handler_execution_times = [] +# ============================================================ Properties ============================================================ + @property + def execution_state(self) -> DDPostGenDialysateStates: + """ + The execution state + """ + return self._execution_state + + @execution_state.setter + def execution_state(self, value: Union[int, DDPostGenDialysateStates]): + if isinstance(value, int): + self._execution_state = DDPostGenDialysateStates(value) + else: + self._execution_state = value + + + +# ============================================================ Handlers ============================================================ @publish(["msg_id_dd_post_gen_dialysate_state_data", "execution_state", "post_gen_state_timestamp"]) def _handler_post_gen_dialysate_sync(self, message, timestamp=0.0): """ @@ -64,14 +84,15 @@ """ start = time.perf_counter() msg_list =[] - msg_list.append(('self.execution_state', DataTypes.U32)) + msg_list.append((type(self).execution_state, DataTypes.U32)) - self.process_into_vars(decoder_list = msg_list, - message = message) + self.process_into_vars(decoder_list = msg_list, message = message) self.post_gen_state_timestamp = timestamp self.handler_execution_times.append((timestamp, message, time.perf_counter() - start)) + +# ============================================================ Overrides and Requests ============================================================ def cmd_post_gen_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the broadcast time interval override for post gen dialysate data.