本文整理汇总了Python中mi.core.instrument.protocol_param_dict.ProtocolParameterDict.get_startup_list方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolParameterDict.get_startup_list方法的具体用法?Python ProtocolParameterDict.get_startup_list怎么用?Python ProtocolParameterDict.get_startup_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.core.instrument.protocol_param_dict.ProtocolParameterDict
的用法示例。
在下文中一共展示了ProtocolParameterDict.get_startup_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestUnitProtocolParameterDict
# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import get_startup_list [as 别名]
#.........这里部分代码省略.........
self.test_yaml = '''
parameters: {
qut: {
description: "QutFileDesc",
units: "QutFileUnits",
value_description: "QutFileValueDesc",
type: "QutFileType",
display_name: "QutDisplay"
},
extra_param: {
description: "ExtraFileDesc",
units: "ExtraFileUnits",
value_description: "ExtraFileValueDesc",
type: "ExtraFileType"
}
}
commands: {
dummy: stuff
}
'''
def test_get_direct_access_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_direct_access_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 3)
self.assert_("foo" in result)
self.assert_("baz" in result)
self.assert_("qut" in result)
def test_get_startup_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_startup_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 2)
self.assert_("foo" in result)
self.assert_("bar" in result)
def test_set_default(self):
"""
Test setting a default value
"""
result = self.param_dict.get_config()
self.assertEquals(result["foo"], None)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.param_dict.update("foo=1000")
self.assertEquals(self.param_dict.get("foo"), 1000)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.assertRaises(ValueError, self.param_dict.set_default, "qux")
def test_update_many(self):
"""
Test updating of multiple variables from the same input
"""
sample_input = """
foo=100
bar=200, baz=300
"""
示例2: InstrumentProtocol
# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import get_startup_list [as 别名]
#.........这里部分代码省略.........
#############################################################
# Configuration logic
#############################################################
def set_init_params(self, config):
"""
Set the initialization parameters to the given values in the protocol
parameter dictionary.
@param config The parameter_name/value to set in the initialization
fields of the parameter dictionary
@raise InstrumentParameterException If the config cannot be set
"""
if not isinstance(config, dict):
raise InstrumentParameterException("Invalid init config format")
self._startup_config = config
param_config = config.get(DriverConfigKey.PARAMETERS)
if(param_config):
for name in param_config.keys():
self._param_dict.set_init_value(name, param_config[name])
def get_startup_config(self):
"""
Gets the startup configuration for the instrument. The parameters
returned are marked as startup, and the values are the best as chosen
from the initialization, default, and current parameters.
@retval The dict of parameter_name/values (override this method if it
is more involved for a specific instrument) that should be set at
a higher level.
"""
return_dict = {}
start_list = self._param_dict.get_startup_list()
log.trace("Startup list: %s", start_list)
assert isinstance(start_list, list)
for param in start_list:
result = self._param_dict.get_init_value(param)
if result != None:
log.trace("Got init value for %s: %s", param, result)
return_dict[param] = result
else:
result = self._param_dict.get_default_value(param)
if result != None:
log.trace("Got default value for %s: %s", param, result)
return_dict[param] = result
else:
log.trace("Got current value for %s: %s", param, result)
return_dict[param] = self._param_dict.get(param)
return return_dict
def get_direct_access_params(self):
"""
Get the list of direct access parameters, useful for restoring direct
access configurations up in the driver.
@retval a list of direct access parameter names
"""
return self._param_dict.get_direct_access_list()
def get_cached_config(self):
"""
Return the configuration object that shows the instrument's
configuration as cached in the parameter dictionary...usually in
示例3: TestUnitProtocolParameterDict
# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import get_startup_list [as 别名]
class TestUnitProtocolParameterDict(MiUnitTestCase):
@staticmethod
def pick_byte2(input):
""" Get the 2nd byte as an example of something tricky and
arbitrary"""
val = int(input) >> 8
val = val & 255
return val
"""
Test cases for instrument driver class. Functions in this class provide
instrument driver unit tests and provide a tutorial on use of
the driver interface.
"""
def setUp(self):
self.param_dict = ProtocolParameterDict()
self.param_dict.add("foo", r'.*foo=(\d+).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=True,
startup_param=True,
default_value=10,
visibility=ParameterDictVisibility.READ_WRITE)
self.param_dict.add("bar", r'.*bar=(\d+).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=False,
startup_param=True,
default_value=15,
visibility=ParameterDictVisibility.READ_WRITE)
self.param_dict.add("baz", r'.*baz=(\d+).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=True,
default_value=20,
visibility=ParameterDictVisibility.DIRECT_ACCESS)
self.param_dict.add("bat", r'.*bat=(\d+).*',
lambda match : int(match.group(1)),
lambda x : str(x),
startup_param=False,
default_value=20,
visibility=ParameterDictVisibility.READ_ONLY)
self.param_dict.add("qux", r'.*qux=(\d+).*',
lambda match : int(match.group(1)),
lambda x : str(x),
startup_param=False,
visibility=ParameterDictVisibility.READ_ONLY)
def test_get_direct_access_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_direct_access_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 2)
self.assert_("foo" in result)
self.assert_("baz" in result)
def test_get_startup_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_startup_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 2)
self.assert_("foo" in result)
self.assert_("bar" in result)
def test_set_default(self):
"""
Test setting a default value
"""
result = self.param_dict.get_config()
self.assertEquals(result["foo"], None)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.param_dict.update("foo=1000")
self.assertEquals(self.param_dict.get("foo"), 1000)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.assertRaises(ValueError, self.param_dict.set_default, "qux")
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)
#.........这里部分代码省略.........
示例4: TestUnitProtocolParameterDict
# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import get_startup_list [as 别名]
class TestUnitProtocolParameterDict(MiUnitTestCase):
"""
Test cases for instrument driver class. Functions in this class provide
instrument driver unit tests and provide a tutorial on use of
the driver interface.
"""
def setUp(self):
self.param_dict = ProtocolParameterDict()
self.param_dict.add("foo", r'.*foo=(\d*).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=True,
startup_param=True,
default_value=10,
visibility=ParameterDictVisibility.READ_WRITE)
self.param_dict.add("bar", r'.*bar=(\d*).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=False,
startup_param=True,
default_value=15,
visibility=ParameterDictVisibility.READ_WRITE)
self.param_dict.add("baz", r'.*baz=(\d*).*',
lambda match : int(match.group(1)),
lambda x : str(x),
direct_access=True,
default_value=20,
visibility=ParameterDictVisibility.DIRECT_ACCESS)
self.param_dict.add("bat", r'.*bat=(\d*).*',
lambda match : int(match.group(1)),
lambda x : str(x),
startup_param=False,
default_value=20,
visibility=ParameterDictVisibility.READ_ONLY)
self.param_dict.add("qux", r'.*qux=(\d*).*',
lambda match : int(match.group(1)),
lambda x : str(x),
startup_param=False,
visibility=ParameterDictVisibility.READ_ONLY)
def test_get_direct_access_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_direct_access_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 2)
self.assert_("foo" in result)
self.assert_("baz" in result)
def test_get_startup_list(self):
"""
Test to see we can get a list of direct access parameters
"""
result = self.param_dict.get_startup_list()
self.assertTrue(isinstance(result, list))
self.assertEquals(len(result), 2)
self.assert_("foo" in result)
self.assert_("bar" in result)
def test_set_default(self):
"""
Test setting a default value
"""
result = self.param_dict.get_config()
self.assertEquals(result["foo"], None)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.param_dict.update("foo=1000")
self.assertEquals(self.param_dict.get("foo"), 1000)
self.param_dict.set_default("foo")
self.assertEquals(self.param_dict.get("foo"), 10)
self.assertRaises(ValueError, self.param_dict.set_default, "qux")
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)
#.........这里部分代码省略.........