Index: dialin/dg/calibration_record.py =================================================================== diff -u -rc96c0b63250155c3bc1610cf9dab60cc56106df1 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision c96c0b63250155c3bc1610cf9dab60cc56106df1) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -133,7 +133,7 @@ self.total_messages = total self.received_msg_length = length # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total - # messages + the received_msg_length of calibration_record. The rest is the CAN messaging CRC that is not needed + # 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.received_msg_length Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -26,7 +26,7 @@ from .heaters import Heaters from .temperature_sensors import TemperatureSensors from .conductivity_sensors import ConductivitySensors -from .heat_disinfection import HeatDisinfection +from .heat_disinfect import HeatDisinfect from .thermistors import Thermistors from .fans import Fans from .uv_reactors import UVReactors @@ -148,7 +148,7 @@ self.conductivity_sensors = ConductivitySensors(self.can_interface, self.logger) self.concentrate_pumps = ConcentratePumps(self.can_interface, self.logger) self.alarms = DGAlarms(self.can_interface, self.logger) - self.heat_disinfect = HeatDisinfection(self.can_interface, self.logger) + self.heat_disinfect = HeatDisinfect(self.can_interface, self.logger) self.thermistors = Thermistors(self.can_interface, self.logger) self.fans = Fans(self.can_interface, self.logger) self.uv_reactors = UVReactors(self.can_interface, self.logger) @@ -161,7 +161,7 @@ """ Gets the DG version. Assumes DG version has already been requested. - @return: The dg version string + @return: The hd version string """ return self.dg_version Index: dialin/dg/heat_disinfect.py =================================================================== diff -u -r681b3e2813b532d2a15cfeec76fe46fdaf4282e0 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision 681b3e2813b532d2a15cfeec76fe46fdaf4282e0) +++ dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -136,4 +136,3 @@ else: self.logger.debug("Timeout!!!!") return False - Fisheye: Tag dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 refers to a dead (removed) revision in file `dialin/dg/heat_disinfection.py'. Fisheye: No comparison available. Pass `N' to diff? Index: dialin/dg/scheduled_runs_record.py =================================================================== diff -u -rd384151f5e4718f092f9cafbf537fbca34b44e07 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/dg/scheduled_runs_record.py (.../scheduled_runs_record.py) (revision d384151f5e4718f092f9cafbf537fbca34b44e07) +++ dialin/dg/scheduled_runs_record.py (.../scheduled_runs_record.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -127,7 +127,7 @@ self.total_messages = total self.received_msg_length = length # The end of scheduled runs record payload is from the start index + 12 bytes for the current message + total - # messages + the received_msg_length of scheduled runs record. The rest is the CAN messaging CRC and is not + # messages + the length of scheduled runs record. The rest is the CAN messaging CRC and is not # needed. end_of_data_index = self.SCHEDULED_RUNS_RECORD_START_INDEX + self.SCHEDULED_RECORD_SPECS_BYTES + self.received_msg_length @@ -176,9 +176,9 @@ data_type = self.DG_SCHEDULED_RUNS_RECORD[group][self.SCHEDULED_RUNS_DATA_TYPE_INDEX] # Check the data type of the padding values (they are unsigned chars) value_bytes = self._get_data_type_bytes(data_type) - # Get the received_msg_length of the padding list + # Get the length of the padding list padding_length = len(self.DG_SCHEDULED_RUNS_RECORD[group][self.SCHEDULED_RUNS_VALUE_INDEX]) - # Add the received_msg_length of the padding bytes to the payload start address + # Add the length of the padding bytes to the payload start address raw_payload_temp_start_index += padding_length * value_bytes # The rest of the groups are hardware which are layered dictionaries else: @@ -320,7 +320,7 @@ [self.SCHEDULED_RUNS_VALUE_INDEX])) scheduled_runs_record_packets.append(temp_buffer) - # If the group is padding, and the received_msg_length of padding is not 0 + # If the group is padding, and the length of padding is not 0 elif group == 'padding': if len(self.DG_SCHEDULED_RUNS_RECORD[group][self.SCHEDULED_RUNS_VALUE_INDEX]) != 0: # Get the data type and calculate the number of bytes @@ -371,10 +371,10 @@ # Append the temp buffer list into the main list to be process later scheduled_runs_record_packets.append(temp_buffer) # Increment the current message count as a new temp buffer is created for the next data - # packet. Update the current payload received_msg_length with the latest addition to the new temp buffer. + # packet. Update the current payload length with the latest addition to the new temp buffer. current_message_count += 1 current_payload_length = data_type_bytes - # Create a new temp buffer and add the current message count, total received_msg_length of payload so far + # Create a new temp buffer and add the current message count, total length of payload so far # and the data that there was not enough space in the previous data packet. temp_buffer = [struct.pack('>> dg = DG() + >>> hd = DG() >>> observation = {'datetime': datetime.datetime(2020, 7, 13, 10, 43, 27, 433357), 'valve_state_VBF': {'id': 5, 'state': True}, @@ -188,7 +188,7 @@ 'valve_state_VRO': {'id': 3, 'state': True}, 'valve_state_VSP': {'id': 9, 'state': True}, 'valve_states_all': 8191} - >>> self.logger.debug(dg.valves.sort_by_id(observation)) + >>> self.logger.debug(hd.valves.sort_by_id(observation)) ('valve_state_VRF', 0, True) ('valve_state_VRI', 1, True) Index: dialin/hd/buttons.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/hd/buttons.py (.../buttons.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/hd/buttons.py (.../buttons.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -79,7 +79,7 @@ @return: None """ if len(message["message"]) < 16: - self.logger.debug("Poweroff message id detected, but was the wrong received_msg_length.") + self.logger.debug("Poweroff message id detected, but was the wrong length.") return mode = struct.unpack('h', bytearray( Index: dialin/hd/calibration_record.py =================================================================== diff -u -r885e2476a98df337598e4cd128b339ca9d7783eb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/hd/calibration_record.py (.../calibration_record.py) (revision 885e2476a98df337598e4cd128b339ca9d7783eb) +++ dialin/hd/calibration_record.py (.../calibration_record.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -49,7 +49,7 @@ self._is_getting_cal_in_progress = False self._write_fw_data_to_excel = True self.cal_data = 0 - self.raw_cal_record = [] + self._raw_cal_record = [] self._utilities = NVOpsUtils() # Calibration main record self.hd_calibration_record = OrderedDict() @@ -63,6 +63,17 @@ # Prepare the calibration_record record by putting sub-dictionaries together self._prepare_hd_calibration_record() + # Prepare the excel report and workspace + self._utilities.prepare_excel_report('HD', 'Calibration') + + 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_calibration_record(self): """ Handles getting HD calibration_record data from firmware. @@ -72,7 +83,7 @@ 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() + self._raw_cal_record.clear() # Run the firmware commands to get the calibration_record record self._request_hd_fw_calibration_record() @@ -118,7 +129,7 @@ self.total_messages = total self.received_msg_length = length # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total - # messages + the received_msg_length of calibration_record. The rest is the CAN messaging CRC that is not needed + # 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.received_msg_length @@ -128,15 +139,59 @@ # 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: # Done with receiving the messages self._is_getting_cal_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_calibration_record, self.raw_cal_record, + self._utilities.process_received_record_from_fw(self.hd_calibration_record, self._raw_cal_record, write_to_excel=self._write_fw_data_to_excel) + def set_hd_calibration_record(self): + """ + Handles updating the HD calibration_record 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 + # 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_calibration_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) + + # Write the excel record + self._utilities.write_excel_record_to_dialin_record(self.hd_calibration_record) + record_packets = self._utilities.prepare_record_to_send_to_fw(self.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 + for packet in record_packets: + # Sleep to let the firmware receive and process the data + time.sleep(self._PAYLOAD_TRANSFER_DELAY_S) + + # Convert the list packet to a bytearray + payload = b''.join(packet) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_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_hd_calibration_record(self): """ Handles assembling the sub dictionaries of each hardware group to make the main HD calibration_record record. @@ -369,46 +424,3 @@ return hardware_group, group_byte_size - def set_hd_calibration_record(self): - """ - Handles updating the HD calibration_record 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 - # 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_calibration_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) - - # Write the excel record - self._utilities.write_excel_record_to_dialin_record(self.hd_calibration_record) - record_packets = self._utilities.prepare_record_to_send_to_fw(self.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 - for packet in record_packets: - # Sleep to let the firmware receive and process the data - time.sleep(self._PAYLOAD_TRANSFER_DELAY_S) - - # Convert the list packet to a bytearray - payload = b''.join(packet) - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=MsgIds.MSG_ID_HD_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 \ No newline at end of file Index: dialin/hd/service_record.py =================================================================== diff -u -rd384151f5e4718f092f9cafbf537fbca34b44e07 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/hd/service_record.py (.../service_record.py) (revision d384151f5e4718f092f9cafbf537fbca34b44e07) +++ dialin/hd/service_record.py (.../service_record.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -93,7 +93,7 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "received_msg_length", "service_data"]) + @_publish(["current_message", "total_messages", "length", "service_data"]) def _handler_hd_service_sync(self, message): """ Handles published HD system record messages. HD system records are captured for @@ -114,7 +114,7 @@ self.total_messages = total self.received_msg_length = length # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total - # messages + the received_msg_length of calibration_record. The rest is the CAN messaging CRC that is not needed + # 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.received_msg_length Index: dialin/hd/system_record.py =================================================================== diff -u -rd384151f5e4718f092f9cafbf537fbca34b44e07 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/hd/system_record.py (.../system_record.py) (revision d384151f5e4718f092f9cafbf537fbca34b44e07) +++ dialin/hd/system_record.py (.../system_record.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -95,7 +95,7 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "received_msg_length", "service_data"]) + @_publish(["current_message", "total_messages", "length", "service_data"]) def _handler_hd_system_sync(self, message): """ Handles published HD system record messages. HD system records are captured for @@ -116,7 +116,7 @@ self.total_messages = total self.received_msg_length = length # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total - # messages + the received_msg_length of calibration_record. The rest is the CAN messaging CRC that is not needed + # 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.received_msg_length Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r18c04cbcd10619250868cec39470a2b29c86121b -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 18c04cbcd10619250868cec39470a2b29c86121b) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -143,7 +143,7 @@ self._handler_treatment_param_settings_response) self.can_interface.register_receiving_publication_function(DenaliChannels.hd_to_ui_ch_id, MsgIds.MSG_ID_USER_SALINE_BOLUS_RESPONSE.value, self._handler_saline_bolus_response) - self.can_interface.register_receiving_publication_function(DenaliChannels.ui_to_hd_ch_id, MsgIds.MSG_ID_UI_SET_UF_VOLUME_PARAMETER.value, + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_to_hd_ch_id, MsgIds.MSG_ID_HD_PRE_TREATMENT_UF_RESPONSE.value, self._handler_uf_volume_setting_response) # initialize variables that will be populated by HD version response Index: dialin/protocols/CAN.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/protocols/CAN.py (.../CAN.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/protocols/CAN.py (.../CAN.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -117,7 +117,7 @@ return [] - # Check payload received_msg_length + # Check payload length payload_length = len(payload) # if payload is larger than 255 return nothing @@ -312,10 +312,10 @@ @staticmethod def get_payload_length(message): """ - Returns payload received_msg_length from message + Returns payload length from message @param message: dictionary with channel_id and message keys - @return:: a unsigned payload received_msg_length + @return:: a unsigned payload length """ return message['message'][DenaliMessage.PAYLOAD_LENGTH_INDEX] @@ -383,7 +383,7 @@ """ LongDialityMessageBuilder is a utility object that helps construct a diality message that is longer than 8 bytes. Basic principle is to construct an object with the - first 8 byte message which contains the received_msg_length of the message, and the later push the + first 8 byte message which contains the length of the message, and the later push the remaining messages. e.g., let's imagine a 3 message packet. obj = LongDialityMessageBuilder(msg1) Index: dialin/ui/hd_simulator.py =================================================================== diff -u -rcdf1c02e39d16c42fcb04a93f7ff180a8533d491 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision cdf1c02e39d16c42fcb04a93f7ff180a8533d491) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -1738,7 +1738,7 @@ def cmd_send_accelerometer_dg_data(self, vX, vY, vZ, vXMax, vYMax, vZMax, vXTilt, vYTilt, vZTilt ): """ - the accelerometer dg data message method + the accelerometer hd data message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: | |0x3400| 0x080 | 8 | 1Hz | N | HD | UI | DG Accelerometer data | @@ -1814,7 +1814,7 @@ def cmd_send_version_dg_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): """ - the dg version response message method + the hd version response message method :param vMajor: Major version number :param vMinor: Minor version number :param vMicro: Micro version number Index: dialin/ui/messageBuilder.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/ui/messageBuilder.py (.../messageBuilder.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/ui/messageBuilder.py (.../messageBuilder.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -54,7 +54,7 @@ def textToByte(vText, vLen): """ - converts the string vText to bytes by the received_msg_length of vLen + converts the string vText to bytes by the length of vLen :param vText: :param vLen: :return: converted text @@ -74,7 +74,7 @@ """ builds message from the parameter givven :param vMsgID: the message ID - :param vLen: received_msg_length of the message payload in bytes + :param vLen: length of the message payload in bytes :param vAck: if true the message requires acknowledge back :param vArgs: payload arguments. :return: Index: dialin/ui/utils.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/ui/utils.py (.../utils.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/ui/utils.py (.../utils.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -116,7 +116,7 @@ and puts the sections from right to left if vRightDirection is True after the split is done :param vString: (str) the given string - :param vPart: (int) received_msg_length of the section + :param vPart: (int) length of the section :param vRightDirection: (bool) order of sections in the output list :return: (list) the section of the string vString in list """ @@ -125,9 +125,9 @@ def padding(vString, vLen): """ - added zero at the right side of the string to be of received_msg_length of vLen + added zero at the right side of the string to be of length of vLen :param vString: (str) the string to add trailing zero to - :param vLen: (int) the entire received_msg_length of the string + :param vLen: (int) the entire length of the string :return: (str) padded string """ lStr = len(vString) Index: dialin/utils/base.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/utils/base.py (.../base.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/utils/base.py (.../base.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -152,7 +152,7 @@ @param is_virtual: (bool) If the interface is virtual or not @param bitrate: (int) The desired bitrate (applies to non-virtual interfaces only) @param restart_ms: (int) The desired restart_ms (applies to non-virtual interfaces only) - @param txqueue: (int) The desired txqueue received_msg_length + @param txqueue: (int) The desired txqueue length @return: """ cmd_iface_up = "sudo ip link set {0} up type can bitrate {1} restart-ms {2}"\ @@ -176,7 +176,7 @@ success, info = run_cmd(cmd_txqueue) if not success: - print("Warning: Could not set txtqueue received_msg_length: {0}".format(cmd_txqueue)) + print("Warning: Could not set txtqueue length: {0}".format(cmd_txqueue)) def create_logger(log_path: str = "/tmp/DialinScript.log", Index: dialin/utils/excel_ops.py =================================================================== diff -u -re949b0efaf7f65be389116f4c905b50cbae60b7d -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/utils/excel_ops.py (.../excel_ops.py) (revision e949b0efaf7f65be389116f4c905b50cbae60b7d) +++ dialin/utils/excel_ops.py (.../excel_ops.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -87,7 +87,7 @@ @param merge: Merge cells. Cells must be provided with A1:A4 format (default none) @param horizontal: Horizontal alignment (default left) @param freeze: Freeze top row (default false) - @param max_col_len: maximum received_msg_length of a column (default none, means it is not restricted) + @param max_col_len: maximum length of a column (default none, means it is not restricted) @return: None """ @@ -101,29 +101,29 @@ # Set the provided data into the specified row and column and set the bold, color and horizontal alignment active_sheet.cell(row=row, column=column).value = data active_sheet.cell(row=row, column=column).font = Font(size=font, bold=bold, name=name) - # Wrapping text is not needed unless the received_msg_length of the data is more than maximum column - # received_msg_length + # Wrapping text is not needed unless the length of the data is more than maximum column + # length active_sheet[cell_name].alignment = Alignment(vertical='center', horizontal=horizontal, wrap_text=False) # Get the width of the current column column_width = active_sheet.column_dimensions[column_letter].width # When the column width is on the default, openpyxl reports None. If the width is reported as None, # it will be set to 0 for math comparison column_width = 0 if column_width is None else column_width - # If the received_msg_length is not provided, use the default maximum received_msg_length + # If the length is not provided, use the default maximum length max_len = self.COLUMN_MAX_WIDTH if max_col_len is None else max_col_len # Remove all the end of the line artifacts length_of_data = len(str(data).rstrip()) - # If the received_msg_length of data was greater than the maximum received_msg_length, calculate the number of + # If the length of data was greater than the maximum length, calculate the number of # rows is needed with the # default height if length_of_data > max_len: - # Since the received_msg_length is greater than maximum, enable wrap text + # Since the length is greater than maximum, enable wrap text active_sheet[cell_name].alignment = Alignment(vertical='center', horizontal=horizontal, wrap_text=True) # Calculate what the row height should be when the cell is extended row_height = math.ceil(length_of_data / max_len) * self.ROW_DEFAULT_HEIGHT active_sheet.column_dimensions[column_letter].width = max_len - # If the received_msg_length of the data provided is already less than the received_msg_length of cell, + # If the length of the data provided is already less than the length of cell, # do nothing elif column_width < length_of_data: active_sheet.column_dimensions[column_letter].width = length_of_data + self.COLUMN_WIDTH_TOLERANCE Index: dialin/utils/nv_ops_utils.py =================================================================== diff -u -re949b0efaf7f65be389116f4c905b50cbae60b7d -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- dialin/utils/nv_ops_utils.py (.../nv_ops_utils.py) (revision e949b0efaf7f65be389116f4c905b50cbae60b7d) +++ dialin/utils/nv_ops_utils.py (.../nv_ops_utils.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -220,6 +220,8 @@ # Clear the temp buffer for the next round of data is_value_different = False dialin_record[group][hardware][spec][1] = crc_value + self.excel_ops.write_to_excel(self._excel_workbook, self._record_name, row, col, + crc_value) col += 2 else: col = 3 @@ -330,9 +332,9 @@ data_type = dialin_record[group][self._DATA_TYPE_INDEX] # Check the data type of the padding values (they are unsigned chars) value_bytes = self.get_data_type_bytes(data_type) - # Get the received_msg_length of the padding list + # Get the length of the padding list padding_length = len(dialin_record[group][self._DATA_VALUE_INDEX]) - # Add the received_msg_length of the padding bytes to the payload start address + # Add the length of the padding bytes to the payload start address raw_payload_temp_start_index += padding_length * value_bytes # The rest of the groups are hardware which are layered dictionaries else: @@ -435,7 +437,7 @@ temp_buffer.append(struct.pack(data_type, dialin_record[group][self._DATA_VALUE_INDEX])) self._record_packets_to_send_to_fw.append(temp_buffer) - # If the group is padding, and the received_msg_length of padding is not 0 + # If the group is padding, and the length of padding is not 0 elif group == 'padding': if len(dialin_record[group][self._DATA_VALUE_INDEX]) != 0: # Get the data type and calculate the number of bytes @@ -489,7 +491,8 @@ # packet since it is the final CRC of the entire dictionary. The final CRC itself # is not included in the CRC calculations. # The actual calibration_record data is started from the 3rd element of the data packet. - # The first 3 are current message, total messages, and the payload received_msg_length of the current packet. + # The first 3 are current message, total messages, and the payload length of the current + # packet. if self._record_packets_to_send_to_fw.index(svc) == len(self._record_packets_to_send_to_fw) - 1: data += b''.join(svc[self._RECORD_SPECS_BYTE_ARRAY:-1]) else: @@ -524,34 +527,35 @@ @param group: dictionary group that is being processed (i.e service_records) @param key: dictionary key of the current group @param temp_buffer: temporary buffer that is holding the values to be converted to bytes - @param current_payload_length: current payload received_msg_length of the temporary buffer (before it gets to maximum allowed) + @param current_payload_length: current payload length of the temporary buffer (before it gets to + maximum allowed) @param current_message_count: current message number of all the payloads @param inner_dict_key: key of a nested dictionary (if it exists) - @return: temp buffer, current message count, current payload received_msg_length + @return: temp buffer, current message count, current payload length """ # No inner key so no nested dictionary if inner_dict_key is None: data_type = dialin_record[group][key][self._DATA_TYPE_INDEX] data_type_bytes = self.get_data_type_bytes(data_type) current_value = dialin_record[group][key][self._DATA_VALUE_INDEX] # This is used only for the data types of self._DICT_VALUE_LIST_LEN: byte_size += current_byte_size * group[key][self._CHAR_LENGTH_INDEX] else: @@ -672,7 +676,7 @@ @staticmethod def calculate_padding_byte_size(total_byte_size, max_buffer_size): """ - Handles calculating the padding received_msg_length based on the provided buffer sizes. This is a static method. + Handles calculating the padding length based on the provided buffer sizes. This is a static method. @param total_byte_size: total byte size of a record dictionary @param max_buffer_size: max buffer size that is allowed to be used in the dictionary Index: tests/dg_heat_disinfect_test.py =================================================================== diff -u -r681b3e2813b532d2a15cfeec76fe46fdaf4282e0 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/dg_heat_disinfect_test.py (.../dg_heat_disinfect_test.py) (revision 681b3e2813b532d2a15cfeec76fe46fdaf4282e0) +++ tests/dg_heat_disinfect_test.py (.../dg_heat_disinfect_test.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -186,6 +186,3 @@ run_heat_disinfect() #actuate_valve() - - - Index: tests/dg_heaters_test.py =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/dg_heaters_test.py (.../dg_heaters_test.py) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ tests/dg_heaters_test.py (.../dg_heaters_test.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -30,48 +30,48 @@ """ - dg.ro_pump.cmd_ro_pump_set_point_override(120) + hd.ro_pump.cmd_ro_pump_set_point_override(120) - dg.heaters.cmd_set_dialysate_target_temperature() + hd.heaters.cmd_set_dialysate_target_temperature() sleep(1) - #dg.heaters.cmd_start_primary_heater() + #hd.heaters.cmd_start_primary_heater() #sleep(1) - dg.heaters.cmd_start_trimmer_heater() + hd.heaters.cmd_start_trimmer_heater() sleep(1) - #dg.heaters.cmd_heaters_broadcast_interval_override(200) - #dg.temperature_sensors.cmd_temperature_sensors_override_value(0, 125.0, reset=1) - #dg.temperature_sensors.cmd_temperature_sensors_broadcast_interval_override(200, reset=1) + #hd.heaters.cmd_heaters_broadcast_interval_override(200) + #hd.temperature_sensors.cmd_temperature_sensors_override_value(0, 125.0, reset=1) + #hd.temperature_sensors.cmd_temperature_sensors_broadcast_interval_override(200, reset=1) - #dg.ro_pump.cmd_ro_flow_rate_override(0.46) + #hd.ro_pump.cmd_ro_flow_rate_override(0.46) while True: - print("TPi: {}, TPo: {}, TD1: {}, TD2: {}, TRo: {}, TDi: {}".format(dg.temperature_sensors.inlet_primary, - dg.temperature_sensors.outlet_primary, - dg.temperature_sensors.cd1, - dg.temperature_sensors.cd2, - dg.temperature_sensors.outlet_redundancy, - dg.temperature_sensors.inlet_dialysate)) - #print("Main Primary Heater DC: {}".format(dg.heaters.mainPrimaryHeaterPWM)) - #print("Small Primary Heater DC: {}".format(dg.heaters.smallPrimaryHeaterPWM)) - #print("Trimmer Heater DC: {}".format(dg.heaters.trimmerHeaterPWM)) + print("TPi: {}, TPo: {}, TD1: {}, TD2: {}, TRo: {}, TDi: {}".format(hd.temperature_sensors.inlet_primary, + hd.temperature_sensors.outlet_primary, + hd.temperature_sensors.cd1, + hd.temperature_sensors.cd2, + hd.temperature_sensors.outlet_redundancy, + hd.temperature_sensors.inlet_dialysate)) + #print("Main Primary Heater DC: {}".format(hd.heaters.mainPrimaryHeaterPWM)) + #print("Small Primary Heater DC: {}".format(hd.heaters.smallPrimaryHeaterPWM)) + #print("Trimmer Heater DC: {}".format(hd.heaters.trimmerHeaterPWM)) sleep(1) counter = counter + 1 if counter > 60: #print(counter) break - dg.heaters.cmd_stop_trimmer_heater() - #dg.heaters.cmd_stop_primary_heater() + hd.heaters.cmd_stop_trimmer_heater() + #hd.heaters.cmd_stop_primary_heater() sleep(1) while True: - print("Main Primary Heater DC: {}".format(dg.heaters.mainPrimaryHeaterPWM)) - print("Small Primary Heater DC: {}".format(dg.heaters.smallPrimaryHeaterPWM)) - print("Trimmer Heater DC: {}".format(dg.heaters.trimmerHeaterPWM)) + print("Main Primary Heater DC: {}".format(hd.heaters.mainPrimaryHeaterPWM)) + print("Small Primary Heater DC: {}".format(hd.heaters.smallPrimaryHeaterPWM)) + print("Trimmer Heater DC: {}".format(hd.heaters.trimmerHeaterPWM)) sleep(0.7) """ Index: tests/dg_valves_test.py =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/dg_valves_test.py (.../dg_valves_test.py) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ tests/dg_valves_test.py (.../dg_valves_test.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -20,7 +20,7 @@ from time import sleep if __name__ == "__main__": - # Create an instance of the DG Class called dg + # Create an instance of the DG Class called hd dg = DG() sleep(2) Index: tests/set_RTCs.py =================================================================== diff -u -r91dc90bd009bdbf5621dcaa1bc12ab3d691673f7 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/set_RTCs.py (.../set_RTCs.py) (revision 91dc90bd009bdbf5621dcaa1bc12ab3d691673f7) +++ tests/set_RTCs.py (.../set_RTCs.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -25,7 +25,7 @@ if __name__ == "__main__": # create an HD object called hd hd = HD() - # create a DG object called dg + # create a DG object called hd dg = DG() sleep(2) Index: tests/set_accels_cal.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/set_accels_cal.py (.../set_accels_cal.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ tests/set_accels_cal.py (.../set_accels_cal.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -24,26 +24,26 @@ # create an HD object called hd hd = HD() # create an DG object called hd - #dg = DG() + #hd = DG() sleep(2) # log in to HD and DG as tester if hd.cmd_log_in_to_hd() == 0: exit(1) - #if dg.cmd_log_in_to_dg() == 0: + #if hd.cmd_log_in_to_dg() == 0: # exit(1) sleep(1) #reset calibrations hd.accel.cmd_set_accel_calibration(0, 0, 0) - #dg.accel.cmd_set_accel_calibration(0, 0, 0) + #hd.accel.cmd_set_accel_calibration(0, 0, 0) #wait for new readings after calibration_record reset sleep(5) #calculate offsets (assuming HD and DG systems are level) hd_offsets = hd.accel.get_accel_vector() - #dg_offsets = dg.accel.get_accel_vector() + #dg_offsets = hd.accel.get_accel_vector() hd_offsets.x *= -1.0 hd_offsets.y *= -1.0 hd_offsets.z -= 1.0 @@ -55,6 +55,6 @@ #set new offsets hd.accel.cmd_set_accel_calibration(hd_offsets.x, hd_offsets.y, hd_offsets.z) - #dg.accel.cmd_set_accel_calibration(dg_offsets.x, dg_offsets.y, dg_offsets.z) + #hd.accel.cmd_set_accel_calibration(dg_offsets.x, dg_offsets.y, dg_offsets.z) exit(0) Index: tests/test_can_protocol.py =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_can_protocol.py (.../test_can_protocol.py) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ tests/test_can_protocol.py (.../test_can_protocol.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -85,9 +85,9 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description="Dial-In Core Can Protocol \n" "\tExample: \n" - "\tpython3 CoreCanProtocol.py --test-dg --log-level=\"debug\"", + "\tpython3 CoreCanProtocol.py --test-hd --log-level=\"debug\"", formatter_class=RawTextHelpFormatter) - parser.add_argument("--test-dg", action="store_true") + parser.add_argument("--test-hd", action="store_true") parser.add_argument("--log-level", default="error") args = parser.parse_args() Index: tests/test_dg.py =================================================================== diff -u -r8ea13ae6dd10732bfcc456798f4785c4d88c95d3 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_dg.py (.../test_dg.py) (revision 8ea13ae6dd10732bfcc456798f4785c4d88c95d3) +++ tests/test_dg.py (.../test_dg.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -44,12 +44,12 @@ def test_dg_login(self): raise NotImplementedError """ - # create an DG object called dg - dg = DG() + # create an DG object called hd + hd = DG() # wait 2 seconds and then login to DG as a tester sleep(2) - dg.cmd_log_in_to_dg() + hd.cmd_log_in_to_dg() """ Index: tests/test_dg_records.py =================================================================== diff -u -re949b0efaf7f65be389116f4c905b50cbae60b7d -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_dg_records.py (.../test_dg_records.py) (revision e949b0efaf7f65be389116f4c905b50cbae60b7d) +++ tests/test_dg_records.py (.../test_dg_records.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -1,5 +1,4 @@ from dialin.dg.dialysate_generator import DG -from dialin.ui import crc from time import sleep @@ -46,6 +45,7 @@ except KeyboardInterrupt: pass + def process_service_record(read=False): sys = dg.service_record @@ -78,7 +78,7 @@ #process_calibration_record(read=False) #process_system_record(read=True) - process_service_record(read=True) + process_service_record(read=False) Fisheye: Tag dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 refers to a dead (removed) revision in file `tests/test_dg_scheduled_runs.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 refers to a dead (removed) revision in file `tests/test_dg_service_record.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 refers to a dead (removed) revision in file `tests/test_dg_system_record.py'. Fisheye: No comparison available. Pass `N' to diff? Index: tests/test_gen_requirements.py =================================================================== diff -u -ra3f3f5ca6fcb24a47bb3056878bb8ff9e3642fd2 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_gen_requirements.py (.../test_gen_requirements.py) (revision a3f3f5ca6fcb24a47bb3056878bb8ff9e3642fd2) +++ tests/test_gen_requirements.py (.../test_gen_requirements.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -121,17 +121,17 @@ dg = DG() modules = [ - # dg.hd_proxy, - # dg.load_cells, - # dg.pressures, - # dg.reservoirs, - # dg.valves, - # dg.ro_pump, - # dg.drain_pump, - # dg.heaters, - # dg.temperature_sensors, - # dg.conductivity_sensors, - # dg.accel, + # hd.hd_proxy, + # hd.load_cells, + # hd.pressures, + # hd.reservoirs, + # hd.valves, + # hd.ro_pump, + # hd.drain_pump, + # hd.heaters, + # hd.temperature_sensors, + # hd.conductivity_sensors, + # hd.accel, dg.alarms, dg.concentrate_pumps, dg.fans, Index: tests/test_hd_records.py =================================================================== diff -u -r7cd740bfb30cafa48847843cd09c3ee346b882a4 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_hd_records.py (.../test_hd_records.py) (revision 7cd740bfb30cafa48847843cd09c3ee346b882a4) +++ tests/test_hd_records.py (.../test_hd_records.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -1,65 +1,81 @@ -import sys -import struct -sys.path.append("..") from dialin.hd.hemodialysis_device import HD -from dialin.utils.nv_ops_utils import NVOpsUtils - from time import sleep -if __name__ == "__main__": - # create an HD object called hd - hd = HD(log_level='DEBUG') - if hd.cmd_log_in_to_hd() == 0: - exit(1) - sleep(2) +def process_calibration_record(read=False): cal = hd.calibration_record - sys = hd.system_record - srv = hd.service_record - utilities = NVOpsUtils() + print(cal.hd_calibration_record) - #print(cal.hd_calibration_record) - print(srv.dg_service_record) - cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['x_offset'][1] = 952.12 - cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['y_offset'][1] = 45.2 - cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['z_offset'][1] = 712.58 - cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['cal_time'][1] = utilities.get_current_time_in_epoch() - #print(sys.dg_system_record) + try: + if read: + cal.get_hd_calibration_record() + while True: + sleep(0.5) + if cal.cal_data != 0: + if cal.is_reading_record_done(): + break + else: + cal.set_hd_calibration_record() - #sys.dg_service_record['system_record']['top_level_pn'][1] = 'abcd-12345' - #sys.dg_service_record['system_record']['mfg_date'][1] = _utilities.get_current_time_in_epoch() + print(cal.hd_calibration_record) - #srv.dg_service_record['service_record']['service_date'][1] = _utilities.get_current_time_in_epoch() + except KeyboardInterrupt: + pass - status = True +def process_system_record(read=False): + + sys = hd.system_record + print(sys.hd_system_record) + try: - if status: - dara = [] - #cal.get_hd_calibration_record() - #sys.get_hd_system_record() - srv.get_dg_service_record() + if read: + sys.get_hd_system_record() while True: - sleep(0.2) - #print(cal.current_message, cal.total_messages, cal.service_data) + sleep(0.5) + if sys.is_reading_record_done(): + if sys.is_reading_record_done(): + break + else: + sys.set_hd_system_record() - if srv.service_data != 0: - #f.write(str(cal.service_data) + '\r') - #dara.append(cal.service_data) + print(sys.hd_system_record) - if srv.current_message == srv.total_messages: - #f.close() + except KeyboardInterrupt: + pass + + +def process_service_record(read=False): + + sys = hd.service_record + print(sys.hd_service_record) + + try: + if read: + sys.get_hd_service_record() + while True: + sleep(0.5) + if sys.is_reading_record_done(): + if sys.is_reading_record_done(): break else: - #cal.set_hd_calibration_record() - #sys.set_hd_system_record() - srv.set_dg_service_record() + sys.set_hd_service_record() - #print(cal.hd_calibration_record) - #print(sys.dg_system_record) - print(srv.dg_service_record) + print(sys.hd_service_record) except KeyboardInterrupt: - #f.close() pass + + +if __name__ == "__main__": + # Create an instance of the DG Class + hd = HD(log_level='DEBUG') + + if hd.cmd_log_in_to_hd() == 0: + exit(1) + sleep(2) + + process_calibration_record(read=False) + #process_system_record(read=True) + #process_service_record(read=False) \ No newline at end of file Index: tests/test_logging.py =================================================================== diff -u -re10534f3df259e137e0ba14d897ecef42a767737 -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_logging.py (.../test_logging.py) (revision e10534f3df259e137e0ba14d897ecef42a767737) +++ tests/test_logging.py (.../test_logging.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -30,7 +30,7 @@ @return: None """ if False: - # dg = DG(log_level="INFO") + # hd = DG(log_level="INFO") dg = DG() if dg.cmd_log_in_to_dg(): dg.cmd_ui_request_dg_version() Index: tests/test_uf.py =================================================================== diff -u -r18c04cbcd10619250868cec39470a2b29c86121b -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 --- tests/test_uf.py (.../test_uf.py) (revision 18c04cbcd10619250868cec39470a2b29c86121b) +++ tests/test_uf.py (.../test_uf.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) @@ -23,7 +23,7 @@ if __name__ == "__main__": # create an HD object called hd hd = HD() - # create a DG object called dg + # create a DG object called hd dg = DG() sleep(2) @@ -33,7 +33,7 @@ # log in to HD and DG as tester # if hd.cmd_log_in_to_hd() == 0: # exit(1) -# if dg.cmd_log_in_to_dg() == 0: +# if hd.cmd_log_in_to_dg() == 0: # exit(1) # sleep(1)