Index: dialin/dg/calibration_record.py =================================================================== diff -u -re0aac8af8cd14024b89f241bb7b92ddd9bc4956e -r6895b99c133b8d5820df5610c3b12ac55a521998 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision e0aac8af8cd14024b89f241bb7b92ddd9bc4956e) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) @@ -62,30 +62,6 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_dg_calibration_sync) - def is_reading_record_done(self): - """ - Handles getting the status of reading record - - @return: True if reading is done otherwise False - """ - return self._utilities.get_writing_to_excel_status() - - def get_dg_calibration_record(self): - """ - Gets the existing calibration record - @return: (OrderedDict) the calibration record, None if calibration record is being received - """ - if not self._is_getting_cal_in_progress: - return self.dg_calibration_record - return None - - def _reset_getting_calibration_record_in_progress(self): - """ - Private method to set the cal in progress flag to False - @return: None - """ - self._is_getting_cal_in_progress = False - def cmd_request_dg_calibration_record(self): """ Handles getting DG calibration_record record from firmware. Index: dialin/hd/calibration_record.py =================================================================== diff -u -re0aac8af8cd14024b89f241bb7b92ddd9bc4956e -r6895b99c133b8d5820df5610c3b12ac55a521998 --- dialin/hd/calibration_record.py (.../calibration_record.py) (revision e0aac8af8cd14024b89f241bb7b92ddd9bc4956e) +++ dialin/hd/calibration_record.py (.../calibration_record.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) @@ -63,37 +63,32 @@ def cmd_request_hd_calibration_record(self): """ - Handles getting HD calibration_record data from firmware. + Handles getting HD calibration_record record from firmware. - @return: None + @return: 1 upon success, False otherwise """ if self._is_getting_cal_in_progress is not True: self._is_getting_cal_in_progress = True # Clear the list for the next call self._raw_cal_record.clear() - # Run the firmware commands to get the calibration_record record - self._request_hd_fw_calibration_record() - def _request_hd_fw_calibration_record(self): - """ - Handles getting HD calibration_record record from firmware. + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_GET_CALIBRATION_RECORD.value) - @return: 1 upon success, False otherwise - """ - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_GET_CALIBRATION_RECORD.value) + self.logger.debug('Getting HD calibration record') - self.logger.debug('Getting HD calibration record') + received_message = self.can_interface.send(message) - received_message = self.can_interface.send(message) + # If there is content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False - # If there is content... - if received_message is not None: - # response payload is OK or not OK - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.debug("Timeout!!!!") - return False + self.logger.debug("Request cancelled: an existing request is in progress.") + return False def _handler_hd_calibration_sync(self, message): """ @@ -153,7 +148,7 @@ """ record_packets = self._utilities.prepare_record_to_send_to_fw(hd_calibration_record) - self.logger.debug('Setting HD calibration record') + self.logger.debug("Setting HD calibration record") # Update all the data packets with the last message count since is the number of messages that firmware # should receive @@ -175,6 +170,9 @@ self.logger.debug("Timeout!!!!") return False + self.logger.debug("Finished sending HD calibration record.") + return True + def _setup_base_calibration_record(self): """ Handles assembling the sub dictionaries of each hardware group to make the main HD calibration_record record. Index: dialin/hd/service_record.py =================================================================== diff -u -r04d9678a26c46fe1567d9e8eecd80414a94ee4bc -r6895b99c133b8d5820df5610c3b12ac55a521998 --- dialin/hd/service_record.py (.../service_record.py) (revision 04d9678a26c46fe1567d9e8eecd80414a94ee4bc) +++ dialin/hd/service_record.py (.../service_record.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) @@ -52,77 +52,49 @@ self.service_data = 0 self._raw_service_record = [] self._utilities = NVOpsUtils(logger=self.logger) - # Service main record - self.hd_service_record = OrderedDict() + self.hd_service_record = self._prepare_hd_service_record() if self.can_interface is not None: channel_id = DenaliChannels.hd_to_dialin_ch_id msg_id = MsgIds.MSG_ID_HD_SEND_SERVICE_RECORD.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_service_sync) - # Prepare the service record by putting sub-dictionaries together - self._prepare_hd_service_record() - def init_excel_report(self, directory: str): + def cmd_request_hd_service_record(self): """ - Prepares the excel report in the provided directory - @param directory: (str) the directory - @return: None - """ - - # Prepare the excel report and workspace - self._utilities.prepare_excel_report('HD', 'Service', directory) - - def is_reading_record_done(self): - """ - Handles getting the status of reading record - - @return: True if reading is done otherwise False - """ - return self._utilities.get_writing_to_excel_status() - - def get_hd_service_record(self): - """ Handles getting HD service record from firmware. - @return: None + @return: 1 upon success, False otherwise """ if self._is_getting_service_in_progress is not True: self._is_getting_service_in_progress = True # Clear the list for the next call self._raw_service_record.clear() - # Run the firmware commands to get the record - self._request_hd_fw_service_record() - def _request_hd_fw_service_record(self): - """ - Handles getting HD service record from firmware. + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_GET_SERVICE_RECORD.value) - @return: None - """ - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_GET_SERVICE_RECORD.value) + self.logger.debug('Getting HD service record') - self.logger.debug('Getting HD service record') + received_message = self.can_interface.send(message) - received_message = self.can_interface.send(message) + # If there is content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False - # If there is content... - if received_message is not None: - # response payload is OK or not OK - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.debug("Timeout!!!!") - return False + self.logger.debug("Request cancelled: an existing request is in progress.") + return False - @_publish(["current_message", "total_messages", "received_msg_length", "service_data"]) def _handler_hd_service_sync(self, message): """ Handles published HD system record messages. HD system records are captured for processing and updating the HD system record. @param message: published HD system record data message - @return: None """ curr = struct.unpack('i', bytearray( @@ -152,31 +124,30 @@ # Done with receiving the messages self._is_getting_service_in_progress = False # If all the messages have been received, call another function to process the raw data - self._utilities.process_received_record_from_fw(self.hd_service_record, self._raw_service_record, - write_to_excel=self._write_fw_data_to_excel) + self._utilities.process_received_record_from_fw(self.hd_service_record, self._raw_service_record) + self._handler_received_complete_hd_service_record() - def set_hd_service_record(self): + @_publish(["hd_service_record"]) + def _handler_received_complete_hd_service_record(self): """ - Handles updating the HD system and sends it to FW. + Publishes the received service record - @return: none + @return: None """ - # Read the data from firmware but do not update the excel document - # At this step, another read from firmware is requested internally to update the dictionary. - # The values in the dictionary is compared against the excel report and if they are different, it automatically - # sets the calibration time and calculates the CRC for that group. By default once a read from firmware is - # requested, the excel report is updated automatically. - self._write_fw_data_to_excel = False - self.get_hd_service_record() - # Wait until reading calibration record from firmware is updated - while self._utilities.get_reading_record_status() is not True: - time.sleep(self._DIALIN_RECORD_UPDATE_DELAY_S) + self.logger.debug("Received a complete hd service record.") - self._utilities.write_excel_record_to_calibration_record(self.hd_service_record) - record_packets = self._utilities.prepare_record_to_send_to_fw(self.hd_service_record) + def cmd_set_hd_service_record(self, hd_service_record: OrderedDict): + """ + Handles updating the HD system and sends it to FW. + @param hd_service_record: (OrderedDict) the hd service record to be sent + @return: True upon success, False otherwise + """ + self.logger.debug('Setting HD service record') + record_packets = self._utilities.prepare_record_to_send_to_fw(hd_service_record) + # Update all the data packets with the last message count since is the number of messages that firmware # should receive for packet in record_packets: @@ -197,12 +168,16 @@ self.logger.debug("Timeout!!!!") return False + self.logger.debug("Finished sending HD service record.") + return True + def _prepare_hd_service_record(self): """ Handles assembling the sub dictionaries of each group to make the main HD service record. - @return: None + @return: (OrderedDict) an assembled hd service record """ + result = OrderedDict() groups_byte_size = 0 # create a list of the functions of the sub dictionaries functions = [self._prepare_service_record()] @@ -211,7 +186,7 @@ # Update the groups bytes size so far to be use to padding later groups_byte_size += function[1] # Update the calibration record - self.hd_service_record.update(function[0]) + result.update(function[0]) # Build the CRC of the main calibration_record record record_crc = OrderedDict({'crc': ['