########################################################################### # # Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file test_syringe.py # # @author (last) Sean Nash # @date (last) 07-May-2021 # @author (original) Sean Nash # @date (original) 15-Mar-2021 # ############################################################################ import sys sys.path.append("..") from dialin.hd.hemodialysis_device import HD from time import sleep if __name__ == "__main__": # create an HD object called hd hd = HD() sleep(2) # log in to HD and DG as tester if hd.cmd_log_in_to_hd() == 0: exit(1) sleep(1) # hd.syringe_pump.cmd_syringe_pump_operation(0,0.0,0.0) # stop # hd.syringe_pump.cmd_syringe_pump_operation(1,0.0,0.0) # retract # sleep(10) # hd.syringe_pump.cmd_syringe_pump_operation(2,0.0,0.0) # seek # sleep(5) # hd.syringe_pump.cmd_syringe_pump_operation(3,0.0,0.0) # prime # sleep(5) # hd.syringe_pump.cmd_syringe_pump_operation(4,0.0,2.0) # bolus # hd.syringe_pump.cmd_syringe_pump_operation(5,1.0,0.0) # continuous # create log file with open("syringe_test.log", "w") as f: # write column header labels to log file header = "PumpState, Hep.State, SetRate, MeasRate, Position, Volume, HomeV, SwitchV, ForceV, SafetyVol\n" f.write(header) # write syringe pump related data from HD to log file while True: sleep(1) syringeData = '{:2d}'.format(hd.syringe_pump.syringe_pump_state) + \ ", " + '{:2d}'.format(hd.syringe_pump.heparin_state) + \ ", " + '{:12.6f}'.format(hd.syringe_pump.syringe_pump_set_rate_ml_hr) + \ ", " + '{:12.6f}'.format(hd.syringe_pump.syringe_pump_meas_rate_ml_hr) + \ ", " + '{:10d}'.format(hd.syringe_pump.syringe_pump_position) + \ ", " + '{:12.9f}'.format(hd.syringe_pump.syringe_pump_volume_ml) + \ ", " + '{:5.3f}'.format(hd.syringe_pump.syringe_pump_home_v) + \ ", " + '{:5.3f}'.format(hd.syringe_pump.syringe_pump_switch_v) + \ ", " + '{:5.3f}'.format(hd.syringe_pump.syringe_pump_force_v) + \ ", " + '{:12.9}'.format(hd.syringe_pump.syringe_pump_safety_volume_ml) + "\n" # log data f.write(syringeData) # print to console print(syringeData)