Index: dialin/dg/__init__.py =================================================================== diff -u -r8c39fe1f9affe360ee6a97c5e6243e58a5c27509 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/__init__.py (.../__init__.py) (revision 8c39fe1f9affe360ee6a97c5e6243e58a5c27509) +++ dialin/dg/__init__.py (.../__init__.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -1 +1 @@ +from ..utils.base import _AbstractSubSystem, _publish Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r5e834984727c1798784d95ae17f686cb8d72fdca -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 5e834984727c1798784d95ae17f686cb8d72fdca) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -25,10 +25,10 @@ DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSystem +from ..utils.base import _AbstractSubSystem, _publish -class DG(_AbstractSystem): +class DG(_AbstractSubSystem): """ Dialysate Generator (DG) Dialin object API. It provides the basic interface to communicate with the DG firmware. @@ -73,6 +73,16 @@ DG_OP_MODE_DISINFECT = 9 DG_OP_MODE_CHEMICAL_DISINFECT = 10 + # DG sub_modes + DG_POST_STATE_START = 0 # Start initialize & POST mode state. + DG_POST_STATE_FPGA = 1 # FPGA POST test state. + DG_POST_STATE_WATCHDOG = 2 # Watchdog POST test state. + DG_POST_STATE_TEMPERATURE_SENSORS = 3 # Temperature Sensors POST state + DG_POST_STATE_HEATERS = 4 # Heaters POST state + DG_POST_STATE_COMPLETED = 5 # POST completed successfully state. + DG_POST_STATE_FAILED = 6 # POST failed state. + NUM_OF_DG_POST_STATES = 7 # Number of initialize & POST mode states. + def __init__(self, can_interface="can0"): """ Initializes the DG object @@ -83,6 +93,8 @@ @param can_interface: string with can bus name, e.g. "can0" """ + super().__init__() + # Create listener self.can_interface = DenaliCanMessenger(can_interface=can_interface) self.can_interface.start() @@ -136,6 +148,7 @@ """ return self.dg_operation_sub_mode + @_publish(["dg_version"]) def _handler_dg_version(self, message): """ Handler for response from DG regarding its version. @@ -162,6 +175,7 @@ print(self.dg_version) return self.dg_version + @_publish(["dg_operation_mode", "dg_operation_sub_mode"]) def _handler_dg_op_mode_sync(self, message): """ Handles published DG operation mode messages. Current DG operation mode Index: dialin/dg/drain_pump.py =================================================================== diff -u -r7b0e7a8562d035de041244e38e1811ddba69694b -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/drain_pump.py (.../drain_pump.py) (revision 7b0e7a8562d035de041244e38e1811ddba69694b) +++ dialin/dg/drain_pump.py (.../drain_pump.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -19,9 +19,10 @@ from .constants import RESET, NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class DGDrainPump: +class DGDrainPump(_AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for drain pump related commands. """ @@ -43,6 +44,8 @@ @param outer_instance: reference to the DG (outer) class. """ + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -69,6 +72,7 @@ """ return self.dac_value + @_publish(["target_drain_pump_speed_RPM", "dac_value"]) def _handler_drain_pump_sync(self, message): """ Handles published drain pump data messages. Drain pump data are captured Index: dialin/dg/hd_proxy.py =================================================================== diff -u -r7b0e7a8562d035de041244e38e1811ddba69694b -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision 7b0e7a8562d035de041244e38e1811ddba69694b) +++ dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -17,8 +17,10 @@ from ..utils.conversions import integer_to_bytearray from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class DGHDProxy: + +class DGHDProxy(_AbstractSubSystem): """ \class DGHDProxy @@ -40,6 +42,7 @@ @param can_interface: Denali CAN Messenger object """ + super().__init__() self.can_interface = can_interface def cmd_switch_reservoirs(self, reservoirID=RESERVOIR1): Index: dialin/dg/pressures.py =================================================================== diff -u -r7b0e7a8562d035de041244e38e1811ddba69694b -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/pressures.py (.../pressures.py) (revision 7b0e7a8562d035de041244e38e1811ddba69694b) +++ dialin/dg/pressures.py (.../pressures.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -19,8 +19,9 @@ from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class DGPressures: +class DGPressures(_AbstractSubSystem): """ DG interface containing pressure related commands. """ @@ -51,6 +52,9 @@ @param can_interface: The DenaliCANMessenger object """ + + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -75,6 +79,12 @@ self.drain_pump_inlet_pressure, self.drain_pump_outlet_pressure] + @_publish([ + "ro_pump_inlet_pressure", + "ro_pump_outlet_pressure", + "drain_pump_inlet_pressure", + "drain_pump_outlet_pressure" + ]) def _handler_pressures_sync(self, message): """ Handles published pressure data messages. Pressure data are captured Index: dialin/dg/reservoirs.py =================================================================== diff -u -r7b0e7a8562d035de041244e38e1811ddba69694b -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/reservoirs.py (.../reservoirs.py) (revision 7b0e7a8562d035de041244e38e1811ddba69694b) +++ dialin/dg/reservoirs.py (.../reservoirs.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -17,9 +17,10 @@ import struct from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class DGReservoirs: +class DGReservoirs(_AbstractSubSystem): """ DG interface containing reservoir related commands. """ @@ -44,6 +45,9 @@ @param can_interface: The DenaliCANMessenger object """ + + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -66,7 +70,6 @@ """ return self.active_reservoir - def get_fill_to_vol(self): """ Gets the fill to volume @@ -82,6 +85,11 @@ """ return self.drain_to_vol_ml + @_publish([ + "active_reservoir", + "fill_to_vol_ml", + "drain_to_vol_ml" + ]) def _handler_reservoirs_sync(self, message): """ Handles published reservoir data messages. Reservoir data are captured Index: dialin/dg/ro_pump.py =================================================================== diff -u -r7b0e7a8562d035de041244e38e1811ddba69694b -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/dg/ro_pump.py (.../ro_pump.py) (revision 7b0e7a8562d035de041244e38e1811ddba69694b) +++ dialin/dg/ro_pump.py (.../ro_pump.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -19,9 +19,10 @@ from .constants import RESET, NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class DGROPump: +class DGROPump(_AbstractSubSystem): """ DGROPump Dialysate Generator (DG) Dialin API sub-class for RO pump related commands. @@ -46,6 +47,9 @@ """ DGROPump constructor """ + + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -79,6 +83,11 @@ """ return self.pwm_duty_cycle_pct + @_publish([ + "target_pressure_psi", + "measured_flow_rate_lpm", + "pwm_duty_cycle_pct" + ]) def _handler_ro_pump_sync(self, message): """ Handles published ro pump data messages. RO pump data are captured Index: dialin/hd/buttons.py =================================================================== diff -u -r02e6bbf85f0699488317daa135d2530bc5b19507 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/buttons.py (.../buttons.py) (revision 02e6bbf85f0699488317daa135d2530bc5b19507) +++ dialin/hd/buttons.py (.../buttons.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -17,9 +17,10 @@ DenaliChannels) from ..utils.conversions import integer_to_bytearray from .constants import RESET, NO_RESET +from ..utils.base import _AbstractSubSystem, _publish -class HDButtons: +class HDButtons(_AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for button related commands. """ @@ -35,6 +36,8 @@ @param can_interface: the denali can interface object """ + super().__init__() + self.can_interface = can_interface def cmd_off_button_override(self, state, reset=NO_RESET): Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -r5e834984727c1798784d95ae17f686cb8d72fdca -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 5e834984727c1798784d95ae17f686cb8d72fdca) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -28,10 +28,10 @@ from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) -from ..utils.base import _AbstractSystem, AbstractObserver +from ..utils.base import _AbstractSubSystem, _publish -class HD(_AbstractSystem): +class HD(_AbstractSubSystem): """ Hemodialysis Device (HD) Dialin object API. It provides the basic interface to communicate with the HD firmware. @@ -107,6 +107,7 @@ """ return self.hd_operation_mode + @_publish(["hd_operation_mode"]) def _handler_hd_op_mode_sync(self, message): """ Handles published HD operation mode messages. Current HD operation mode Index: dialin/hd/pressure_occlusion.py =================================================================== diff -u -rae1e423f7cf68432e1e3daf01b50a162de4563e4 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision ae1e423f7cf68432e1e3daf01b50a162de4563e4) +++ dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -52,7 +52,6 @@ """ HDPressureOcclusion constructor - @return: HDPressureOcclusion object. """ super().__init__() self.can_interface = can_interface Index: dialin/hd/rtc.py =================================================================== diff -u -r044087c3a2f8b762452ebd58eaeb27db968b31a2 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/rtc.py (.../rtc.py) (revision 044087c3a2f8b762452ebd58eaeb27db968b31a2) +++ dialin/hd/rtc.py (.../rtc.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -18,10 +18,12 @@ from ..protocols.CAN import (DenaliMessage, DenaliChannels) from ..utils.conversions import integer_to_bytearray +from ..utils.base import _AbstractSubSystem, _publish -class HDRTC: + +class HDRTC(_AbstractSubSystem): """ - Hemodialysis Device (HD) Dialin API sub-class for rtc commands. + Hemodialysis Device (HD) Dialin API class for rtc commands. """ MSG_ID_SET_RTC_DATE_TIME = 0x801D @@ -35,6 +37,9 @@ @param can_interface: Denali Can Messenger object """ + + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -52,6 +57,7 @@ """ return self.rtc_epoch + @_publish(["rtc_epoch"]) def _handler_rtc_epoch(self, message): """ Publishes the rtc time in epoch Index: dialin/hd/treatment.py =================================================================== diff -u -r044087c3a2f8b762452ebd58eaeb27db968b31a2 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/treatment.py (.../treatment.py) (revision 044087c3a2f8b762452ebd58eaeb27db968b31a2) +++ dialin/hd/treatment.py (.../treatment.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -17,12 +17,13 @@ import struct from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import _AbstractSubSystem, _publish -class HDTreatment: + +class HDTreatment(_AbstractSubSystem): """ - \class HD_Treatment - \brief Hemodialysis Device (HD) Dialin API sub-class for treatment related commands. + Hemodialysis Device (HD) Dialin API class for treatment related commands. """ @@ -48,8 +49,11 @@ def __init__(self, can_interface=None): """ - HD_Treatment constructor + HDTreatment constructor """ + + super().__init__() + self.can_interface = can_interface if self.can_interface is not None: @@ -116,6 +120,11 @@ """ return self.saline_bolus_in_progress + @_publish([ + "treatment_time_prescribed", + "treatment_time_elapsed", + "treatment_time_remaining" + ]) def _handler_treatment_time_sync(self, message): """ Handles published treatment time data messages. treatment time data are captured @@ -136,6 +145,11 @@ self.treatment_time_elapsed = ela[0] self.treatment_time_remaining = rem[0] + @_publish([ + "treatment_state", + "treatment_uf_state", + "saline_bolus_in_progress" + ]) def _handler_treatment_state_sync(self, message): """ Handles published treatment state data messages. treatment state data are captured Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r044087c3a2f8b762452ebd58eaeb27db968b31a2 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 044087c3a2f8b762452ebd58eaeb27db968b31a2) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -18,9 +18,10 @@ DenaliChannels) from ..utils.conversions import integer_to_bytearray, float_to_bytearray import struct +from ..utils.base import _AbstractSubSystem, _publish -class HDUIProxy: +class HDUIProxy(_AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for ui commands. """ @@ -112,6 +113,9 @@ @param can_interface: the denali can interface object """ + + super().__init__() + self.can_interface = can_interface # register function to handle HD response to UF change requests @@ -333,6 +337,9 @@ """ return self.target_dialysate_flow_rate + @_publish([ + "hd_version" + ]) def _handler_hd_version(self, message): """ Handler for response from HD regarding its version. @@ -359,6 +366,14 @@ print(self.hd_version) return self.hd_version + @_publish([ + "min_treatment_duration_min", + "max_treatment_duration_min", + "min_uf_volume_ml", + "max_uf_volume_ml", + "min_dialysate_flow_rate_ml_min", + "max_dialysate_flow_rate_ml_min" + ]) def _handler_treatment_param_ranges(self, message): """ Handler for response from HD regarding valid treatment parameter ranges. @@ -393,6 +408,12 @@ self.min_dialysate_flow_rate_ml_min = mindialrt[0] self.max_dialysate_flow_rate_ml_min = maxdialrt[0] + @_publish([ + "duration_change_succeeded", + "duration_change_reject_reason", + "duration_change_time_min", + "duration_change_uf_vol_ml" + ]) def _handler_treatment_duration_change_response(self, message): """ Handler for response from HD regarding treatment duration change request. @@ -419,6 +440,12 @@ self.duration_change_time_min = tim[0] self.duration_change_uf_vol_ml = vol[0] + @_publish([ + "blood_and_dialysate_flow_rate_change_succeeded", + "blood_and_dialysate_flow_rate_change_reject_reason", + "target_blood_flow_rate", + "target_dialysate_flow_rate" + ]) def _handler_blood_and_dialysate_change_response(self, message): """ Handler for response from HD regarding blood & dialysate flow rate change request. @@ -449,6 +476,15 @@ self.target_blood_flow_rate = bld[0] self.target_dialysate_flow_rate = dil[0] + @_publish([ + "uf_change_succeeded", + "uf_change_reject_reason", + "uf_change_volume_ml", + "uf_change_time_min", + "uf_change_time_diff", + "uf_change_rate_ml_min", + "uf_change_rate_diff" + ]) def _handler_uf_change_response(self, message): """ Handler for response from HD regarding UF change request. Index: dialin/hd/watchdog.py =================================================================== diff -u -r044087c3a2f8b762452ebd58eaeb27db968b31a2 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/hd/watchdog.py (.../watchdog.py) (revision 044087c3a2f8b762452ebd58eaeb27db968b31a2) +++ dialin/hd/watchdog.py (.../watchdog.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -18,9 +18,10 @@ DenaliChannels) from ..utils.conversions import integer_to_bytearray from .constants import RESET, NO_RESET +from ..utils.base import _AbstractSubSystem, _publish -class HDWatchdog: +class HDWatchdog(_AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for watchdog related commands. """ @@ -34,6 +35,8 @@ @param can_interface: the denali can interface object """ + super().__init__() + self.can_interface = can_interface def cmd_watchdog_task_check_in_override(self, state, task, reset=NO_RESET): Index: dialin/utils/base.py =================================================================== diff -u -rb612ddd4cabc1078e2bc2e6d28385210df80a874 -rca7f6eff65d988c19ccce8cde5efd1ef537e2095 --- dialin/utils/base.py (.../base.py) (revision b612ddd4cabc1078e2bc2e6d28385210df80a874) +++ dialin/utils/base.py (.../base.py) (revision ca7f6eff65d988c19ccce8cde5efd1ef537e2095) @@ -79,18 +79,3 @@ return _decorator -class _AbstractSystem(ABC): - """ - Parent class for all system classes - """ - - @abstractmethod - def __init__(self): - """ - Initialization function for the system - - """ - pass - - -