本文整理汇总了Python中mi.core.instrument.protocol_param_dict.ProtocolParameterDict.add_paramdictval方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolParameterDict.add_paramdictval方法的具体用法?Python ProtocolParameterDict.add_paramdictval怎么用?Python ProtocolParameterDict.add_paramdictval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.core.instrument.protocol_param_dict.ProtocolParameterDict
的用法示例。
在下文中一共展示了ProtocolParameterDict.add_paramdictval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestUnitProtocolParameterDict
# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import add_paramdictval [as 别名]
#.........这里部分代码省略.........
def test_update_many(self):
"""
Test updating of multiple variables from the same input
"""
sample_input = """
foo=100
bar=200, baz=300
"""
self.assertNotEquals(self.param_dict.get("foo"), 100)
self.assertNotEquals(self.param_dict.get("bar"), 200)
self.assertNotEquals(self.param_dict.get("baz"), 300)
result = self.param_dict.update_many(sample_input)
log.debug("result: %s", result)
self.assertEquals(result["foo"], True)
self.assertEquals(result["bar"], True)
self.assertEquals(result["baz"], True)
self.assertEquals(self.param_dict.get("foo"), 100)
self.assertEquals(self.param_dict.get("bar"), 200)
self.assertEquals(self.param_dict.get("baz"), 300)
def test_visibility_list(self):
lst = self.param_dict.get_visibility_list(ParameterDictVisibility.READ_WRITE)
self.assertEquals(lst, ["foo", "bar"])
lst = self.param_dict.get_visibility_list(ParameterDictVisibility.DIRECT_ACCESS)
self.assertEquals(lst, ["baz"])
lst = self.param_dict.get_visibility_list(ParameterDictVisibility.READ_ONLY)
self.assertEquals(lst, ["bat", "qux"])
def test_function_values(self):
"""
Make sure we can add and update values with functions instead of patterns
"""
self.param_dict.add_paramdictval(
FunctionParamDictVal(
"fn_foo",
self.pick_byte2,
lambda x : str(x),
direct_access=True,
startup_param=True,
value=1,
visibility=ParameterDictVisibility.READ_WRITE)
)
self.param_dict.add_paramdictval(
FunctionParamDictVal(
"fn_bar",
lambda x : bool(x&2), # bit map example
lambda x : str(x),
direct_access=True,
startup_param=True,
value=False,
visibility=ParameterDictVisibility.READ_WRITE)
)
# check defaults just to be safe
val = self.param_dict.get("fn_foo")
self.assertEqual(val, 1)
val = self.param_dict.get("fn_bar")
self.assertEqual(val, False)
result = self.param_dict.update(1005) # just change first in list
val = self.param_dict.get("fn_foo")
self.assertEqual(val, 3)
val = self.param_dict.get("fn_bar")
self.assertEqual(val, False)