本文整理汇总了Python中ntcore.value.Value.makeDouble方法的典型用法代码示例。如果您正苦于以下问题:Python Value.makeDouble方法的具体用法?Python Value.makeDouble怎么用?Python Value.makeDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ntcore.value.Value
的用法示例。
在下文中一共展示了Value.makeDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_EntryNewRemote
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_EntryNewRemote(nt_live, server_cb):
nt_server, nt_client = nt_live
nt_server_api = nt_server._api
nt_client_api = nt_client._api
nt_server_api.addEntryListenerById(
nt_server_api.getEntryId("/foo"), server_cb, NT_NOTIFY_NEW
)
# Trigger an event
nt_client_api.setEntryValueById(
nt_client_api.getEntryId("/foo/bar"), Value.makeDouble(2.0)
)
nt_client_api.setEntryValueById(
nt_client_api.getEntryId("/foo"), Value.makeDouble(1.0)
)
nt_client_api.flush()
assert nt_server_api.waitForEntryListenerQueue(1.0)
# Check the event
events = server_cb.wait(1)
# assert events[0].listener == handle
assert events[0].local_id == nt_server_api.getEntryId("/foo")
assert events[0].name == "/foo"
assert events[0].value == Value.makeDouble(1.0)
assert events[0].flags == NT_NOTIFY_NEW
示例2: test_Double
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_Double():
v = Value.makeDouble(0.5)
assert NT_DOUBLE == v.type
assert 0.5 == v.value
v = Value.makeDouble(0.25)
assert NT_DOUBLE == v.type
assert 0.25 == v.value
示例3: test_LoadPersistentUpdateValue
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_LoadPersistentUpdateValue(
storage_populated, dispatcher, entry_notifier, is_server
):
storage = storage_populated
entry = storage.m_entries.get("foo2")
entry.flags = NT_PERSISTENT
entry.isPersistent = True
fp = StringIO('[NetworkTables Storage 3.0]\ndouble "foo2"=1.0\n')
assert storage.loadPersistent(fp=fp) is None
entry = storage.m_entries.get("foo2")
assert Value.makeDouble(1.0) == entry.value
assert NT_PERSISTENT == entry.flags
assert entry.isPersistent
# client shouldn't send an update as id not assigned yet
if is_server:
# id assigned as this is the server; seq_num incremented
dispatcher._queueOutgoing.assert_has_calls(
[call(Message.entryUpdate(1, 2, entry.value), None, None)]
)
else:
assert dispatcher._queueOutgoing.call_count == 0
entry_notifier.notifyEntry.assert_has_calls(
[call(1, "foo2", entry.value, NT_NOTIFY_UPDATE | NT_NOTIFY_LOCAL)]
)
if not is_server:
assert 2 == storage.m_entries.get("foo2").seq_num # still should be incremented
示例4: test_DeleteEntryExist
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_DeleteEntryExist(storage_populated, dispatcher, entry_notifier, is_server):
storage = storage_populated
storage.deleteEntry("foo2")
entry = storage.m_entries.get("foo2")
assert entry is not None
assert entry.value is None
assert entry.id == 0xFFFF
assert entry.local_write == False
# client shouldn't send an update as id not assigned yet
if is_server:
# id assigned as this is the server
dispatcher._queueOutgoing.assert_has_calls(
[call(Message.entryDelete(1), None, None)]
)
else:
# shouldn't send an update id not assigned yet
assert dispatcher._queueOutgoing.call_count == 0
entry_notifier.notifyEntry.assert_has_calls(
[call(1, "foo2", Value.makeDouble(0.0), NT_NOTIFY_DELETE | NT_NOTIFY_LOCAL)]
)
if is_server:
assert len(storage.m_idmap) >= 2
assert not storage.m_idmap[1]
示例5: generateNotifications
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def generateNotifications(notifier):
# All flags combos that can be generated by Storage
flags = [
# "normal" notifications
NT_NOTIFY_NEW,
NT_NOTIFY_DELETE,
NT_NOTIFY_UPDATE,
NT_NOTIFY_FLAGS,
NT_NOTIFY_UPDATE | NT_NOTIFY_FLAGS,
# immediate notifications are always "new"
NT_NOTIFY_IMMEDIATE | NT_NOTIFY_NEW,
# local notifications can be of any flag combo
NT_NOTIFY_LOCAL | NT_NOTIFY_NEW,
NT_NOTIFY_LOCAL | NT_NOTIFY_DELETE,
NT_NOTIFY_LOCAL | NT_NOTIFY_UPDATE,
NT_NOTIFY_LOCAL | NT_NOTIFY_FLAGS,
NT_NOTIFY_LOCAL | NT_NOTIFY_UPDATE | NT_NOTIFY_FLAGS,
]
# Generate across keys
keys = ["/foo/bar", "/baz", "/boo"]
val = Value.makeDouble(1)
# Provide unique key indexes for each key
keyindex = 5
for key in keys:
for flag in flags:
notifier.notifyEntry(keyindex, key, val, flag)
keyindex += 1
示例6: test_SetEntryValueDifferentValue
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_SetEntryValueDifferentValue(
storage_populated, is_server, dispatcher, entry_notifier
):
storage = storage_populated
# update with same type and different value results in value update message
value = Value.makeDouble(1.0)
assert storage.setEntryValue("foo2", value)
entry = storage.m_entries.get("foo2")
assert value == entry.value
# client shouldn't send an update as id not assigned yet
if is_server:
# id assigned if server; seq_num incremented
dispatcher._queueOutgoing.assert_has_calls(
[call(Message.entryUpdate(1, 2, value), None, None)]
)
else:
assert dispatcher._queueOutgoing.call_count == 0
entry_notifier.notifyEntry.assert_has_calls(
[call(1, "foo2", value, NT_NOTIFY_UPDATE | NT_NOTIFY_LOCAL)]
)
if not is_server:
assert 2 == storage.m_entries.get("foo2").seq_num # still should be incremented
示例7: test_ProcessIncomingEntryAssignWithFlags
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_ProcessIncomingEntryAssignWithFlags(
storage_populate_one, dispatcher, entry_notifier, is_server, conn
):
storage = storage_populate_one
value = Value.makeDouble(1.0)
storage.processIncoming(Message.entryAssign("foo", 0, 1, value, 0x2), conn)
# EXPECT_CALL(*conn, proto_rev()).WillRepeatedly(Return(0x0300u))
if is_server:
# server broadcasts new value/flags to all *other* connections
dispatcher._queueOutgoing.assert_has_calls(
[call(Message.entryAssign("foo", 0, 1, value, 0x2), None, conn)]
)
entry_notifier.notifyEntry.assert_has_calls(
[call(0, "foo", value, NT_NOTIFY_UPDATE | NT_NOTIFY_FLAGS)]
)
else:
# client forces flags back when an assign message is received for an
# existing entry with different flags
dispatcher._queueOutgoing.assert_has_calls(
[call(Message.flagsUpdate(0, 0), None, None)]
)
entry_notifier.notifyEntry.assert_has_calls(
[call(0, "foo", value, NT_NOTIFY_UPDATE)]
)
示例8: storage_populated
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def storage_populated(storage_empty, dispatcher, entry_notifier):
storage = storage_empty
entry_notifier.m_local_notifiers = False
entry_notifier.m_local_notifiers = False
storage.setEntryTypeValue("foo", Value.makeBoolean(True))
storage.setEntryTypeValue("foo2", Value.makeDouble(0.0))
storage.setEntryTypeValue("bar", Value.makeDouble(1.0))
storage.setEntryTypeValue("bar2", Value.makeBoolean(False))
dispatcher.reset_mock()
entry_notifier.reset_mock()
entry_notifier.m_local_notifiers = True
return storage
示例9: forceSetDouble
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def forceSetDouble(self, value):
"""Sets the entry's value.
:param value: the value to set
"""
value = Value.makeDouble(value)
return self.__api.setEntryTypeValueById(self._local_id, value)
示例10: setDefaultDouble
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def setDefaultDouble(self, defaultValue):
"""Sets the entry's value if it does not exist.
:param defaultValue: the default value to set
:returns: False if the entry exists with a different type
"""
value = Value.makeDouble(defaultValue)
return self.__api.setDefaultEntryValueById(self._local_id, value)
示例11: setDouble
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def setDouble(self, value):
"""Sets the entry's value.
:param value: the value to set
:returns: False if the entry exists with a different type
"""
value = Value.makeDouble(value)
return self.__api.setEntryValueById(self._local_id, value)
示例12: test_ProcessIncomingEntryAssignIgnore
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_ProcessIncomingEntryAssignIgnore(
storage_populate_one, dispatcher, entry_notifier, is_server, conn
):
storage = storage_populate_one
value = Value.makeDouble(1.0)
storage.processIncoming(Message.entryAssign("foo", 0xFFFF, 1, value, 0), conn)
assert dispatcher._queueOutgoing.call_count == 0
assert entry_notifier.notifyEntry.call_count == 0
示例13: test_SetEntryValueAssignTypeChange
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_SetEntryValueAssignTypeChange(
storage_populate_one, dispatcher, entry_notifier
):
storage = storage_populate_one
# update with different type results in error and no message
value = Value.makeDouble(0.0)
assert not storage.setEntryValue("foo", value)
entry = storage.m_entries.get("foo")
assert value != entry.value
assert dispatcher._queueOutgoing.call_count == 0
assert entry_notifier.notifyEntry.call_count == 0
示例14: test_SetDefaultEntryExistsDifferentType
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_SetDefaultEntryExistsDifferentType(
storage_populate_one, dispatcher, entry_notifier
):
storage = storage_populate_one
# existing entry is boolean
value = Value.makeDouble(2.0)
ret_val = storage.setDefaultEntryValue("foo", value)
assert not ret_val
# should not have updated value in table if it already existed.
assert value != storage.m_entries.get("foo").value
assert dispatcher._queueOutgoing.call_count == 0
assert entry_notifier.notifyEntry.call_count == 0
示例15: test_PrefixNewLocal
# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeDouble [as 别名]
def test_PrefixNewLocal(nt_live, server_cb):
nt_server, nt_client = nt_live
nt_server_api = nt_server._api
nt_server_api.addEntryListener("/foo", server_cb, NT_NOTIFY_NEW | NT_NOTIFY_LOCAL)
# Trigger an event
nt_server_api.setEntryValueById(
nt_server_api.getEntryId("/foo/bar"), Value.makeDouble(1.0)
)
nt_server_api.setEntryValueById(
nt_server_api.getEntryId("/baz"), Value.makeDouble(1.0)
)
assert nt_server_api.waitForEntryListenerQueue(1.0)
events = server_cb.wait(1)
# assert events[0].listener == handle
assert events[0].local_id == nt_server_api.getEntryId("/foo/bar")
assert events[0].name == "/foo/bar"
assert events[0].value == Value.makeDouble(1.0)
assert events[0].flags == NT_NOTIFY_NEW | NT_NOTIFY_LOCAL