Index: dialin/hd/ui_proxy.py =================================================================== diff -u -rcd24d55a5ed87035a19f38b44d1d49f61a186a3b -r089bdbd0666ffeef307621beb61d8a2e429b1a30 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision cd24d55a5ed87035a19f38b44d1d49f61a186a3b) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 089bdbd0666ffeef307621beb61d8a2e429b1a30) @@ -37,6 +37,8 @@ MSG_ID_TREATMENT_DURATION_SETTING_CHANGE_RESPONSE_FROM_HD = 0x001B MSG_ID_BLOOD_DIALYSATE_FLOW_SETTING_CHANGE_REQUEST_BY_USER = 0x0017 MSG_ID_BLOOD_DIALYSATE_FLOW_SETTING_CHANGE_RESPONSE_FROM_HD = 0x0018 + MSG_ID_UI_REQUEST_HD_VERSION = 0x001C + MSG_ID_UI_HD_VERSION_RESPONSE = 0x001D LITER_TO_ML_CONVERSION_FACTOR = 1000.0 UF_CMD_PAUSE = 0 @@ -46,6 +48,14 @@ RESPONSE_REJECTED = 0 RESPONSE_ACCEPTED = 1 + # HD version message field positions + START_POS_MAJOR = DenaliMessage.PAYLOAD_START_INDEX + END_POS_MAJOR = START_POS_MAJOR + 1 + START_POS_MINOR = END_POS_MAJOR + END_POS_MINOR = START_POS_MINOR + 1 + START_POS_BUILD = END_POS_MINOR + END_POS_BUILD = START_POS_BUILD + 2 + # HD update on valid treatment parameter ranges message field positions START_POS_MIN_TREAT_TIME = DenaliMessage.PAYLOAD_START_INDEX END_POS_MIN_TREAT_TIME = START_POS_MIN_TREAT_TIME + 4 @@ -118,7 +128,11 @@ self.handler_blood_and_dialysate_change_response) self.can_interface.register_receiving_publication_function(channel_id, self.MSG_ID_HD_TREATMENT_PARAMS_RANGES, self.handler_treatment_param_ranges) + self.can_interface.register_receiving_publication_function(DenaliChannels.hd_to_ui_ch_id, self.MSG_ID_UI_HD_VERSION_RESPONSE, + self.handler_hd_version) + # initialize variables that will be populated by HD version response + self.hd_version = '' # initialize variables that will be populated by treatment parameter ranges message self.min_treatment_duration_min = 0 self.max_treatment_duration_min = 0 @@ -145,6 +159,26 @@ self.target_blood_flow_rate = 0 self.target_dialysate_flow_rate = 0 + def handler_hd_version(self, message): + """ + Handler for response from HD regarding its version. + + \param message: response message from HD regarding valid treatment parameter ranges.\n + U08 Major \n + U08 Minor \n + U16 Build \n + + \returns none + """ + major = struct.unpack('B', bytearray( + message['message'][self.START_POS_MAJOR:self.END_POS_MAJOR])) + minor = struct.unpack('B', bytearray( + message['message'][self.START_POS_MINOR:self.END_POS_MINOR])) + build = struct.unpack('H', bytearray( + message['message'][self.START_POS_BUILD:self.END_POS_BUILD])) + + self.hd_version = 'v'+str(major)+'.'+str(minor)+'.'+str(build) + def handler_treatment_param_ranges(self, message): """ Handler for response from HD regarding valid treatment parameter ranges. @@ -293,6 +327,22 @@ return 0 + def cmd_ui_request_hd_version(self): + """ + Constructs and sends the ui request for version message + + \returns 0 + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=self.MSG_ID_UI_REQUEST_HD_VERSION) + + print("Sending ui request for version to HD") + + self.can_interface.send(message, 0) + + return 0 + def cmd_ui_uf_pause_resume(self, cmd=UF_CMD_PAUSE): """ Constructs and sends a ui UF command message