Index: dialin/common/msg_defs.py =================================================================== diff -u -re36d87e663d95c79214f66b5db9aa6d6e8b47adf -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f --- dialin/common/msg_defs.py (.../msg_defs.py) (revision e36d87e663d95c79214f66b5db9aa6d6e8b47adf) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) @@ -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 data - MSG_ID_DG_CALIBRATION_DATA = 0x4A # DG broadcast calibration 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_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 factors request - MSG_ID_HD_BLOOD_FLOW_SET_CALIBRATION = 0x802B # Blood flow set calibration factors request - MSG_ID_HD_DIALYSATE_FLOW_SET_CALIBRATION = 0x802C # Dialysate flow set calibration factors 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_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,17 @@ 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 data from HD - MSG_ID_HD_ERASE_CALIBRATION_DATA = 0x803C # Requests calibration data on HD be erased + 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_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) + MSG_ID_HD_SET_SYSTEM_RECORD = 0x8040 # HD set system record that is received from Dialin + MSG_ID_HD_GET_SYSTEM_RECORD = 0x8041 # HD get system record that is requested from Dialin + 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_DG_TESTER_LOGIN_REQUEST = 0XA000 # DG tester log-in MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 # DG alarm state override message ID @@ -191,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 factors request + MSG_ID_DG_ACCEL_SET_CALIBRATION = 0xA01A # DG accelerometer set calibration_record factors request 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 @@ -206,7 +215,7 @@ MSG_ID_CONCENTRATE_PUMP_STATE_CHANGE_REQUEST = 0xA026 # Concentrate pumps' state change request (on / off) MSG_ID_CONCENTRATE_PUMP_PUBLISH_INTERVAL_OVERRIDE = 0xA027 # Concentrate pumps' data publish interval override request MSG_ID_DG_START_STOP_INLET_UV_REACTOR = 0xA028 # DG start/stop inlet UV reactor - MSG_ID_DG_REQUEST_CALIBRATION_DATA = 0xA029 # Requests calibration data from DG + MSG_ID_DG_REQUEST_CALIBRATION_DATA = 0xA029 # Requests calibration_record data from DG MSG_ID_DG_FANS_DATA_PUBLISH_OVERRIDE = 0xA02A # Fans data publish interval override request MSG_ID_DG_START_STOP_OUTLET_UV_REACTOR = 0xA02B # DG start/stop outlet UV reactor MSG_ID_DG_UV_REACTORS_HEALTH_OVERRIDE = 0xA02C # DG UV reactors health override request @@ -216,9 +225,9 @@ MSG_ID_DG_RO_FLOW_RATE_OVERRIDE = 0xA030 # DG RO flow rate override MSG_ID_DG_RO_PUMP_TARGET_FLOW_OVERRIDE = 0xA031 # DG RO pump target flow rate override MSG_ID_DG_RO_PUMP_TARGET_PRESSURE_OVERRIDE = 0xA032 # DG RO pump target pressure override - MSG_ID_DG_SET_CALIBRATION_RECORD = 0xA033 # DG set calibration record - MSG_ID_DG_GET_CALIBRATION_RECORD = 0xA034 # DG get calibration record - MSG_ID_DG_SEND_CALIBRATION_RECORD = 0xA035 # DG send calibration record from firmware + MSG_ID_DG_SET_CALIBRATION_RECORD = 0xA033 # DG set calibration_record record + MSG_ID_DG_GET_CALIBRATION_RECORD = 0xA034 # DG get calibration_record record + MSG_ID_DG_SEND_CALIBRATION_RECORD = 0xA035 # DG send calibration_record record from firmware MSG_ID_DG_SET_SYSTEM_RECORD = 0xA036 # DG send system record MSG_ID_DG_GET_SYSTEM_RECORD = 0xA037 # DG get system record MSG_ID_DG_SEND_SYSTEM_RECORD = 0xA038 # DG send system record from firmware Index: dialin/dg/accelerometer.py =================================================================== diff -u -r812bbf1e5b3b2f1c4f5cfbef1264787e18afb5c3 -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f --- dialin/dg/accelerometer.py (.../accelerometer.py) (revision 812bbf1e5b3b2f1c4f5cfbef1264787e18afb5c3) +++ dialin/dg/accelerometer.py (.../accelerometer.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) @@ -242,11 +242,11 @@ def cmd_set_accel_calibration(self, x_offset, y_offset, z_offset): """ - Constructs and sends the DG accelerometer axis calibration offsets message to the DG. + Constructs and sends the DG accelerometer axis calibration_record offsets message to the DG. - @param x_offset: float - calibration offset for X axis - @param y_offset: float - calibration offset for Y axis - @param z_offset: float - calibration offset for Z axis + @param x_offset: float - calibration_record offset for X axis + @param y_offset: float - calibration_record offset for Y axis + @param z_offset: float - calibration_record offset for Z axis @return: 1 if successful, zero otherwise """ @@ -259,7 +259,7 @@ message_id=MsgIds.MSG_ID_DG_ACCEL_SET_CALIBRATION.value, payload=payload) - self.logger.debug("Setting DG accelerometer axis calibration offsets") + self.logger.debug("Setting DG accelerometer axis calibration_record offsets") # Send message received_message = self.can_interface.send(message) @@ -268,7 +268,7 @@ if received_message is not None: self.logger.debug(received_message) # str_res = str(flow) - self.logger.debug("DG accelerometer calibration axis offsets set to : " + str(x_offset) + ", " + str(y_offset) + ", " + + self.logger.debug("DG accelerometer calibration_record axis offsets set to : " + str(x_offset) + ", " + str(y_offset) + ", " + str(z_offset) + ". " + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] Index: dialin/dg/calibration_record.py =================================================================== diff -u -ra26b886c2bbe75c1292afa150a63d1d9b8026b3b -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision a26b886c2bbe75c1292afa150a63d1d9b8026b3b) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) @@ -2,7 +2,6 @@ import struct import datetime import time -import math from collections import OrderedDict from ..ui.crc import crc_16 from ..common.msg_defs import MsgIds, MsgFieldPositions @@ -15,17 +14,17 @@ class DGCalibration(_AbstractSubSystem): """ - Dialysate Generator (DG) Dialin API sub-class for calibration commands. + Dialysate Generator (DG) Dialin API sub-class for calibration_record 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_RATIO_VALUE = 1 + _DEFAULT_VOLUME_VALUE = 0 + _DEFAULT_CONCENTRATE_VALUE = 1 DEFAULT_BICARB_VALUE = 1 _DEFAULT_CALIBRATION_VALUE = 1 _DEFAULT_TIME_VALUE = 0 @@ -44,9 +43,6 @@ _EEPROM_MAX_BYTES_TO_WRITE = 16 - PAYLOAD_CURRENT_MSG_INDEX = 0 - PAYLOAD_TOTAL_MSG_INDEX = 1 - PAYLOAD_CAL_BYTES_INDEX = 2 _PAYLOAD_TRANSFER_DELAY = 0.2 def __init__(self, can_interface, logger: Logger): @@ -65,7 +61,7 @@ self.cal_data = 0 self.raw_cal_record = [] self.utilities = Utils() - # DG calibration main record + # DG calibration_record main record self.dg_calibration_record = OrderedDict() if self.can_interface is not None: @@ -74,30 +70,30 @@ msg_id = MsgIds.MSG_ID_DG_SEND_CALIBRATION_RECORD.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_dg_calibration_sync) - # Prepare the calibration record by putting sub-dictionaries together + # Prepare the calibration_record record by putting sub-dictionaries together self._prepare_dg_calibration_record() def get_dg_calibration_record(self): """ - Handles getting DG calibration data from firmware. + Handles getting DG calibration_record data from firmware. @return: None """ # Clear the list for the next call self.raw_cal_record.clear() - # Run the firmware commands to get the calibration record + # Run the firmware commands to get the calibration_record record self._request_dg_fw_calibration_record() def _request_dg_fw_calibration_record(self): """ - Handles getting DG calibration record from firmware. + Handles getting DG calibration_record record from firmware. @return: None """ 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') + self.logger.debug('Getting DG calibration_record record') received_message = self.can_interface.send(message) @@ -109,13 +105,13 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "length", "cal_data"]) #TODO do we need to publish these? + @_publish(["current_message", "total_messages", "length", "cal_data"]) def _handler_dg_calibration_sync(self, message): """ - Handles published DG calibration record messages. DG calibration records are captured for processing and - updating the DG calibration record. + Handles published DG calibration_record record messages. DG calibration_record records are captured for + processing and updating the DG calibration_record record. - @param message: published DG calibration record data message + @param message: published DG calibration_record record data message @return: None """ @@ -129,15 +125,15 @@ self.current_message = curr self.total_messages = total self.length = length - # The end of calibration record payload is from the start index + 12 bytes for the current message + total - # messages + the length of calibration. The rest is the CAN messaging CRC that is not needed to be kept + # 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 data only + # Get the calibration_record data only self.cal_data = message['message'][self._RECORD_START_INDEX:end_of_data_index] - # Continue getting calibration records until the all the calibration messages are received. Concatenate the - # calibration 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]) @@ -147,7 +143,7 @@ def _prepare_dg_calibration_record(self): """ - Handles assembling the sub dictionaries of each hardware group to make the main DG calibration record. + Handles assembling the sub dictionaries of each hardware group to make the main DG calibration_record record. @return: None """ @@ -165,7 +161,7 @@ bicarb = self._prepare_bicarb_concentrates_record() filters = self._prepare_filters_record() fans = self._prepare_fans_record() - # Build the CRC of the main calibration record + # Build the CRC of the main calibration_record record record_crc = OrderedDict({'crc': ['