def setUp(self): """Create a Controller, TriggerGate and PoolSynchronization objects from dummy configurations """ unittest.TestCase.setUp(self) try: from mock import Mock except ImportError: self.skipTest("mock module is not available") pool = FakePool() dummy_tg_ctrl = createPoolController(pool, dummyPoolTGCtrlConf01) self.dummy_tg = createPoolTriggerGate(pool, dummy_tg_ctrl, dummyTriggerGateConf01) dummy_tg_ctrl.add_element(self.dummy_tg) pool.add_element(dummy_tg_ctrl) pool.add_element(self.dummy_tg) self.cfg = createPoolSynchronizationConfiguration( (dummy_tg_ctrl, ), ((self.dummy_tg, ), ), ) # Create mock and define its functions ctrl_methods = [ 'PreStartAll', 'StartAll', 'PreStartOne', 'StartOne', 'PreStateAll', 'StateAll', 'PreStateOne', 'StateOne', 'PreSynchAll', 'PreSynchOne', 'SynchOne', 'SynchAll' ] self.mock_tg_ctrl = Mock(spec=ctrl_methods) self.mock_tg_ctrl.StateOne.return_value = (State.Moving, 'triggering') dummy_tg_ctrl.ctrl = self.mock_tg_ctrl self.tgaction = PoolSynchronization(self.dummy_tg) self.tgaction.add_element(self.dummy_tg)
def setUp(self): """Create a Controller, TriggerGate and PoolSynchronization objects from dummy configurations """ unittest.TestCase.setUp(self) try: from mock import Mock except ImportError: self.skipTest("mock module is not available") pool = FakePool() dummy_tg_ctrl = createPoolController(pool, dummyPoolTGCtrlConf01) self.dummy_tg = createPoolTriggerGate(pool, dummy_tg_ctrl, dummyTriggerGateConf01) dummy_tg_ctrl.add_element(self.dummy_tg) pool.add_element(dummy_tg_ctrl) pool.add_element(self.dummy_tg) self.conf_ctrl = createControllerConfiguration(dummy_tg_ctrl, [self.dummy_tg]) self.ctrls = get_acq_ctrls([self.conf_ctrl]) # self.cfg = createPoolSynchronizationConfiguration((dummy_tg_ctrl,), # ((self.dummy_tg,),),) # Create mock and define its functions ctrl_methods = ['PreStartAll', 'StartAll', 'PreStartOne', 'StartOne', 'PreStateAll', 'StateAll', 'PreStateOne', 'StateOne', 'PreSynchAll', 'PreSynchOne', 'SynchOne', 'SynchAll'] self.mock_tg_ctrl = Mock(spec=ctrl_methods) self.mock_tg_ctrl.StateOne.return_value = (State.Moving, 'triggering') dummy_tg_ctrl.ctrl = self.mock_tg_ctrl self.tgaction = PoolSynchronization(self.dummy_tg) self.tgaction.add_element(self.dummy_tg)
def createTGElement(self, ctrl_obj, name, axis): e_cfg = createElemConf(self.pool, axis, name) elem_obj = createPoolTriggerGate(self.pool, ctrl_obj, e_cfg) ctrl_obj.add_element(elem_obj) # TG elements self.tgs[name] = elem_obj self.pool.add_element(elem_obj) return elem_obj
def createElements(self, ctrl_klass, ctrl_lib, ctrl_props): # create controller and element ctrl_conf = createCtrlConf(self.pool, 'tgctrl01', ctrl_klass, ctrl_lib, ctrl_props) elem_conf = createElemConf(self.pool, 1, 'tg01') self.tg_ctrl = createPoolController(self.pool, ctrl_conf) self.tg_elem = createPoolTriggerGate(self.pool, self.tg_ctrl, elem_conf) # add controller and elements to containers self.tg_ctrl.add_element(self.tg_elem) self.pool.add_element(self.tg_ctrl) self.pool.add_element(self.tg_elem) # create Synchronization action and its configuration self.conf_ctrl = createControllerConfiguration(self.tg_ctrl, [self.tg_elem]) self.ctrls = get_acq_ctrls([self.conf_ctrl]) self.tgaction = PoolSynchronization(self.tg_elem) self.tgaction.add_element(self.tg_elem)
def setUp(self): """Create a Controller, TriggerGate and PoolSynchronization objects from dummy configurations """ unittest.TestCase.setUp(self) pool = FakePool() dummy_tg_ctrl = createPoolController(pool, dummyPoolTGCtrlConf01) self.dummy_tg = createPoolTriggerGate(pool, dummy_tg_ctrl, dummyTriggerGateConf01) # marrying the element with the controller dummy_tg_ctrl.add_element(self.dummy_tg) self.ctrl_conf = createControllerConfiguration(dummy_tg_ctrl, [self.dummy_tg]) # marrying the element with the action self.tg_action = PoolSynchronization(self.dummy_tg) self.tg_action.add_element(self.dummy_tg)