Index: dialin/dg/calibration_record.py =================================================================== diff -u -r5fe81152c836440fe3c41308ebcc02cfbedce2cd -r7cd740bfb30cafa48847843cd09c3ee346b882a4 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision 5fe81152c836440fe3c41308ebcc02cfbedce2cd) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision 7cd740bfb30cafa48847843cd09c3ee346b882a4) @@ -48,6 +48,7 @@ self.length = 0 self.cal_data = 0 self._raw_cal_record = [] + self._write_fw_data_to_excel = True self._utilities = NVOpsUtils() # DG calibration_record main record self.dg_calibration_record = OrderedDict() @@ -65,8 +66,12 @@ self._utilities.prepare_excel_report('DG', 'Calibration') def is_reading_record_done(self): + """ + Handles getting the status of reading record - return self._utilities.get_reading_status() + @return: True if reading is done otherwise False + """ + return self._utilities.get_writing_to_excel_status() def get_dg_calibration_record(self): """ @@ -134,8 +139,49 @@ 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, + write_to_excel=self._write_fw_data_to_excel) + def set_dg_calibration_record(self): + """ + Handles updating the DG calibration record with the newest calibration_record data of a hardware and + sends it to FW. + + @return: none + """ + # Read the data from firmware but do not update the excel document + self._write_fw_data_to_excel = False + self.get_dg_calibration_record() + + while self._utilities.get_reading_record_status() is not True: + time.sleep(0.2) + + self._utilities.write_excel_record_to_dialin_record(self.dg_calibration_record) + + record_packets = self._utilities.prepare_record_to_send_to_fw(self.dg_calibration_record) + + self.logger.debug('Setting DG calibration started') + + # 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: + # Sleep to let the firmware receive and process the data + time.sleep(self._PAYLOAD_TRANSFER_DELAY) + + # Convert the list packet to a bytearray + payload = b''.join(packet) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_SET_CALIBRATION_RECORD.value, + payload=payload) + + received_message = self.can_interface.send(message) + + # If there is no content... + if received_message is None: + self.logger.debug("Timeout!!!!") + return False + def _prepare_dg_calibration_record(self): """ Handles assembling the sub dictionaries of each hardware group to make the main DG calibration record. @@ -497,38 +543,3 @@ hardware_group[group_name] = hardware return hardware_group, group_byte_size - - def set_dg_calibration_record(self): - """ - Handles updating the DG calibration record with the newest calibration_record data of a hardware and - sends it to FW. - - @return: none - """ - - self._utilities.write_excel_record_to_dialin_record(self.dg_calibration_record) - - record_packets = self._utilities.prepare_record_to_send_to_fw(self.dg_calibration_record) - - self.logger.debug('Setting DG calibration started') - - # 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: - # Sleep to let the firmware receive and process the data - time.sleep(self._PAYLOAD_TRANSFER_DELAY) - - # Convert the list packet to a bytearray - payload = b''.join(packet) - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, - message_id=MsgIds.MSG_ID_DG_SET_CALIBRATION_RECORD.value, - payload=payload) - - received_message = self.can_interface.send(message) - - # If there is no content... - if received_message is None: - self.logger.debug("Timeout!!!!") - return False - Index: dialin/dg/system_record.py =================================================================== diff -u -r5fe81152c836440fe3c41308ebcc02cfbedce2cd -r7cd740bfb30cafa48847843cd09c3ee346b882a4 --- dialin/dg/system_record.py (.../system_record.py) (revision 5fe81152c836440fe3c41308ebcc02cfbedce2cd) +++ dialin/dg/system_record.py (.../system_record.py) (revision 7cd740bfb30cafa48847843cd09c3ee346b882a4) @@ -48,17 +48,21 @@ self.length = 0 self.sys_data = 0 self.raw_system_record = [] - self.utilities = NVOpsUtils() + self._utilities = NVOpsUtils() # System main record self.dg_system_record = OrderedDict() if self.can_interface is not None: channel_id = DenaliChannels.dg_to_dialin_ch_id msg_id = MsgIds.MSG_ID_DG_SEND_SYSTEM_RECORD.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_dg_system_sync) + # Prepare the system record by putting sub-dictionaries together self._prepare_dg_system_record() + # Prepare the excel report and workspace + self._utilities.prepare_excel_report('DG', 'System') + def get_dg_system_record(self): """ Handles getting HD calibration_record data from firmware. @@ -70,6 +74,14 @@ # Run the firmware commands to get the record self._request_dg_fw_system_record() + 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 _request_dg_fw_system_record(self): """ Handles getting DG system record from firmware. @@ -125,7 +137,7 @@ 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_system_record, self.raw_system_record) + self._utilities.process_received_record_from_fw(self.dg_system_record, self.raw_system_record) def _prepare_dg_system_record(self): """ @@ -147,10 +159,10 @@ record_crc = OrderedDict({'crc': ['