Class MotorBase

All Implemented Interfaces:
Device, Motor, Configurable, Findable, gda.observable.IObservable, Serializable
Direct Known Subclasses:
DummyMotor, EpicsMotor, MotorIocDecorator, ThreadlessDummyMotor

public abstract class MotorBase extends DeviceBase implements Motor, Serializable
A base implementation of a generic Motor for all real motor types, which are therefore subclasses of this class.
See Also:
  • Field Details

    • correctBacklash

      protected boolean correctBacklash
    • minPosition

      protected double minPosition
    • maxPosition

      protected double maxPosition
    • isInitialised

      protected volatile boolean isInitialised
  • Constructor Details

    • MotorBase

      public MotorBase()
  • Method Details

    • setFastSpeed

      public void setFastSpeed(double fastSpeed)
      Changes the maximum velocity fast speed setting.
      Parameters:
      fastSpeed - velocity in motor hardware units
    • getFastSpeed

      public double getFastSpeed()
      Returns:
      fast speed velocity in motor hardware units
    • setMediumSpeed

      public void setMediumSpeed(double mediumSpeed)
      Changes the maximum velocity medium speed setting.
      Parameters:
      mediumSpeed - velocity in motor hardware units
    • getMediumSpeed

      public double getMediumSpeed()
      Returns:
      medium speed velocity in motor hardware units
    • setSlowSpeed

      public void setSlowSpeed(double slowSpeed)
      Changes the maximum velocity slow speed setting.
      Parameters:
      slowSpeed - velocity in motor hardware units
    • getSlowSpeed

      public double getSlowSpeed()
      Returns:
      slow speed velocity in motor hardware units
    • setBacklashSteps

      public void setBacklashSteps(double backlashSteps)
      Changes the current backlash correction to the specified hardware units.
      Parameters:
      backlashSteps - backlash correction drive in motor hardware units
    • getBacklashSteps

      public double getBacklashSteps()
      Returns:
      current backlash correction in hardware units
    • isLimitsSettable

      public boolean isLimitsSettable()
      Checks whether this motor is allowed to change its hardware soft limits. Motor implementations should overide this method if required.
      Specified by:
      isLimitsSettable in interface Motor
      Returns:
      a default of false here, but would return true where limits are settable.
    • setLimitsSettable

      public void setLimitsSettable(boolean limitsSettable)
      Sets whether this motor should change the hardware's soft limits.
      Parameters:
      limitsSettable - flag true if limits are settable
    • getTimeToVelocity

      public double getTimeToVelocity() throws MotorException
      Description copied from interface: Motor
      Returns this motor's time to velocity.
      Specified by:
      getTimeToVelocity in interface Motor
      Throws:
      MotorException
    • 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
      Throws:
      MotorException
    • setSpeedLevel

      public void setSpeedLevel(int speed) throws MotorException
      Description copied from interface: Motor
      Sets the speed level of the motor
      Specified by:
      setSpeedLevel in interface Motor
      Parameters:
      speed - one of a range of possible levels eg slow, medium, fast
      Throws:
      MotorException
    • addInBacklash

      public double addInBacklash(double increment)
      The calculation used to determine the size of the first part of a backlash move and to set whether backlash is required.
      Parameters:
      increment - requested size of move in hardware units
      Returns:
      size of move adjusted for backlash correction if needed
    • correctBacklash

      public void correctBacklash() throws MotorException
      If backlash is required, this method instigates the final backlash move. This method works for motors which use incremental moves and should be overridden by motors which use absolute encoder positions.
      Specified by:
      correctBacklash in interface Motor
      Throws:
      MotorException
    • waitWhileStatusBusy

      public MotorStatus waitWhileStatusBusy() throws InterruptedException, DeviceException
      Description copied from interface: Motor
      Blocks while the motors status is Busy
      Specified by:
      waitWhileStatusBusy in interface Motor
      Returns:
      status after being busy
      Throws:
      InterruptedException
      DeviceException
    • setSoftLimits

      public void setSoftLimits(double minPosition, double maxPosition) throws MotorException
      Sets the software limits. Some motors/motor controllers are capable of setting up softlimits in them so that the so that the hard limit switch is never hit (at least theoretically) Such motor implementations should overide this method if required.
      Specified by:
      setSoftLimits in interface Motor
      Parameters:
      minPosition - the minimum softlimit
      maxPosition - the maximum softlimit
      Throws:
      MotorException
    • getMinPosition

      public double getMinPosition() throws MotorException
      Description copied from interface: Motor
      Gets the minimum or lower soft limits of the motor itself (i.e. NOT limits cached in GDA software). By convention return NaN if not set.
      Specified by:
      getMinPosition in interface Motor
      Returns:
      the lower soft limit of the motor
      Throws:
      MotorException
    • setMinPosition

      public void setMinPosition(double minPosition) throws MotorException
      Description copied from interface: Motor
      Set the lower soft limit of the motor
      Specified by:
      setMinPosition in interface Motor
      Parameters:
      minPosition - the lower limit to set
      Throws:
      MotorException
    • getMaxPosition

      public double getMaxPosition() throws MotorException
      Description copied from interface: Motor
      Gets the maximum or upper soft limits of the motor itself (i.e. NOT limits cached in GDA software). By convention return NaN if not set.
      Specified by:
      getMaxPosition in interface Motor
      Returns:
      the upper soft limit of the motor
      Throws:
      MotorException
    • setMaxPosition

      public void setMaxPosition(double maxPosition) throws MotorException
      Description copied from interface: Motor
      Set the upper soft limit of the motor
      Specified by:
      setMaxPosition in interface Motor
      Parameters:
      maxPosition - upper limit to set
      Throws:
      MotorException
    • getRetryDeadband

      public double getRetryDeadband() throws MotorException
      Description copied from interface: Motor
      return the position tolerance or accuracy
      Specified by:
      getRetryDeadband in interface Motor
      Returns:
      positioning tolerance
      Throws:
      MotorException
    • isHomeable

      public boolean isHomeable()
      Checks if the motor is homeable or not. Motor implementations should overide this method if required.
      Specified by:
      isHomeable in interface Motor
      Returns:
      if the motor is homeable. Returns false!
    • isHomed

      public boolean isHomed() throws MotorException
      Checks if the motor is homed or not. Motor implementations should overide this method if required.
      Specified by:
      isHomed in interface Motor
      Returns:
      if the motor is homed. Returns false!
      Throws:
      MotorException
    • home

      public void home() throws MotorException
      Moves the motor to a repeatable starting location. Motor implementations should overide this method if required.
      Specified by:
      home in interface Motor
      Throws:
      MotorException
    • isInitialised

      public boolean isInitialised()
      Description copied from interface: Motor
      Gets initialisition state of the motor with respect to its connection to low level device service e.g. EPICS server. This value does not imply that the motors initial values are set (or not set).
      Specified by:
      isInitialised in interface Motor
      Returns:
      return true if motor is already initialised.
    • setInitialised

      public void setInitialised(boolean initialised)
      Parameters:
      initialised -
    • setMotorResolution

      public void setMotorResolution(double motorResolution) throws MotorException
      Throws:
      MotorException
    • getMotorResolution

      public double getMotorResolution() throws MotorException
      Specified by:
      getMotorResolution in interface Motor
      Throws:
      MotorException
    • getUserOffset

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

      public String getUnitString() throws MotorException
      Specified by:
      getUnitString in interface Motor
      Returns:
      unit as a String
      Throws:
      MotorException