Class DummyMotor

All Implemented Interfaces:
Device, Motor, Configurable, Findable, gda.observable.IObservable, Serializable

public class DummyMotor extends MotorBase
A Dummy motor class
See Also:
  • Constructor Details

    • DummyMotor

      public DummyMotor()
  • Method Details

    • configure

      public void configure()
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
    • toString

      public String toString()
      Returns a string to represent the motor.
      Overrides:
      toString in class Object
      Returns:
      a string to represent the motor
    • moveTo

      public void moveTo(double requestedPosition) throws MotorException
      Starts a move to requestedPosition
      Parameters:
      requestedPosition -
      Throws:
      MotorException
    • moveContinuously

      public void moveContinuously(int direction)
      Starts the motor moving continuously
      Parameters:
      direction - the direction to move in
    • moveBy

      public void moveBy(double amount) throws MotorException
      Moves the motor by the specified amount.
      Parameters:
      amount - the specified amount.
      Throws:
      MotorException
    • setPosition

      public void setPosition(double newPosition)
      Sets the current position (i.e. changes the value without actually moving).

      This property can be used in Spring configuration to define what the initial position of the motor should be after the motor object has been configured.

      However if a different position has previously been saved to file, the motor will instead be at that position after it has been configured.

      In other words: at configuration time, a previously-saved position takes precedence over the initial position set using the position property.

      Parameters:
      newPosition - the current position
    • getPosition

      public double getPosition()
      Returns the current position
      Returns:
      the current position
    • setSpeed

      public void setSpeed(double stepsPerSecond) throws MotorException
      Set the speed
      Parameters:
      stepsPerSecond - the new speed
      Throws:
      MotorException
    • getSpeed

      public double getSpeed() throws MotorException
      Return the current speed.
      Returns:
      the current speed
      Throws:
      MotorException
    • getMaxSpeed

      public double getMaxSpeed()
    • setMaxSpeed

      public void setMaxSpeed(double maxSpeed)
    • setTimeToVelocity

      public void setTimeToVelocity(double timeToVelocity) throws MotorException
      Description copied from interface: Motor
      Sets this motor's time to velocity.
      Specified by:
      setTimeToVelocity in interface Motor
      Overrides:
      setTimeToVelocity in class MotorBase
      Throws:
      MotorException
    • getTimeToVelocity

      public double getTimeToVelocity() throws MotorException
      Description copied from interface: Motor
      Returns this motor's time to velocity.
      Specified by:
      getTimeToVelocity in interface Motor
      Overrides:
      getTimeToVelocity in class MotorBase
      Throws:
      MotorException
    • stop

      public void stop() throws MotorException
      Stop the motor
      Throws:
      MotorException
    • panicStop

      public void panicStop() throws MotorException
      Should do an immediate stop but actually does the same as stop() *
      Throws:
      MotorException
    • getStatus

      public MotorStatus getStatus()
      Returns the current status.
      Returns:
      the current status
    • setStatus

      public void setStatus(MotorStatus status)
    • isMoving

      public boolean isMoving()
      Returns whether or not the motor is moving.
      Returns:
      true if the motor is moving
    • isRandomlyProduceExceptions

      public boolean isRandomlyProduceExceptions()
      Returns whether the motor will randomly produce exceptions. Stupid name of method forced by the conventions.
      Returns:
      whether the motor will randomly produce exceptions
    • setRandomlyProduceExceptions

      public void setRandomlyProduceExceptions(boolean randomlyProduceExceptions)
      Sets the randomlyProduceExceptions flag.
      Parameters:
      randomlyProduceExceptions -
    • isHomeable

      public boolean isHomeable()
      Returns whether or not the motor is homeable. For real motors this is a fixed property however DummyMotor allows it to be set in XML.
      Specified by:
      isHomeable in interface Motor
      Overrides:
      isHomeable in class MotorBase
      Returns:
      true if motor is homeable
    • home

      public void home() throws MotorException
      Tells the motor to home itself.
      Specified by:
      home in interface Motor
      Overrides:
      home in class MotorBase
      Throws:
      MotorException
    • isHomed

      public boolean isHomed()
      Returns whether or not the motor has been homed.
      Specified by:
      isHomed in interface Motor
      Overrides:
      isHomed in class MotorBase
      Returns:
      true if motor is already homed
    • getRandomExceptionTriggerLevel

      public double getRandomExceptionTriggerLevel()
      Gets the value of the trigger level for randomly produced exceptions.
      Returns:
      the trigger level
    • setRandomExceptionTriggerLevel

      public void setRandomExceptionTriggerLevel(double randomExceptionTriggerLevel)
      Sets the trigger level for randomly produced exceptions. The value is used in the same way as the randomLimitTriggerLevel. See setRandomLimitTriggerLevel() for an explanation.
      Parameters:
      randomExceptionTriggerLevel - the new value
    • getRandomLimitTriggerLevel

      public double getRandomLimitTriggerLevel()
      Gets the trigger level for randomly produced limits.
      Returns:
      the trigger level for randomly produced limits
    • setRandomLimitTriggerLevel

      public void setRandomLimitTriggerLevel(double randomLimitTriggerLevel)
      Sets the trigger level for randomly produced limits. The random number generator is used to generate a Gaussian distribution with centre 0.0 and sigma 1.0. A random limit is triggered if abs(random number) is greater than trigger level. This means a value of 1.0 will trigger roughly 40% of the time, 2.0 roughly 5% and 3.0 roughly 0.3%. The default value of 10.0 has a negligible chance of triggering an event.
      Parameters:
      randomLimitTriggerLevel -
    • setHomeable

      public void setHomeable(boolean isHomeable)
      Sets the isHomeable flag - real motors would not allow this of course.
      Parameters:
      isHomeable -
    • isRandomPositionVariation

      public boolean isRandomPositionVariation()
    • setRandomPositionVariation

      public void setRandomPositionVariation(boolean randomPositionVariation)
    • getRandomPositionVariationAmount

      public double getRandomPositionVariationAmount()
    • setRandomPositionVariationAmount

      public void setRandomPositionVariationAmount(double randomPositionVariationAmount)
    • getUserOffset

      public double getUserOffset() throws MotorException
      Specified by:
      getUserOffset in interface Motor
      Overrides:
      getUserOffset in class MotorBase
      Returns:
      the user offset set on the motor
      Throws:
      MotorException
    • getUnitString

      public String getUnitString() throws MotorException
      Specified by:
      getUnitString in interface Motor
      Overrides:
      getUnitString in class MotorBase
      Returns:
      unit as a String
      Throws:
      MotorException
    • setUnitString

      public void setUnitString(String unitString)
    • getTargetPosition

      public double getTargetPosition()
    • getLowerHardLimit

      public double getLowerHardLimit()
    • setLowerHardLimit

      public void setLowerHardLimit(double lowerHardLimit)
    • getUpperHardLimit

      public double getUpperHardLimit()
    • setUpperHardLimit

      public void setUpperHardLimit(double upperHardLimit)
    • tweakForward

      public void tweakForward() throws MotorException
      tweak motor position forward by one increment
      Throws:
      MotorException
    • tweakReverse

      public void tweakReverse() throws MotorException
      tweak motor position backward by one increment
      Throws:
      MotorException
    • getTweakSize

      public double getTweakSize()
      return the increment of tweak
      Returns:
      increment
    • setTweakSize

      public void setTweakSize(double tweakSize)
      set the increment for the tweak
      Parameters:
      tweakSize -
    • getRetryDeadband

      public double getRetryDeadband()
      Description copied from interface: Motor
      return the position tolerance or accuracy
      Specified by:
      getRetryDeadband in interface Motor
      Overrides:
      getRetryDeadband in class MotorBase
      Returns:
      positioning tolerance
    • setRetryDeadband

      public void setRetryDeadband(double retryDeadband)
      Set retry dead band returned for a dummy motor, so ScannableMotors with returnDemandPosition=true don't constantly warn that it is undefined, for example:
      
       <gda:motor returnDemandPosition="true" dummy-retryDeadband="0.01" />
       
      Alternatively, use:
      
       <bean id="xMotor" class="gda.device.motor.DummyMotor">
           ...
           <property name="retryDeadband" value="0.01" />
       </bean>
       
      when it is being used by
      
       <bean id="x" class="gda.device.scannable.ScannableMotor">
           <property name="motor" ref="xMotor" />
           ...
           <property name="returnDemandPosition" value="true" />
       </bean>
       
      Parameters:
      retryDeadband -