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 __init__(self, main_element, name="Acquisition"): PoolAction.__init__(self, main_element, name) zerodname = name + ".0DAcquisition" hwname = name + ".HardwareAcquisition" swname = name + ".SoftwareAcquisition" synchname = name + ".Synchronization" self._sw_acq_config = None self._0d_config = None self._0d_acq = Pool0DAcquisition(main_element, name=zerodname) self._sw_acq = PoolAcquisitionSoftware(main_element, name=swname) self._hw_acq = PoolAcquisitionHardware(main_element, name=hwname) self._synch = PoolSynchronization(main_element, name=synchname)
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)
def createPoolSynchronization(self, tg_list): self.main_element = FakeElement(self.pool) self.tggeneration = PoolSynchronization(self.main_element) for tg in tg_list: self.tggeneration.add_element(tg) self.tggeneration.add_listener(self)
def __init__(self, **kwargs): kwargs['elem_type'] = ElementType.TriggerGate PoolElement.__init__(self, **kwargs) tggen_name = "%s.TGGeneration" % self._name self.set_action_cache(PoolSynchronization(self, name=tggen_name)) self._index = Index(self)