示例#1
0
    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 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'
示例#3
0
    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(InstrManagerManifest())
        self.workbench.register(TaskManagerManifest())

        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}
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]})}

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_amplitude'), 2.0)

    def test_perform5(self):
        self.task.mode = 'Phase'

        self.root.run_time['profiles'] = {'Test1': ({}, {'read_phase': [2.0]})}

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_phase'), 2.0)

    def test_perform6(self):
        self.task.mode = 'Amp&Phase'

        self.root.run_time['profiles'] = {'Test1': ({},
                                          {'read_amp_and_phase': [(2.0, 3.0)]})
                                          }

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_amplitude'), 2.0)
        assert_equal(self.root.get_from_database('Test_phase'), 3.0)
示例#5
0
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]
            })
        }

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_amplitude'), 2.0)

    def test_perform5(self):
        self.task.mode = 'Phase'

        self.root.run_time['profiles'] = {'Test1': ({}, {'read_phase': [2.0]})}

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_phase'), 2.0)

    def test_perform6(self):
        self.task.mode = 'Amp&Phase'

        self.root.run_time['profiles'] = {
            'Test1': ({}, {
                'read_amp_and_phase': [(2.0, 3.0)]
            })
        }

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_amplitude'), 2.0)
        assert_equal(self.root.get_from_database('Test_phase'), 3.0)