本文整理汇总了Python中hqc_meas.tasks.api.RootTask.get_from_database方法的典型用法代码示例。如果您正苦于以下问题:Python RootTask.get_from_database方法的具体用法?Python RootTask.get_from_database怎么用?Python RootTask.get_from_database使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hqc_meas.tasks.api.RootTask
的用法示例。
在下文中一共展示了RootTask.get_from_database方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ex_access_handling3
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
def test_ex_access_handling3():
# Test moving a task with whose one entry has an ex_access.
root = RootTask()
task1 = ComplexTask(task_name='task1')
root.children_task.append(task1)
task2 = SimpleTask(task_name='task2',
task_database_entries={'val2': 'r'})
task1.children_task.append(task2)
task1.add_access_exception('task2_val2')
assert_equal(root.get_from_database('task2_val2'), 'r')
task1.children_task = []
assert_raises(KeyError, root.get_from_database, 'task2_val2')
task1.children_task.append(task2)
assert_equal(root.get_from_database('task2_val2'), 'r')
示例2: TestLogTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestLogTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = LogTask(task_name='Test')
self.root.children_task.append(self.task)
def test_check1(self):
# Simply test that everything is ok message is evaluable.
self.task.message = 'True'
test, traceback = self.task.check()
assert_true(test)
assert_false(traceback)
def test_check2(self):
# Test handling a wrong message.
self.task.message = 'True{'
test, traceback = self.task.check()
assert_false(test)
assert_equal(len(traceback), 1)
assert_in('root/Test', traceback)
def test_perform(self):
# Test performing when condition is True.
self.task.message = 'toro'
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_message'), 'toro')
示例3: TestPNASetRFFrequencyTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestPNASetRFFrequencyTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = SetRFFrequencyTask(task_name='Test')
self.root.children_task.append(self.task)
self.root.run_time['drivers'] = {'Test': InstrHelper}
self.task.unit = 'GHz'
# This is set simply to make sure the test of InstrTask pass.
self.task.selected_driver = 'Test'
self.task.selected_profile = 'Test1'
def test_check_pna_interface1(self):
# Simply test that everything is ok if frequency can be evaluated.
self.task.interface = PNASetRFFrequencyInterface(task=self.task,
channel=1)
self.task.frequency = '1.0'
profile = {'Test1': ({'defined_channels': [[1]]},
{})}
self.root.run_time['profiles'] = profile
test, traceback = self.task.check(test_instr=True)
assert_true(test)
assert_false(traceback)
def test_check_pna_interface2(self):
# Check handling a wrong channel.
self.task.interface = PNASetRFFrequencyInterface(task=self.task,
channel=1)
self.task.frequency = '1.0'
profile = {'Test1': ({'defined_channels': [[2]]},
{})}
self.root.run_time['profiles'] = profile
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
def test_perform_pna_interface(self):
self.task.interface = PNASetRFFrequencyInterface(task=self.task)
self.task.frequency = '1.0'
profile = {'Test1': ({'frequency': [0.0],
'owner': [None]},
{'get_channel': lambda x, i: x}
)}
self.root.run_time['profiles'] = profile
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_frequency'), 1.0e9)
示例4: test_child_addition_handling1
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
def test_child_addition_handling1():
# Test that adding a task to the root task is correctly handled.
root = RootTask()
task1 = ComplexTask(task_name='task1',
task_database_entries={'val1': 2.0})
root.children_task.append(task1)
assert_equal(task1.task_depth, 1)
assert_equal(task1.task_path, 'root')
assert_is(task1.task_database, root.task_database)
assert_is(task1.root_task, root)
assert_is(task1.parent_task, root)
assert_equal(task1.get_from_database('task1_val1'), 2.0)
assert_equal(root.get_from_database('task1_val1'), 2.0)
示例5: TestSetRFOnOffTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestSetRFOnOffTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = SetRFOnOffTask(task_name='Test')
self.root.children_task.append(self.task)
self.root.run_time['drivers'] = {'Test': InstrHelper}
# This is set simply to make sure the test of InstrTask pass.
self.task.selected_driver = 'Test'
self.task.selected_profile = 'Test1'
def test_check_base_interface1(self):
# Simply test that everything is ok if voltage can be evaluated.
self.task.switch = '1.0'
test, traceback = self.task.check(test_instr=True)
assert_true(test)
assert_false(traceback)
def test_check_base_interface2(self):
# Check handling a wrong voltage.
self.task.switch = '*1.0*'
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
def test_perform_base_interface(self):
self.task.switch = '1.0'
self.root.run_time['profiles'] = {'Test1': ({'output': [0.0],
'owner': [None]}, {})}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_output'), 1.0)
示例6: TestSetDCVoltageTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestSetDCVoltageTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = MeasDCVoltageTask(task_name='Test')
self.root.children_task.append(self.task)
self.root.run_time['drivers'] = {'Test': InstrHelper}
# This is set simply to make sure the test of InstrTask pass.
self.task.selected_driver = 'Test'
self.task.selected_profile = 'Test1'
def test_perform(self):
self.task.wait_time = 1.0
self.root.run_time['profiles'] = {'Test1': ({},
{'read_voltage_dc': [2.0]})
}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_voltage'), 2.0)
示例7: TestLoopTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestLoopTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = LoopTask(task_name='Test')
self.root.children_task.append(self.task)
def test_task_handling(self):
# Test adding removing a task.
aux = CheckTask()
self.task.task = aux
# Check value is not written in database if a task is present.
assert_not_in('value', self.task.task_database_entries)
# Confirm the child was added (_child_added called)
assert_is(aux.root_task, self.root)
del self.task.task
# Check value is written in database if no task is present.
assert_in('value', self.task.task_database_entries)
# Confirm the child was added (_child_removed called)
assert_is(aux.root_task, None)
def test_timing_handling(self):
# Test enabling/disabling the timing.
assert_not_in('elapsed_time', self.task.task_database_entries)
self.task.timing = True
assert_in('elapsed_time', self.task.task_database_entries)
self.task.timing = False
assert_not_in('elapsed_time', self.task.task_database_entries)
def test_check_linspace_interface1(self):
# Simply test that everything is ok when all formulas are true.
interface = LinspaceLoopInterface()
interface.start = '1.0'
interface.stop = '2.0'
interface.step = '0.1'
self.task.interface = interface
test, traceback = self.task.check()
assert_true(test)
assert_false(traceback)
assert_equal(self.task.get_from_database('Test_point_number'), 11)
def test_check_linspace_interface2(self):
# Test handling a wrong start.
interface = LinspaceLoopInterface()
interface.start = '1.0*'
interface.stop = '2.0'
interface.step = '0.1'
self.task.interface = interface
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
assert_in('root/Test-start', traceback)
def test_check_linspace_interface3(self):
# Test handling a wrong stop.
interface = LinspaceLoopInterface()
interface.start = '1.0'
interface.stop = '2.0*'
interface.step = '0.1'
self.task.interface = interface
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
assert_in('root/Test-stop', traceback)
def test_check_linspace_interface4(self):
# Test handling a wrong step.
interface = LinspaceLoopInterface()
interface.start = '1.0'
interface.stop = '2.0'
interface.step = '0.1*'
self.task.interface = interface
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
assert_in('root/Test-step', traceback)
def test_check_linspace_interface5(self):
# Test handling a wrong number of point.
interface = LinspaceLoopInterface()
interface.start = '1.0'
interface.stop = '2.0'
interface.step = '0.0'
self.task.interface = interface
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 2)
assert_in('root/Test-points', traceback)
#.........这里部分代码省略.........
示例8: TestApplyMagFieldTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestApplyMagFieldTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = ApplyMagFieldTask(task_name='Test')
self.root.children_task.append(self.task)
self.root.run_time['drivers'] = {'Test': InstrHelper}
# This is set simply to make sure the test of InstrTask pass.
self.task.selected_driver = 'Test'
self.task.selected_profile = 'Test1'
def test_check1(self):
# Simply test that everything is ok if field can be evaluated.
self.task.target_field = '3.0'
test, traceback = self.task.check(test_instr=True)
assert_true(test)
assert_false(traceback)
assert_equal(self.task.get_from_database('Test_Bfield'), 3.0)
def test_check2(self):
# Check handling a wrong field.
self.task.target_field = '*1.0*'
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
assert_in('root/Test-field', traceback)
assert_equal(self.task.get_from_database('Test_Bfield'), 0.01)
def test_perform1(self):
# Simple test when everything is right.
self.task.target_field = '2.0'
self.root.run_time['profiles'] = {'Test1': ({'owner': []},
{'make_ready': [None],
'go_to_field': [None]}
)}
self.root.task_database.prepare_for_running()
self.task.perform()
join_threads(self.root)
assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)
def test_perform2(self):
# Test multiple run when connection is maintained.
self.task.target_field = '2.0'
self.root.run_time['profiles'] = {'Test1': ({'owner': []},
{'make_ready': [None],
'go_to_field': [None],
'check_connection': [True]
}
)}
self.root.task_database.prepare_for_running()
self.task.perform()
join_threads(self.root)
self.task.perform()
join_threads(self.root)
# In case of fail make_ready would be called twice.
assert_equal(self.root.get_from_database('Test_Bfield'), 2.0)
示例9: TestSetDCVoltageTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
#.........这里部分代码省略.........
{})}
self.root.run_time['profiles'] = profile
test, traceback = self.task.check(test_instr=True)
assert_true(test)
assert_false(traceback)
def test_check_multichannel_interface2(self):
# Check the multichannel specific tests, failing = driver.
interface = MultiChannelVoltageSourceInterface(task=self.task)
interface.channel = 1
self.task.interface = interface
self.task.target_value = '1.0'
self.root.run_time['drivers'] = {}
profile = {'Test1': ({'defined_channels': [[1]]},
{})}
self.root.run_time['profiles'] = profile
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
def test_check_multichannel_interface3(self):
# Check the multichannel specific tests, failing =profile.
interface = MultiChannelVoltageSourceInterface(task=self.task)
interface.channel = 1
self.task.interface = interface
self.task.target_value = '1.0'
self.task.selected_profile = ''
self.root.run_time['drivers'] = {'Test': InstrHelper}
test, traceback = self.task.check()
assert_false(test)
assert_equal(len(traceback), 1)
def test_check_multichannel_interface4(self):
# Check the multichannel specific tests, failing = channel.
interface = MultiChannelVoltageSourceInterface(task=self.task)
interface.channel = 2
self.task.interface = interface
self.task.target_value = '1.0'
profile = {'Test1': ({'defined_channels': [[1]]},
{})}
self.root.run_time['profiles'] = profile
self.root.run_time['drivers'] = {'Test': InstrHelper}
test, traceback = self.task.check(test_instr=True)
assert_false(test)
assert_equal(len(traceback), 1)
def test_smooth_set_stopping(self):
self.root.run_time['profiles'] = {'Test1': ({'voltage': [0.0],
'funtion': ['VOLT'],
'owner': [None]}, {})}
self.root.task_database.prepare_for_running()
self.root.should_stop.set()
setter = lambda value: setattr(self.driver, 'voltage', value)
self.task.smooth_set(1.0, setter, 0.0)
assert_equal(self.root.get_from_database('Test_voltage'), 0.0)
def test_perform_base_interface(self):
# Test also that a target which is not a multiple of the back step
# is correctly handled.
self.task.target_value = '0.05'
self.root.run_time['profiles'] = {'Test1': ({'voltage': [0.0],
'funtion': ['VOLT'],
'owner': [None]}, {})}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_voltage'), 0.05)
self.task.target_value = '1.06'
self.task.perform()
assert_equal(self.root.get_from_database('Test_voltage'), 1.06)
def test_perform_multichannel_interface(self):
interface = MultiChannelVoltageSourceInterface(task=self.task)
interface.channel = 1
self.task.interface = interface
self.task.target_value = '1.0'
profile = {'Test1': ({'voltage': [0.0],
'funtion': ['VOLT'],
'owner': [None]},
{'get_channel': lambda x, i: x}
)}
self.root.run_time['profiles'] = profile
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_voltage'), 1.0)
示例10: TestSetDCVoltageTask
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
class TestSetDCVoltageTask(object):
def setup(self):
self.root = RootTask(should_stop=Event(), should_pause=Event())
self.task = LockInMeasureTask(task_name='Test')
self.root.children_task.append(self.task)
self.root.run_time['drivers'] = {'Test': InstrHelper}
# This is set simply to make sure the test of InstrTask pass.
self.task.selected_driver = 'Test'
self.task.selected_profile = 'Test1'
def test_mode_observation(self):
# Check database is correctly updated when the mode change.
self.task.mode = 'X'
assert_equal(self.task.get_from_database('Test_x'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_y', aux)
assert_not_in('Test_amplitude', aux)
assert_not_in('Test_phase', aux)
self.task.mode = 'Y'
assert_equal(self.task.get_from_database('Test_y'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_x', aux)
assert_not_in('Test_amplitude', aux)
assert_not_in('Test_phase', aux)
self.task.mode = 'X&Y'
assert_equal(self.task.get_from_database('Test_x'), 1.0)
assert_equal(self.task.get_from_database('Test_y'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_amplitude', aux)
assert_not_in('Test_phase', aux)
self.task.mode = 'Amp'
assert_equal(self.task.get_from_database('Test_amplitude'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_x', aux)
assert_not_in('Test_y', aux)
assert_not_in('Test_phase', aux)
self.task.mode = 'Phase'
assert_equal(self.task.get_from_database('Test_phase'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_x', aux)
assert_not_in('Test_y', aux)
assert_not_in('Test_amplitude', aux)
self.task.mode = 'Amp&Phase'
assert_equal(self.task.get_from_database('Test_amplitude'), 1.0)
assert_equal(self.task.get_from_database('Test_phase'), 1.0)
aux = self.task.accessible_database_entries()
assert_not_in('Test_x', aux)
assert_not_in('Test_y', aux)
def test_perform1(self):
self.task.mode = 'X'
self.root.run_time['profiles'] = {'Test1': ({}, {'read_x': [2.0]})}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_x'), 2.0)
def test_perform2(self):
self.task.mode = 'Y'
self.root.run_time['profiles'] = {'Test1': ({}, {'read_y': [2.0]})}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_y'), 2.0)
def test_perform3(self):
self.task.mode = 'X&Y'
self.root.run_time['profiles'] = {'Test1': ({},
{'read_xy': [(2.0, 3.0)]})}
self.root.task_database.prepare_for_running()
self.task.perform()
assert_equal(self.root.get_from_database('Test_x'), 2.0)
assert_equal(self.root.get_from_database('Test_y'), 3.0)
def test_perform4(self):
self.task.mode = 'Amp'
self.root.run_time['profiles'] = {'Test1': ({},
{'read_amplitude': [2.0]})}
#.........这里部分代码省略.........
示例11: test_register_in_database1
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import get_from_database [as 别名]
def test_register_in_database1():
# Check that the root task does write its default entries in the database
# when instantiated.
root = RootTask()
assert_equal(root.get_from_database('default_path'), '')