本文整理汇总了Python中querier.Querier.startWait方法的典型用法代码示例。如果您正苦于以下问题:Python Querier.startWait方法的具体用法?Python Querier.startWait怎么用?Python Querier.startWait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类querier.Querier
的用法示例。
在下文中一共展示了Querier.startWait方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Modem2413U
# 需要导入模块: from querier import Querier [as 别名]
# 或者: from querier.Querier import startWait [as 别名]
class Modem2413U(Device):
"""============== Insteon PowerLinc modem (PLM) ==============="""
def __init__(self, name, addr):
Device.__init__(self, name, addr)
self.dbbuilder = ModemDBBuilder(addr, self.db)
def __modifyModemDB(self, listener):
self.dbbuilder.setListener(listener)
# after db download complete, listener will perform action
iofun.out("getting db, be patient!")
self.dbbuilder.clear()
self.dbbuilder.start()
def getdb(self):
"""getdb()
download the modem database and print it on the console"""
self.dbbuilder.start()
self.dbbuilder.wait()
self.dbbuilder.dumpDB()
out("Modem Link DB complete")
def startWatch(self):
"""startWatch()
modem will print all incoming messages on terminal"""
self.querier = Querier(InsteonAddress("00.00.00"))
self.querier.setMsgHandler(MsgDumper("modem"))
self.querier.startWait(10000)
def stopWatch(self):
"""stopWatch()
stop modem from printing all incoming messages on terminal"""
if (self.querier):
self.querier.cancel()
def getid(self):
"""getid()
get modem id data"""
self.querier = Querier(InsteonAddress("00.00.00"))
self.querier.setMsgHandler(IMInfoMsgHandler("getid"))
msg = Msg.s_makeMessage("GetIMInfo")
self.querier.sendMsg(msg)
def sendOn(self, group):
"""sendOn(group)
sends ALLLink broadcast ON message to group "group" """
msg = message.createStdMsg(InsteonAddress("00.00.00"), 0x0f,
0x11, 0xFF, group)
iofun.writeMsg(msg)
iofun.out("sent msg: " + msg.toString())
def sendOff(self, group):
"""sendOff(group)
sends ALLLink broadcast OFF message to group "group" """
msg = message.createStdMsg(InsteonAddress("00.00.00"), 0x0f,
0x13, 0xFF, group)
iofun.writeMsg(msg)
iofun.out("sent msg: " + msg.toString())
def linkAsController(self, otherDevice, group):
"""linkAsController(otherDevice, group)
puts modem in link mode to control device "otherDevice" on group "group" """
addr = InsteonAddress(otherDevice)
self.querier = Querier(addr)
self.querier.setMsgHandler(DefaultMsgHandler("link as controller"))
msg = Msg.s_makeMessage("StartALLLinking")
msg.setByte("LinkCode", 0x01)
msg.setByte("ALLLinkGroup", group)
self.querier.sendMsg(msg)
def linkAsResponder(self, otherDevice, group):
"""linkAsResponder(otherDevice, group)
puts modem in link mode to respond to device "otherDevice" on group "group" """
addr = InsteonAddress(otherDevice)
self.querier = Querier(addr)
self.querier.setMsgHandler(DefaultMsgHandler("start linking"))
msg = Msg.s_makeMessage("StartALLLinking")
msg.setByte("LinkCode", 0x00)
msg.setByte("ALLLinkGroup", group)
self.querier.sendMsg(msg)
def linkAsEither(self, otherDevice, group):
"""linkAsEither(otherDevice, group)
puts modem in link mode to link as controller or responder to device "otherDevice" on group "group" """
addr = InsteonAddress(otherDevice)
self.querier = Querier(addr)
self.querier.setMsgHandler(
DefaultMsgHandler("link/unlink as controller or responder"))
msg = Msg.s_makeMessage("StartALLLinking")
msg.setByte("LinkCode", 0x03)
msg.setByte("ALLLinkGroup", group)
self.querier.sendMsg(msg)
def respondToUnlink(self, otherDevice, group):
"""respondToUnlink(otherDevice, group)
make modem respond to unlink message from other device"""
# could not get 0xFF to unlink
self.linkAsEither(otherDevice, group)
def unlinkAsController(self, otherDevice, group):
"""unlinkAsController(otherDevice, group)
puts modem in unlink mode to unlink as controller from device "otherDevice" on group "group" """
addr = InsteonAddress(otherDevice)
self.querier = Querier(addr)
self.querier.setMsgHandler(DefaultMsgHandler("unlink as controller"))
msg = Msg.s_makeMessage("StartALLLinking")
msg.setByte("LinkCode", 0xFF)
msg.setByte("ALLLinkGroup", group)
self.querier.sendMsg(msg)
def cancelLinking(self):
"""cancelLinking()
#.........这里部分代码省略.........