Index: dialin/common/msg_defs.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -r97c98d84604e3700dd446235e91a5ebe2db08022 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 97c98d84604e3700dd446235e91a5ebe2db08022) @@ -92,8 +92,8 @@ MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST = 0x46 # UI request to change pressure limits MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE = 0x47 # HD response to change pressure limits request MSG_ID_DG_FANS_DATA = 0x48 # DG broadcast fans data - MSG_ID_HD_CALIBRATION_DATA = 0x49 # HD broadcast calibration_record data - MSG_ID_DG_CALIBRATION_DATA = 0x4A # DG broadcast calibration_record data + MSG_ID___AVAILABLE_4 = 0x49 # HD broadcast calibration_record data + MSG_ID___AVAILABLE_5 = 0x4A # DG broadcast calibration_record data MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST = 0x4B # UI request to pause/resume Heparin delivery MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE = 0x4C # HD response to pause/resume Heparing delivery request MSG_ID_HD_HEPARIN_DATA_BROADCAST = 0x4D # HD broadcast of Heparin delivery data @@ -146,9 +146,9 @@ MSG_ID_HD_ACCEL_OVERRIDE = 0x8027 # HD accelerometer sensor override request MSG_ID_HD_ACCEL_MAX_OVERRIDE = 0x8028 # HD accelerometer sensor max. override request MSG_ID_HD_ACCEL_SEND_INTERVAL_OVERRIDE = 0x8029 # HD accelerometer data broadcast interval override request - MSG_ID_HD_ACCEL_SET_CALIBRATION = 0x802A # HD accelerometer set calibration_record factors request - MSG_ID_HD_BLOOD_FLOW_SET_CALIBRATION = 0x802B # Blood flow set calibration_record factors request - MSG_ID_HD_DIALYSATE_FLOW_SET_CALIBRATION = 0x802C # Dialysate flow set calibration_record factors request + MSG_ID___AVAILABLE_6 = 0x802A # This msg ID is available for use + MSG_ID___AVAILABLE_7 = 0x802B # This msg ID is available for use + MSG_ID___AVAILABLE_8 = 0x802C # This msg ID is available for use MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER = 0x802D # Set a treatment parameter (will change actual setting, not an override) MSG_ID_HD_VALVES_HOME = 0x802E # Home an HD Valve MSG_ID_HD_VALVES_POSITION_OVERRIDE = 0x802F # Set an HD valve to a position in counts @@ -163,8 +163,8 @@ MSG_ID_DIAL_IN_PUMP_HOME_CMD = 0x8038 # Dialysate inlet pump home command MSG_ID_DIAL_OUT_PUMP_HOME_CMD = 0x8039 # Dialysate outlet pump home command MSG_ID_SUPER_CLEAR_ALARMS_CMD = 0x803A # Clears all alarms (even if non-recoverable or fault) - MSG_ID_HD_REQUEST_CALIBRATION_DATA = 0x803B # Requests calibration_record data from HD - MSG_ID_HD_ERASE_CALIBRATION_DATA = 0x803C # Requests calibration_record data on HD be erased + MSG_ID___AVAILABLE_9 = 0x803B # This msg ID is available for use + MSG_ID___AVAILABLE_10 = 0x803C # This msg ID is available for use MSG_ID_HD_SET_CALIBRATION_RECORD = 0x803D # HD set calibration_record record that is received from Dialin MSG_ID_HD_GET_CALIBRATION_RECORD = 0x803E # HD get calibration_record record that is requested from Dialin MSG_ID_HD_SEND_CALIBRATION_RECORD = 0x803F # HD send calibration_record record to CAN bus to be received in Dialin (equivalent to publish) @@ -173,7 +173,7 @@ MSG_ID_HD_SEND_SYSTEM_RECORD = 0x8042 # HD send system record to CAN bus to be received in Dialin (equivalent to publish) MSG_ID_HD_GET_SERVICE_RECORD = 0x8043 # HD get service record that is requested from Dialin MSG_ID_HD_SET_SERVICE_RECORD = 0x8044 # HD set service record that is received from Dialin - MSG_ID_Hd_SEND_SERVICE_RECORD = 0x8045 # HD send service record to CAN bus to be received in Dialin (equivalent to publish) + MSG_ID_HD_SEND_SERVICE_RECORD = 0x8045 # HD send service record to CAN bus to be received in Dialin (equivalent to publish) MSG_ID_DG_TESTER_LOGIN_REQUEST = 0XA000 # DG tester log-in MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 # DG alarm state override message ID @@ -200,7 +200,7 @@ MSG_ID_DG_ACCEL_OVERRIDE = 0xA017 # DG accelerometer sensor override request MSG_ID_DG_ACCEL_MAX_OVERRIDE = 0xA018 # DG accelerometer sensor max. override request MSG_ID_DG_ACCEL_SEND_INTERVAL_OVERRIDE = 0xA019 # DG accelerometer data broadcast interval override request - MSG_ID_DG_ACCEL_SET_CALIBRATION = 0xA01A # DG accelerometer set calibration_record factors request + MSG_ID___AVAILABLE_11 = 0xA01A # This msg ID is available for use MSG_ID_RO_PUMP_SET_PWM = 0xA01B # RO pump set PWM for open loop MSG_ID_DRAIN_PUMP_SET_DELTA_PRESSURE_OVERRIDE = 0xA01C # Drain pump set delta pressure override MSG_ID_HEAT_DISINFECT_RECIRC_PATH_DURATION_MINS = 0xA01D # Heat disinfection recirculation path duration in minutes Index: dialin/dg/calibration_record.py =================================================================== diff -u -rab49c2b2e6bd03745f5a910780791d4b18000fd1 -r97c98d84604e3700dd446235e91a5ebe2db08022 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision ab49c2b2e6bd03745f5a910780791d4b18000fd1) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision 97c98d84604e3700dd446235e91a5ebe2db08022) @@ -14,33 +14,21 @@ class DGCalibration(_AbstractSubSystem): """ - Dialysate Generator (DG) Dialin API sub-class for calibration_record commands. + Dialysate Generator (DG) Dialin API sub-class for calibration commands. """ _RECORD_START_INDEX = 6 _RECORD_SPECS_BYTES = 12 - CALIBRATION_RECORDS_SPECS_BYTE_ARRAY = 3 _DEFAULT_GAIN_VALUE = 1 _DEFAULT_OFFSET_VALUE = 0 _DEFAULT_RATIO_VALUE = 1 _DEFAULT_VOLUME_VALUE = 0 _DEFAULT_CONCENTRATE_VALUE = 1 - DEFAULT_BICARB_VALUE = 1 + _DEFAULT_BICARB_VALUE = 1 _DEFAULT_CALIBRATION_VALUE = 1 _DEFAULT_TIME_VALUE = 0 _DEFAULT_CRC_VALUE = 0 - CURRENT_MESSAGE_NUM_INDEX = 0 - TOTAL_MESSAGES_NUM_INDEX = 4 - PAYLOAD_LENGTH_INDEX = 8 - PAYLOAD_START_INDEX = 12 - - CALIBRATION_DATA_TYPE_INDEX = 0 - CALIBRATION_VALUE_INDEX = 1 - - TARGET_BYTES_TO_SEND_TO_FW = 150 - MIN_PAYLOAD_BYTES_SPACE = 4 - _EEPROM_MAX_BYTES_TO_WRITE = 16 _PAYLOAD_TRANSFER_DELAY = 0.2 @@ -59,8 +47,8 @@ self.total_messages = 0 self.length = 0 self.cal_data = 0 - self.raw_cal_record = [] - self.utilities = Utils() + self._raw_cal_record = [] + self._utilities = Utils() # DG calibration_record main record self.dg_calibration_record = OrderedDict() @@ -75,12 +63,12 @@ def get_dg_calibration_record(self): """ - Handles getting DG calibration_record data from firmware. + Handles getting DG calibration data from firmware. @return: None """ # Clear the list for the next call - self.raw_cal_record.clear() + self._raw_cal_record.clear() # Run the firmware commands to get the calibration_record record self._request_dg_fw_calibration_record() @@ -93,7 +81,7 @@ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, message_id=MsgIds.MSG_ID_DG_GET_CALIBRATION_RECORD.value) - self.logger.debug('Getting DG calibration_record record') + self.logger.debug('Getting DG calibration record') received_message = self.can_interface.send(message) @@ -105,10 +93,10 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "length", "sys_data"]) + @_publish(["current_message", "total_messages", "length", "service_data"]) def _handler_dg_calibration_sync(self, message): """ - Handles published DG calibration_record record messages. DG calibration_record records are captured for + Handles published DG calibration_record record messages. DG calibration records are captured for processing and updating the DG calibration_record record. @param message: published DG calibration_record record data message @@ -125,67 +113,64 @@ self.current_message = curr self.total_messages = total self.length = length - # The end of calibration_record record payload is from the start index + 12 bytes for the current message + total + # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total # messages + the length of calibration_record. The rest is the CAN messaging CRC that is not needed to be kept end_of_data_index = self._RECORD_START_INDEX + self._RECORD_SPECS_BYTES + self.length # Get the calibration_record data only self.cal_data = message['message'][self._RECORD_START_INDEX:end_of_data_index] - # Continue getting calibration_record records until the all the calibration_record messages are received. Concatenate the - # calibration_record records to each other + # Continue getting calibration_record records until the all the calibration_record messages are received. + # Concatenate the calibration_record records to each other. if self.current_message <= self.total_messages: - self.raw_cal_record += (message['message'][self._RECORD_START_INDEX + - self._RECORD_SPECS_BYTES:end_of_data_index]) + self._raw_cal_record += (message['message'][self._RECORD_START_INDEX + + self._RECORD_SPECS_BYTES:end_of_data_index]) if self.current_message == self.total_messages: # If all the messages have been received, call another function to process the raw data - self.utilities.process_received_record_from_fw(self.dg_calibration_record, self.raw_cal_record) + self._utilities.process_received_record_from_fw(self.dg_calibration_record, self._raw_cal_record) def _prepare_dg_calibration_record(self): """ - Handles assembling the sub dictionaries of each hardware group to make the main DG calibration_record record. + Handles assembling the sub dictionaries of each hardware group to make the main DG calibration record. @return: None """ + groups_byte_size = 0 # Call the other functions to get the dictionaries of each hardware group. All the dictionaries are # ordered dictionaries to maintain the order in which they are inserted. The results are a tuple, the first # element is the dictionary that was built and the second element is the byte size of the dictionary. - pressure = self._prepare_pressure_sensors_cal_record() - flow = self._prepare_flow_sensors_cal_record() - load_cells = self._prepare_load_cells_record() - temperature = self._prepare_temperature_sensors_record() - conductivity = self._prepare_conductivity_sensors_record() - pumps = self._prepare_pumps_record() - volumes = self._prepare_volume_record() - acid = self._prepare_acid_concentrates_record() - bicarb = self._prepare_bicarb_concentrates_record() - filters = self._prepare_filters_record() - fans = self._prepare_fans_record() + functions = [self._prepare_pressure_sensors_cal_record(), self._prepare_flow_sensors_cal_record(), + self._prepare_load_cells_record(), self._prepare_temperature_sensors_record(), + self._prepare_conductivity_sensors_record(), self._prepare_pumps_record(), + self._prepare_volume_record(), self._prepare_acid_concentrates_record(), + self._prepare_bicarb_concentrates_record(), self._prepare_filters_record(), + self._prepare_fans_record(), self._prepare_accelerometer_sensor_record()] + + for function in functions: + # Update the groups bytes size so far to be use to padding later + groups_byte_size += function[1] + # Update the calibration record + self.dg_calibration_record.update(function[0]) + # Build the CRC of the main calibration_record record record_crc = OrderedDict({'crc': [' self.MIN_PAYLOAD_BYTES_SPACE: - current_payload_length += data_type_bytes - temp_buffer[self.PAYLOAD_TOTAL_MSG_INDEX] = struct.pack(' self.MIN_PAYLOAD_BYTES_SPACE: - current_payload_length += data_type_bytes - # Insert a 4-byte 0 to the index of the total messages. This is a place holder and it will - # be updated with the right value later. - temp_buffer[self.PAYLOAD_TOTAL_MSG_INDEX] = struct.pack('