Index: dialin/common/dg_defs.py =================================================================== diff -u -r2e20a6df69477c796f8c8912ff77cf3b1c1c1b45 -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/common/dg_defs.py (.../dg_defs.py) (revision 2e20a6df69477c796f8c8912ff77cf3b1c1c1b45) +++ dialin/common/dg_defs.py (.../dg_defs.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -276,6 +276,22 @@ @unique +class DGROPermeateSampleSates(DialinEnum): + DG_RO_PERM_SAMPLE_STATE_START = 0 + DG_RO_PERM_SAMPLE_STATE_DRAIN_R1 = 1 + DG_RO_PERM_SAMPLE_STATE_DRAIN_R2 = 2 + DG_RO_PERM_SAMPLE_STATE_FLUSH_DRAIN = 3 + DG_RO_PERM_SAMPLE_STATE_FLUSH_DIALYSATE = 4 + DG_RO_PERM_SAMPLE_STATE_FLUSH_CONCENTRATE_STRAWS = 5 + DG_RO_PERM_SAMPLE_STATE_FLUSH_R2_TO_R1_AND_DRAIN_R1 = 6 + DG_RO_PERM_SAMPLE_STATE_SAMPLE_COLLECTION = 7 + DG_RO_PERM_SAMPLE_STATE_CANCEL_BASIC_PATH = 8 + DG_RO_PERM_SAMPLE_STATE_CANCEL_WATER_PATH = 9 + DG_RO_PERM_SAMPLE_STATE_COMPLETE = 10 + NUM_OF_DG_RO_PERM_STATES = 11 + + +@unique class DGEventList(DialinEnum): DG_EVENT_STARTUP = 0 # DG startup event DG_EVENT_OP_MODE_CHANGE = 1 # DG Op mode change event @@ -309,4 +325,4 @@ @unique class DGServiceModesStates(DialinEnum): DG_SERVICE_STATE_START = 0 # Start service mode state - NUM_OF_DG_SERVICE_STATES = 1 # Number of service mode states \ No newline at end of file + NUM_OF_DG_SERVICE_STATES = 1 # Number of service mode states Index: dialin/common/msg_ids.py =================================================================== diff -u -r1b04b37b3a327b145b150477f567e26a26c60e4e -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 1b04b37b3a327b145b150477f567e26a26c60e4e) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -221,6 +221,8 @@ MSG_ID_DG_START_STOP_HEAT_DISINFECT_ACTIVE_COOL = 0xC6 MSG_ID_HD_AIR_PUMP_DATA = 0xC7 MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG = 0xC8 + MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST = 0xC9 + MSG_ID_DG_RO_PERMEATE_SAMPLE_DATA = 0xCA MSG_ID_CAN_ERROR_COUNT = 0x999 @@ -375,6 +377,7 @@ MSG_ID_HD_SEND_TEST_CONFIGURATION = 0x8095 MSG_ID_HD_RESET_ALL_TEST_CONFIGURATIONS = 0x8096 MSG_ID_HD_SET_TEST_CONFIGURATION = 0x8097 + MSG_ID_HD_SIGNAL_RECOVER_FROM_FAULT_MODE = 0x8098 MSG_ID_DG_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 Index: dialin/dg/chemical_disinfect.py =================================================================== diff -u -r0188c0a21079a4c92efca69e298beeccb93ed22c -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/dg/chemical_disinfect.py (.../chemical_disinfect.py) (revision 0188c0a21079a4c92efca69e298beeccb93ed22c) +++ dialin/dg/chemical_disinfect.py (.../chemical_disinfect.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -65,7 +65,6 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_chemical_disinfect_to_ui_sync) - def clear_chem_disinfect_info(self) -> None: """ Clears public class properties that are updated by the handler. Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r0188c0a21079a4c92efca69e298beeccb93ed22c -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 0188c0a21079a4c92efca69e298beeccb93ed22c) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -53,6 +53,7 @@ from .sw_configs import DGSoftwareConfigs from .usage_info_record import DGUsageNVRecord from .dg_test_configs import DGTestConfig +from .ro_permeate_sample import ROPermeateSample from ..common.msg_defs import MsgIds, MsgFieldPositions from enum import unique from .constants import NO_RESET @@ -206,6 +207,7 @@ self.sw_configs = DGSoftwareConfigs(self.can_interface, self.logger) self.usage_record = DGUsageNVRecord(self.can_interface, self.logger) self.test_configs = DGTestConfig(self.can_interface, self.logger) + self.ro_permeate_sample = ROPermeateSample(self.can_interface, self.logger) def __del__(self): self.can_interface.transmit_interval_dictionary[self.callback_id].stop() Index: dialin/dg/hd_proxy.py =================================================================== diff -u -rb2883ad890516361d0c22919811ff1d5752c0aaf -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision b2883ad890516361d0c22919811ff1d5752c0aaf) +++ dialin/dg/hd_proxy.py (.../hd_proxy.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -403,6 +403,38 @@ self.logger.debug("Timeout!!!!") return False + def cmd_start_stop_dg_ro_permeate_sample(self, start: bool = True) -> int: + """ + Constructs and sends the start/stop DG RO permeate sample command + + @param start: (bool) True = start RO permeate sample, False = stop RO permeate sample. + @return: non-zero integer if successful, False otherwise + """ + # 1 is to start + if start: + cmd = 1 + str_text = "Starting" + else: + cmd = 0 + str_text = "Stopping" + payload = integer_to_bytearray(cmd) + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id= + MsgIds.MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST.value, + payload=payload) + + self.logger.debug(str_text + " DG RO permeate sample") + + 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 + def cmd_resend_dg_alarms(self) -> int: """ Constructs and sends the re-send DG alarms command Index: dialin/dg/heat_disinfect.py =================================================================== diff -u -r6ff50b4ae97f1d8071f1d8fdafae60f6fd704b9d -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision 6ff50b4ae97f1d8071f1d8fdafae60f6fd704b9d) +++ dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -122,7 +122,7 @@ self.r2_level = 0 self.heat_disinfect_ui_state = 0 - @publish(["dg_heat_disinfection_time_timestamp","heat_disinfect_target_time", "heat_disinfect_count_down_time"]) + @publish(["dg_heat_disinfection_time_timestamp", "heat_disinfect_target_time", "heat_disinfect_count_down_time"]) def _handler_heat_disinfect_to_ui_sync(self, message, timestamp=0.0): """ Handles published heat disinfect message Index: dialin/dg/ro_permeate_sample.py =================================================================== diff -u --- dialin/dg/ro_permeate_sample.py (revision 0) +++ dialin/dg/ro_permeate_sample.py (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -0,0 +1,68 @@ + + +import struct +from logging import Logger +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..protocols.CAN import DenaliMessage, DenaliChannels +from ..utils.base import AbstractSubSystem, publish, DialinEnum +from ..utils.conversions import integer_to_bytearray, bytearray_to_integer, bytearray_to_float + + +class ROPermeateSample(AbstractSubSystem): + """ + RO permeate sample class with APIs to set the timing of each of the stages. + """ + + def __init__(self, can_interface, logger: Logger): + super().__init__() + + self.can_interface = can_interface + self.logger = logger + + self.ro_permeate_sample_state = 0 + self.overall_elapsed_time = 0 + self.state_elapsed_time = 0 + self.dispensed_volume_ml = 0.0 + + if self.can_interface is not None: + channel_id = DenaliChannels.dg_sync_broadcast_ch_id + msg_id = MsgIds.MSG_ID_DG_RO_PERMEATE_SAMPLE_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self._handler_ro_permeate_sample_sync) + + def clear_ro_permeate_sample_info(self) -> None: + """ + Clears public class properties that are updated by the handler. + + @returns none + """ + self.ro_permeate_sample_state = 0 + self.overall_elapsed_time = 0 + self.state_elapsed_time = 0 + self.dispensed_volume_ml = 0.0 + + def get_ro_permeate_sample_state(self) -> int: + """ + Gets RO permeate sample State + + @return: (int) + """ + return self.ro_permeate_sample_state + + def get_ro_permeate_dispensed_volume_ml(self) -> float: + """ + Gets RO permeate sample dispensed volume in milliliters + + @return: (float) + """ + return self.dispensed_volume_ml + + @publish(["ro_permeate_sample_state", "overall_elapsed_time", "state_elapsed_time", "dispensed_volume_ml"]) + def _handler_ro_permeate_sample_sync(self, message, timestamp=0.0): + """ + Handles published RO permeate sample message + + @param message: published RO permeate sample data message + @returns none + """ + pass Index: dialin/hd/hd_test_configs.py =================================================================== diff -u -r6ff50b4ae97f1d8071f1d8fdafae60f6fd704b9d -rd784180e6543330849bf7fbb6bd9acfd36323706 --- dialin/hd/hd_test_configs.py (.../hd_test_configs.py) (revision 6ff50b4ae97f1d8071f1d8fdafae60f6fd704b9d) +++ dialin/hd/hd_test_configs.py (.../hd_test_configs.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -50,6 +50,31 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_test_config_sync) + def cmd_set_recover_from_mode_fault_signal(self): + """ + Constructs and sends the HD test config the signal to recover from mode fault + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_SIGNAL_RECOVER_FROM_FAULT_MODE.value) + + self.logger.debug("Setting signal to recover from mode fault") + + # Send message + received_message = self.can_interface.send(message) + + # If there is no 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 + def cmd_get_test_config_status(self, config: int): """ Returns the status of a test config Index: tests/dg_nvm_scripts.py =================================================================== diff -u -r1b04b37b3a327b145b150477f567e26a26c60e4e -rd784180e6543330849bf7fbb6bd9acfd36323706 --- tests/dg_nvm_scripts.py (.../dg_nvm_scripts.py) (revision 1b04b37b3a327b145b150477f567e26a26c60e4e) +++ tests/dg_nvm_scripts.py (.../dg_nvm_scripts.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -54,7 +54,7 @@ # Use cmd_set_dg_calibration_excel_to_fw() set the changes back to firmware # This function requires an address for the excel report. Use the absolute address of your excel report like the # example below - #dg.calibration_record.cmd_set_dg_calibration_excel_to_fw('/home/fw/projects/DG_NV_Records/2023-05-19-DG-Record.xlsx') + #dg.calibration_record.cmd_set_dg_calibration_excel_to_fw('/home/fw/projects/DG_NV_Records/2023-05-20-DG-Record.xlsx') # For resetting the calibration record to benign values, use the function below #dg.calibration_record.cmd_reset_dg_calibration_record() Index: tests/dg_tests.py =================================================================== diff -u -r6f4c3b18f8b57ad891116e29cda04c8194f5ff34 -rd784180e6543330849bf7fbb6bd9acfd36323706 --- tests/dg_tests.py (.../dg_tests.py) (revision 6f4c3b18f8b57ad891116e29cda04c8194f5ff34) +++ tests/dg_tests.py (.../dg_tests.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -655,6 +655,8 @@ #hd.test_configs.cmd_set_test_config(HDTestConfigOptions.TEST_CONFIG_DISABLE_WET_SELFTEST_DISPLACEMENT_CHECK.value) #dg.load_cells.cmd_get_load_cells_tare_values() + #dg.test_configs.cmd_set_recover_from_mode_fault_signal() + #while True: # print(dg.load_cells.load_cells_tare_values) # sleep(0.5) Index: tests/tx_test_config_tests.py =================================================================== diff -u -r1b04b37b3a327b145b150477f567e26a26c60e4e -rd784180e6543330849bf7fbb6bd9acfd36323706 --- tests/tx_test_config_tests.py (.../tx_test_config_tests.py) (revision 1b04b37b3a327b145b150477f567e26a26c60e4e) +++ tests/tx_test_config_tests.py (.../tx_test_config_tests.py) (revision d784180e6543330849bf7fbb6bd9acfd36323706) @@ -54,16 +54,73 @@ from dialin.common.dg_defs import DGFlushStates, DGHeatDisinfectActiveCoolStates from dialin.common.test_config_defs import DGTestConfigOptions, HDTestConfigOptions from dialin.common.dg_defs import DGOpModes +from dg_tests import * from time import sleep from datetime import datetime import sys sys.path.append("..") +def get_dg_run_info(): + info = ('DG_op_mode, {}, DG_op_mode_num, {}, DG_sub_mode, {}, '.format(DGOperationModes(dg.dg_operation_mode).name, + dg.dg_operation_mode, + dg.dg_operation_sub_mode)) + return info + + +def get_dg_valves_states(): + info = ('VPi, {}, VSP, {}, VPd, {}, VBf, {}, VPo, {}, VDr, {}, VRc, {}, VRo, {}, VRi, {}, VRf, {}, ' + 'VRD1, {}, VRD2, {}, ' + .format(dg.valves.valve_states_enum[DGValveNames.VALVE_PRESSURE_INLET.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_SAMPLING_PORT.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_PRODUCTION_DRAIN.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_BYPASS_FILTER.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_PRESSURE_OUTLET.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_DRAIN.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RECIRCULATE.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RESERVOIR_OUTLET.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RESERVOIR_INLET.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RESERVOIR_FILL.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RESERVOIR_DRAIN_1.value], + dg.valves.valve_states_enum[DGValveNames.VALVE_RESERVOIR_DRAIN_2.value])) + return info + + +def get_drain_states_info(): + info = ('Drain, {}, DAC, {}, Tgt_RPM, {}, Curr_RPM, {}, PRd, {:5.3f}, PDr, {:5.3f}, Baro, {:5.3f}, ' + 'Drain_curr_A, {:5.3f}, Drain_dir, {}, Target_flow_lpm, {:5.3f}, Maxon_rpm, {}, ' + .format(DrainPumpStates(dg.drain_pump.drain_pump_state).name, dg.drain_pump.dac_value, + dg.drain_pump.target_drain_pump_rpm, + dg.drain_pump.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_HALL_SNSR_FB.name], + dg.pressures.drain_pump_inlet_pressure, dg.pressures.drain_pump_outlet_pressure, + dg.pressures.barometric_pressure, dg.drain_pump.drain_pump_current_A, + dg.drain_pump.drain_pump_direction, dg.drain_pump.target_drain_pump_outlet_flow_lpm, + dg.drain_pump.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_MAXON_SNSR_FB.name])) + return info + + +def get_load_cells_info(): + info = ('A1, {:5.3f}, A2, {:5.3f}, B1, {:5.3f}, B2, {:5.3f}, ' + .format(dg.load_cells.load_cell_A1, dg.load_cells.load_cell_A2, dg.load_cells.load_cell_B1, + dg.load_cells.load_cell_B2)) + return info + + +def get_ro_info(): + info = ('RO, {}, PPi, {:5.3f}, PPo, {:5.3f}, PWM, {:5.3f}, Flow, {:5.3f}, Tgt_flow, {:5.3f}, ' + 'Feedback_PWM, {:5.3f}, Flow_with_conc_pumps, {:5.3f}, Dialysate_flow, {:5.3f}, ' + .format(dg.ro_pump.ro_pump_state, dg.pressures.ro_pump_inlet_pressure, + dg.pressures.ro_pump_outlet_pressure, dg.ro_pump.pwm_duty_cycle_pct, + dg.flow_sensors.measured_ro_flow_LPM, dg.ro_pump.target_flow_lpm, + dg.ro_pump.feedback_duty_cycle_pct, + dg.flow_sensors.measured_ro_flow_with_cp_LPM, dg.flow_sensors.measured_dialysate_flow_LPM)) + return info + + def check_status(delay_counter, sleep_time, target_delay, state_counter): - if delay_counter > (target_delay / sleep_time): + if delay_counter >= (target_delay / sleep_time): state_counter += 1 delay_counter = 0 else: @@ -79,83 +136,127 @@ delay_counter = 0 target_delay = 1 - while True: - if counter == 1: - if delay_counter == 0: - # Received the load cells tare values from DG. Reset both stacks - dg.cmd_dg_software_reset_request() - hd.cmd_hd_software_reset_request() + address = os.path.join(os.getcwd(), "treatment_recovery.log") + f = open(address, "w") - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + try: + while True: - elif counter == 2 and dg.dg_operation_mode == DGOpModes.DG_MODE_STAN.value: - if delay_counter == 0: - # After reset log in again - dg.cmd_log_in_to_dg() + dg_run = get_dg_run_info() + drain = get_drain_states_info() + load_cell = get_load_cells_info() + valves = get_dg_valves_states() + ro = get_ro_info() - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + var = dg_run + load_cell + drain + ro + valves + '\r' - elif counter == 3 and hd.hd_operation_mode == 3: - if delay_counter == 0: - hd.cmd_log_in_to_hd() + print(counter, target_delay, var) + f.write(var) - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + if counter == 1: + if delay_counter == 0: + #dg.load_cells.cmd_get_load_cells_tare_values() + pass - elif counter == 4: - if delay_counter == 0: - # Set the operation mode is pre-treatment before commanding the start DG - hd.cmd_hd_set_operation_mode(HDOpModes.MODE_TPAR.value) + # For testing only. Use the get function to get the actual tare values during the development of this + # script and the procedure for this + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_PRIMARY.name] = 1726.822998046875 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_BACKUP.name] = 1716.2781982421875 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_2_PRIMARY.name] = 1716.46484375 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_2_BACKUP.name] = 1712.1719970703125 - counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 5 and hd.hd_operation_mode == HDOpModes.MODE_TPAR.value: - if delay_counter == 0: - # Start DG cannot be when HD is in standby - dg.hd_proxy.cmd_start_stop_dg() + elif counter == 2 and \ + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_PRIMARY.name] != 0.0: + if delay_counter == 0: + # Received the load cells tare values from DG. Reset both stacks + dg.cmd_dg_software_reset_request() + hd.cmd_hd_software_reset_request() - counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 6 and dg.dg_operation_mode == DGOpModes.DG_MODE_GENE.value and dg.dg_operation_sub_mode == 1: - if delay_counter == 0: - # This section is for testing only to make sure we always have fluid in the reservoir. This part is not - # needed in the actual test procedure - dg.hd_proxy.cmd_fill(1600) + elif counter == 3 and dg.dg_operation_mode == DGOpModes.DG_MODE_STAN.value: + if delay_counter == 0: + # After reset log in again + dg.cmd_log_in_to_dg() - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 7 and dg.dg_operation_mode == DGOpModes.DG_MODE_GENE.value and dg.dg_operation_sub_mode == 1: - if delay_counter == 0: - hd.test_configs.cmd_set_test_config(DGTestConfigOptions.TEST_CONFIG_RECOVER_TREATMENT.value) + elif counter == 4 and dg.dg_operation_mode == DGOpModes.DG_MODE_STAN.value: + if delay_counter == 0: + dg.load_cells.cmd_set_load_cells_tare_values() - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 8 and dg.dg_operation_mode == DGOpModes.DG_MODE_GENE.value and dg.dg_operation_sub_mode == 1: - if delay_counter == 0: - dg.hd_proxy.cmd_drain() + elif counter == 5 and hd.hd_operation_mode == HDOpModes.MODE_STAN.value: + if delay_counter == 0: + hd.cmd_log_in_to_hd() - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 9 and dg.dg_operation_mode == DGOpModes.DG_MODE_DRAI.value and dg.dg_operation_sub_mode == 1: - if delay_counter == 0: - dg.alarms.cmd_alarm_state_override(AlarmList.ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE.value, 1) + elif counter == 6: + if delay_counter == 0: + # Set the operation mode is pre-treatment before commanding the start DG + hd.cmd_hd_set_operation_mode(HDOpModes.MODE_TPAR.value) - counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) - elif counter == 10 and dg.dg_operation_mode == DGOpModes.DG_MODE_FAUL.value and dg.dg_operation_sub_mode == 2: - if delay_counter == 0: - dg.alarms.cmd_alarm_state_override(AlarmList.ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE.value, 1, RESET=1) + elif counter == 7 and hd.hd_operation_mode == HDOpModes.MODE_TPAR.value: + if delay_counter == 0: + # Start DG cannot be when HD is in standby + dg.hd_proxy.cmd_start_stop_dg() - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - elif counter == 11 and dg.dg_operation_mode == DGOpModes.DG_MODE_FAUL.value and dg.dg_operation_sub_mode == 2: - if delay_counter == 0: - dg.test_configs.cmd_set_recover_from_mode_fault_signal() + elif counter == 8 and dg.dg_operation_mode == DGOpModes.DG_MODE_GENE.value and dg.dg_operation_sub_mode == 1: + if delay_counter == 0: + # This section is for testing only to make sure we always have fluid in the reservoir. This part is not + # needed in the actual test procedure + dg.hd_proxy.cmd_fill(500) + #pass - counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) - sleep(sleep_time) + elif counter == 9 and dg.dg_operation_mode == DGOpModes.DG_MODE_GENE.value and dg.dg_operation_sub_mode == 1: + if delay_counter == 0: + dg.hd_proxy.cmd_drain() + counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + elif counter == 10 and dg.dg_operation_mode == DGOpModes.DG_MODE_DRAI.value and dg.dg_operation_sub_mode == 1: + if delay_counter == 0: + #dg.test_configs.cmd_set_test_config(DGTestConfigOptions.TEST_CONFIG_RECOVER_TREATMENT.value) + pass + + counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + + elif counter == 11 and dg.dg_operation_mode == DGOpModes.DG_MODE_DRAI.value and dg.dg_operation_sub_mode == 1: + if delay_counter == 0: + dg.alarms.cmd_alarm_state_override(AlarmList.ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE.value, 1) + + counter, delay_counter = check_status(delay_counter, sleep_time, 0, counter) + + elif counter == 12 and dg.dg_operation_mode == DGOpModes.DG_MODE_FAUL.value and dg.dg_operation_sub_mode == 2: + if delay_counter == 0: + dg.alarms.cmd_alarm_state_override(AlarmList.ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE.value, 1, reset=1) + dg.test_configs.cmd_set_test_config(DGTestConfigOptions.TEST_CONFIG_RECOVER_TREATMENT.value) + + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + + elif counter == 13 and dg.dg_operation_mode == DGOpModes.DG_MODE_FAUL.value and dg.dg_operation_sub_mode == 2: + if delay_counter == 0: + dg.test_configs.cmd_set_recover_from_mode_fault_signal() + + counter, delay_counter = check_status(delay_counter, sleep_time, target_delay, counter) + + sleep(sleep_time) + + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + + def expedite_pretreatment(): sleep_time = 0.1 @@ -289,3 +390,4 @@ #expedite_pretreatment() recover_treatment() +