本文整理汇总了Python中protocol.Protocol.home方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.home方法的具体用法?Python Protocol.home怎么用?Python Protocol.home使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.home方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from protocol import Protocol [as 别名]
# 或者: from protocol.Protocol import home [as 别名]
class Pointer:
def __init__(self, device='/dev/ttyUSB0', baud=115200):
self.__hw = Protocol(device, baud)
self.hid = self.get_id()
self.calib = self.__get_calib()
self.__pm = PointingModel(z1=self.calib[0], z2=self.calib[1],
z3=self.calib[2])
self.target = EqCoords(0, 0)
self.home()
def get_id(self):
return self.__hw.get_id()
def home(self):
return self.__hw.home()
def __get_calib(self):
return [self.__hw.get_calib(i) for i in range(3)]
def set_calib(self, calib):
if len(calib) != 3:
raise ValueError("Wrong number of calibration values")
for i, v in enumerate(calib):
self.__hw.set_calib(i, v)
def set_ref(self, eq=None, inst=None, t=0):
self.__pm.set_ref(eq or self.target, inst or self.get_inst_coords(), t)
def get_refs(self):
"""Return a list of dictionaries, each containing the observation time,
equatorial and instrumental coordinates of a reference star"""
eq = self.__pm.eq_refs
inst = self.__pm.inst_refs
t = self.__pm.t_refs
refs = []
for i in range(self.__pm.get_nrefs()):
refs.append({'eq': eq[i], 'inst': inst[i], 't': t[i]})
return refs
def steps(self, ha, el):
self.__hw.move(ha, el)
def run(self, ha_dir, el_dir):
if not -1 <= ha_dir <= 1:
raise ValueError("ha_dir must be between -1 and 1")
if not -1 <= el_dir <= 1:
raise ValueError("el_dir must be between -1 and 1")
half = STEPS/2 - 1
self.__hw.move(ha_dir*half, el_dir*half)
def stop(self):
self.__hw.stop()
def enable_laser(self, enable):
self.__hw.enable_laser(enable)
def get_coords(self):
return self.__pm.inst_to_eq(steps2rad(*self.__hw.get_pos()))
def get_inst_coords(self):
return Coords(*steps2rad(*self.__hw.get_pos()))
def get_motor_pos(self):
return self.__hw.get_pos()
def goto(self, eq):
self.target = eq
self.__hw.goto(*rad2steps(*self.__pm.eq_to_inst(eq)))
def close(self):
self.__hw.close()