本文整理汇总了Python中querier.Querier.querysd方法的典型用法代码示例。如果您正苦于以下问题:Python Querier.querysd方法的具体用法?Python Querier.querysd怎么用?Python Querier.querysd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类querier.Querier
的用法示例。
在下文中一共展示了Querier.querysd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InsteonAddress
# 需要导入模块: from querier import Querier [as 别名]
# 或者: from querier.Querier import querysd [as 别名]
class Device:
name = ""
address = InsteonAddress()
db = None
dbbuilder = None
querier = None
def __init__(self, name, addr):
self.name = name
self.address = addr
self.db = DB()
self.querier = Querier(addr)
addDev(self)
def modifyDB(self, listener):
self.dbbuilder.setListener(listener)
# after db download complete, listener will perform action
self.getdb()
def setRecord(self, offset, laddr, group, linkType, data):
msg = self.makeMsg(offset, laddr, group, linkType,data)
self.querier.setMsgHandler(MsgHandler("got set record"))
self.querier.sendMsg(msg)
def makeMsg(self, offset, laddr, group, linkType, data):
msg = Msg.s_makeMessage("SendExtendedMessage")
msg.setAddress("toAddress", InsteonAddress(self.getAddress()))
msg.setByte("messageFlags", 0x1f)
msg.setByte("command1", 0x2f)
msg.setByte("command2", 0x00)
msg.setByte("userData1", 0x00) # don't care info
msg.setByte("userData2", 0x02) # set database
msg.setByte("userData3", offset >> 8) # high byte
msg.setByte("userData4", offset & 0xff) # low byte
msg.setByte("userData5", 8) # number of bytes set: 1...8
msg.setByte("userData6", linkType)
msg.setByte("userData7", group)
msg.setByte("userData8", laddr.getHighByte())
msg.setByte("userData9", laddr.getMiddleByte())
msg.setByte("userData10", laddr.getLowByte())
# depends on mode: could be e.g. trigger point
msg.setByte("userData11", data[0])
msg.setByte("userData12", data[1]) # unused?
msg.setByte("userData13", data[2]) # unused?
rb = msg.getBytes("command1", 15);
checksum = (~sum(rb) + 1) & 0xFF
msg.setByte("userData14", checksum)
return msg
def getName(self):
return self.name
def getAddress(self):
return self.address
def getdb(self):
"""getdb()
download the device database and print it on the console"""
iofun.out("getting db, be patient!")
self.dbbuilder.clear()
self.dbbuilder.start()
def printdb(self):
"""printdb()
print the downloaded link database to the console"""
self.dbbuilder.printdb()
def getId(self):
"""getId()
get category, subcategory, firmware, hardware version"""
self.querier.setMsgHandler(IdMsgHandler("id"))
self.querier.querysd(0x10, 0x00)
#
# link database management
#
def addController(self, addr, group, data = None):
"""addController(addr, group, data)
add device with "addr" as controller for group "group", with link data "data" """
data = data if data else [00, 00, group];
self.modifyDB(LinkRecordAdder(self, addr, group, data, True))
def removeController(self, addr, group):
"""removeController(addr, group)
remove device with "addr" as controller for group "group", with link data "data" """
self.modifyDB(LinkRecordRemover(self, addr, group, True))
def addResponder(self, addr, group, data = None):
"""addResponder(addr, group, data)
add device with "addr" as responder for group "group", with link data "data" """
data = data if data else [00, 00, group];
self.modifyDB(LinkRecordAdder(self, addr, group, data, False))
def removeResponder(self, addr, group):
"""removeResponder(addr, group)
remove device with "addr" as responder for group "group" """
self.modifyDB(LinkRecordRemover(self, addr, group, False))
def removeDevice(self, addr):
"""removeDevice(addr):
removes all links to device with address "addr" from device database"""
self.modifyDB(DeviceRemover(self, addr))
def replaceDevice(self, oldAddr, newAddr):
"""replaceDevice(oldAddr, newAddr):
#.........这里部分代码省略.........