def setUp(self): """Create a Controller, and Motor 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_mot_ctrl = createPoolController(pool, dummyPoolMotorCtrlConf01) self.dummy_mot = createPoolMotor(pool, dummy_mot_ctrl, dummyMotorConf01) self.dummy_mot2 = createPoolMotor(pool, dummy_mot_ctrl, dummyMotorConf02) dummy_mot_ctrl.add_element(self.dummy_mot) pool.add_element(dummy_mot_ctrl) pool.add_element(self.dummy_mot) pool.add_element(self.dummy_mot2) # {moveable: (position, dial_position, # do_backlash, backlash, instability_time=None)} self.items = {self.dummy_mot: (0, 0, False, 0), self.dummy_mot2: (0, 0, False, 0)} # Create mock and define its functions ctrl_methods = ['PreStartAll', 'StartAll', 'PreStartOne', 'StartOne', 'PreStateAll', 'StateAll', 'PreStateOne', 'StateOne', 'PreReadAll', 'PreReadOne', 'ReadOne', 'ReadAll', 'PreStopAll', 'StopAll', 'PreStopOne', 'StopOne', 'PreAbortAll', 'AbortAll', 'PreAbortOne', 'AbortOne'] self.mock_mot_ctrl = Mock(spec=ctrl_methods) self.mock_mot_ctrl.StateOne.return_value = (State.Moving, 'moving') dummy_mot_ctrl.ctrl = self.mock_mot_ctrl self.motionaction = PoolMotion(self.dummy_mot) self.motionaction.add_element(self.dummy_mot) self.motionaction.add_element(self.dummy_mot2)
def __init__(self, **kwargs): kwargs['elem_type'] = ElementType.Motor PoolElement.__init__(self, **kwargs) on_change = self.on_change self._offset = Offset(self, initial_value=0, listeners=on_change) self._sign = Sign(self, initial_value=1, listeners=on_change) self._dial_position = DialPosition(self, listeners=on_change) self._position = Position(self, listeners=on_change) self._backlash = 0 self._step_per_unit = 1.0 self._limit_switches = LimitSwitches(self, name="Limit_switches", initial_value=3 * (False,), listeners=on_change) self._acceleration = None self._deceleration = None self._velocity = None self._base_rate = None self._instability_time = None self._in_start_move = False motion_name = "%s.Motion" % self._name self.set_action_cache(PoolMotion(self, motion_name))
def _create_action_cache(self): motion_name = "%s.Motion" % self._name return PoolMotion(self, motion_name)