本文整理汇总了Python中protocol.Protocol.close方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.close方法的具体用法?Python Protocol.close怎么用?Python Protocol.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from protocol import Protocol [as 别名]
# 或者: from protocol.Protocol import close [as 别名]
print ('Command line: getweather.py serial_port serial_speed')
sys.exit(1)
currenttime = time.time()
db = DBHelper(dbFileName)
device = Protocol(serialPort, baudRate, logEnabled)
if device.ping(deviceAddress):
pressure, sernumP = device.getPressure(deviceAddress)
if 10 < pressure < 1000:
print ('Pressure - ' + str(pressure) + ' mmHg')
pressureSensorId = db.getSensorId(pressureSensorType, sernumP)
db.storeValue(currenttime, pressure, pressureSensorId)
humidity, sernumH = device.getHumidity(deviceAddress)
if not math.isnan(humidity):
print ('Humidity - ' + str(humidity) + '%')
humiditySensorID = db.getSensorId(humiditySensorType, sernumH)
db.storeValue(currenttime, humidity, humiditySensorID)
values = device.getTemp(deviceAddress)
i = 1
for (temperature, sn) in values:
print ('T' + str(i) + ' - ' + "%.1f" % temperature + ' C, sensor'),
device.printPacket(sn)
i += 1
termSensorId = db.getSensorId(termSensorType, sn)
db.storeValue(currenttime, temperature, termSensorId)
device.close()
db.updateAvgTables()
db.updateAllRecordsView()
db.close()
示例2: __init__
# 需要导入模块: from protocol import Protocol [as 别名]
# 或者: from protocol.Protocol import close [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()
示例3: Protocol
# 需要导入模块: from protocol import Protocol [as 别名]
# 或者: from protocol.Protocol import close [as 别名]
log.info("Starting up.")
p = Protocol(args.device)
time.sleep(2)
p.setMotor(0, 2, 0)
p.setMotor(1, 2, 0)
p.setServo(0, 450)
p.setServo(1, 450)
p.getCS()
p.getEN()
# Run while not ctrl-c'd
run = True
while run:
try:
p.handle()
k = p.read()
if k != None:
print k
except KeyboardInterrupt:
run = False
print "Caught CTRL+C, stopping ..."
# All done, clean up.
p.close()
log.info("All done.")
if args.logfile:
log_out.close()
exit(0)