当前位置: 首页>>代码示例>>Python>>正文


Python Value.makeBoolean方法代码示例

本文整理汇总了Python中ntcore.value.Value.makeBoolean方法的典型用法代码示例。如果您正苦于以下问题:Python Value.makeBoolean方法的具体用法?Python Value.makeBoolean怎么用?Python Value.makeBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ntcore.value.Value的用法示例。


在下文中一共展示了Value.makeBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Boolean

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_Boolean():
    v = Value.makeBoolean(False)
    assert NT_BOOLEAN == v.type
    assert not v.value

    v = Value.makeBoolean(True)
    assert NT_BOOLEAN == v.type
    assert v.value
开发者ID:robotpy,项目名称:pynetworktables,代码行数:10,代码来源:test_value.py

示例2: test_SetEntryTypeValueAssignNew

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_SetEntryTypeValueAssignNew(
    storage_empty, dispatcher, entry_notifier, is_server
):
    storage = storage_empty

    # brand new entry
    value = Value.makeBoolean(True)
    storage.setEntryTypeValue("foo", value)
    assert value == storage.m_entries.get("foo").value

    dispatcher._queueOutgoing.assert_has_calls(
        [
            call(
                Message.entryAssign("foo", 0 if is_server else 0xFFFF, 1, value, 0),
                None,
                None,
            )
        ]
    )
    entry_notifier.notifyEntry.assert_has_calls(
        [call(0, "foo", value, NT_NOTIFY_NEW | NT_NOTIFY_LOCAL)]
    )

    if is_server:
        assert 1 == len(storage.m_idmap)
        assert value == storage.m_idmap[0].value
    else:
        assert len(storage.m_idmap) == 0
开发者ID:robotpy,项目名称:pynetworktables,代码行数:30,代码来源:test_storage.py

示例3: forceSetBoolean

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
 def forceSetBoolean(self, value):
     """Sets the entry's value.
     
     :param value: the value to set
     """
     value = Value.makeBoolean(value)
     return self.__api.setEntryTypeValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:9,代码来源:entry.py

