本文整理汇总了Python中networktables.NetworkTable.addGlobalListener方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkTable.addGlobalListener方法的具体用法?Python NetworkTable.addGlobalListener怎么用?Python NetworkTable.addGlobalListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networktables.NetworkTable
的用法示例。
在下文中一共展示了NetworkTable.addGlobalListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import addGlobalListener [as 别名]
def open(self):
logger.info("NetworkTables websocket opened")
self.ioloop = IOLoop.current()
self.nt = NetworkTable.getGlobalTable()
NetworkTable.addGlobalListener(self.on_nt_change, immediateNotify=True)
self.nt.addConnectionListener(self, immediateNotify=True)
示例2: __init__
# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import addGlobalListener [as 别名]
def __init__(self, update_callback):
"""
:param update_callback: A callable with signature ```callable(update)``` for processing outgoing updates
formatted as strings.
"""
self.update_callback = update_callback
self.nt = NetworkTable.getGlobalTable()
NetworkTable.addGlobalListener(self._nt_on_change, immediateNotify=True)
class Empty:
pass
self.conn_listener = Empty()
self.conn_listener.connected = self._nt_connected
self.conn_listener.disconnected = self._nt_disconnected
self.nt.addConnectionListener(self.conn_listener, immediateNotify=True)
示例3: foo
# 需要导入模块: from networktables import NetworkTable [as 别名]
# 或者: from networktables.NetworkTable import addGlobalListener [as 别名]
import sys
import time
import logging
logging.basicConfig(level=logging.DEBUG)
NetworkTable.setIPAddress("127.0.0.1")
NetworkTable.setClientMode()
NetworkTable.initialize()
def foo(value):
print("foo", value)
def bar(value):
print("bar", value)
def valueChanged(key, value, isNew):
print("valueChanged: %s = %s" % (key, value) )
NetworkTable.addGlobalListener(valueChanged)
cc = ChooserControl("control_preset",
foo,
bar)
sd = NetworkTable.getTable("SmartDashboard")
while True:
time.sleep(1)