本文整理汇总了Python中PyExpLabSys.common.sockets.LiveSocket.set_point方法的典型用法代码示例。如果您正苦于以下问题:Python LiveSocket.set_point方法的具体用法?Python LiveSocket.set_point怎么用?Python LiveSocket.set_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyExpLabSys.common.sockets.LiveSocket
的用法示例。
在下文中一共展示了LiveSocket.set_point方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_live_multiple_variables
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point [as 别名]
def test_live_multiple_variables(sock):
codenames = ['name1', 'name2']
live_socket = LiveSocket(NAME, codenames, 1.0)
live_socket.start()
port = 8000
# Test the 'codenames' command
data = send_and_resc(sock, 'codenames', port)
expected = ['name1', 'name2']
assert(json.loads(data) == expected)
# Test the 'sane_interval' command
data = send_and_resc(sock, 'sane_interval', port)
assert(json.loads(data) - 1.0 < 1E-8)
for n in range(3):
now = time.time()
live_socket.set_point('name1', (now, n))
live_socket.set_point('name2', (now, n+1))
# Test the 'data' command
data = send_and_resc(sock, 'data', port)
expected = [[now, n], [now, n+1]]
assert(json.loads(data) == expected)
time.sleep(0.1)
live_socket.stop()
示例2: test_live_wrong_codename
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point [as 别名]
def test_live_wrong_codename():
codenames = ['name1', 'name2']
live_socket = LiveSocket(NAME, codenames, 1.0)
live_socket.start()
# Test that trying to set an unknown name raises an exception
with pytest.raises(ValueError):
live_socket.set_point('bad name', (1, 2))
live_socket.stop()