Index: dialin/__init__.py =================================================================== diff -u -r82e32ae00355b2245a2660569935de152a883799 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/__init__.py (.../__init__.py) (revision 82e32ae00355b2245a2660569935de152a883799) +++ dialin/__init__.py (.../__init__.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -1,4 +1,4 @@ -from .version import VERSION +from .version import * from .hd import * from .dg import * from .ui import * Index: dialin/common/alarm_defs.py =================================================================== diff -u -rbe97d97e1ddd765351cdc51cb75aee9e7e63ba58 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/common/alarm_defs.py (.../alarm_defs.py) (revision be97d97e1ddd765351cdc51cb75aee9e7e63ba58) +++ dialin/common/alarm_defs.py (.../alarm_defs.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -8,9 +8,9 @@ # @file alarm_defs.py # # @author (last) Peter Lucia -# @date (last) 20-Apr-2021 +# @date (last) 27-Apr-2021 # @author (original) Peter Lucia -# @date (original) 20-Apr-2021 +# @date (original) 27-Apr-2021 # ############################################################################ from enum import unique @@ -203,3 +203,13 @@ ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT = 181 ALARM_ID_DIALYSATE_TEMPERATURE_HIGH = 182 ALARM_ID_DIALYSATE_TEMPERATURE_LOW = 183 + ALARM_ID_DG_VOLTAGE_OUT_OF_RANGE = 184 + ALARM_ID_DG_DRAIN_CIRCULATION_LINE_TIMEOUT = 185 + ALARM_ID_DG_INVALID_LOAD_CELL_VALUE = 186 + ALARM_ID_HD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR = 187 + ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR = 188 + ALARM_ID_HD_SYRINGE_PUMP_FAULT = 189 + ALARM_ID_HD_SYRINGE_PUMP_OVER_TRAVEL_ERROR = 190 + ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM = 191 + ALARM_ID_HD_SYRINGE_PUMP_DAC_WRITE_ERROR = 192 + ALARM_ID_HD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR = 193 Index: dialin/common/msg_defs.py =================================================================== diff -u -rbe687b87ec7dbbb312fc9dc67fd422119e43e64c -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision be687b87ec7dbbb312fc9dc67fd422119e43e64c) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -21,7 +21,11 @@ # Define msg ids that are not yet added to common but are needed in dialin @unique class MsgIdsDialin(DialinEnum): - pass + DMSG_ID_HD_SERIAL_NUMBER_RESPONSE = 0X87 + DMSG_ID_DG_SERIAL_NUMBER_RESPONSE = 0X88 + DMSG_ID_UI_SYSTEM_USAGE_REQUEST = 0x89 + DMSG_ID_HD_SYSTEM_USAGE_RESPONSE = 0x8A + DMSG_ID_DG_SYSTEM_USAGE_RESPONSE = 0x8C # extend MsgIds for each in MsgIdsDialin: Index: dialin/common/msg_ids.py =================================================================== diff -u -rbe97d97e1ddd765351cdc51cb75aee9e7e63ba58 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision be97d97e1ddd765351cdc51cb75aee9e7e63ba58) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -8,9 +8,9 @@ # @file msg_ids.py # # @author (last) Peter Lucia -# @date (last) 20-Apr-2021 +# @date (last) 27-Apr-2021 # @author (original) Peter Lucia -# @date (original) 20-Apr-2021 +# @date (original) 27-Apr-2021 # ############################################################################ from enum import unique @@ -211,7 +211,7 @@ MSG_ID_HD_SEND_SERVICE_RECORD = 0X8045 MSG_ID_HD_SET_OP_MODE_REQUEST = 0X8046 MSG_ID_HD_FLUID_LEAK_SEND_INTERVAL_OVERRIDE = 0X8047 - MSG_ID_HD_FLUID_LEAK_STATE_DETECTOR_OVERRIDE = 0X8048 + MSG_ID_HD_FLUID_LEAK_STATE_OVERRIDE = 0X8048 MSG_ID_HD_SYRINGE_PUMP_MEASURED_HOME_OVERRIDE = 0X8049 MSG_ID_HD_SYRINGE_PUMP_MEASURED_POSITION_OVERRIDE = 0X804A MSG_ID_HD_SYRINGE_PUMP_MEASURED_VOLUME_OVERRIDE = 0X804B @@ -225,6 +225,7 @@ MSG_ID_HD_ALARM_AUDIO_CURRENT_HG_OVERRIDE = 0X8054 MSG_ID_HD_ALARM_AUDIO_CURRENT_LG_OVERRIDE = 0X8055 MSG_ID_HD_ALARM_BACKUP_AUDIO_CURRENT_OVERRIDE = 0X8056 + MSG_ID_DG_VOLTAGES_DATA = 0X86 MSG_ID_PRESSURE_OCCLUSION_DATA = 0X9 MSG_ID_CAN_ERROR_COUNT = 0X999 MSG_ID_RTC_EPOCH = 0XA @@ -252,8 +253,8 @@ MSG_ID_DG_ACCEL_OVERRIDE = 0XA017 MSG_ID_DG_ACCEL_MAX_OVERRIDE = 0XA018 MSG_ID_DG_ACCEL_SEND_INTERVAL_OVERRIDE = 0XA019 - MSG_ID___AVAILABLE_11 = 0XA01A - MSG_ID___AVAILABLE_17 = 0XA01B + MSG_ID_DG_MONITORED_VOLTAGES_SEND_INTERVAL_OVERRIDE = 0XA01A + MSG_ID_DG_MONITORED_VOLTAGES_OVERRIDE = 0XA01B MSG_ID_DRAIN_PUMP_SET_DELTA_PRESSURE_OVERRIDE = 0XA01C MSG_ID___AVAILABLE_12 = 0XA01D MSG_ID___AVAILABLE_13 = 0XA01E Index: dialin/hd/ui_proxy.py =================================================================== diff -u -rdff57c4c3c6364cbfe585eda9143302e94964937 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision dff57c4c3c6364cbfe585eda9143302e94964937) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -1002,7 +1002,7 @@ "treatment_end_cmd_succeeded", "treatment_end_cmd_reject_reason", ]) - def _handler_treatment_end_cmd_response(self, message): + def _handler_treatment_end_cmd_response(self, message: dict) -> None: """ Handler for response from HD regarding treatment end user command. @@ -1069,7 +1069,7 @@ self.logger.debug("Sending ui request to set alarm audio volume to level " + str(volume) + " to HD") self.can_interface.send(message, 0) - def cmd_ui_uf_volume_set(self, uf_volume): + def cmd_ui_uf_volume_set(self, uf_volume: float): """ Constructs and sends the ui set ultrafiltration volume parameter message @@ -1153,13 +1153,12 @@ self.can_interface.send(message, 0) - def cmd_ui_treatment_duration_setting_change_request(self, time_min=0): + def cmd_ui_treatment_duration_setting_change_request(self, time_min: int = 0): """ - Constructs and sends a ui UF change settings confirmed by user message + Constructs and sends a ui UF change settings confirmed by user message - @param time_min: (int) treatment time (in min). - - @return: None + @param time_min: (int) treatment time (in min). + @return: None """ payload = integer_to_bytearray(time_min) Index: dialin/protocols/CAN.py =================================================================== diff -u -r20659ffd56482b0596253aa0f1f1a7eda1221945 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/protocols/CAN.py (.../CAN.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) +++ dialin/protocols/CAN.py (.../CAN.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -278,7 +278,7 @@ 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 : None, + 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 Index: dialin/ui/dg_simulator.py =================================================================== diff -u -rbe687b87ec7dbbb312fc9dc67fd422119e43e64c -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision be687b87ec7dbbb312fc9dc67fd422119e43e64c) +++ dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -16,20 +16,22 @@ import struct from ..utils import YES -from ..common.msg_defs import MsgIds +from ..common import * from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) from ..utils.base import _AbstractSubSystem, _LogManager from ..utils.conversions import integer_to_bytearray, float_to_bytearray, byte_to_bytearray, short_to_bytearray from . import messageBuilder -from ..common import GuiActionType class DGSimulator(_AbstractSubSystem): instance_count = 0 - def __init__(self, can_interface="can0", log_level=None, console_out=False): + def __init__(self, can_interface:str="can0", + log_level:str=None, + console_out:bool=False, + passive_mode:bool=False): super().__init__() self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") @@ -38,15 +40,40 @@ self.can_interface = DenaliCanMessenger(can_interface=can_interface, logger=self.logger, log_can=self._log_manager.log_level == "CAN_ONLY", - console_out=console_out) + console_out=console_out, + passive_mode=passive_mode) self.can_interface.start() if self.can_interface is not None: channel_id = DenaliChannels.ui_to_hd_ch_id self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_DG_SET_RTC_REQUEST.value, self._handler_set_rtc_request) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIds.MSG_ID_REQUEST_FW_VERSIONS.value, + self._handler_request_dg_version) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIdsDialin.DMSG_ID_UI_SYSTEM_USAGE_REQUEST.value, + self._handler_system_usage_response) + def _handler_system_usage_response(self, message: dict) -> None: + """ + Handles a request for system usage + + @param message: (dict) the message + @return: None + """ + self.logger.debug("Handling request for system usage.") + + payload = integer_to_bytearray(1619628663) + payload += integer_to_bytearray(1619887863) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIdsDialin.DMSG_ID_DG_SYSTEM_USAGE_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def _handler_set_rtc_request(self, message: dict) -> None: """ Handles a request to set the DG RTC @@ -95,7 +122,6 @@ self.can_interface.send(message, 0) - def cmd_set_dg_ro_pump_data(self, vSetPtPressure, vFlowRate, vPWM): """ the DG RO Pump Data message setter/sender method @@ -391,6 +417,31 @@ self.can_interface.send(message, 0) + def _handler_request_dg_version(self, message: dict) -> None: + """ + Handles a request for the HD version + + @param message: (dict) the received message + @return: None + """ + self.logger.debug("Handling request for dg version.") + + self.cmd_send_version_dg_data(9, 9, 9, 9, 9, 9, 9, 9) + self.cmd_send_dg_serial_number() + + def cmd_send_dg_serial_number(self) -> None: + """ + Sends the dg serial number + @return: None + """ + payload = b'0123456789\0' + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIdsDialin.DMSG_ID_DG_SERIAL_NUMBER_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_version_dg_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): """ the hd version response message method @@ -431,3 +482,4 @@ txt = messageBuilder.textToByte(vText, message_length) # + 1 null term msg = messageBuilder.buildMessage(GuiActionType.DGDebugText, 1 * (message_length + 1), False, txt) return messageBuilder.toFrames(msg) + Index: dialin/ui/hd_simulator.py =================================================================== diff -u -rba6d26ee1006f3fd215a5c11a078b20006a489d4 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision ba6d26ee1006f3fd215a5c11a078b20006a489d4) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -21,10 +21,8 @@ import subprocess from . import messageBuilder -from ..common import TreatmentParameterRejections, GuiActionType, EResponse, TXStates from .hd_simulator_alarms import HDAlarmsSimulator -from ..common.msg_defs import RequestRejectReasons, MsgIds, MsgFieldPositions -from ..common.hd_defs import HDOpModes +from ..common import * from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) @@ -37,7 +35,10 @@ NUM_TREATMENT_PARAMETERS = 18 instanceCount = 0 - def __init__(self, can_interface="can0", log_level=None, console_out=False): + def __init__(self, can_interface:str="can0", + log_level:bool= None, + console_out:bool= False, + passive_mode:bool=False): """ The HDSimulator constructor @@ -54,7 +55,8 @@ self.can_interface = DenaliCanMessenger(can_interface=can_interface, logger=self.logger, log_can=self._log_manager.log_level == "CAN_ONLY", - console_out=console_out) + console_out=console_out, + passive_mode=passive_mode) self.can_interface.start() if self.can_interface is not None: @@ -77,17 +79,33 @@ self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_HD_SET_RTC_REQUEST.value, self._handler_set_rtc_request) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIds.MSG_ID_REQUEST_FW_VERSIONS.value, + self._handler_request_hd_version) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIdsDialin.DMSG_ID_UI_SYSTEM_USAGE_REQUEST.value, + self._handler_system_usage_response) self.alarms_simulator = HDAlarmsSimulator(self.can_interface, self.logger) self.treatment_parameter_rejections = TreatmentParameterRejections() - def alarm(self) -> HDAlarmsSimulator: + def _handler_system_usage_response(self, message: dict) -> None: """ - Gets the alarm simulator object - @return: (HDAlarmsSimulator) the alarms simulator + Handles a request for system usage + + @param message: (dict) the message + @return: None """ - return self.alarms_simulator + + payload = integer_to_bytearray(1619628663) + payload += integer_to_bytearray(1619887863) + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIdsDialin.DMSG_ID_HD_SYSTEM_USAGE_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def _handler_set_rtc_request(self, message: dict) -> None: """ Handles a UI request to set the HD RTC @@ -123,7 +141,6 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_parameter_validation_response(self, rejections: List[RequestRejectReasons]): """ Sends a treatment parameter validation response @@ -1354,6 +1371,34 @@ self.can_interface.send(message, 0) + def _handler_request_hd_version(self, message: dict): + """ + Handles a request for the HD version + + @param message: (dict) the received message + @return: None + """ + + self.logger.debug("Handling request for hd version.") + self.cmd_send_version_hd_data(9, 9, 9, 9, 9, 9, 9, 9) + self.cmd_send_hd_serial_number() + + def cmd_send_hd_serial_number(self): + """ + Sends the hd serial number response + + @return: None + """ + self.logger.debug("Sending hd serial number...") + + payload = bytearray('0123456789\0', encoding="utf-8") + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIdsDialin.DMSG_ID_HD_SERIAL_NUMBER_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_version_hd_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): """ the hd version response message method @@ -1382,3 +1427,10 @@ payload=payload) self.can_interface.send(message, 0) + + def alarm(self) -> HDAlarmsSimulator: + """ + Gets the alarm simulator object + @return: (HDAlarmsSimulator) the alarms simulator + """ + return self.alarms_simulator Index: dialin/version.py =================================================================== diff -u -ra04732a70009aecac79c06fedbf69e217b7304df -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- dialin/version.py (.../version.py) (revision a04732a70009aecac79c06fedbf69e217b7304df) +++ dialin/version.py (.../version.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -61,8 +61,8 @@ if check_if_git_repo(): branch = get_branch() commit = get_last_commit() - DEV_VERSION += "-{0}".format(branch) - DEV_VERSION += "-{0}".format(commit) + DEV_VERSION += ".{0}".format(branch) + DEV_VERSION += ".{0}".format(commit) if __name__ == '__main__': Index: setup.py =================================================================== diff -u -rad86414f76929e8ee94543f7815234837bb90073 -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 --- setup.py (.../setup.py) (revision ad86414f76929e8ee94543f7815234837bb90073) +++ setup.py (.../setup.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) @@ -14,7 +14,7 @@ # ############################################################################ import setuptools -from version import VERSION +from version import * setuptools.setup( name="dialin",