Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -r5994adea1a1022175f9cc4e6dacfa02de3fc45a0 -r5ee0dd4d1d95856defa2a8f20936d5080da62bd5 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 5994adea1a1022175f9cc4e6dacfa02de3fc45a0) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 5ee0dd4d1d95856defa2a8f20936d5080da62bd5) @@ -197,10 +197,6 @@ MSG_ID_TD_DRY_SELF_TEST_PROGRESS_DATA = 0xAE MSG_ID_TD_TUBE_SET_AUTHENTICATION_REQUEST = 0xAF MSG_ID_UI_TUBE_SET_AUTHENTICATION_ACK_RESPONSE = 0xB0 - MSG_ID_TD_TREATMENT_LOG_AVERAGE_DATA = 0xAD - MSG_ID_TD_DRY_SELF_TEST_PROGRESS_DATA = 0xAE - MSG_ID_TD_TUBE_SET_AUTHENTICATION_REQUEST = 0xAF - MSG_ID_UI_TUBE_SET_AUTHENTICATION_ACK_RESPONSE = 0xB0 MSG_ID_TD_SYRINGE_PUMP_DATA = 0xB1 MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE= 0xB2 MSG_ID_FFU_SIGNAL_TD_UPDATE_AVAILABLE = 0xB3 @@ -212,31 +208,31 @@ MSG_ID_TD_VITALS_ADJUSTMENT_RESPONSE = 0xB9 MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST = 0xBA MSG_ID_DD_NVM_SYSTEM_RECORD_RESPONSE = 0xBB - MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD = 0xBC + MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST = 0xBC MSG_ID_DD_NVM_SERVICE_RECORD_RESPONSE = 0xBD - MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD = 0xBE + MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST = 0xBE MSG_ID_DD_NVM_INSTITUTIONAL_RECORD_RESPONSE = 0xBF - MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD = 0xC0 + MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD_REQUEST = 0xC0 MSG_ID_DD_NVM_USAGE_INFO_RECORD_RESPONSE = 0xC1 - MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD = 0xC2 + MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST = 0xC2 MSG_ID_DD_NVM_CAL_PRESSURE_SENSOR_RESPONSE = 0xC3 - MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR = 0xC4 + MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST = 0xC4 MSG_ID_DD_NVM_CAL_TEMP_SENSOR_RESPONSE = 0xC5 - MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR = 0xC6 + MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST = 0xC6 MSG_ID_DD_NVM_CAL_CONC_PUMP_RESPONSE = 0xC7 - MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP = 0xC8 + MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST = 0xC8 MSG_ID_DD_NVM_CAL_D12_PUMP_RESPONSE = 0xC9 - MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP = 0xCA + MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST = 0xCA MSG_ID_DD_NVM_CAL_D48_PUMP_RESPONSE = 0xCB - MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP = 0xCC + MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST = 0xCC MSG_ID_DD_NVM_CAL_ACID_CONCENTRATE_RESPONSE = 0xCD - MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE = 0xCE + MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST = 0xCE MSG_ID_DD_NVM_CAL_BICARB_CONCENTRATE_RESPONSE = 0xCF - MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE = 0xD0 + MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST = 0xD0 MSG_ID_DD_NVM_CAL_ACCEL_SENSOR_RESPONSE = 0xD1 - MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR = 0xD2 + MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR_REQUEST = 0xD2 MSG_ID_DD_NVM_CAL_BLOOD_LEAK_SENSOR_RESPONSE = 0xD3 - MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR = 0xD4 + MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_REQUEST = 0xD4 MSG_ID_DD_NVM_RECORD_CRC_OVERRIDE_REQUEST = 0xD5 MSG_ID_UI_SETUP_CONNECTION_CONFIRM_REQUEST = 0xD6 MSG_ID_TD_SETUP_CONNECTION_CONFIRM_RESPONSE = 0xD7 @@ -247,20 +243,20 @@ MSG_ID_DD_CONDUCTIVITY_SENSOR_RESISTANCE_DATA = 0xDC MSG_ID_FP_FILTER_FLUSH_DATA = 0xDD MSG_ID_FP_PERMEATE_FLUSH_DATA = 0xDE - TBD_DF = 0xDF - TBD_E0 = 0xE0 - TBD_E1 = 0xE1 - TBD_E2 = 0xE2 - TBD_E3 = 0xE3 - TBD_E4 = 0xE4 - TBD_E5 = 0xE5 - TBD_E6 = 0xE6 - TBD_E7 = 0xE7 - TBD_E8 = 0xE8 - TBD_E9 = 0xE9 - TBD_EA = 0xEA - TBD_EB = 0xEB - TBD_EC = 0xEC + MSG_ID_DD_NVM_GET_RECORD_RESPONSE = 0xDF + MSG_ID_DD_NVM_SET_SYSTEM_RECORD_RESPONSE = 0xE0 + MSG_ID_DD_NVM_SET_SERVICE_RECORD_RESPONSE = 0xE1 + MSG_ID_DD_NVM_SET_INSTITUTIONAL_RECORD_RESPONSE = 0xE2 + MSG_ID_DD_NVM_SET_USAGE_INFO_RECORD_RESPONSE = 0xE3 + MSG_ID_DD_NVM_SET_CAL_PRESSURE_SENSOR_RESPONSE = 0xE4 + MSG_ID_DD_NVM_SET_CAL_TEMP_SENSOR_RESPONSE = 0xE5 + MSG_ID_DD_NVM_SET_CAL_CONC_PUMP_RESPONSE = 0xE6 + MSG_ID_DD_NVM_SET_CAL_D12_PUMP_RESPONSE = 0xE7 + MSG_ID_DD_NVM_SET_CAL_D48_PUMP_RESPONSE = 0xE8 + MSG_ID_DD_NVM_SET_CAL_ACID_CONCENTRATE_RESPONSE = 0xE9 + MSG_ID_DD_NVM_SET_CAL_BICARB_CONCENTRATE_RESPONSE = 0xEA + MSG_ID_DD_NVM_SET_CAL_ACCEL_SENSOR_RESPONSE = 0xEB + MSG_ID_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_RESPONSE = 0xEC TBD_ED = 0xED TBD_EE = 0xEE TBD_EF = 0xEF Index: leahi_dialin/dd/modules/records.py =================================================================== diff -u -rd9fb3a77c1d91225ab0e925398458f6d2f71f8ce -r5ee0dd4d1d95856defa2a8f20936d5080da62bd5 --- leahi_dialin/dd/modules/records.py (.../records.py) (revision d9fb3a77c1d91225ab0e925398458f6d2f71f8ce) +++ leahi_dialin/dd/modules/records.py (.../records.py) (revision 5ee0dd4d1d95856defa2a8f20936d5080da62bd5) @@ -45,6 +45,7 @@ self.logger = logger if self.can_interface is not None: + # Data Request Response messages self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, message_id = MsgIds.MSG_ID_DD_NVM_SYSTEM_RECORD_RESPONSE.value, function = self._handler_system_record_sync) @@ -84,19 +85,44 @@ self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, message_id = MsgIds.MSG_ID_DD_NVM_USAGE_INFO_RECORD_RESPONSE.value, function = self._handler_usage_info_record_sync) + # Set Data Response messages + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.dd_sync_broadcast_ch_id, + message_id = MsgIds.MSG_ID_DD_NVM_SET_USAGE_INFO_RECORD_RESPONSE.value, + function = self._handler_usage_info_rr_sync) + - self.system_records_timestamp = 0 #: The timestamp of the latest System Records message - self.service_records_timestamp = 0 #: The timestamp of the latest Service Records message - self.calibration_records_timestamp = 0 #: The timestamp of the latest Calibration Records message - self.institutional_records_timestamp = 0 #: The timestamp of the latest Institutional Records message - self.usage_info_records_timestamp = 0 #: The timestamp of the latest Usage Information Records message + self.system_records_timestamp = 0 #: The timestamp of the latest System Records message + self.system_set_rr_timestamp = 0 #: The timestamp of the latest Set System Reject Reason message + self.service_records_timestamp = 0 #: The timestamp of the latest Service Records message + self.service_set_rr_timestamp = 0 #: The timestamp of the latest Set Service Reject Reason message + self.calibration_records_timestamp = 0 #: The timestamp of the latest Calibration Records message + self.calibration_set_rr_timestamp = 0 #: The timestamp of the latest Set Calibration Reject Reason message + self.institutional_records_timestamp = 0 #: The timestamp of the latest Institutional Records message + self.institutional_set_rr_timestamp = 0 #: The timestamp of the latest Set Institutional Reject Reason message + self.usage_info_records_timestamp = 0 #: The timestamp of the latest Usage Information Records message + self.usage_info_set_rr_timestamp = 0 #: The timestamp of the latest Set Usage Information Reject Reason message - self.system_records = { } #: The System Records data in dictionary format - self.service_records = { } #: The Service Records data in dictionary format - self.calibration_records = { } #: The Calibration Records data in dictionary format - self.institutional_records = { } #: The Institutional Records data in dictionary format - self.usage_info_records = { } #: The Usage Information Records data in dictionary format + self.system_records = { } #: The System Records data in dictionary format + self.system_records_ack = { } #: The Set System Records message acceptance + self.system_records_rr = { } #: The Set System Records message reject reason + self.service_records = { } #: The Service Records data in dictionary format + self.service_records_ack = { } #: The Set Service Records message acceptance + self.service_records_rr = { } #: The Set Service Records message reject reason + + self.calibration_records = { } #: The Calibration Records data in dictionary format + self.calibration_records_ack = { } #: The Set Calibration Records message acceptance + self.calibration_records_rr = { } #: The Set Calibration Records message reject reason + + self.institutional_records = { } #: The Institutional Records data in dictionary format + self.institutional_records_ack = { } #: The Set Institutional Records message acceptance + self.institutional_records_rr = { } #: The Set Institutional Records message reject reason + + + self.usage_info_records = { } #: The Usage Information Records data in dictionary format + self.usage_info_ack = { } #: The Set Usage Information Records message acceptance + self.usage_info_rr = { } #: The Set Usage Information Records message reject reason + for sys_record in dd_enum_repository.SystemRecordFields: if 'num_' not in sys_record.name: self.system_records[sys_record.name] = None @@ -174,7 +200,11 @@ msg_list = [('sensor_id', DataTypes.U08)] result = self.process_into_vars(decoder_list = msg_list, message = message) - sensor_name = dd_enum_repository.DDPressureSensorNames(result['sensor_id']).name + if int(result['sensor_id']) < dd_enum_repository.DDPressureSensorNames.NUM_OF_PRESSURE_SENSORS.value: + sensor_name = dd_enum_repository.DDPressureSensorNames(result['sensor_id']).name + else: + fp_sensor_id = int(result['sensor_id']) - dd_enum_repository.DDPressureSensorNames.NUM_OF_PRESSURE_SENSORS.value + sensor_name = fp_enum_repository.FPPressureSensorNames(fp_sensor_id).name record_list = [] for member in dd_enum_repository.CalibRecordSensorFields: @@ -444,6 +474,84 @@ self.usage_info_records_timestamp = timestamp +# ================================================= Reject Reason Message Handler Methods ================================================= + @publish(["msg_id_dd_nvm_set_system_record_response", "system_records_ack", "system_records_rr", "system_set_rr_timestamp"]) + def _handler_system_rr_sync(self, message, timestamp = 0.0): + """ + Handles published DD Set System Records Reject Reason data messages. DD Set System Records Reject Reason are captured + for reference. + + @param message: published data message + @return: none + """ + msg_list = [] + msg_list.append(('self.system_records_ack', DataTypes.BOOL)) + msg_list.append(('self.system_records_rr', DataTypes.U32)) + + self.process_into_vars(decoder_list = msg_list, + message = message) + + self.system_set_rr_timestamp = timestamp + + + @publish(["msg_id_dd_nvm_set_service_record_response", "system_records_ack", "service_records_rr", "service_set_rr_timestamp"]) + def _handler_service_rr_sync(self, message, timestamp = 0.0): + """ + Handles published DD Set Service Records Reject Reason data messages. DD Set Service Records Reject Reason are captured + for reference. + + @param message: published data message + @return: none + """ + msg_list = [] + msg_list.append(('self.service_records_ack', DataTypes.BOOL)) + msg_list.append(('self.service_records_rr', DataTypes.U32)) + + self.process_into_vars(decoder_list = msg_list, + message = message) + + self.service_set_rr_timestamp = timestamp + + + @publish(["msg_id_dd_nvm_set_institutional_record_response", "institutional_records_ack", "institutional_records_rr", "id", "institutional_set_rr_timestamp"]) + def _handler_institutional_rr_sync(self, message, timestamp = 0.0): + """ + Handles published DD Set Institutional Records Reject Reason data messages. DD Set Institutional Records Reject Reason are captured + for reference. + + @param message: published data message + @return: none + """ + msg_list = [] + msg_list.append(('self.institutional_records_ack', DataTypes.BOOL)) + msg_list.append(('self.institutional_records_rr', DataTypes.U32)) + msg_list.append(('self.id', DataTypes.U32)) + + self.process_into_vars(decoder_list = msg_list, + message = message) + + self.institutional_set_rr_timestamp = timestamp + + + @publish(["msg_id_dd_nvm_set_usage_info_record_response", "usage_info_ack", "usage_info_rr", "usage_info_set_rr_timestamp"]) + def _handler_usage_info_rr_sync(self, message, timestamp = 0.0): + """ + Handles published DD Set Usage Information Records Reject Reason data messages. DD Set Usage Information Records Reject Reason are captured + for reference. + + @param message: published data message + @return: none + """ + msg_list = [] + msg_list.append(('self.usage_info_ack', DataTypes.BOOL)) + msg_list.append(('self.usage_info_rr', DataTypes.U32)) + + self.process_into_vars(decoder_list = msg_list, + message = message) + + self.usage_info_set_rr_timestamp = timestamp + + # ================================================= Go to Service Mode Method ================================================= def cmd_initiate_service_mode(self) -> int: """ @@ -615,7 +723,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD, + msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST, entity_name = f'New DD System Record', override_text = 'being set', logger = self.logger, @@ -649,7 +757,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD, + msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST, entity_name = f'New DD Service Record', override_text = 'being set', logger = self.logger, @@ -667,14 +775,14 @@ @return: 1 if successful, zero otherwise """ msg_id_pairing = { - 'PRES': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR, - 'TEMP': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR, - 'CONC': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP, - 'DIAL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP, - 'ACID': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE, - 'BICARB': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE, - 'ACCEL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR, - 'BLOOD_LEAK': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR, + 'PRES': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST, + 'TEMP': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST, + 'CONC': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST, + 'DIAL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST, + 'ACID': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST, + 'BICARB': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST, + 'ACCEL': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR_REQUEST, + 'BLOOD_LEAK': MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_REQUEST, } # Make a dictionary to store all the send functions for later send send_data = [] @@ -717,7 +825,7 @@ kwargs['sensor_enum'] = sensor if sensor == dd_enum_repository.DDDialysatePumpNames.D12_PUMP: - kwargs['msg_id'] = MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP + kwargs['msg_id'] = MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST else: kwargs['msg_id'] = msg_id_pairing[group] @@ -905,7 +1013,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD, + msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD_REQUEST, entity_name = f'DD Institutional Record', override_text = 'being set', logger = self.logger, @@ -955,7 +1063,7 @@ payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, - msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD, + msg_id = MsgIds.MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST, entity_name = f'New DD Usage Information Record', override_text = 'being set', logger = self.logger, @@ -979,7 +1087,7 @@ else: payload_sensor = byte_to_bytearray(sensor_enum.value) payload_content = b'' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP: + if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST: payload_content += float_to_bytearray(dialysate_pump_target_speed) payload_content += float_to_bytearray(forth_order_coeff) payload_content += float_to_bytearray(third_order_coeff) @@ -991,13 +1099,13 @@ payload = payload_sensor + payload_content sensor_type = '' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR: + if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST: sensor_type = 'Pressure Sensor' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR: + elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST: sensor_type = 'Temperature Sensor' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP: + elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST: sensor_type = 'Concentrate Pump' - elif msg_id in [MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP, MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP]: + elif msg_id in [MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST, MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST]: sensor_type = 'Dialysate Pump' return cmd_generic_override(payload = payload, @@ -1029,9 +1137,9 @@ payload = payload_sensor + payload_content conc_type = '' - if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE: + if msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST: conc_type = 'Acid' - elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE: + elif msg_id == MsgIds.MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST: conc_type = 'Bicarb' return cmd_generic_override(payload = payload,