Skip to main content
 首页 » 编程设计

python之在 Python Openzwave 上设置轮询间隔

2024年10月24日12exmyth

如何在 Python-Openzwave 上为设备设置轮询间隔。命令 network.set_polling_interval(time) 似乎没有改变默认的轮询间隔

代码

network = ZWaveNetwork(options, autostart=False) 
 
dispatcher.connect(louie_network_started,ZWaveNetwork.SIGNAL_NETWORK_STARTED) 
dispatcher.connect(louie_network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED) 
dispatcher.connect(louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY) 
 
 
network.start() 
network.set_poll_interval(1000) 
print network.get_poll_interval()   

这里好像是设置成指定的值

#We wait for the network. 
#print "***** Waiting for network to become ready : " 
for i in range(0,90): 
if network.state>=network.STATE_READY: 
    #print "***** Network is ready" 
    break 
else: 
    #sys.stdout.write(".") 
    #sys.stdout.flush() 
    time.sleep(1.0) 
 
 
 print network.get_poll_interval() 

此处重置为默认值

请您参考如下方法:

来自inline documentation of python-openzwave's network.py ,函数不是set_polling_interval,而是实际上

def set_poll_interval(self, milliseconds=500, bIntervalBetweenPolls=True): 

毫秒在哪里

[the] length of the polling interval in milliseconds

和bIntervalBetweenPolls 是一个 bool 值,它

[if] set to true (via SetPollInterval), the pollInterval will be interspersed between each poll (so a much smaller m_pollInterval like 100, 500, or 1,000 may be appropriate). If false, the library attempts to complete all polls within m_pollInterval.