Index: leahi_dialin/dd/modules/records.py =================================================================== diff -u -rc1bff8da59cff294d67d90dd1e1f102dd5b65466 -rc8bafcb198910f30a8fb1c37024050b2c20ea898 --- leahi_dialin/dd/modules/records.py (.../records.py) (revision c1bff8da59cff294d67d90dd1e1f102dd5b65466) +++ leahi_dialin/dd/modules/records.py (.../records.py) (revision c8bafcb198910f30a8fb1c37024050b2c20ea898) @@ -119,7 +119,7 @@ # ================================================= CAN Message Handler Methods ================================================= - @publish(["msg_id_dd_nvm_send_system_record", "system_records", "system_records_timestamp"]) + @publish(["msg_id_dd_nvm_send_system_record_response", "system_records", "system_records_timestamp"]) def _handler_system_record_sync(self, message, timestamp = 0.0): """ Handles published DD System Record data messages. DD System Records are captured @@ -139,7 +139,7 @@ self.system_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_service_record", "service_records", "service_records_timestamp"]) + @publish(["msg_id_dd_nvm_send_service_record_response", "service_records", "service_records_timestamp"]) def _handler_service_record_sync(self, message, timestamp = 0.0): """ Handles published DD Service Record data messages. DD Service Records are captured @@ -159,7 +159,7 @@ self.service_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_pressure_sensor_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_pres_sensor_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Pressure Sensor Details data messages. @@ -169,7 +169,7 @@ @return: none """ # Get the sensor_id to identify the location of the payload - msg_list = [('sensor_id', DataTypes.U08)] + msg_list = [('sensor_id', DataTypes.U32)] result = self.process_into_vars(decoder_list = msg_list, message = message) sensor_name = dd_enum_repository.DDPressureSensorNames(result['sensor_id']).name @@ -181,12 +181,12 @@ self.process_into_dict(dict_to_update = self.calibration_records, decoder_list = record_list, message = message, - start_from_byte = len(msg_list) * DataTypes.U08.size()) + start_from_byte = len(msg_list) * msg_list[0][1].size()) self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_temp_sensor_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_temp_sensor_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Temperature Sensor Details data messages. @@ -196,7 +196,7 @@ @return: none """ # Get the sensor_id to identify the location of the payload - msg_list = [('sensor_id', DataTypes.U08)] + msg_list = [('sensor_id', DataTypes.U32)] result = self.process_into_vars(decoder_list = msg_list, message = message) sensor_name = dd_enum_repository.DDTemperatureSensorNames(result['sensor_id']).name @@ -208,12 +208,12 @@ self.process_into_dict(dict_to_update = self.calibration_records, decoder_list = record_list, message = message, - start_from_byte = len(msg_list) * DataTypes.U08.size()) + start_from_byte = len(msg_list) * msg_list[0][1].size()) self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_conc_pump_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_conc_pump_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Concentrate Pump Details data messages. @@ -223,7 +223,7 @@ @return: none """ # Get the sensor_id to identify the location of the payload - msg_list = [('sensor_id', DataTypes.U08)] + msg_list = [('sensor_id', DataTypes.U32)] result = self.process_into_vars(decoder_list = msg_list, message = message) sensor_name = dd_enum_repository.DDConcentratePumpNames(result['sensor_id']).name @@ -235,12 +235,12 @@ self.process_into_dict(dict_to_update = self.calibration_records, decoder_list = record_list, message = message, - start_from_byte = len(msg_list) * DataTypes.U08.size()) + start_from_byte = len(msg_list) * msg_list[0][1].size()) self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_d12_pump_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_dial_pump_d12_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Dialysate Pump D12 Details data messages. @@ -261,7 +261,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_d48_pump_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_dial_pump_d48_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Dialysate Pump D48 Details data messages. @@ -281,7 +281,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_acid_concentrate_sensor", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_acid_conc_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Acid Concentrate Details data messages. @@ -301,7 +301,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_bicarb_concentrate_sensor", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_bicarb_conc_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Bicarb Concentrate Details data messages. @@ -321,7 +321,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_accel_sensor_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_accelerometer_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Accelerometer Details data messages. @@ -341,7 +341,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_cal_pressure_sensor", "calibration_records", "calibration_records_timestamp"]) + @publish(["msg_id_dd_nvm_cal_blood_leak_response", "calibration_records", "calibration_records_timestamp"]) def _handler_calibration_record_blood_leak_sync(self, message, timestamp = 0.0): """ Handles published DD Calibration Record Blood Leak Details data messages. @@ -361,7 +361,7 @@ self.calibration_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_institutional_record", "institutional_records", "institutional_records_timestamp"]) + @publish(["msg_id_dd_nvm_institutional_record_response", "institutional_records", "institutional_records_timestamp"]) def _handler_institutional_record_sync(self, message, timestamp = 0.0): """ Handles published DD Institutional Record data messages. DD Institutional Records are captured @@ -370,8 +370,8 @@ @param message: published data message @return: none """ - record_list = [('record_id', DataTypes.U08)] - results = self.process_into_vars(decoder_list = record_list, + msg_list = [('record_id', DataTypes.U32)] + results = self.process_into_vars(decoder_list = msg_list, message = message) record_id = int(results['record_id']) @@ -383,12 +383,12 @@ self.process_into_dict(dict_to_update = self.institutional_records, decoder_list = record_list, message = message, - start_from_byte = len(record_list) * DataTypes.U08.size()) + start_from_byte = len(msg_list) * msg_list[0][1].size()) self.institutional_records_timestamp = timestamp - @publish(["msg_id_dd_nvm_send_usage_info_record", "usage_info_records", "usage_info_records_timestamp"]) + @publish(["msg_id_dd_nvm_usage_info_record_response", "usage_info_records", "usage_info_records_timestamp"]) def _handler_usage_info_record_sync(self, message, timestamp = 0.0): """ Handles published DD Usage Information Record data messages. DD Usage Information Records are captured Index: leahi_dialin/utils/abstract_classes.py =================================================================== diff -u -r41805cd3ccca131f8e592b0777f90ab587d2be3f -rc8bafcb198910f30a8fb1c37024050b2c20ea898 --- leahi_dialin/utils/abstract_classes.py (.../abstract_classes.py) (revision 41805cd3ccca131f8e592b0777f90ab587d2be3f) +++ leahi_dialin/utils/abstract_classes.py (.../abstract_classes.py) (revision c8bafcb198910f30a8fb1c37024050b2c20ea898) @@ -163,25 +163,27 @@ datatype: DataTypes = decode_details[-1] key_list_length = len(decode_details) - 1 - end_pos = start_pos + datatype.size() - for i in range(0, length): + end_pos = start_pos + datatype.size() try: new_value = struct.unpack(datatype.unpack_attrib(), bytearray(message['message'][start_pos:end_pos]))[0] - if i == 0: + if length == 1: value = new_value - else: - value += new_value + elif datatype == DataTypes.U08 and length > 1: + if i == 0: + value = chr(new_value) + else: + value += chr(new_value) + if debug: + print(f'Input Data: {bytearray(message["message"][start_pos:end_pos])}') + print(f'Unpack attrib: {datatype.unpack_attrib()}') + print(f'Value: {value}') + print(f'New value: {new_value}') except Exception as e: value = None break + start_pos = end_pos - if debug: - print(f'key_1: {key_1}') - print(f'key_2: {key_2}') - print(f'value: {value} ({datatype.name})') - print(f'pos: {start_pos} - {end_pos}') - if 'nan' in str(value).lower(): value = None # raise ValueError(f'{value} is not an accepted value!')