def x_pp(self, addr, tmp=0.01, T=5, value=[-100, 100], sleep_t=0.01): hwnd = self.hwnd tt = Time() while (1): if (tt.exceed(T)): break if (dm.stop_0()): break data0 = -100 for addr_i in addr: data_init = dm.ReadDouble(hwnd, addr_i) data = data_init + tmp # print(data) # if (data0 - data == 0): # return 1 data0 = data if (data < value[0]): data = value[0] if (data > value[1]): data = value[1] data_ = dm.DoubleToData(data) dm.WriteData(hwnd, addr_i, data_) sleep(sleep_t) return 0
def jump(self,addr,value = 3, T=3, sleep_t=0.1,control_value = 0.3): #addr = self.addr_z print(value,T,sleep_t) tt = Time() while (1): if (tt.exceed(T)): break if (dm.stop_0()): break if(self.stop()): break if(1): #是否用按键控制跳跃的高度 tmp_key = 0.3 if (kk.state(vk.ctrl)): if (kk.state(kk.get_ord('w'))): value += control_value print(value) sleep(tmp_key) if (kk.state(vk.ctrl)): if (kk.state(kk.get_ord('s'))): value -= control_value print(value) sleep(tmp_key) for addr_i in addr: data = dm.DoubleToData(value) dm.WriteData(self.hwnd, addr_i, data) sleep(sleep_t)
def move_to_xyz_slowly(self,values=[0,0,0], T=3, sleep_t=0.001): #values = [0, 0, 0]; T = 3; sleep_t = 0.001 print(values,'---', T, sleep_t) tt = Time() while (1): if (tt.exceed(T)): break if (dm.stop_0()): break if(self.stop()): break #dict(zip(cd.addr_xyz,values)) #cd.addrs # for addr,data in dict(zip(self.addr_xyz,values)) : # for addr_i in addr: # dm.WriteData(self.hwnd, addr_i, data) # #print(addr_i,data) import numpy as np array_xyz = np.array(cd.addr_xyz) # for i in range(array_xyz.shape[1]): # #for j in range(array_xyz.shape[0]): # for addr,data in enumerate(dict(zip(array_xyz[:,i],values))): # print(addr,data) # print() for i in range(array_xyz.shape[1]): #for j in range(array_xyz.shape[0]): array_xyz_i = array_xyz[:,i] #values_ = array_xyz_i for addr,data in enumerate( dict(zip(array_xyz_i, values)) ): dm.WriteData(self.hwnd, addr, data) # for addr_i,data in enumerate( dict(zip(cd.addr_xyz,values)) ): # print(addr_i,data) # for addr in self.addr_xyz : # for addr_i,data in dict(zip(addr,values)): # dm.WriteData(self.hwnd, addr_i, data) sleep(sleep_t) return 1
def print_xyz(self,T=10, sleep_t=0.1): tt = Time() while (1): if (tt.exceed(T)): break if (dm.stop_0()): break if (self.stop()): break self.get_xyz() import numpy as np self.xyz = np.array([self.x,self.y,self.z]) print(self.xyz) sleep(sleep_t) return
def run_func(self,addr,value=2.3, T=3, sleep_t=0.001): #addr = self.addr_z print(value,T,sleep_t) data = dm.DoubleToData(value) tt = Time() while (1): if (tt.exceed(T)): break if (dm.stop_0()): break if(self.stop()): break for addr_i in addr: dm.WriteData(self.hwnd, addr_i, data) sleep(sleep_t)