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


Python Value.getFactory方法代码示例

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


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

示例1: getGlobalAutoUpdateValue

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import getFactory [as 别名]
    def getGlobalAutoUpdateValue(cls, key, defaultValue, writeDefault):
        """Global version of getAutoUpdateValue. This function will not initialize
        NetworkTables.
        
        :param key: the full NT path of the value (must start with /)
        :type key: str
        :param defaultValue: The default value to return if the key doesn't exist
        :type defaultValue: any
        :param writeDefault: If True, force the value to the specified default
        :type writeDefault: bool
        
        .. versionadded:: 2015.3.0
        
        .. seealso:: :func:`.ntproperty` is a read-write alternative to this
        """
        assert key.startswith("/")

        # Use raw NT api to avoid having to initialize networktables
        value = None
        valuefn = None  # optimization for ntproperty

        if not writeDefault:
            value = cls._api.getEntryValue(key)

        if value is None:
            valuefn = Value.getFactory(defaultValue)
            cls._api.setEntryValue(key, valuefn(defaultValue))
            value = defaultValue
        else:
            valuefn = Value.getFactory(value)

        return cls._api.createAutoValue(key, AutoUpdateValue(key, value, valuefn))
开发者ID:robotpy,项目名称:pynetworktables,代码行数:34,代码来源:networktables.py

示例2: forceSetValue

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import getFactory [as 别名]
 def forceSetValue(self, value):
     """Sets the entry's value
     
     :param value: the value that will be assigned
     
     .. warning:: Empty lists will fail
     """
     value = Value.getFactory(value)(value)
     return self.__api.setEntryTypeValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:11,代码来源:entry.py

示例3: setValue

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import getFactory [as 别名]
 def setValue(self, value):
     """Sets the entry's value
     
     :param value: the value that will be assigned
     :returns: False if the table key already exists with a different type
     
     .. warning:: Empty lists will fail
     """
     value = Value.getFactory(value)(value)
     return self.__api.setEntryValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:12,代码来源:entry.py

示例4: setDefaultValue

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import getFactory [as 别名]
 def setDefaultValue(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
     
     .. warning:: Do not set an empty list, it will fail
     """
     value = Value.getFactory(defaultValue)(defaultValue)
     return self.__api.setDefaultEntryValueById(self._local_id, value)
开发者ID:robotpy,项目名称:pynetworktables,代码行数:12,代码来源:entry.py

示例5: __init__

# 需要导入模块: from ntcore.value import Value [as 别名]
# 或者: from ntcore.value.Value import getFactory [as 别名]
    def __init__(
        self,
        default: V,
        *,
        writeDefault: bool = True,
        subtable: Optional[str] = None,
        doc=None
    ) -> None:
        if doc is not None:
            warnings.warn("tunable no longer uses the doc argument", stacklevel=2)

        self._ntdefault = default
        self._ntsubtable = subtable
        self._ntwritedefault = writeDefault
        # self.__doc__ = doc

        self._mkv = Value.getFactory(default)
        self._nt = NetworkTables
开发者ID:robotpy,项目名称:robotpy-wpilib-utilities,代码行数:20,代码来源:magic_tunable.py


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