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,