Class TimerWrapper

java.lang.Object
uk.ac.gda.server.ncd.timing.TimerWrapper
All Implemented Interfaces:
Device, Timer, Configurable, Findable, gda.observable.IObservable
Direct Known Subclasses:
LoadFramesTimerHook

public class TimerWrapper extends Object implements Timer
Delegating wrapper to allow additional functionality to be added to an existing Timer
  • Field Summary

    Fields inherited from interface gda.device.Timer

    ACTIVE, ARMED, IDLE, PAUSED
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFrameSet(int frameCount, double requestedDeadTime, double requestedLiveTime)
    Create a single frameSet object for a specified live and dead time.
    void
    addFrameSet(int frameCount, double requestedDeadTime, double requestedLiveTime, int deadPort, int livePort, int deadPause, int livePause)
    Create a single frameSet object for a specified live and dead time.
    void
    addIObserver(gda.observable.IObserver observer)
     
    void
    Clear all current frameSets
    void
    Close and unconfigure the device.
    void
    Perform operations that must be done after Spring initialisation i.e.
    void
    countAsync(double time)
    Initiates a single specified timing period and allows the timer to proceed asynchronously.
    void
    deleteIObserver(gda.observable.IObserver observer)
     
    void
     
    getAttribute(String attributeName)
    Get the value of the specified attribute
    int
    Returns the current cycle number.
    int
    Returns the current frame number.
    int
    Returns the total number of frame pairs supported (each specifying a live and a dead period)
    Get the object name.
    int
     
    int
    Returns the current state of the timer All timers must fully implement this.
    boolean
    Indicates whether this object should be configured at startup.
    boolean
    Checks to see if the object is already configured.
    void
    Load an array of frameSets obtained from calls to makeFrameSet() are loaded into the timer.
    void
    output(String file)
    Output data from timer directly to file
    void
    Re-initialisation of values and states.
    void
    Restarts framing from the paused state
    void
    setAttribute(String attributeName, Object value)
    Set any attribute the implementing classes may provide
    void
    setCycles(int cycles)
    sets the number of times the timer cycles through the framesets.
    void
    Set or change the name of the object (as defined in XML).
    void
    setProtectionLevel(int newLevel)
    Sets the permission level for this object.
    void
    For a time framing counter-timer, this initiates framing, starting from the current frame number (specified by setFrameNumber())
    void
    Aborts any current timing and returns it to an idle state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimerWrapper

      public TimerWrapper(Timer timer)
  • Method Details

    • setName

      public void setName(String name)
      Description copied from interface: Findable
      Set or change the name of the object (as defined in XML).
      Specified by:
      setName in interface Findable
      Parameters:
      name - the object name
    • configure

      public void configure() throws FactoryException
      Description copied from interface: Configurable
      Perform operations that must be done after Spring initialisation i.e. anything that goes beyond setting member variables.
      Specified by:
      configure in interface Configurable
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • getName

      public String getName()
      Description copied from interface: Findable
      Get the object name. Used by Castor to check if the object name has been set before calling the Findable.setName(String) method.
      Specified by:
      getName in interface Findable
      Returns:
      a String containing the object name.
    • addIObserver

      public void addIObserver(gda.observable.IObserver observer)
      Specified by:
      addIObserver in interface gda.observable.IObservable
    • setAttribute

      public void setAttribute(String attributeName, Object value) throws DeviceException
      Description copied from interface: Device
      Set any attribute the implementing classes may provide
      Specified by:
      setAttribute in interface Device
      Parameters:
      attributeName - is the name of the attribute
      value - is the value of the attribute
      Throws:
      DeviceException - if an attribute cannot be set
    • getStatus

      public int getStatus() throws DeviceException
      Description copied from interface: Timer
      Returns the current state of the timer All timers must fully implement this.
      Specified by:
      getStatus in interface Timer
      Returns:
      ACTIVE if the timer has not finished the requested operation(s), IDLE if in an completely idle state and PAUSED if temporarily suspended.
      Throws:
      DeviceException
    • deleteIObserver

      public void deleteIObserver(gda.observable.IObserver observer)
      Specified by:
      deleteIObserver in interface gda.observable.IObservable
    • isConfigured

      public boolean isConfigured()
      Description copied from interface: Configurable
      Checks to see if the object is already configured.
      Specified by:
      isConfigured in interface Configurable
      Returns:
      return true if configured false otherwise
    • deleteIObservers

      public void deleteIObservers()
      Specified by:
      deleteIObservers in interface gda.observable.IObservable
    • reconfigure

      public void reconfigure() throws FactoryException
      Description copied from interface: Configurable
      Re-initialisation of values and states.

      Moved from Reconfigurable which has been deleted

      Specified by:
      reconfigure in interface Configurable
      Throws:
      FactoryException
    • getAttribute

      public Object getAttribute(String attributeName) throws DeviceException
      Description copied from interface: Device
      Get the value of the specified attribute
      Specified by:
      getAttribute in interface Device
      Parameters:
      attributeName - is the name of the attribute
      Returns:
      the value of the attribute as an Object type
      Throws:
      DeviceException - if an attribute cannot be retrieved
    • getMaximumFrames

      public int getMaximumFrames() throws DeviceException
      Description copied from interface: Timer
      Returns the total number of frame pairs supported (each specifying a live and a dead period)
      Specified by:
      getMaximumFrames in interface Timer
      Returns:
      maximum number of time frames available
      Throws:
      DeviceException
    • isConfigureAtStartup

      public boolean isConfigureAtStartup()
      Description copied from interface: Configurable
      Indicates whether this object should be configured at startup.

      Moved from ConditionallyConfigurable which has been deleted

      Specified by:
      isConfigureAtStartup in interface Configurable
    • getCurrentFrame

      public int getCurrentFrame() throws DeviceException
      Description copied from interface: Timer
      Returns the current frame number.
      Specified by:
      getCurrentFrame in interface Timer
      Returns:
      the current frame counter number (1st=0)
      Throws:
      DeviceException
    • close

      public void close() throws DeviceException
      Description copied from interface: Device
      Close and unconfigure the device.
      Specified by:
      close in interface Device
      Throws:
      DeviceException
    • getCurrentCycle

      public int getCurrentCycle() throws DeviceException
      Description copied from interface: Timer
      Returns the current cycle number. If not implemented this should return a default of 1.
      Specified by:
      getCurrentCycle in interface Timer
      Returns:
      the current cycle number
      Throws:
      DeviceException
    • setProtectionLevel

      public void setProtectionLevel(int newLevel)
      Description copied from interface: Device
      Sets the permission level for this object. If this is not set then a default value will be applied.
      Specified by:
      setProtectionLevel in interface Device
      Parameters:
      newLevel -
    • setCycles

      public void setCycles(int cycles) throws DeviceException
      Description copied from interface: Timer
      sets the number of times the timer cycles through the framesets. Default is 1 if h/w does not allow the implementation
      Specified by:
      setCycles in interface Timer
      Parameters:
      cycles - sets the cycle count to the specified number
      Throws:
      DeviceException
    • getProtectionLevel

      public int getProtectionLevel()
      Specified by:
      getProtectionLevel in interface Device
      Returns:
      int - the permission level for this object.
    • start

      public void start() throws DeviceException
      Description copied from interface: Timer
      For a time framing counter-timer, this initiates framing, starting from the current frame number (specified by setFrameNumber())
      Specified by:
      start in interface Timer
      Throws:
      DeviceException
    • stop

      public void stop() throws DeviceException
      Description copied from interface: Timer
      Aborts any current timing and returns it to an idle state.
      Specified by:
      stop in interface Timer
      Throws:
      DeviceException
    • restart

      public void restart() throws DeviceException
      Description copied from interface: Timer
      Restarts framing from the paused state
      Specified by:
      restart in interface Timer
      Throws:
      DeviceException
    • addFrameSet

      public void addFrameSet(int frameCount, double requestedDeadTime, double requestedLiveTime) throws DeviceException
      Description copied from interface: Timer
      Create a single frameSet object for a specified live and dead time. A count for identical frames is specified by the frameCount.
      Specified by:
      addFrameSet in interface Timer
      Parameters:
      frameCount - the requested number of frames required of this type
      requestedDeadTime - the requested frame dead time in milliseconds
      requestedLiveTime - the requested frame live time in milliseconds
      Throws:
      DeviceException
    • addFrameSet

      public void addFrameSet(int frameCount, double requestedDeadTime, double requestedLiveTime, int deadPort, int livePort, int deadPause, int livePause) throws DeviceException
      Description copied from interface: Timer
      Create a single frameSet object for a specified live and dead time. A count for identical frames is specified by the frameCount.
      Specified by:
      addFrameSet in interface Timer
      Parameters:
      frameCount - the requested number of frames required of this type
      requestedDeadTime - the requested frame dead time in milliseconds
      requestedLiveTime - the requested frame live time in milliseconds
      deadPort - the wait period output level 0 or 1
      livePort - the run period output level 0 or 1
      deadPause - the pause before wait period 0 or 1
      livePause - the pause before run period 0 or 1
      Throws:
      DeviceException
    • clearFrameSets

      public void clearFrameSets() throws DeviceException
      Description copied from interface: Timer
      Clear all current frameSets
      Specified by:
      clearFrameSets in interface Timer
      Throws:
      DeviceException
    • loadFrameSets

      public void loadFrameSets() throws DeviceException
      Description copied from interface: Timer
      Load an array of frameSets obtained from calls to makeFrameSet() are loaded into the timer.
      Specified by:
      loadFrameSets in interface Timer
      Throws:
      DeviceException
    • countAsync

      public void countAsync(double time) throws DeviceException
      Description copied from interface: Timer
      Initiates a single specified timing period and allows the timer to proceed asynchronously. The end of period can be determined by calls to getStatus() returning IDLE.
      Specified by:
      countAsync in interface Timer
      Parameters:
      time - the requested counting time in milliseconds
      Throws:
      DeviceException
    • output

      public void output(String file) throws DeviceException
      Description copied from interface: Timer
      Output data from timer directly to file
      Specified by:
      output in interface Timer
      Parameters:
      file - is the fully qualified file name
      Throws:
      DeviceException