Index: leahi_dialin/common/dd_defs.py =================================================================== diff -u -r71f2092930ad621e8a738de12faf806e8c46b1b9 -r1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b --- leahi_dialin/common/dd_defs.py (.../dd_defs.py) (revision 71f2092930ad621e8a738de12faf806e8c46b1b9) +++ leahi_dialin/common/dd_defs.py (.../dd_defs.py) (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -1004,3 +1004,32 @@ 'CANCELLATION_MODE_WATER': ['water'], 'NUM_OF_CANCELLATION_MODES': [], } + +@unique +class DDSwitchStatus(DialinEnum): + CLOSED = 0 # Closed State of the TD Switch + OPEN = 1 # Open State of the TD Switch + NUM_OF_SWITCH_STATES = 2 # Number of Switch States + +DDSwitchStatus._str_list = { + # Official Name : Accepted strings + 'CLOSED': [], + 'OPEN': [], + 'NUM_OF_SWITCH_STATES': [], +} + +@unique +class DDSwitchNames(DialinEnum): + D101_SWITCH1 = 0 # Connector/cap switch 1 + D102_SWITCH2 = 1 # Connector/cap switch 2 + D103_CAP = 2 # Cap parked switch + NUM_OF_DOORS_AND_SWITCHES = 3 # Number of Switches + +DDSwitchNames._str_list = { + # Official Name : Accepted strings + 'D101_SWITCH1': ['d101', 'connector/cap switch 1', 'switch1'], + 'D102_SWITCH2': ['d102', 'connector/cap switch 2', 'switch2'], + 'D103_CAP': ['d103', 'cap parked', 'cap_parked'], + 'NUM_OF_DOORS_AND_SWITCHES': [], +} + Index: leahi_dialin/common/dd_defs_proxy.py =================================================================== diff -u -rff7652f24de0ff9249d0236df5c436b37ee6e640 -r1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b --- leahi_dialin/common/dd_defs_proxy.py (.../dd_defs_proxy.py) (revision ff7652f24de0ff9249d0236df5c436b37ee6e640) +++ leahi_dialin/common/dd_defs_proxy.py (.../dd_defs_proxy.py) (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -53,6 +53,7 @@ DDTemperatureSensorNames = dd_defs.DDTemperatureSensorNames DDValveNames = dd_defs.DDValveNames DDMonitoredVoltages = dd_defs.DDMonitoredVoltages + DDSwitchNames = dd_defs.DDSwitchNames # Sensor Attributes DDBalancingChamberStates = dd_defs.DDBalancingChamberStates Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -rcd42d37d675f3e0118c6d19bb4a60087383a2dcd -r1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision cd42d37d675f3e0118c6d19bb4a60087383a2dcd) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -190,7 +190,7 @@ MSG_ID_TD_RECIRCULATE_DATA = 0xA8 MSG_ID_UI_ADJUST_TREATMENT_LOGS_REQUEST = 0xA9 MSG_ID_TD_ADJUST_TREATMENT_LOGS_RESPONSE = 0xAA - + MSG_ID_DD_SWITCHES_DATA = 0xB3 MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 MSG_ID_TD_TESTER_LOGIN_REQUEST = 0x8000 Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -r1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 20c821bd230fc7689a0275a2918981669ff5cc19) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -37,6 +37,7 @@ from .modules.ultrafiltration import DDUltrafiltration from .modules.valves import DDValves from .modules.voltages import DDVoltages +from .modules.switches import DDSwitches from .proxies.ro_proxy import ROProxy from .proxies.td_proxy import TDProxy @@ -134,13 +135,15 @@ self.pre_gen_dialysate = DDPreGenDialysate(self.can_interface, self.logger) #: The Pre Generate Dialysate module self.rinse_pump = DDRinsePump(self.can_interface, self.logger) #: The Rinse Pump module self.spent_chamber_fill = DDSpentChamberFill(self.can_interface, self.logger) #: The Spent Chamber module + self.switches = DDSwitches(self.can_interface, self.logger) #: The Switches module self.drybicart = DDDryBicart(self.can_interface, self.logger) #: The Dry Bicarb module self.temperature_sensors = DDTemperatureSensors(self.can_interface, self.logger) #: The Temperature Sensors module self.test_configs = DDTestConfig(self.can_interface, self.logger) #: The Test Configs module self.ultrafiltration = DDUltrafiltration(self.can_interface, self.logger) #: The Ultrafiltration module self.valves = DDValves(self.can_interface, self.logger) #: The Valves module self.voltages = DDVoltages(self.can_interface, self.logger) #: The Voltages module + self.ro_proxy = ROProxy(self.can_interface, self.logger) #: The RO Proxy module (imitates commands sent by DD) self.td_proxy = TDProxy(self.can_interface, self.logger) #: The TD Proxy module (imitates commands sent by UI) Index: tests/dd_login.py =================================================================== diff -u --- tests/dd_login.py (revision 0) +++ tests/dd_login.py (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -0,0 +1,36 @@ +from leahi_dialin.dd.dialysate_delivery import DD +from leahi_dialin.dd.modules.blood_leak import EmbModeCommands +from time import sleep +import os + +def get_blood_leak_info(): + info = ('Blood_leak_state, {}, Blood_leak_status, {}, Blood_leak_intensity, {}, Blood_leak_detect, {}, ' + 'Blood_leak_int_mv_avg, {}, ' + .format(dd.blood_leak.get_blood_leak_state(), dd.blood_leak.get_blood_leak_status(), + dd.blood_leak.blood_leak_intensity, dd.blood_leak.blood_leak_blood_detect, + dd.blood_leak.blood_leak_intensity_moving_average)) + return info + + +if __name__ == "__main__": + address = os.path.join(os.getcwd(), "leahi_zero.log") + f = open(address, "w") + dd = DD() + dd.cmd_log_in_to_dd() + sleep(0.1) + dd.blood_leak.cmd_blood_leak_data_broadcast_interval_override(50) + var = get_blood_leak_info() + '\r' + f.write(var) + print(var) + sleep(0.1) + dd.blood_leak.cmd_blood_leak_zero_request() + #dd.blood_leak.cmd_blood_leak_set_embedded_mode_command(EmbModeCommands.I.value, msg_payload=0) + + while True: + var = get_blood_leak_info() + '\r' + sleep(0.05) + #print("Detect", dd.blood_leak.get_blood_leak_emb_mode_command_response(EmbModeCommands.V.value)) + print(var) + f.write(var) + + f.close() \ No newline at end of file Index: tests/td_login.py =================================================================== diff -u --- tests/td_login.py (revision 0) +++ tests/td_login.py (revision 1e48f7a8c91ce73aa9023dc71a23b6db13c7bd5b) @@ -0,0 +1,25 @@ +from leahi_dialin.td.treatment_delivery import TD +from time import sleep +import os + +if __name__ == "__main__": + address = os.path.join(os.getcwd(), "td_valves.log") + #f = open(address, "w") + td = TD() + td.cmd_log_in_to_td() + sleep(0.5) + + td.valves.cmd_valves_broadcast_interval_override(50) + sleep(0.5) + td.valves.cmd_set_valve_position(0, 1) + #td.valves.cmd_home_valve(0, 1, 0) + #sleep(0.5) + #td.valves.cmd_home_valve(1, 1, 0) + + #td.blood_flow.cmd_home_blood_pump() + #sleep(25) + + #td.blood_flow.cmd_blood_flow_set_speed_rate_request(1000) + #sleep(15) + + #td.blood_flow.cmd_hard_stop_blood_pump()