Index: tests/test_syringe.py =================================================================== diff -u -rc8e3d47e1c55e29eb03eb86207d2c99c2ddcf56d -r680ab4c35b3902a5397513ef93c97f8b7a6daca8 --- tests/test_syringe.py (.../test_syringe.py) (revision c8e3d47e1c55e29eb03eb86207d2c99c2ddcf56d) +++ tests/test_syringe.py (.../test_syringe.py) (revision 680ab4c35b3902a5397513ef93c97f8b7a6daca8) @@ -17,28 +17,51 @@ import sys sys.path.append("..") from dialin.hd.hemodialysis_device import HD -#from dialin.dg.dialysate_generator import DG from time import sleep if __name__ == "__main__": # create an HD object called hd hd = HD() - # create a DG object called dg -# dg = 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_hd() == 0: # exit(1) - sleep(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/prime +# 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,2.0) # bolus -# hd.syringe_pump.cmd_syringe_pump_operation(4,1.0,0.0) # continuous +# 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\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) + "\n" + + # log data + f.write(syringeData) + + # print to console + print(syringeData) + +