Index: dialin/hd/institutional_record.py =================================================================== diff -u -rcc1292b0d75e7a3fc1cbd0e45610805af4790108 -r369b3b7cb7d66a4d4c251083c0aea3eacb0b39ea --- dialin/hd/institutional_record.py (.../institutional_record.py) (revision cc1292b0d75e7a3fc1cbd0e45610805af4790108) +++ dialin/hd/institutional_record.py (.../institutional_record.py) (revision 369b3b7cb7d66a4d4c251083c0aea3eacb0b39ea) @@ -17,13 +17,29 @@ Hemodialysis Device (HD) Dialin API sub-class for institutional record commands. """ + _DEFAULT_MIN_BLOOD_FLOW_MLPM = 100 + _DEFAULT_MAX_BLOOD_FLOW_MLPM = 500 + _DEFAULT_MIN_DIALYSATE_FLOW_MLPM = 100 + _DEFAULT_MAX_DIALYSATE_FLOW_MLPM = 600 + _DEFAULT_MIN_TX_DURATION_MIN = 60 + _DEFAULT_MAX_TX_DURATION_MIN = 480 + _DEFAULT_HEPARIN_ENABLE = 1 + _DEFAULT_MIN_STOP_HEP_DISP_BEFORE_TX_END_MIN = 0 + _DEFAULT_MAX_STOP_HEP_DISP_BEFORE_TX_END_MIN = 480 + _DEFAULT_MIN_SALINE_BOLUS_VOLUME_ML = 100 + _DEFAULT_MAX_SALINE_BOLUS_VOLUME_ML = 300 + _DEFAULT_MIN_DIALYSATE_TEMPERATURE_C = 35.0 + _DEFAULT_MAX_DIALYSATE_TEMPERATURE_C = 37.0 + _DEFAULT_MIN_ART_PRESS_LIMIT_WINDOW_MMHG = 120 + _DEFAULT_MAX_ART_PRESS_LIMIT_WINDOW_MMHG = 200 + _DEFAULT_MIN_VEN_PRESS_LIMIT_WINDOW_MMHG = 100 + _DEFAULT_MAX_VEN_PRESS_LIMIT_WINDOW_MMHG = 200 + _DEFAULT_MIN_VEN_ASYM_PRESS_LIMIT_WINDOW_MMHG = 20 + _DEFAULT_MAX_VEN_ASYM_PRESS_LIMIT_WINDOW_MMHG = 35 + _DEFAULT_MIN_UF_VOLUME_L = 0.0 + _DEFAULT_MAX_UF_VOLUME_L = 8.0 - # The default service time interval is 6 months in seconds - _DEFAULT_SERVICE_INTERVAL_S = 15768000 _RECORD_SPECS_BYTES = 12 - _DEFAULT_SERVICE_LOCATION = ServiceLocation.SERVICE_LOCATION_FACTORY.value - # TODO bring in the default values - _DEFAULT_TIME_VALUE = 0 _DEFAULT_CRC_VALUE = 0 _FIRMWARE_STACK_NAME = 'HD' @@ -54,28 +70,28 @@ self._institutional_data = 0 self._raw_institutional_record = [] self._utilities = NVOpsUtils(logger=self.logger) - self.hd_institutional_record = self._prepare_hd_service_record() + self.hd_institutional_record = self._prepare_hd_institutional_record() if self.can_interface is not None: channel_id = DenaliChannels.hd_to_dialin_ch_id msg_id = MsgIds.MSG_ID_HD_SEND_INSTITUTIONAL_RECORD.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_institutional_sync) self.hd_institutional_record_timestamp = 0.0 - HERE - def cmd_reset_hd_service_record(self) -> bool: + + def cmd_reset_hd_institutional_record(self) -> bool: """ - Handles resetting HD service record. + Handles resetting HD institutional record. @return: True if successful, False otherwise """ - self.hd_institutional_record = self._prepare_hd_service_record() + self.hd_institutional_record = self._prepare_hd_institutional_record() self.hd_institutional_record = self._utilities.reset_fw_system_service_record(self.hd_institutional_record) - status = self.cmd_set_hd_service_record(self.hd_institutional_record) + status = self.cmd_set_hd_institutional_record(self.hd_institutional_record) return status - def cmd_request_hd_service_record(self) -> int: + def cmd_request_hd_institutional_record(self) -> int: """ Handles getting HD service record from firmware. @@ -87,9 +103,9 @@ self._raw_institutional_record.clear() message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_GET_SERVICE_RECORD.value) + message_id=MsgIds.MSG_ID_HD_GET_INSTITUTIONAL_RECORD.value) - self.logger.debug('Getting HD service record') + self.logger.debug('Getting HD institutional record') received_message = self.can_interface.send(message) @@ -104,9 +120,9 @@ self.logger.debug("Request cancelled: an existing request is in progress.") return False - def cmd_hd_service_record_crc_override(self, crc: int) -> bool: + def cmd_hd_institutional_record_crc_override(self, crc: int) -> bool: """ - Handles setting HD service_record CRC override. + Handles setting HD institutional CRC override. @param crc: (int) the CRC override value @@ -116,14 +132,14 @@ # so the payload length is the same when it is received in the firmware. reset_byte_array = integer_to_bytearray(0) crc_value = integer_to_bytearray(crc) - hd_record = integer_to_bytearray(NVRecordsHD.NVDATAMGMT_SERVICE_RECORD.value) + hd_record = integer_to_bytearray(NVRecordsHD.NVDATAMGMT_INSTITUTIONAL_RECORD.value) payload = reset_byte_array + crc_value + hd_record message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=MsgIds.MSG_ID_HD_NV_RECORD_CRC_OVERRIDE.value, payload=payload) - self.logger.debug("Overriding HD service record CRC to: " + str(crc)) + self.logger.debug("Overriding HD institutional record CRC to: " + str(crc)) # Send message received_message = self.can_interface.send(message) @@ -173,29 +189,29 @@ # If all the messages have been received, call another function to process the raw data self._utilities.process_received_record_from_fw(self.hd_institutional_record, self._raw_institutional_record) self.hd_institutional_record_timestamp = timestamp - self._handler_received_complete_hd_service_record() + self._handler_received_complete_hd_institutional_record() - @publish(["hd_service_record_timestamp","hd_service_record"]) - def _handler_received_complete_hd_service_record(self): + @publish(["hd_institutional_record_timestamp", "hd_institutional_record"]) + def _handler_received_complete_hd_institutional_record(self): """ - Publishes the received service record + Publishes the received institutional record @return: None """ - self.logger.debug("Received a complete hd service record.") + self.logger.debug("Received a complete hd institutional record.") - def cmd_set_hd_service_record(self, hd_service_record: OrderedDict) -> bool: + def cmd_set_hd_institutional_record(self, hd_institutional_record: OrderedDict) -> bool: """ - Handles updating the HD system and sends it to FW. + Handles updating the HD institutional and sends it to FW. - @param hd_service_record: (OrderedDict) the hd service record to be sent + @param hd_institutional_record: (OrderedDict) the hd institutional record to be sent @return: True upon success, False otherwise """ transfer_status = 1 - self.logger.debug('Setting HD service record') + self.logger.debug('Setting HD institutional record') - record_packets = self._utilities.prepare_record_to_send_to_fw(hd_service_record) + record_packets = self._utilities.prepare_record_to_send_to_fw(hd_institutional_record) # Update all the data packets with the last message count since is the number of messages that firmware # should receive @@ -207,7 +223,7 @@ payload = b''.join(packet) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_SET_SERVICE_RECORD.value, + message_id=MsgIds.MSG_ID_HD_SET_INSTITUTIONAL_RECORD.value, payload=payload) received_message = self.can_interface.send(message) @@ -217,30 +233,30 @@ self.logger.warning("HD ACK not received!") continue elif transfer_status == 0: - self.logger.debug("Sending HD service record failed") + self.logger.debug("Sending HD institutional record failed") return False transfer_status = received_message['message'][6] if transfer_status == 1: - self.logger.debug("Finished sending HD service record.") + self.logger.debug("Finished sending HD institutional record.") return True - def _prepare_hd_service_record(self): + def _prepare_hd_institutional_record(self): """ - Handles assembling the sub dictionaries of each group to make the main HD service record. + Handles assembling the sub dictionaries of each group to make the main HD institutional record. - @return: (OrderedDict) an assembled hd service record + @return: (OrderedDict) an assembled hd institutional record """ result = OrderedDict() groups_byte_size = 0 # create a list of the functions of the sub dictionaries - functions = [self._prepare_service_record()] + functions = [self._prepare_institutional_record()] for function in functions: - # Update the groups bytes size so far to be use to padding later + # Update the groups bytes size so far to be used to padding later groups_byte_size += function[1] - # Update the calibration record + # Update the institutional record result.update(function[0]) # Build the CRC of the main calibration_record record @@ -250,7 +266,7 @@ groups_byte_size += self._utilities.calculate_group_byte_size(record_crc) # Get the padding size to create a dictionary from it - padding_size = self._utilities.calculate_padding_byte_size(groups_byte_size, self._RTC_RAM_MAX_BYTES_TO_WRITE) + padding_size = self._utilities.calculate_padding_byte_size(groups_byte_size, self._EEPROM_MAX_BYTES_TO_WRITE) # Create the padding dictionary as list of unsigned char. All the elements are 0. padding = OrderedDict({'padding': [' bool: + def cmd_set_hd_institutional_record_excel_to_fw(self, report_address: str) -> bool: """ - Handles setting the service record data that is in an excel report to the firmware. + Handles setting the institutional record data that is in an excel report to the firmware. @param report_address: (str) the address in which its data must be written from excel @return: none """ - # Request the DG service record and set and observer class to callback when the record is read back - self.cmd_request_hd_service_record() - observer = NVUtilsObserver("hd_service_record") + # Request the DG institutional record and set and observer class to callback when the record is read back + self.cmd_request_hd_institutional_record() + observer = NVUtilsObserver("hd_institutional_record") # Attach the observer to the list self.attach(observer) while not observer.received: sleep(0.1) self._utilities.write_excel_record_to_fw_record(self.hd_institutional_record, report_address, - self._utilities.SERVICE_RECORD_TAB_NAME) + self._utilities.INSTITUTIONAL_RECORD_TAB_NAME) - ret = self.cmd_set_hd_service_record(self.hd_institutional_record) + ret = self.cmd_set_hd_institutional_record(self.hd_institutional_record) return ret def cmd_get_hd_service_record(self, report_address: str = None): """ - Publicly accessible function to request the HD service record and write the record to excel. + Publicly accessible function to request the HD institutional record and write the record to excel. @param report_address: the address that the report needs to be written to. The default is None so it picks an address and writes the excel report. @@ -313,16 +347,16 @@ """ # Create the excel report - self._utilities.prepare_excel_report(self._FIRMWARE_STACK_NAME, self._utilities.SERVICE_RECORD_TAB_NAME, + self._utilities.prepare_excel_report(self._FIRMWARE_STACK_NAME, self._utilities.INSTITUTIONAL_RECORD_TAB_NAME, report_address, protect_sheet=True) # Create an object of the observer class to observe the dictionary - observer = NVUtilsObserver("hd_service_record") + observer = NVUtilsObserver("hd_institutional_record") # Attach the observer to the list self.attach(observer) # Request the latest software configuration record from firmware - self.cmd_request_hd_service_record() + self.cmd_request_hd_institutional_record() # Wait until data has been received from firmware while not observer.received: sleep(0.1) Index: dialin/hd/service_record.py =================================================================== diff -u -rcc1292b0d75e7a3fc1cbd0e45610805af4790108 -r369b3b7cb7d66a4d4c251083c0aea3eacb0b39ea --- dialin/hd/service_record.py (.../service_record.py) (revision cc1292b0d75e7a3fc1cbd0e45610805af4790108) +++ dialin/hd/service_record.py (.../service_record.py) (revision 369b3b7cb7d66a4d4c251083c0aea3eacb0b39ea) @@ -268,7 +268,7 @@ groups_byte_size += self._utilities.calculate_group_byte_size(record_crc) # Get the padding size to create a dictionary from it - padding_size = self._utilities.calculate_padding_byte_size(groups_byte_size, self._RTC_RAM_MAX_BYTES_TO_WRITE) + padding_size = self._utilities.calculate_padding_byte_size(groups_byte_size, self._EEPROM_MAX_BYTES_TO_WRITE) # Create the padding dictionary as list of unsigned char. All the elements are 0. padding = OrderedDict({'padding': ['