示例4: storage_populated

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [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
开发者ID:robotpy,项目名称:pynetworktables,代码行数:18,代码来源:test_storage.py

示例5: test_LoadPersistentAssign

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_LoadPersistentAssign(storage_empty, dispatcher, entry_notifier, is_server):
    storage = storage_empty

    fp = StringIO('[NetworkTables Storage 3.0]\nboolean "foo"=true\n')
    assert storage.loadPersistent(fp=fp) is None

    entry = storage.m_entries.get("foo")
    assert Value.makeBoolean(True) == entry.value
    assert NT_PERSISTENT == entry.flags
    assert entry.isPersistent

    dispatcher._queueOutgoing.assert_has_calls(
        [
            call(
                Message.entryAssign(
                    "foo", 0 if is_server else 0xFFFF, 1, entry.value, NT_PERSISTENT
                ),
                None,
                None,
            )
        ]
    )

    entry_notifier.notifyEntry.assert_has_calls(
        [call(0, "foo", entry.value, NT_NOTIFY_NEW | NT_NOTIFY_LOCAL)]
    )
开发者ID:robotpy,项目名称:pynetworktables,代码行数:28,代码来源:test_storage.py

示例6: setDefaultBoolean

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
 def setDefaultBoolean(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.makeBoolean(defaultValue)
     return self.__api.setDefaultEntryValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:10,代码来源:entry.py

示例7: setBoolean

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
 def setBoolean(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.makeBoolean(value)
     return self.__api.setEntryValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:10,代码来源:entry.py

示例8: test_DeleteCheckHandle

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_DeleteCheckHandle(storage_populate_one, dispatcher, entry_notifier, is_server):
    storage = storage_populate_one

    handle = storage.getEntryId("foo")
    storage.deleteEntry("foo")
    storage.setEntryTypeValue("foo", Value.makeBoolean(True))

    handle2 = storage.getEntryId("foo")
    assert handle == handle2
开发者ID:robotpy,项目名称:pynetworktables,代码行数:11,代码来源:test_storage.py

示例9: test_GetEntryValueExist

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_GetEntryValueExist(storage_empty, dispatcher, entry_notifier):
    storage = storage_empty

    value = Value.makeBoolean(True)
    storage.setEntryTypeValue("foo", value)
    assert dispatcher._queueOutgoing.call_count == 1
    assert entry_notifier.notifyEntry.call_count == 1

    assert value == storage.getEntryValue("foo")
开发者ID:robotpy,项目名称:pynetworktables,代码行数:11,代码来源:test_storage.py

示例10: test_SetEntryValueEmptyName

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_SetEntryValueEmptyName(storage_empty, dispatcher, entry_notifier):
    storage = storage_empty

    value = Value.makeBoolean(True)
    assert storage.setEntryValue("", value)
    assert len(storage.m_entries) == 0
    assert len(storage.m_idmap) == 0

    assert dispatcher._queueOutgoing.call_count == 0
    assert entry_notifier.notifyEntry.call_count == 0
开发者ID:robotpy,项目名称:pynetworktables,代码行数:12,代码来源:test_storage.py

示例11: test_SetEntryTypeValueEqualValue

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_SetEntryTypeValueEqualValue(storage_populate_one, dispatcher, entry_notifier):
    storage = storage_populate_one

    # update with same type and same value: change value contents but no update
    # message is issued (minimizing bandwidth usage)
    value = Value.makeBoolean(True)
    storage.setEntryTypeValue("foo", value)
    assert value == storage.m_entries.get("foo").value

    assert dispatcher._queueOutgoing.call_count == 0
    assert entry_notifier.notifyEntry.call_count == 0
开发者ID:robotpy,项目名称:pynetworktables,代码行数:13,代码来源:test_storage.py

示例12: storage_populate_one

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def storage_populate_one(storage_empty, dispatcher, entry_notifier):
    storage = storage_empty

    entry_notifier.m_local_notifiers = False

    storage.setEntryTypeValue("foo", Value.makeBoolean(True))

    dispatcher.reset_mock()
    entry_notifier.reset_mock()
    entry_notifier.m_local_notifiers = True

    return storage
开发者ID:robotpy,项目名称:pynetworktables,代码行数:14,代码来源:test_storage.py

示例13: test_empty_SetDefaultEntryEmptyName

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_empty_SetDefaultEntryEmptyName(storage_empty, dispatcher, entry_notifier):
    storage = storage_empty

    value = Value.makeBoolean(True)
    ret_val = storage.setDefaultEntryValue("", value)
    assert not ret_val
    assert "foo" not in storage.m_entries

    assert len(storage.m_entries) == 0
    assert len(storage.m_idmap) == 0

    assert dispatcher._queueOutgoing.call_count == 0
    assert entry_notifier.notifyEntry.call_count == 0
开发者ID:robotpy,项目名称:pynetworktables,代码行数:15,代码来源:test_storage.py

示例14: test_SetDefaultEntryExistsSameType

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def test_SetDefaultEntryExistsSameType(
    storage_populate_one, dispatcher, entry_notifier
):
    storage = storage_populate_one

    # existing entry
    value = Value.makeBoolean(False)
    ret_val = storage.setDefaultEntryValue("foo", value)
    assert ret_val
    assert value != storage.m_entries.get("foo").value

    assert dispatcher._queueOutgoing.call_count == 0
    assert entry_notifier.notifyEntry.call_count == 0
开发者ID:robotpy,项目名称:pynetworktables,代码行数:15,代码来源:test_storage.py

示例15: storage_persistent

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import makeBoolean [as 别名]
def storage_persistent(storage_empty, dispatcher, entry_notifier):
    storage = storage_empty

    entry_notifier.m_local_notifiers = False

    storage.setEntryTypeValue("boolean/true", Value.makeBoolean(True))
    storage.setEntryTypeValue("boolean/false", Value.makeBoolean(False))
    storage.setEntryTypeValue("double/neg", Value.makeDouble(-1.5))
    storage.setEntryTypeValue("double/zero", Value.makeDouble(0.0))
    storage.setEntryTypeValue("double/big", Value.makeDouble(1.3e8))
    storage.setEntryTypeValue("string/empty", Value.makeString(""))
    storage.setEntryTypeValue("string/normal", Value.makeString("hello"))
    storage.setEntryTypeValue("string/special", Value.makeString("\0\3\5\n"))
    storage.setEntryTypeValue("string/quoted", Value.makeString('"a"'))
    storage.setEntryTypeValue("raw/empty", Value.makeRaw(b""))
    storage.setEntryTypeValue("raw/normal", Value.makeRaw(b"hello"))
    storage.setEntryTypeValue("raw/special", Value.makeRaw(b"\0\3\5\n"))
    storage.setEntryTypeValue("booleanarr/empty", Value.makeBooleanArray([]))
    storage.setEntryTypeValue("booleanarr/one", Value.makeBooleanArray([True]))
    storage.setEntryTypeValue("booleanarr/two", Value.makeBooleanArray([True, False]))
    storage.setEntryTypeValue("doublearr/empty", Value.makeDoubleArray([]))
    storage.setEntryTypeValue("doublearr/one", Value.makeDoubleArray([0.5]))
    storage.setEntryTypeValue("doublearr/two", Value.makeDoubleArray([0.5, -0.25]))
    storage.setEntryTypeValue("stringarr/empty", Value.makeStringArray([]))
    storage.setEntryTypeValue("stringarr/one", Value.makeStringArray(["hello"]))
    storage.setEntryTypeValue(
        "stringarr/two", Value.makeStringArray(["hello", "world\n"])
    )
    storage.setEntryTypeValue("\0\3\5\n", Value.makeBoolean(True))
    storage.setEntryTypeValue("CaseSensitive/KeyName", Value.makeBoolean(True))
    storage.setEntryTypeValue("=", Value.makeBoolean(True))

    dispatcher.reset_mock()
    entry_notifier.reset_mock()
    entry_notifier.m_local_notifiers = True

    return storage
开发者ID:robotpy,项目名称:pynetworktables,代码行数:39,代码来源:test_storage.py


注:本文中的ntcore.value.Value.makeBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。