Index: dialin/dg/accelerometer.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/accelerometer.py (.../accelerometer.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/accelerometer.py (.../accelerometer.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -18,12 +18,12 @@ DenaliChannels) from ..utils.conversions import integer_to_bytearray, float_to_bytearray from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..common.msg_defs import MsgIds, MsgFieldPositions from ..utils.checks import check_broadcast_interval_override_ms from logging import Logger -class DGAccelerometer(_AbstractSubSystem): +class DGAccelerometer(AbstractSubSystem): """ Hemodialysis Delivery (DG) Dialin API sub-class for accelerometer related commands. """ @@ -87,7 +87,7 @@ """ return self.tilts - @_publish([ + @publish([ "vector", "vector_max", "tilts" Index: dialin/dg/alarms.py =================================================================== diff -u -ra505f80795643e531cb0b0120a38a7765cbf7b9c -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/alarms.py (.../alarms.py) (revision a505f80795643e531cb0b0120a38a7765cbf7b9c) +++ dialin/dg/alarms.py (.../alarms.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -16,7 +16,7 @@ from ..protocols.CAN import (DenaliMessage, DenaliChannels) from ..utils.conversions import integer_to_bytearray -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from .constants import RESET, NO_RESET from collections import OrderedDict import struct @@ -25,7 +25,7 @@ from ..common.msg_defs import MsgIds -class DGAlarms(_AbstractSubSystem): +class DGAlarms(AbstractSubSystem): """ DG interface containing alarm related commands. """ @@ -69,7 +69,7 @@ """ return self.alarm_states[alarm_id] - @_publish(["alarm_states"]) + @publish(["alarm_states"]) def _handler_alarm_activate(self, message): """ Handles published DG alarm activation messages. @@ -81,7 +81,7 @@ alarm_id = struct.unpack(' None: """ Handles published fluid leak state messages. Fluid leak state is captured Index: dialin/dg/flush.py =================================================================== diff -u -r7d528c2109af39ed65e9dd3d61162de89ad22d96 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/flush.py (.../flush.py) (revision 7d528c2109af39ed65e9dd3d61162de89ad22d96) +++ dialin/dg/flush.py (.../flush.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -2,7 +2,7 @@ import struct from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -26,7 +26,7 @@ DG_FLUSH_STATE_COMPLETE = 13 -class FlushMode(_AbstractSubSystem): +class FlushMode(AbstractSubSystem): """ \class Flush Mode @@ -49,7 +49,7 @@ msg_id = MsgIds.MSG_ID_DG_FLUSH_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_flush_sync) - @_publish(["flush_state", "overall_elapsed_time", "state_elapsed_time", "flush_drain_line_volume"]) + @publish(["flush_state", "overall_elapsed_time", "state_elapsed_time", "flush_drain_line_volume"]) def _handler_flush_sync(self, message:dict) -> None: """ Handles published flush message Index: dialin/dg/hd_proxy.py =================================================================== diff -u -r89f9210ef5bf37a6812c4dc06aaa636dd47b9d72 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision 89f9210ef5bf37a6812c4dc06aaa636dd47b9d72) +++ dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -17,11 +17,11 @@ from ..common.msg_defs import MsgIds from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from logging import Logger -class DGHDProxy(_AbstractSubSystem): +class DGHDProxy(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for HD proxy commands. """ Index: dialin/dg/heat_disinfect.py =================================================================== diff -u -r0c7bff7d1c3407a564b0a2c8237f4aff4cfa9ae3 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision 0c7bff7d1c3407a564b0a2c8237f4aff4cfa9ae3) +++ dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -2,7 +2,7 @@ import struct from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliMessage, DenaliChannels -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -16,7 +16,7 @@ CANCELLATION_MODE_COLD = 3 -class HeatDisinfect(_AbstractSubSystem): +class HeatDisinfect(AbstractSubSystem): """ \class HeatDisinfect @@ -51,7 +51,7 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_heat_disinfect_to_ui_sync) - @_publish(["heat_disinfect_target_time", "heat_disinfect_count_down_time"]) + @publish(["heat_disinfect_target_time", "heat_disinfect_count_down_time"]) def _handler_heat_disinfect_to_ui_sync(self, message): """ Handles published heat disinfect message @@ -67,7 +67,7 @@ self.heat_disinfect_target_time = int(disinfect_target_time / 1000) self.heat_disinfect_count_down_time = disinfect_count_down_time - @_publish(["heat_disinfect_state", "overall_elapsed_time", "state_elapsed_time", "cancellation_mode", "r1_level", + @publish(["heat_disinfect_state", "overall_elapsed_time", "state_elapsed_time", "cancellation_mode", "r1_level", "r2_level", "heat_disinfect_ui_state"]) def _handler_heat_disinfect_sync(self, message): """ Index: dialin/dg/heaters.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/heaters.py (.../heaters.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/heaters.py (.../heaters.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -21,7 +21,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -33,7 +33,7 @@ START = 1 -class Heaters(_AbstractSubSystem): +class Heaters(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for heaters related commands. @@ -101,7 +101,7 @@ """ return self.trimmer_heater_target_temperature - @_publish(["main_primary_heater_duty_cycle", "small_primary_heater_duty_cycle", "trimmer_heater_duty_cycle", + @publish(["main_primary_heater_duty_cycle", "small_primary_heater_duty_cycle", "trimmer_heater_duty_cycle", "primary_heaters_target_temperature", "trimmer_heater_target_temperature"]) def _handler_heaters_sync(self, message): """ Index: dialin/dg/load_cells.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/load_cells.py (.../load_cells.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/load_cells.py (.../load_cells.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -20,11 +20,11 @@ from .constants import RESET,NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from logging import Logger -class DGLoadCells(_AbstractSubSystem): +class DGLoadCells(AbstractSubSystem): """ DGLoadCells @@ -64,7 +64,7 @@ """ return [self.load_cell_A1, self.load_cell_A2, self.load_cell_B1, self.load_cell_B2] - @_publish(["load_cell_A1", "load_cell_A2", "load_cell_B1", "load_cell_B2"]) + @publish(["load_cell_A1", "load_cell_A2", "load_cell_B1", "load_cell_B2"]) def _handler_load_cells_sync(self, message): """ Handles published load cell data messages. Load cell data are captured Index: dialin/dg/pressures.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/pressures.py (.../pressures.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/pressures.py (.../pressures.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -20,11 +20,11 @@ from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from logging import Logger -class DGPressures(_AbstractSubSystem): +class DGPressures(AbstractSubSystem): """ DG interface containing pressure related commands. """ @@ -67,7 +67,7 @@ self.drain_pump_inlet_pressure, self.drain_pump_outlet_pressure] - @_publish([ + @publish([ "ro_pump_inlet_pressure", "ro_pump_outlet_pressure", "drain_pump_inlet_pressure", Index: dialin/dg/reservoirs.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/reservoirs.py (.../reservoirs.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/reservoirs.py (.../reservoirs.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -17,12 +17,12 @@ from logging import Logger from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..common.msg_defs import MsgIds, MsgFieldPositions from ..utils.conversions import integer_to_bytearray -class DGReservoirs(_AbstractSubSystem): +class DGReservoirs(AbstractSubSystem): """ DG interface containing reservoir related commands. """ @@ -98,7 +98,7 @@ return True - @_publish([ + @publish([ "active_reservoir", "fill_to_vol_ml", "drain_to_vol_ml" Index: dialin/dg/ro_pump.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/ro_pump.py (.../ro_pump.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/dg/ro_pump.py (.../ro_pump.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -19,7 +19,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import RESET, NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -33,7 +33,7 @@ RO_PUMP_OPEN_LOOP_STATE = 4 -class DGROPump(_AbstractSubSystem): +class DGROPump(AbstractSubSystem): """ DGROPump Dialysate Generator (DG) Dialin API sub-class for RO pump related commands. @@ -92,7 +92,7 @@ """ return self.ro_pump_state - @_publish(["target_pressure_psi", "measured_flow_rate_lpm", "pwm_duty_cycle_pct", "ro_pump_state"]) + @publish(["target_pressure_psi", "measured_flow_rate_lpm", "pwm_duty_cycle_pct", "ro_pump_state"]) def _handler_ro_pump_sync(self, message): """ Handles published ro pump data messages. RO pump data are captured Index: dialin/dg/rtc.py =================================================================== diff -u -r179cd697f39a80fa34e7293a5f8a8700898ba4ce -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/rtc.py (.../rtc.py) (revision 179cd697f39a80fa34e7293a5f8a8700898ba4ce) +++ dialin/dg/rtc.py (.../rtc.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -16,12 +16,12 @@ import ctypes from ..protocols.CAN import (DenaliMessage, DenaliChannels) from ..utils.conversions import integer_to_bytearray -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..common.msg_defs import MsgIds from logging import Logger -class DGRTC(_AbstractSubSystem): +class DGRTC(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for rtc commands. Index: dialin/dg/samplewater.py =================================================================== diff -u -rc1ea1df3705c31440c25aba6cb39ea94974a2cb7 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/samplewater.py (.../samplewater.py) (revision c1ea1df3705c31440c25aba6cb39ea94974a2cb7) +++ dialin/dg/samplewater.py (.../samplewater.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -15,13 +15,13 @@ ############################################################################ import struct from ..protocols.CAN import DenaliChannels -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import NO_RESET from logging import Logger -class DGSampleWater(_AbstractSubSystem): +class DGSampleWater(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for sample water related commands. @@ -61,7 +61,7 @@ """ return self.filter_flush_time_countdown - @_publish([ + @publish([ "filter_flush_timeout", "filter_flush_time_countdown" ]) Index: dialin/dg/scheduled_runs_record.py =================================================================== diff -u -r47eb368c929e01fbff7d7749a822ee0efb467ea5 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/scheduled_runs_record.py (.../scheduled_runs_record.py) (revision 47eb368c929e01fbff7d7749a822ee0efb467ea5) +++ dialin/dg/scheduled_runs_record.py (.../scheduled_runs_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -4,12 +4,12 @@ from collections import OrderedDict from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..utils.nv_ops_utils import NVOpsUtils from logging import Logger -class DGScheduledRunsNVRecord(_AbstractSubSystem): +class DGScheduledRunsNVRecord(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for scheduled runs commands. @@ -158,7 +158,7 @@ self._update_dg_scheduled_record_from_fw() self._handler_received_complete_dg_scheduled_runs_record() - @_publish(["dg_scheduled_runs_record"]) + @publish(["dg_scheduled_runs_record"]) def _handler_received_complete_dg_scheduled_runs_record(self): """ Publishes the received scheduled runs record Index: dialin/dg/service_record.py =================================================================== diff -u -r47eb368c929e01fbff7d7749a822ee0efb467ea5 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/service_record.py (.../service_record.py) (revision 47eb368c929e01fbff7d7749a822ee0efb467ea5) +++ dialin/dg/service_record.py (.../service_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -3,7 +3,7 @@ from collections import OrderedDict from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, DialinEnum, _publish +from ..utils.base import AbstractSubSystem, DialinEnum, publish from ..utils.nv_ops_utils import NVOpsUtils from logging import Logger from enum import unique @@ -15,7 +15,7 @@ SERVICE_LOCATION_FIELD = 1 -class DGServiceNVRecord(_AbstractSubSystem): +class DGServiceNVRecord(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for service record commands. @@ -139,7 +139,7 @@ self._utilities.process_received_record_from_fw(self.dg_service_record, self._raw_service_record) self._handler_received_complete_dg_service_record() - @_publish(["dg_service_record"]) + @publish(["dg_service_record"]) def _handler_received_complete_dg_service_record(self): """ Publishes the received service record Index: dialin/dg/switches.py =================================================================== diff -u -rc4776c1885f259b231532ef5ba7e904178cd0005 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/switches.py (.../switches.py) (revision c4776c1885f259b231532ef5ba7e904178cd0005) +++ dialin/dg/switches.py (.../switches.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -4,7 +4,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import RESET, NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.checks import check_broadcast_interval_override_ms from logging import Logger from enum import unique @@ -23,7 +23,7 @@ FLUID_DOOR = 2 -class DGSwitches(_AbstractSubSystem): +class DGSwitches(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for switches related commands. """ @@ -55,7 +55,7 @@ """ return self.dg_switches_status - @_publish(["dg_switches_status"]) + @publish(["dg_switches_status"]) def _handler_switches_sync(self, message): """ Handles published drain pump data messages. Switches data are captured Index: dialin/dg/system_record.py =================================================================== diff -u -r47eb368c929e01fbff7d7749a822ee0efb467ea5 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/system_record.py (.../system_record.py) (revision 47eb368c929e01fbff7d7749a822ee0efb467ea5) +++ dialin/dg/system_record.py (.../system_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -4,7 +4,7 @@ from collections import OrderedDict from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, DialinEnum, _publish +from ..utils.base import AbstractSubSystem, DialinEnum, publish from ..utils.nv_ops_utils import NVOpsUtils from logging import Logger from enum import unique @@ -15,7 +15,7 @@ MFG_LOCATION_FACTORY = 0 -class DGSystemNVRecord(_AbstractSubSystem): +class DGSystemNVRecord(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for system record commands. @@ -142,7 +142,7 @@ self._utilities.process_received_record_from_fw(self.dg_system_record, self._raw_system_record) self._handler_received_complete_dg_system_record() - @_publish(["dg_system_record"]) + @publish(["dg_system_record"]) def _handler_received_complete_dg_system_record(self): """ Publishes the received system record Index: dialin/dg/temperature_sensors.py =================================================================== diff -u -rd4cf7e98bfe73fde95043613fa894b64b57d11a8 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/temperature_sensors.py (.../temperature_sensors.py) (revision d4cf7e98bfe73fde95043613fa894b64b57d11a8) +++ dialin/dg/temperature_sensors.py (.../temperature_sensors.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -20,7 +20,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -47,7 +47,7 @@ INTERNAL_COND_TEMP_SENSOR = 17 -class TemperatureSensors(_AbstractSubSystem): +class TemperatureSensors(AbstractSubSystem): def __init__(self, can_interface, logger: Logger): @@ -97,7 +97,7 @@ """ return self.temperature_sensors[sensor] - @_publish(["temperature_sensors", "primary_raw_thermo_couple", "primary_raw_cold_junc", + @publish(["temperature_sensors", "primary_raw_thermo_couple", "primary_raw_cold_junc", "trimmer_raw_thermo_couple", "trimmer_raw_cold_junc", "conductivity_1_raw", "conductivity_2_raw"]) def _handler_temperature_sensors_sync(self, message): """ Index: dialin/dg/thermistors.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/thermistors.py (.../thermistors.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/dg/thermistors.py (.../thermistors.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -2,7 +2,7 @@ import struct from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.conversions import integer_to_bytearray, float_to_bytearray from ..utils.checks import check_broadcast_interval_override_ms from .constants import RESET, NO_RESET @@ -17,7 +17,7 @@ THERMISTOR_POWER_SUPPLY_2 = 2 -class Thermistors(_AbstractSubSystem): +class Thermistors(AbstractSubSystem): """ Dialysate Generation (DG) interface for thermistors and board temperature sensors related commands. """ @@ -52,7 +52,7 @@ """ return self.thermistors[thermistor] - @_publish(['thermistors']) + @publish(['thermistors']) def _handler_thermistors_sync(self, message): """ Handles published thermistors message. Index: dialin/dg/uv_reactors.py =================================================================== diff -u -r45295f4f2cbe058fea83711ae16b2a94a53f4ffb -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/uv_reactors.py (.../uv_reactors.py) (revision 45295f4f2cbe058fea83711ae16b2a94a53f4ffb) +++ dialin/dg/uv_reactors.py (.../uv_reactors.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -5,7 +5,7 @@ from .constants import NO_RESET, RESET from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -32,7 +32,7 @@ UV_REACTOR_OFF = 2 -class UVReactors(_AbstractSubSystem): +class UVReactors(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for UV reactors related commands. @@ -92,7 +92,7 @@ """ return self.outlet_uv_reactor_state - @_publish(['inlet_uv_reactor_health', 'outlet_uv_reactor_health', 'inlet_uv_reactor_state', + @publish(['inlet_uv_reactor_health', 'outlet_uv_reactor_health', 'inlet_uv_reactor_state', 'outlet_uv_reactor_state']) def _handler_uv_reactors_sync(self, message:dict) -> None: """ @@ -251,4 +251,4 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug(operation + "outlet UV reactor timeout!!") - return False \ No newline at end of file + return False Index: dialin/dg/valves.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/valves.py (.../valves.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/dg/valves.py (.../valves.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -20,7 +20,7 @@ from ..common.msg_defs import MsgIds from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from logging import Logger from enum import unique @@ -71,7 +71,7 @@ VALVE_STATE_R1_C_TO_NC = 1 -class DGValves(_AbstractSubSystem): +class DGValves(AbstractSubSystem): """ Dialysate Generation (DG) interface for valve related commands. """ @@ -228,7 +228,7 @@ else: return DEENERGIZED - @_publish([ + @publish([ "valve_states_all", "valve_state_VRF", "valve_state_VRI", Index: dialin/dg/voltages.py =================================================================== diff -u -ra2d44432a913537ca0627cd7dde7dcb1154f2156 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/dg/voltages.py (.../voltages.py) (revision a2d44432a913537ca0627cd7dde7dcb1154f2156) +++ dialin/dg/voltages.py (.../voltages.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -21,7 +21,7 @@ DenaliChannels) from ..utils.conversions import integer_to_bytearray, float_to_bytearray from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..common.msg_defs import MsgIds, MsgFieldPositions from logging import Logger @@ -47,7 +47,7 @@ NUM_OF_MONITORED_LINES = 15 # Number of monitored voltages -class DGVoltages(_AbstractSubSystem): +class DGVoltages(AbstractSubSystem): """ Hemodialysis Delivery (DG) Dialin API sub-class for voltage monitor related commands and data. """ @@ -76,7 +76,7 @@ """ return self.monitored_voltages - @_publish([ + @publish([ "monitored_voltages" ]) def _handler_monitored_voltages_sync(self, message): Index: dialin/hd/__init__.py =================================================================== diff -u -rb543d90a50cbef509d10f4c1412d87bf6eee2e4e -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/__init__.py (.../__init__.py) (revision b543d90a50cbef509d10f4c1412d87bf6eee2e4e) +++ dialin/hd/__init__.py (.../__init__.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -1,10 +1,10 @@ -from .hemodialysis_device import HD from .alarms import HDAlarms from .blood_flow import HDBloodFlow from .buttons import HDButtons from .constants import RESET, NO_RESET, BUTTON_PRESSED, BUTTON_RELEASED from .dialysate_inlet_flow import HDDialysateInletFlow from .dialysate_outlet_flow import HDDialysateOutletFlow +from .hemodialysis_device import HD from .pressure_occlusion import HDPressureOcclusion from .rtc import HDRTC from .treatment import HDTreatment Index: dialin/hd/accelerometer.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/accelerometer.py (.../accelerometer.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/hd/accelerometer.py (.../accelerometer.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,16 +14,17 @@ # ############################################################################ import struct +from logging import Logger + +from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import AbstractSubSystem, publish from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms -from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish -from ..common.msg_defs import MsgIds, MsgFieldPositions -from logging import Logger -class HDAccelerometer(_AbstractSubSystem): + +class HDAccelerometer(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for accelerometer related commands. """ @@ -87,7 +88,7 @@ """ return self.tilts - @_publish([ + @publish([ "vector", "vector_max", "tilts" @@ -107,25 +108,25 @@ message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) z = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) - self.vector = self.AccelerometerVector( x[0], y[0], z[0] ) + self.vector = self.AccelerometerVector(x[0], y[0], z[0]) x = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) y = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5])) z = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) - self.vector_max = self.AccelerometerVector( x[0], y[0], z[0] ) + self.vector_max = self.AccelerometerVector(x[0], y[0], z[0]) x = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) y = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) z = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9])) - self.tilts = self.AccelerometerVector( x[0], y[0], z[0] ) + self.tilts = self.AccelerometerVector(x[0], y[0], z[0]) - def cmd_accel_vector_override(self, axis: int, mag: float, reset: int=NO_RESET) -> int: + def cmd_accel_vector_override(self, axis: int, mag: float, reset: int = NO_RESET) -> int: """ Constructs and sends the accelerometer vector override command Constraints: @@ -158,14 +159,14 @@ else: str_res = str(mag) + " g. " self.logger.debug("Accelerometer axis " + str(axis) + " overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_accel_max_vector_override(self, axis: int, mag: float, reset: int=NO_RESET) -> int: + def cmd_accel_max_vector_override(self, axis: int, mag: float, reset: int = NO_RESET) -> int: """ Constructs and sends the accelerometer maximum vector override command Constraints: @@ -198,7 +199,7 @@ else: str_res = str(mag) + " g. " self.logger.debug("Accelerometer max. axis " + str(axis) + " overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -240,9 +241,9 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Accelerometer broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") - return False \ No newline at end of file + return False Index: dialin/hd/air_bubbles.py =================================================================== diff -u -r6f5b393244002b52706ab6c59e11cde30f702f35 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision 6f5b393244002b52706ab6c59e11cde30f702f35) +++ dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,15 +14,16 @@ # ############################################################################ import struct -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..common.msg_defs import MsgIds, MsgFieldPositions -from .constants import RESET, NO_RESET -from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish from logging import Logger +from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -class HDAirBubbles(_AbstractSubSystem): + +class HDAirBubbles(AbstractSubSystem): """ HDAirBubbles @@ -84,7 +85,7 @@ return self.air_bubbles_state[index] - @_publish("air_bubbles_data") + @publish("air_bubbles_data") def _handler_air_bubbles_data_sync(self, message): """ Handles published air bubbles data messages. Air bubble status and state are captured Index: dialin/hd/air_trap.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/air_trap.py (.../air_trap.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/hd/air_trap.py (.../air_trap.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,17 +14,17 @@ # ############################################################################ import struct -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms -from .constants import RESET,NO_RESET -from ..common.msg_defs import MsgIds, MsgFieldPositions -from ..protocols.CAN import (DenaliMessage, - DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish from logging import Logger +from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -class HDAirTrap(_AbstractSubSystem): + +class HDAirTrap(AbstractSubSystem): """ HDAirTrap @@ -81,7 +81,7 @@ """ return self.upper_level - @_publish(["lower_level", "upper_level"]) + @publish(["lower_level", "upper_level"]) def _handler_air_trap_sync(self, message): """ Handles published air trap data messages. Air trap data are captured @@ -173,7 +173,7 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Air trap data broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/alarms.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/alarms.py (.../alarms.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/hd/alarms.py (.../alarms.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -18,14 +18,13 @@ from .constants import RESET, NO_RESET from ..common.msg_defs import MsgIds, MsgFieldPositions -from ..protocols.CAN import (DenaliMessage, - DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish -from ..utils.conversions import integer_to_bytearray, float_to_bytearray +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray -class HDAlarms(_AbstractSubSystem): +class HDAlarms(AbstractSubSystem): """ HD interface containing alarm related commands. """ @@ -308,7 +307,7 @@ """ return (self.alarms_flags & 16384) > 0 - @_publish(["alarms_state", "alarm_top", "alarms_silence_expires_in", "alarms_escalates_in", "alarms_flags"]) + @publish(["alarms_state", "alarm_top", "alarms_silence_expires_in", "alarms_escalates_in", "alarms_flags"]) def _handler_alarms_status_sync(self, message): """ Handles published alarms status messages. alarms status data are captured @@ -339,7 +338,7 @@ for x in range(500): self.alarm_states[x] = False - @_publish(["alarm_states"]) + @publish(["alarm_states"]) def _handler_alarm_activate(self, message): """ Handles published HD alarm activation messages. @@ -353,7 +352,7 @@ self.alarm_states[alarm_id[0]] = True self.alarm_conditions[alarm_id[0]] = True - @_publish(["alarm_states"]) + @publish(["alarm_states"]) def _handler_alarm_clear(self, message): """ Handles published HD alarm clear messages. @@ -366,7 +365,7 @@ self.alarm_states[alarm_id[0]] = False self.alarm_conditions[alarm_id[0]] = False - @_publish(["alarm_conditions"]) + @publish(["alarm_conditions"]) def _handler_alarm_condition_clear(self, message): """ Handles published HD alarm clear alarm condition messages. @@ -378,8 +377,7 @@ alarm_id = struct.unpack(' int: + def cmd_blood_flow_set_point_override(self, flow: int, mode: int = PUMP_CONTROL_MODE_CLOSED_LOOP, + reset: int = NO_RESET) -> int: """ Constructs and sends the blood flow set point override command Constraints: @@ -239,7 +238,7 @@ else: str_res = str(flow) self.logger.debug("Blood flow (measured)) overridden to " + str_res + " mL/min: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -279,7 +278,7 @@ else: str_res = str(speed) self.logger.debug("Blood pump MC speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -318,7 +317,7 @@ else: str_res = str(curr) self.logger.debug("Blood pump MC current (measured) overridden to " + str_res + " mA: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -358,7 +357,7 @@ else: str_res = str(speed) self.logger.debug("Blood pump speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -398,14 +397,14 @@ else: str_res = str(speed) self.logger.debug("Blood pump rotor speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_blood_flow_signal_strength_override(self, signal_strength: float, reset: int =NO_RESET) -> int: + def cmd_blood_flow_signal_strength_override(self, signal_strength: float, reset: int = NO_RESET) -> int: """ Constructs and sends the measured blood flow signal strength % override \n command. @@ -438,7 +437,7 @@ else: str_sig = str(signal_strength) self.logger.debug("Blood pump flow signal strength overridden to " + str_sig + " %: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -481,7 +480,7 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Blood flow broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -508,7 +507,7 @@ # If there is content... if received_message is not None: self.logger.debug("Blood pump homed : " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/blood_leak.py =================================================================== diff -u -r0a84621b0b0f807dd4019fa9ec44cc3efb7bb30a -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/blood_leak.py (.../blood_leak.py) (revision 0a84621b0b0f807dd4019fa9ec44cc3efb7bb30a) +++ dialin/hd/blood_leak.py (.../blood_leak.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,30 +14,31 @@ # ############################################################################ import struct -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..common.msg_defs import MsgIds, MsgFieldPositions +from logging import Logger + from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish -from logging import Logger +from ..utils.base import AbstractSubSystem, publish +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -class HDBloodLeak(_AbstractSubSystem): +class HDBloodLeak(AbstractSubSystem): """ HDBloodLeak Hemodialysis Delivery (HD) Dialin API sub-class for blood leak related commands. """ # Blood leak detector status - BLOOD_LEAK_DETECTED = 0 # Blood detected - NO_BLOOD_LEAK_DETECTED = 1 # No blood detected + BLOOD_LEAK_DETECTED = 0 # Blood detected + NO_BLOOD_LEAK_DETECTED = 1 # No blood detected # Blood leak detector state machine states - BLOOD_LEAK_INIT_STATE = 0 # Initial state - BLOOD_LEAK_ZERO_STATE = 1 # Zero state - BLOOD_LEAK_SELF_TEST_STATE = 2 # Self-test state - BLOOD_LEAK_NORMAL_STATE = 3 # Normal state + BLOOD_LEAK_INIT_STATE = 0 # Initial state + BLOOD_LEAK_ZERO_STATE = 1 # Zero state + BLOOD_LEAK_SELF_TEST_STATE = 2 # Self-test state + BLOOD_LEAK_NORMAL_STATE = 3 # Normal state def __init__(self, can_interface, logger: Logger): """ @@ -73,7 +74,7 @@ """ return self.blood_leak_state - @_publish("blood_leak_status") + @publish("blood_leak_status") def _handler_blood_leak_sync(self, message): """ Handles published blood leak status messages. Blood leak status is captured @@ -84,9 +85,9 @@ """ status = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) self.blood_leak_status = status[0] self.blood_leak_state = state[0] @@ -180,7 +181,7 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Blood leak data broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/buttons.py =================================================================== diff -u -r0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/buttons.py (.../buttons.py) (revision 0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490) +++ dialin/hd/buttons.py (.../buttons.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -13,18 +13,19 @@ # @date (original) 02-Apr-2020 # ############################################################################ +import struct +from logging import Logger + +from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) +from ..utils.base import AbstractSubSystem, publish from ..utils.conversions import integer_to_bytearray -from ..common.msg_defs import MsgIds, MsgFieldPositions -from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish -from logging import Logger -import struct -class HDButtons(_AbstractSubSystem): +class HDButtons(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for button related commands. """ @@ -64,7 +65,7 @@ self.poweroff_timeout_expired = False - @_publish(["poweroff_timeout_expired"]) + @publish(["poweroff_timeout_expired"]) def _handler_poweroff_timeout_occurred(self, message): """ Poweroff timeout occurred handler @@ -116,7 +117,7 @@ str_res = ("pressed" if state != 0 else "released") self.logger.debug("Off button overridden to " + str_res + ":" + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -156,7 +157,7 @@ else: str_res = ("pressed" if state != 0 else "released") self.logger.debug("Stop button overridden to " + str_res + ":" + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message["message"][DenaliMessage.PAYLOAD_START_INDEX] Index: dialin/hd/calibration_record.py =================================================================== diff -u -r47eb368c929e01fbff7d7749a822ee0efb467ea5 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/calibration_record.py (.../calibration_record.py) (revision 47eb368c929e01fbff7d7749a822ee0efb467ea5) +++ dialin/hd/calibration_record.py (.../calibration_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -1,15 +1,15 @@ import struct -import datetime import time from collections import OrderedDict +from logging import Logger + from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import AbstractSubSystem, publish from ..utils.nv_ops_utils import NVOpsUtils -from logging import Logger -class HDCalibrationNVRecord(_AbstractSubSystem): +class HDCalibrationNVRecord(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for calibration_record commands. @@ -56,7 +56,6 @@ self.hd_calibration_record = self._prepare_hd_calibration_record() if self.can_interface is not None: - channel_id = DenaliChannels.hd_to_dialin_ch_id msg_id = MsgIds.MSG_ID_HD_SEND_CALIBRATION_RECORD.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, @@ -142,7 +141,7 @@ self._utilities.process_received_record_from_fw(self.hd_calibration_record, self._raw_cal_record) self._handler_received_complete_hd_calibration_record() - @_publish(["hd_calibration_record"]) + @publish(["hd_calibration_record"]) def _handler_received_complete_hd_calibration_record(self): """ Publishes the received system record @@ -239,7 +238,6 @@ hardware = OrderedDict() for i in hardware_names: - hardware[i] = {'pwm_to_speed': [' int: + def cmd_dialysate_inlet_pump_measured_motor_controller_speed_override(self, speed: int, + reset: int = NO_RESET) -> int: """ Constructs and sends the measured dialysate inlet pump motor controller speed \n override command. @@ -287,14 +289,15 @@ else: str_res = str(speed) self.logger.debug("Dialysate pump MC speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_dialysate_inlet_pump_measured_motor_controller_current_override(self, curr: int, reset: int = NO_RESET) -> int: + def cmd_dialysate_inlet_pump_measured_motor_controller_current_override(self, curr: int, + reset: int = NO_RESET) -> int: """ Constructs and sends the measured dialysate inlet pump motor current override command Constraints: @@ -326,7 +329,7 @@ else: str_res = str(curr) self.logger.debug("Dialysate inlet pump MC current (measured) overridden to " + str_res + " mA: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -366,7 +369,7 @@ else: str_res = str(speed) self.logger.debug("Dialysate inlet pump speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -406,7 +409,7 @@ else: str_res = str(speed) self.logger.debug("Dialysate inlet pump rotor speed (measured) overridden to " + str_res + " RPM: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -446,7 +449,7 @@ else: str_sig = str(signal_strength) self.logger.debug("Dialysate pump flow signal strength overridden to " + str_sig + " %: " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -488,7 +491,7 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Dialysate inlet flow broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -515,7 +518,7 @@ # If there is content... if received_message is not None: self.logger.debug("Dialysate inlet pump homed : " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/dialysate_outlet_flow.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,19 +14,18 @@ # ############################################################################ import struct -from ..protocols.CAN import (DenaliMessage, - DenaliChannels) -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms -from .constants import RESET, NO_RESET +from logging import Logger + from .constants import PUMP_CONTROL_MODE_CLOSED_LOOP, PUMP_CONTROL_MODE_OPEN_LOOP -from ..utils.base import _AbstractSubSystem, _publish +from .constants import RESET, NO_RESET from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from logging import Logger - -class HDDialysateOutletFlow(_AbstractSubSystem): +class HDDialysateOutletFlow(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for dialysate outlet pump related commands. """ @@ -107,7 +106,7 @@ """ return self.pwm_duty_cycle_pct - @_publish([ + @publish([ "reference_dialysate_outlet_uf_volume", "measured_dialysate_outlet_uf_volume", "measured_dialysate_outlet_pump_rotor_speed", @@ -151,7 +150,7 @@ def cmd_dialysate_outlet_flow_set_point_override(self, flow: int, mode: int = PUMP_CONTROL_MODE_CLOSED_LOOP, - reset: int =NO_RESET) -> int: + reset: int = NO_RESET) -> int: """ Constructs and sends the dialysate outlet pump set point override command Constraints: @@ -272,14 +271,15 @@ else: str_res = "overridden to " + str(measvol) + " mL. " self.logger.debug("UF measured volume " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_dialysate_outlet_pump_measured_motor_controller_speed_override(self, speed: float, reset: int = NO_RESET) -> int: + def cmd_dialysate_outlet_pump_measured_motor_controller_speed_override(self, speed: float, + reset: int = NO_RESET) -> int: """ Constructs and sends the measured dialysate outlet pump motor controller measured speed \n override command. @@ -312,14 +312,15 @@ else: str_res = "overridden to " + str(speed) + " RPM. " self.logger.debug("Dialysate outlet pump MC speed (measured) " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_dialysate_outlet_pump_measured_motor_controller_current_override(self, curr: float, reset: int = NO_RESET) -> int: + def cmd_dialysate_outlet_pump_measured_motor_controller_current_override(self, curr: float, + reset: int = NO_RESET) -> int: """ Constructs and sends the measured dialysate outlet pump motor current override command Constraints: @@ -351,7 +352,7 @@ else: str_res = "overridden to " + str(curr) + " mA. " self.logger.debug("Dialysate outlet pump MC current (measured) " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -391,7 +392,7 @@ else: str_res = "overridden to " + str(speed) + " RPM. " self.logger.debug("Dialysate outlet pump speed (measured) " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -431,7 +432,7 @@ else: str_res = "overridden to " + str(speed) + " RPM. " self.logger.debug("Dialysate outlet pump rotor speed (measured) " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -474,14 +475,15 @@ else: str_res = "overridden to " + str(ms) + " ms. " self.logger.debug("Dialysate outlet flow broadcast interval " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") return False - def cmd_dialysate_outlet_pump_load_cell_weight_override(self, sensor: int, weight: float, reset: int = NO_RESET) -> int: + def cmd_dialysate_outlet_pump_load_cell_weight_override(self, sensor: int, weight: float, + reset: int = NO_RESET) -> int: """ Constructs and sends the measured load cell weight override command. Constraints: @@ -509,7 +511,8 @@ message_id=MsgIds.MSG_ID_DIAL_OUT_LOAD_CELL_WEIGHT_OVERRIDE.value, payload=payload) - self.logger.debug("override measured load cell weight to " + str(weight) + " grams for load cell # " + str(sensor)) + self.logger.debug( + "override measured load cell weight to " + str(weight) + " grams for load cell # " + str(sensor)) # Send message received_message = self.can_interface.send(message) @@ -522,7 +525,7 @@ else: str_res = "overridden to " + str(weight) + " grams. " self.logger.debug("Load cell # " + str(sensor) + " " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -577,7 +580,7 @@ # If there is content... if received_message is not None: self.logger.debug("Dialysate outlet pump homed : " + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/fluid_leak.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/fluid_leak.py (.../fluid_leak.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/hd/fluid_leak.py (.../fluid_leak.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,25 +14,26 @@ # ############################################################################ import struct -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms -from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgIdsDialin -from .constants import RESET, NO_RESET -from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish from logging import Logger +from .constants import RESET, NO_RESET +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray -class HDFluidLeak(_AbstractSubSystem): + +class HDFluidLeak(AbstractSubSystem): """ HDFluidLeak Hemodialysis Delivery (HD) Dialin API sub-class for fluid leak related commands. """ # Fluid leak detector state - FLUID_LEAK_DETECTED_STATE = 0 # Wet - NO_FLUID_LEAK_DETECTED_STATE = 1 # Dry + FLUID_LEAK_DETECTED_STATE = 0 # Wet + NO_FLUID_LEAK_DETECTED_STATE = 1 # Dry def __init__(self, can_interface, logger: Logger): """ @@ -59,7 +60,7 @@ """ return self.fluid_leak_state - @_publish(["fluid_leak_state"]) + @publish(["fluid_leak_state"]) def _handler_fluid_leak_sync(self, message): """ Handles published fluid leak state messages. Fluid leak state is captured @@ -142,9 +143,9 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Fluid leak state broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("Timeout!!!!") - return False \ No newline at end of file + return False Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -rc19568936f7925714a39b7951eae672ab91769a4 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision c19568936f7925714a39b7951eae672ab91769a4) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,41 +14,40 @@ # ############################################################################ import struct + from .accelerometer import HDAccelerometer from .air_bubbles import HDAirBubbles from .air_trap import HDAirTrap from .alarms import HDAlarms +from .blood_flow import HDBloodFlow from .blood_leak import HDBloodLeak from .buttons import HDButtons -from .fluid_leak import HDFluidLeak -from .ui_proxy import HDUIProxy -from .watchdog import HDWatchdog -from .rtc import HDRTC -from .blood_flow import HDBloodFlow +from .calibration_record import HDCalibrationNVRecord +from .constants import NO_RESET from .dialysate_inlet_flow import HDDialysateInletFlow from .dialysate_outlet_flow import HDDialysateOutletFlow -from .treatment import HDTreatment -from .valves import HDValves -from .voltages import HDVoltages -from .calibration_record import HDCalibrationNVRecord -from .system_record import HDSystemNVRecords -from .service_record import HDServiceNVRecords +from .fluid_leak import HDFluidLeak from .pressure_occlusion import HDPressureOcclusion from .pretreatment import HDPreTreatment -from .syringe_pump import HDSyringePump +from .rtc import HDRTC +from .service_record import HDServiceNVRecords from .switches import HDSwitches -from ..protocols.CAN import (DenaliMessage, - DenaliCanMessenger, - DenaliChannels) - -from ..utils.conversions import integer_to_bytearray -from ..utils.base import _AbstractSubSystem, _publish, _LogManager -from .constants import NO_RESET -from ..common.msg_defs import MsgIds, MsgFieldPositions +from .syringe_pump import HDSyringePump +from .service_record import HDServiceNVRecords +from .system_record import HDSystemNVRecords +from .treatment import HDTreatment +from .ui_proxy import HDUIProxy +from .valves import HDValves +from .voltages import HDVoltages +from .watchdog import HDWatchdog from ..common.hd_defs import HDOpModes +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels +from ..utils.base import AbstractSubSystem, publish, LogManager +from ..utils.conversions import integer_to_bytearray -class HD(_AbstractSubSystem): +class HD(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin object API. It provides the basic interface to communicate with the HD firmware. @@ -72,7 +71,7 @@ """ super().__init__() - self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__+".log") + self._log_manager = LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") self.logger = self._log_manager.logger # Create listener @@ -135,7 +134,7 @@ """ return self.hd_logged_in - @_publish(["hd_logged_in"]) + @publish(["hd_logged_in"]) def hd_set_logged_in_status(self, logged_in:bool=False): """ Callback for HD logged in status change. @@ -144,7 +143,7 @@ """ self.hd_logged_in = logged_in - @_publish(["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 @@ -219,14 +218,14 @@ self.logger.debug("Timeout!!!!") return False - def cmd_hd_set_operation_mode(self, newMode: int = 0) -> int: + def cmd_hd_set_operation_mode(self, new_mode: int = 0) -> int: """ Constructs and sends a set operation mode request command via CAN bus. Constraints: Must be logged into HD. Transition from current to requested op mode must be legal. - @param newMode: ID of operation mode to transition to + @param new_mode: ID of operation mode to transition to HD_OP_MODE_FAULT = 0 HD_OP_MODE_SERVICE = 1 HD_OP_MODE_INIT_POST = 2 @@ -240,13 +239,13 @@ """ - payload = integer_to_bytearray(newMode) + payload = integer_to_bytearray(new_mode) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=MsgIds.MSG_ID_HD_SET_OP_MODE_REQUEST.value, payload=payload) - self.logger.debug("Requesting HD mode change to " + str(newMode)) + self.logger.debug("Requesting HD mode change to " + str(new_mode)) # Send message received_message = self.can_interface.send(message) @@ -276,9 +275,9 @@ """ if active: - sft=1 + sft = 1 else: - sft=0 + sft = 0 rst = integer_to_bytearray(reset) saf = integer_to_bytearray(sft) payload = rst + saf Index: dialin/hd/pressure_occlusion.py =================================================================== diff -u -r6e20f4690ce887c351d8c65546f93311e5df6ad1 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision 6e20f4690ce887c351d8c65546f93311e5df6ad1) +++ dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,17 +14,17 @@ # ############################################################################ import struct -from ..protocols.CAN import (DenaliMessage, - DenaliChannels) -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms +from logging import Logger + from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish from ..common.msg_defs import MsgIds, MsgFieldPositions -from logging import Logger +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -class HDPressureOcclusion(_AbstractSubSystem): +class HDPressureOcclusion(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for pressure related commands. """ @@ -89,7 +89,7 @@ """ return self.dialysate_outlet_pump_occlusion - @_publish([ + @publish([ "arterial_pressure", "venous_pressure", "blood_pump_occlusion", @@ -153,7 +153,7 @@ else: str_res = str(pres) + " mmHg. " self.logger.debug("Arterial pressure (measured)) overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -192,7 +192,7 @@ else: str_res = str(pres) + " mmHg. " self.logger.debug("Venous pressure (measured) overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -230,7 +230,7 @@ else: str_res = str(occl) + " mmHg. " self.logger.debug("Blood pump occlusion pressure (measured) overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -269,7 +269,7 @@ else: str_res = str(occl) + " mmHg. " self.logger.debug("Dialysate inlet pump occlusion pressure (measured) overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -308,7 +308,7 @@ else: str_res = str(occl) + " mmHg. " self.logger.debug("Dialysate outlet pump occlusion pressure (measured) overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: @@ -350,7 +350,7 @@ else: str_res = str(ms) + " ms: " self.logger.debug("Pressure/occlusion broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/pretreatment.py =================================================================== diff -u -r1dcdd74a0515845ccde2be8271d3576b9ca80033 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/pretreatment.py (.../pretreatment.py) (revision 1dcdd74a0515845ccde2be8271d3576b9ca80033) +++ dialin/hd/pretreatment.py (.../pretreatment.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,20 +14,21 @@ # ############################################################################ import struct -from ..protocols.CAN import DenaliChannels -from ..utils.base import _AbstractSubSystem, _publish -from ..common.msg_defs import MsgIds, MsgFieldPositions +from logging import Logger + from ..common import (PreTreatmentSubModes, PreTreatmentSampleWaterStates, PreTreatmentConsumableSelfTestStates, PreTreatmentRecircStates, PreTreatmentNoCartSelfTestStates, PreTreatmentDrySelfTestStates, PreTreatmentPrimeStates) -from logging import Logger +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliChannels +from ..utils.base import AbstractSubSystem, publish -class HDPreTreatment(_AbstractSubSystem): +class HDPreTreatment(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for pretreatment related commands. @@ -199,7 +200,7 @@ """ return self.prime_time_countdown - @_publish([ + @publish([ "pre_treatment_submode", "pre_treatment_sample_water_state", "pre_treatment_consumable_self_test_state", @@ -247,7 +248,8 @@ self.pre_treatment_consumable_self_test_state = 'Unknown State' if PreTreatmentConsumableSelfTestStates.has_value(pt_consumable_st_state): - self.pre_treatment_consumable_self_test_state = PreTreatmentConsumableSelfTestStates(pt_consumable_st_state).name + self.pre_treatment_consumable_self_test_state = PreTreatmentConsumableSelfTestStates( + pt_consumable_st_state).name self.pre_treatment_no_cart_self_test_state = 'Unknown State' if PreTreatmentNoCartSelfTestStates.has_value(pt_no_cart_st_state): @@ -269,7 +271,7 @@ if PreTreatmentRecircStates.has_value(pt_recirc_state): self.pre_treatment_recirc_state = PreTreatmentRecircStates(pt_recirc_state).name - @_publish([ + @publish([ "no_cart_self_test_timeout", "no_cart_self_test_time_countdown" ]) @@ -286,7 +288,7 @@ self.no_cart_self_test_time_countdown = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - @_publish([ + @publish([ "dry_self_test_timeout", "dry_self_test_time_countdown" ]) @@ -303,7 +305,7 @@ self.dry_self_test_time_countdown = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - @_publish([ + @publish([ "prime_timeout", "prime_time_countdown" ]) @@ -319,4 +321,3 @@ message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] self.prime_time_countdown = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - Index: dialin/hd/rtc.py =================================================================== diff -u -r2e392c92d55178f457a67423ba8c503a86dcf3c8 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/rtc.py (.../rtc.py) (revision 2e392c92d55178f457a67423ba8c503a86dcf3c8) +++ dialin/hd/rtc.py (.../rtc.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,15 +14,16 @@ # ############################################################################ import ctypes +from logging import Logger + +from ..common.msg_defs import MsgIds from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import AbstractSubSystem, publish from ..utils.conversions import integer_to_bytearray -from ..utils.base import _AbstractSubSystem, _publish -from ..common.msg_defs import MsgIds -from logging import Logger -class HDRTC(_AbstractSubSystem): +class HDRTC(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for rtc commands. @@ -57,7 +58,7 @@ """ return self.rtc_epoch - @_publish(["rtc_epoch"]) + @publish(["rtc_epoch"]) def _handler_rtc_epoch(self, message): """ Publishes the rtc time in epoch @@ -104,9 +105,10 @@ self.logger.debug(received_message) # str_res = str(flow) - self.logger.debug("Time and Date in rtc set to seconds: " + str(sec) + " minutes: " + str(min) + " hours: " + - str(hour) + " days: " + str(day) + " months: " + str(month) + " years: " + str(year) + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + self.logger.debug( + "Time and Date in rtc set to seconds: " + str(sec) + " minutes: " + str(min) + " hours: " + + str(hour) + " days: " + str(day) + " months: " + str(month) + " years: " + str(year) + + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/hd/service_record.py =================================================================== diff -u -r47eb368c929e01fbff7d7749a822ee0efb467ea5 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/service_record.py (.../service_record.py) (revision 47eb368c929e01fbff7d7749a822ee0efb467ea5) +++ dialin/hd/service_record.py (.../service_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -1,13 +1,13 @@ import struct -import datetime import time from collections import OrderedDict +from enum import unique +from logging import Logger + from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.nv_ops_utils import NVOpsUtils -from logging import Logger -from enum import unique @unique @@ -16,7 +16,7 @@ SERVICE_LOCATION_FIELD = 1 -class HDServiceNVRecords(_AbstractSubSystem): +class HDServiceNVRecords(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for service record commands. @@ -142,7 +142,7 @@ self._utilities.process_received_record_from_fw(self.hd_service_record, self._raw_service_record) self._handler_received_complete_hd_service_record() - @_publish(["hd_service_record"]) + @publish(["hd_service_record"]) def _handler_received_complete_hd_service_record(self): """ Publishes the received service record @@ -237,4 +237,4 @@ for record in service_records.keys(): groups_byte_size += self._utilities.calculate_group_byte_size(service_records[record]) - return service_records, groups_byte_size \ No newline at end of file + return service_records, groups_byte_size Index: dialin/hd/switches.py =================================================================== diff -u -rc4776c1885f259b231532ef5ba7e904178cd0005 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/switches.py (.../switches.py) (revision c4776c1885f259b231532ef5ba7e904178cd0005) +++ dialin/hd/switches.py (.../switches.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -1,13 +1,14 @@ import struct +from enum import unique +from logging import Logger + from ..utils.conversions import integer_to_bytearray from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import RESET, NO_RESET -from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.checks import check_broadcast_interval_override_ms -from logging import Logger -from enum import unique @unique @@ -21,7 +22,7 @@ FRONT_DOOR = 0 -class HDSwitches(_AbstractSubSystem): +class HDSwitches(AbstractSubSystem): """ @brief Hemodialysis Device (HD) Dialin API sub-class for HD switches related commands. """ @@ -52,7 +53,7 @@ """ return self.hd_switches_status - @_publish(["hd_switches_status"]) + @publish(["hd_switches_status"]) def _handler_switches_sync(self, message): """ Handles published drain pump data messages. Switches data are captured Index: dialin/hd/syringe_pump.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/syringe_pump.py (.../syringe_pump.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/hd/syringe_pump.py (.../syringe_pump.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -14,18 +14,19 @@ # ############################################################################ import struct -from ..utils.conversions import integer_to_bytearray, float_to_bytearray -from ..utils.checks import check_broadcast_interval_override_ms +from logging import Logger + from .constants import RESET, NO_RESET +from ..common.hd_defs import HeparinStates, SyringePumpStates, SyringePumpOperations from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish -from ..common.hd_defs import HeparinStates, SyringePumpStates, SyringePumpOperations -from logging import Logger +from ..utils.base import AbstractSubSystem, publish +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray, float_to_bytearray -class HDSyringePump(_AbstractSubSystem): +class HDSyringePump(AbstractSubSystem): """ HDSyringePump @@ -189,13 +190,13 @@ """ return self.syringe_pump_adc_read_counter - @_publish(["syringe_pump_state", "syringe_pump_set_rate_ml_hr", - "syringe_pump_meas_rate_ml_hr", "syringe_pump_position", - "syringe_pump_volume_ml", "syringe_pump_home_v", - "syringe_pump_switch_v", "syringe_pump_force_v", - "heparin_state", "syringe_pump_safety_volume_ml", - "syringe_pump_status", "syringe_pump_encoder_status", - "syringe_pump_adc_dac_status", "syringe_pump_adc_read_counter"]) + @publish(["syringe_pump_state", "syringe_pump_set_rate_ml_hr", + "syringe_pump_meas_rate_ml_hr", "syringe_pump_position", + "syringe_pump_volume_ml", "syringe_pump_home_v", + "syringe_pump_switch_v", "syringe_pump_force_v", + "heparin_state", "syringe_pump_safety_volume_ml", + "syringe_pump_status", "syringe_pump_encoder_status", + "syringe_pump_adc_dac_status", "syringe_pump_adc_read_counter"]) def _handler_syringe_pump_data(self, message): """ Handles published syringe pump data messages. Syringe pump data are captured Index: dialin/hd/system_record.py =================================================================== diff -u -r94a543f6b3f0d408b46637dbd831e98219755f47 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/system_record.py (.../system_record.py) (revision 94a543f6b3f0d408b46637dbd831e98219755f47) +++ dialin/hd/system_record.py (.../system_record.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -1,22 +1,21 @@ import struct -import datetime import time from collections import OrderedDict +from enum import unique +from logging import Logger + from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.nv_ops_utils import NVOpsUtils -from logging import Logger -from enum import unique - @unique class MFGLocation(DialinEnum): MFG_LOCATION_FACTORY = 0 -class HDSystemNVRecords(_AbstractSubSystem): +class HDSystemNVRecords(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin API sub-class for system record commands. @@ -143,7 +142,7 @@ self._utilities.process_received_record_from_fw(self.hd_system_record, self._raw_system_record) self._handler_received_complete_hd_system_record() - @_publish(["hd_system_record"]) + @publish(["hd_system_record"]) def _handler_received_complete_hd_system_record(self): """ Publishes the received system record @@ -228,14 +227,16 @@ @return: system record dictionary and the byte size of this group """ groups_byte_size = 0 - system_records = OrderedDict({'system_record': - {'top_level_pn': [' None: + def cmd_set_treatment_parameters(self, bld_flow: int = 100, + dia_flow: int = 100, + duration: int = 240, + hep_rate: float = 0.0, + hep_bol: float = 0.0, + hep_stop: int = 0, + sal_bol: int = 100, + acid: int = 0, + bicarb: int = 0, + dialyzer: int = 0, + dia_temp: float = 37.0, + art_low: int = -300, + art_high: int = 0, + ven_low: int = 20, + ven_high: int = 400, + bp_intvl: int = 30, + rb_flow: int = 75) -> None: """ Constructs and sends a ui set treatment parameters message Constraints: @@ -1324,7 +1325,7 @@ hbv = float_to_bytearray(hep_bol) tmp = float_to_bytearray(dia_temp) - payload = bld+dia+dur+hps+sal+acc+bic+dzr+bpi+rbf+apl+aph+vpl+vph+hdr+hbv+tmp + payload = bld + dia + dur + hps + sal + acc + bic + dzr + bpi + rbf + apl + aph + vpl + vph + hdr + hbv + tmp message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS.value, payload=payload) @@ -1370,21 +1371,22 @@ if start: sta = integer_to_bytearray(1) - str = "start" + request = "start" else: sta = integer_to_bytearray(0) - str = "abort" + request = "abort" payload = sta message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=MsgIds.MSG_ID_USER_SALINE_BOLUS_REQUEST.value, payload=payload) - self.logger.debug("Sending request to " + str + " a saline bolus.") + self.logger.debug("Sending request to " + request + " a saline bolus.") self.can_interface.send(message, 0) - def cmd_ui_rinseback_user_action(self, action: int = RinsebackUserActions.REQUESTED_USER_ACTION_RINSEBACK_CONFIRM_START.value) -> None: + def cmd_ui_rinseback_user_action( + self, action: int = RinsebackUserActions.REQUESTED_USER_ACTION_RINSEBACK_CONFIRM_START.value) -> None: """ Constructs and sends a UI rinseback user action message Constraints: @@ -1416,7 +1418,8 @@ self.can_interface.send(message, 0) - def cmd_ui_recirculate_user_action(self, action: int = RecircUserActions.REQUESTED_USER_ACTION_TX_RECIRC_RECONNECT.value) -> None: + def cmd_ui_recirculate_user_action( + self, action: int = RecircUserActions.REQUESTED_USER_ACTION_TX_RECIRC_RECONNECT.value) -> None: """ Constructs and sends a UI recirculate user action message Constraints: @@ -1442,7 +1445,8 @@ self.can_interface.send(message, 0) - def cmd_ui_treatment_end_user_action(self, action: int = TreatmentEndUserActions.REQUESTED_USER_ACTION_TX_END_RINSEBACK_START.value) -> None: + def cmd_ui_treatment_end_user_action( + self, action: int = TreatmentEndUserActions.REQUESTED_USER_ACTION_TX_END_RINSEBACK_START.value) -> None: """ Constructs and sends a UI treatment end user action message Constraints: @@ -1667,7 +1671,7 @@ self.logger.debug("Sending setting standby submode to wait for disinfect to HD.") self.can_interface.send(message, 0) - @_publish(["disinfects_hd_submode", "disinfects_dg_mode"]) + @publish(["disinfects_hd_submode", "disinfects_dg_mode"]) def _handler_disinfects_data_publish(self, message: dict) -> None: """ Handles published disinfect mode and submode that is published to UI @@ -1683,5 +1687,3 @@ self.disinfects_hd_submode = hd_state self.disinfects_dg_mode = dg_submode - - Index: dialin/hd/valves.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/valves.py (.../valves.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/hd/valves.py (.../valves.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -16,14 +16,15 @@ import struct -from ..utils.checks import check_broadcast_interval_override_ms -from ..utils.conversions import integer_to_bytearray, float_to_bytearray +from enum import unique +from logging import Logger + from .constants import NO_RESET -from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish, DialinEnum from ..common import MsgIds, MsgIdsDialin -from logging import Logger -from enum import unique +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish, DialinEnum +from ..utils.checks import check_broadcast_interval_override_ms +from ..utils.conversions import integer_to_bytearray, float_to_bytearray @unique @@ -36,33 +37,31 @@ @unique class ValvesPositions(DialinEnum): - VALVE_POSITION_A_INSERT_EJECT = 1 - VALVE_POSITION_B_OPEN = 2 - VALVE_POSITION_C_CLOSE = 3 + VALVE_POSITION_A_INSERT_EJECT = 1 + VALVE_POSITION_B_OPEN = 2 + VALVE_POSITION_C_CLOSE = 3 @unique class ValvesStates(DialinEnum): - VALVE_STATE_WAIT_FOR_POST = 0 - VALVE_STATE_HOMING_NOT_STARTED = 1 - VALVE_STATE_HOMING_FIND_ENERGIZED_EDGE = 2 + VALVE_STATE_WAIT_FOR_POST = 0 + VALVE_STATE_HOMING_NOT_STARTED = 1 + VALVE_STATE_HOMING_FIND_ENERGIZED_EDGE = 2 VALVE_STATE_HOMING_FIND_DEENERGIZED_EDGE = 3 - VALVE_STATE_IDLE = 4 - VALVE_STATE_IN_TRANSITION = 5 - VALVE_STATE_IN_BYPASS_MODE = 6 + VALVE_STATE_IDLE = 4 + VALVE_STATE_IN_TRANSITION = 5 + VALVE_STATE_IN_BYPASS_MODE = 6 @unique class AirTrapState(DialinEnum): STATE_CLOSED = 0 - STATE_OPEN = 1 + STATE_OPEN = 1 -class HDValves(_AbstractSubSystem): +class HDValves(AbstractSubSystem): """ - \class HDValves - - @brief Hemodialysis Device (HD) Dialin API sub-class for valves related commands. + Hemodialysis Device (HD) Dialin API sub-class for valves related commands. """ # Valves states publish message field positions # Note the MsgFieldPosition was not used since some of the published data are S16 @@ -117,8 +116,8 @@ self._handler_hd_valves_sync) # A dictionary of the valves with the status - self.valves_status = {ValvesEnum.VDI.name:{}, ValvesEnum.VDO.name:{}, ValvesEnum.VBA.name:{}, - ValvesEnum.VBV.name:{}} + self.valves_status = {ValvesEnum.VDI.name: {}, ValvesEnum.VDO.name: {}, ValvesEnum.VBA.name: {}, + ValvesEnum.VBV.name: {}} self.hd_air_trap_status = 0 @@ -285,7 +284,7 @@ VDO = 1 VBA = 2 VBV = 3 - @pwm pwm: integer - sets the pwm value + @param pwm: integer - sets the pwm value @param direction: integer - Direction number: 0 = Clockwise 1 = Counter clockwise @@ -295,8 +294,8 @@ reset_value = integer_to_bytearray(reset) vlv = integer_to_bytearray(valve) pwm = integer_to_bytearray(pwm) - dir = integer_to_bytearray(direction) - payload = reset_value + vlv + pwm + dir + dir_value = integer_to_bytearray(direction) + payload = reset_value + vlv + pwm + dir_value message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=MsgIds.MSG_ID_HD_VALVES_SET_PWM_OVERRIDE.value, @@ -367,20 +366,20 @@ self.logger.debug("Opening air trap valve timeout!!") return False - @_publish(["valves_status", "hd_air_trap_status"]) - def _handler_hd_valves_sync(self, message:dict) -> None: + @publish(["valves_status", "hd_air_trap_status"]) + def _handler_hd_valves_sync(self, message: dict) -> None: """ Handles published HD valves data messages. HD valves data are captured for reference. @param message: published HD valves data message @returns none """ - vlv_ID = struct.unpack('i', bytearray( + vlv_id = struct.unpack('i', bytearray( message['message'][self.START_POS_VALVES_ID:self.END_POS_VALVES_ID]))[0] - state_ID = struct.unpack('i', bytearray( + state_id = struct.unpack('i', bytearray( message['message'][self.START_VALVES_STATE:self.END_VALVES_STATE]))[0] - pos_ID = struct.unpack('i', bytearray( + pos_id = struct.unpack('i', bytearray( message['message'][self.START_POS_VALVES_CURR_POS:self.END_POS_VALVES_CURR_POS]))[0] pos_cnt = struct.unpack('h', bytearray( message['message'][self.START_POS_VALVES_CURR_POS_CNT:self.END_POS_VALVES_CURR_POS_CNT]))[0] @@ -400,11 +399,12 @@ message['message'][self.START_AIR_TRAP_VALVE_STATUS:self.END_AIR_TRAP_VALVE_STATUS]))[0] # To make sure values of the enums are not out of range - if ValvesEnum.has_value(vlv_ID) and ValvesPositions.has_value(pos_ID) and ValvesStates.has_value(pos_ID): - vlv_name = ValvesEnum(vlv_ID).name + if ValvesEnum.has_value(vlv_id) and ValvesPositions.has_value(pos_id) and ValvesStates.has_value(pos_id): + vlv_name = ValvesEnum(vlv_id).name # Update the valves dictionary - self.valves_status[vlv_name] = {'Valve': vlv_name, 'PosID': ValvesPositions(pos_ID).name, 'PosCnt': pos_cnt, - 'Cmd': next_pos, 'State': ValvesStates(state_ID).name, 'Current': current, + self.valves_status[vlv_name] = {'Valve': vlv_name, 'PosID': ValvesPositions(pos_id).name, 'PosCnt': pos_cnt, + 'Cmd': next_pos, 'State': ValvesStates(state_id).name, 'Current': current, 'PosA': pos_a, 'PosB': pos_b, 'PosC': pos_c, 'PWM': pwm} # Update the air trap valve's status self.hd_air_trap_status = air_trap + Index: dialin/hd/voltages.py =================================================================== diff -u -ra2d44432a913537ca0627cd7dde7dcb1154f2156 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/voltages.py (.../voltages.py) (revision a2d44432a913537ca0627cd7dde7dcb1154f2156) +++ dialin/hd/voltages.py (.../voltages.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -15,15 +15,14 @@ ############################################################################ import struct from enum import unique -from ..utils.base import DialinEnum -from ..utils.checks import check_broadcast_interval_override_ms -from ..protocols.CAN import (DenaliMessage, - DenaliChannels) -from ..utils.conversions import integer_to_bytearray, float_to_bytearray +from logging import Logger + from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish, DialinEnum +from ..utils.conversions import integer_to_bytearray, float_to_bytearray +from ..utils.checks import check_broadcast_interval_override_ms from ..common.msg_defs import MsgIds, MsgFieldPositions -from logging import Logger # Monitored voltages @@ -40,7 +39,7 @@ NUM_OF_MONITORED_VOLTAGE_LINES = 8 # Number of HD operation modes -class HDVoltages(_AbstractSubSystem): +class HDVoltages(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for voltage monitor related commands and data. """ @@ -69,9 +68,7 @@ """ return self.monitored_voltages - @_publish([ - "monitored_voltages" - ]) + @publish(["monitored_voltages"]) def _handler_monitored_voltages_sync(self, message): """ Handles published HD monitored voltages data messages. Voltage data are captured Index: dialin/hd/watchdog.py =================================================================== diff -u -r0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/hd/watchdog.py (.../watchdog.py) (revision 0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490) +++ dialin/hd/watchdog.py (.../watchdog.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -13,17 +13,17 @@ # @date (original) 02-Apr-2020 # ############################################################################ +from logging import Logger + +from .constants import RESET, NO_RESET +from ..common import MsgIds from ..protocols.CAN import (DenaliMessage, DenaliChannels) +from ..utils.base import AbstractSubSystem from ..utils.conversions import integer_to_bytearray -from .constants import RESET, NO_RESET -from ..utils.base import _AbstractSubSystem, _publish -from logging import Logger -from ..common import MsgIds - -class HDWatchdog(_AbstractSubSystem): +class HDWatchdog(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for watchdog related commands. """ @@ -74,7 +74,7 @@ else: str_res = ("checked in" if state != 0 else "not checked in") self.logger.debug("watchdog task check-in overridden to " + str_res + ":" + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: Index: dialin/protocols/CAN.py =================================================================== diff -u -re6345b2585260c85432f888c296aaf899dfdd47e -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/protocols/CAN.py (.../CAN.py) (revision e6345b2585260c85432f888c296aaf899dfdd47e) +++ dialin/protocols/CAN.py (.../CAN.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -19,6 +19,7 @@ import asyncio import can +from can.interfaces import socketcan import math from time import sleep import sys @@ -27,7 +28,6 @@ from .. import common from ..utils import SingletonMeta from concurrent.futures import ThreadPoolExecutor -from typing import Callable, List class DenaliMessage: @@ -255,48 +255,49 @@ if passive_mode: channel_rx_tx_pairs = { - DenaliChannels.hd_alarm_broadcast_ch_id : None, - DenaliChannels.dg_alarm_broadcast_ch_id : None, - DenaliChannels.ui_alarm_broadcast_ch_id : None, - DenaliChannels.hd_to_dg_ch_id : None, - DenaliChannels.dg_to_hd_ch_id : None, - DenaliChannels.hd_to_ui_ch_id : None, - DenaliChannels.hd_sync_broadcast_ch_id : None, - DenaliChannels.dg_to_ui_ch_id : None, - DenaliChannels.dg_sync_broadcast_ch_id : None, - DenaliChannels.ui_to_hd_ch_id : None, - DenaliChannels.ui_sync_broadcast_ch_id : None, - DenaliChannels.hd_to_dialin_ch_id : DenaliChannels.dialin_to_hd_ch_id, - DenaliChannels.dg_to_dialin_ch_id : DenaliChannels.dialin_to_dg_ch_id, - DenaliChannels.ui_to_dialin_ch_id : DenaliChannels.dialin_to_ui_ch_id + DenaliChannels.hd_alarm_broadcast_ch_id: None, + DenaliChannels.dg_alarm_broadcast_ch_id: None, + DenaliChannels.ui_alarm_broadcast_ch_id: None, + DenaliChannels.hd_to_dg_ch_id: None, + DenaliChannels.dg_to_hd_ch_id: None, + DenaliChannels.hd_to_ui_ch_id: None, + DenaliChannels.hd_sync_broadcast_ch_id: None, + DenaliChannels.dg_to_ui_ch_id: None, + DenaliChannels.dg_sync_broadcast_ch_id: None, + DenaliChannels.ui_to_hd_ch_id: None, + DenaliChannels.ui_sync_broadcast_ch_id: None, + DenaliChannels.hd_to_dialin_ch_id: DenaliChannels.dialin_to_hd_ch_id, + DenaliChannels.dg_to_dialin_ch_id: DenaliChannels.dialin_to_dg_ch_id, + DenaliChannels.ui_to_dialin_ch_id: DenaliChannels.dialin_to_ui_ch_id } else: channel_rx_tx_pairs = { - DenaliChannels.hd_alarm_broadcast_ch_id : None, - DenaliChannels.dg_alarm_broadcast_ch_id : None, - DenaliChannels.ui_alarm_broadcast_ch_id : None, - DenaliChannels.hd_to_dg_ch_id : DenaliChannels.dialin_to_hd_ch_id, - DenaliChannels.dg_to_hd_ch_id : DenaliChannels.dialin_to_dg_ch_id, - DenaliChannels.hd_to_ui_ch_id : DenaliChannels.dialin_to_hd_ch_id, - DenaliChannels.hd_sync_broadcast_ch_id : None, - DenaliChannels.dg_to_ui_ch_id : DenaliChannels.dialin_to_dg_ch_id, - DenaliChannels.dg_sync_broadcast_ch_id : None, - DenaliChannels.ui_to_hd_ch_id : DenaliChannels.hd_to_ui_ch_id, - DenaliChannels.ui_sync_broadcast_ch_id : DenaliChannels.hd_to_ui_ch_id, - DenaliChannels.hd_to_dialin_ch_id : DenaliChannels.dialin_to_hd_ch_id, - DenaliChannels.dg_to_dialin_ch_id : DenaliChannels.dialin_to_dg_ch_id, - DenaliChannels.ui_to_dialin_ch_id : DenaliChannels.dialin_to_ui_ch_id + DenaliChannels.hd_alarm_broadcast_ch_id: None, + DenaliChannels.dg_alarm_broadcast_ch_id: None, + DenaliChannels.ui_alarm_broadcast_ch_id: None, + DenaliChannels.hd_to_dg_ch_id: DenaliChannels.dialin_to_hd_ch_id, + DenaliChannels.dg_to_hd_ch_id: DenaliChannels.dialin_to_dg_ch_id, + DenaliChannels.hd_to_ui_ch_id: DenaliChannels.dialin_to_hd_ch_id, + DenaliChannels.hd_sync_broadcast_ch_id: None, + DenaliChannels.dg_to_ui_ch_id: DenaliChannels.dialin_to_dg_ch_id, + DenaliChannels.dg_sync_broadcast_ch_id: None, + DenaliChannels.ui_to_hd_ch_id: DenaliChannels.hd_to_ui_ch_id, + DenaliChannels.ui_sync_broadcast_ch_id: DenaliChannels.hd_to_ui_ch_id, + DenaliChannels.hd_to_dialin_ch_id: DenaliChannels.dialin_to_hd_ch_id, + DenaliChannels.dg_to_dialin_ch_id: DenaliChannels.dialin_to_dg_ch_id, + DenaliChannels.ui_to_dialin_ch_id: DenaliChannels.dialin_to_ui_ch_id } channel_id_tx = channel_rx_tx_pairs.get(channel_id_rx, None) if channel_id_tx is None: return None - message = DenaliMessage.build_message(channel_id=channel_id_tx, - message_id=common.msg_defs.MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value, - payload=payload, - seq=-seq) + message = DenaliMessage.build_message( + channel_id=channel_id_tx, + message_id=common.msg_defs.MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value, + payload=payload, + seq=-seq) return message @@ -461,7 +462,7 @@ # try to setup can bus and exit if the can bus has not ben setup to use. try: - self.bus = can.interfaces.socketcan.SocketcanBus(channel=can_interface) + self.bus = socketcan.SocketcanBus(channel=can_interface) self.loop = asyncio.get_event_loop() if self.bus is not None: self.thread_canbus = threading.Thread(target=self.listener, daemon=True) @@ -575,7 +576,7 @@ elif can_data[0] == DenaliMessage.START_BYTE and \ message_length <= DenaliMessage.PAYLOAD_LENGTH_FIRST_PACKET: # This is a short packet # This is the first time that we are building a message - self.messages = can_data # deliver the packet + self.messages = can_data # deliver the packet elif can_data[0] == self.START_BYTE and \ message_length > DenaliMessage.PAYLOAD_LENGTH_FIRST_PACKET: # Long packet start @@ -749,12 +750,12 @@ return "{0} {1} [{2}] {3}\n".format(channel, hex(message.arbitration_id)[2:], message.dlc, - tmp[-23:].upper()) + tmp[-23:].upper()) else: return "{0} {1} [{2}] {3}\n".format(channel, hex(message.arbitration_id)[2:], message.dlc, - tmp[-41:-18].upper()) + tmp[-41:-18].upper()) def do_log_can(self, packet: can.Message, style="candump", channel="can0", send=True): """ @@ -776,4 +777,3 @@ else: with open(filename, 'a') as f: f.write("{0}\n".format(packet)) - Index: dialin/ui/dg_simulator.py =================================================================== diff -u -r817f108b234f6652fecbda170dcaae9636feec7b -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision 817f108b234f6652fecbda170dcaae9636feec7b) +++ dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -18,11 +18,11 @@ DenaliCanMessenger, DenaliChannels) from ..utils import * -from ..utils.base import _AbstractSubSystem, _LogManager +from ..utils.base import AbstractSubSystem, LogManager from . import messageBuilder -class DGSimulator(_AbstractSubSystem): +class DGSimulator(AbstractSubSystem): instance_count = 0 def __init__(self, can_interface:str="can0", @@ -31,7 +31,7 @@ passive_mode:bool=False): super().__init__() - self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") + self._log_manager = LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") self.logger = self._log_manager.logger self.console_out = console_out self.can_interface = DenaliCanMessenger(can_interface=can_interface, Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r6356891100bf5058c4c77ac388eb23415d6435c6 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 6356891100bf5058c4c77ac388eb23415d6435c6) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -25,10 +25,10 @@ DenaliCanMessenger, DenaliChannels) from ..utils import * -from ..utils.base import _AbstractSubSystem, _LogManager +from ..utils.base import AbstractSubSystem, LogManager -class HDSimulator(_AbstractSubSystem): +class HDSimulator(AbstractSubSystem): NUM_TREATMENT_PARAMETERS = 18 instanceCount = 0 @@ -46,7 +46,7 @@ super().__init__() HDSimulator.instanceCount = HDSimulator.instanceCount + 1 - self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") + self._log_manager = LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") self.logger = self._log_manager.logger self.console_out = console_out self.can_interface = DenaliCanMessenger(can_interface=can_interface, Index: dialin/ui/hd_simulator_alarms.py =================================================================== diff -u -ra505f80795643e531cb0b0120a38a7765cbf7b9c -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/ui/hd_simulator_alarms.py (.../hd_simulator_alarms.py) (revision a505f80795643e531cb0b0120a38a7765cbf7b9c) +++ dialin/ui/hd_simulator_alarms.py (.../hd_simulator_alarms.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -21,7 +21,7 @@ DenaliCanMessenger, DenaliChannels) from logging import Logger -from ..utils.base import _AbstractSubSystem +from ..utils.base import AbstractSubSystem from ..utils.conversions import integer_to_bytearray, integer_to_bit_array, float_to_bytearray from ..common.msg_defs import MsgIds, MsgFieldPositions from ..common.alarm_defs import AlarmList @@ -102,7 +102,7 @@ ALARM_ID_DOES_NOT_EXIST = (HIGH, 99, 0, 0, 0) -class HDAlarmsSimulator(_AbstractSubSystem): +class HDAlarmsSimulator(AbstractSubSystem): instanceCount = 0 Index: dialin/utils/base.py =================================================================== diff -u -ra505f80795643e531cb0b0120a38a7765cbf7b9c -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/utils/base.py (.../base.py) (revision a505f80795643e531cb0b0120a38a7765cbf7b9c) +++ dialin/utils/base.py (.../base.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -65,7 +65,7 @@ print("CRITICAL: {0}".format(msg)) -class _LogManager: +class LogManager: LOG_FMT = '%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s' LOG_FMT_NO_METADATA = '%(message)s' @@ -206,7 +206,7 @@ return "{0}{1}{2}".format(path, i, ext) -class _AbstractSubSystem: +class AbstractSubSystem: @abstractmethod def __init__(self): @@ -232,10 +232,10 @@ self._observers.remove(observer) -def _publish(keys): +def publish(keys): """ Decorator that accepts a list of variable names to publish - To be used in any _AbstractSubSystem + To be used in any AbstractSubSystem @param keys: The variable names to publish @return: A function that will take a function and return another function Index: dialin/utils/helpers.py =================================================================== diff -u -r6780ca960d531deda7056cf910baa59826468223 -rebf0a72a1a1a52f3cfe20975de4857201275888c --- dialin/utils/helpers.py (.../helpers.py) (revision 6780ca960d531deda7056cf910baa59826468223) +++ dialin/utils/helpers.py (.../helpers.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) @@ -16,7 +16,7 @@ import logging import subprocess from datetime import datetime -from .base import _LogManager +from .base import LogManager def setup_virtual_can_interface(): @@ -208,10 +208,10 @@ ch = logging.StreamHandler() ch.setLevel(numeric_level) if enable_metadata: - formatter = logging.Formatter(fmt=_LogManager.LOG_FMT, - datefmt=_LogManager.LOG_DT_FMT) + formatter = logging.Formatter(fmt=LogManager.LOG_FMT, + datefmt=LogManager.LOG_DT_FMT) else: - formatter = logging.Formatter(fmt=_LogManager.LOG_FMT_NO_METADATA) + formatter = logging.Formatter(fmt=LogManager.LOG_FMT_NO_METADATA) fh.setFormatter(formatter) ch.setFormatter(formatter)