########################################################################### # # Copyright (c) 2020-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 set_accels_cal.py # # @author (last) Dara Navaei # @date (last) 01-Apr-2021 # @author (original) Sean Nash # @date (original) 05-Aug-2020 # ############################################################################ 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 an DG object called hd #hd = DG() sleep(2) # log in to HD and DG as tester if hd.cmd_log_in_to_hd() == 0: exit(1) #if hd.cmd_log_in_to_dg() == 0: # exit(1) sleep(1) #reset calibrations hd.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 = hd.accel.get_accel_vector() hd_offsets.x *= -1.0 hd_offsets.y *= -1.0 hd_offsets.z -= 1.0 hd_offsets.z *= -1.0 #dg_offsets.x *= -1.0 #dg_offsets.y *= -1.0 #dg_offsets.z -= 1.0 #dg_offsets.z *= -1.0 #set new offsets hd.accel.cmd_set_accel_calibration(hd_offsets.x, hd_offsets.y, hd_offsets.z) #hd.accel.cmd_set_accel_calibration(dg_offsets.x, dg_offsets.y, dg_offsets.z) exit(0)