org.lsst.ccs.subsystems.fcs.common
Class MobileItemModule

java.lang.Object
  extended by java.util.Observable
      extended by org.lsst.ccs.framework.Module
          extended by org.lsst.ccs.subsystems.fcs.common.MobileItemModule
All Implemented Interfaces:
Serializable, Observer, org.lsst.ccs.framework.Configurable
Direct Known Subclasses:
BasicAutoChangerModule, CarouselSocket, FilterClampModule, FilterLatchModule

public abstract class MobileItemModule
extends org.lsst.ccs.framework.Module

This represents a Mechanical Item which can be moved by a motor. Generaly we want to execute an action on this mechanical item : - start the action, - read sensors to know if the action is completed, - wait for the end of the action. This module provides a general way to start an action and wait until the action is completed. It factorises some code that otherwise would have to be duplicated in each Module that needs such fonctionnalities.

Author:
virieux
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.lsst.ccs.framework.Module
org.lsst.ccs.framework.Module.ValueUpdate
 
Nested classes/interfaces inherited from interface org.lsst.ccs.framework.Configurable
org.lsst.ccs.framework.Configurable.Environment
 
Field Summary
protected  boolean itemMoving
           
 Lock lock
           
 Condition motionCompleted
           
 
Fields inherited from class org.lsst.ccs.framework.Module
environment, log, name, nObserverThreads, registry, tickMillis
 
Constructor Summary
MobileItemModule()
           
 
Method Summary
 void cancelReadingSensors()
          This stops the reading of the sensors.
 String executeAction(FcsEnumerations.MobileItemAction action, long timeoutForAction)
          This executes an action which moves the MobileItem and waits for the end od this action.
abstract  boolean isActionCompleted(FcsEnumerations.MobileItemAction action)
           
abstract  void postAction(FcsEnumerations.MobileItemAction action)
           
 void readSensorsUntilActionIsCompleted(FcsEnumerations.MobileItemAction action, long beginTime, long timeout)
          Start reading the sensors at a fixed rate (scheduler.scheduleAtFixedRate) until the action is completed or the timeout for this action is past.
 void shutdownNow()
          This shutdowns the scheduler.
abstract  void startAction(FcsEnumerations.MobileItemAction action)
           
abstract  void updateStateWithSensorsToCheckIfActionIsCompleted()
           
 void waitForEndOfAction(FcsEnumerations.MobileItemAction action)
          This method waits until the action is completed.
 
Methods inherited from class org.lsst.ccs.framework.Module
alias, change, checkHardware, dropConfigurationContext, getAvailableCommands, getCheckedValueFromConfiguration, getChildren, getContext, getModule, getName, getNObserverThreads, getObservables, getSubsystem, getTickMillis, init, initModule, listens, newConfigurationContext, notifyChange, notifyChangeWithoutPreliminaryChecks, processUpdate, publishData, publishData, publishData, publishData, publishData, publishData, publishData, register, register, removeLogPanicState, sendToReply, sendToStatus, setBeanName, setContext, setEnvironment, setHandlerLevel, setLogLevel, setName, setNObserverThreads, setObservables, setStateModularSubsystem, setStateModularSubsystem, setTickMillis, shutdownCommand, start, startTicking, tick, update
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemMoving

protected boolean itemMoving

lock

public final Lock lock

motionCompleted

public final Condition motionCompleted
Constructor Detail

MobileItemModule

public MobileItemModule()
Method Detail

cancelReadingSensors

public void cancelReadingSensors()
This stops the reading of the sensors.


isActionCompleted

public abstract boolean isActionCompleted(FcsEnumerations.MobileItemAction action)

updateStateWithSensorsToCheckIfActionIsCompleted

public abstract void updateStateWithSensorsToCheckIfActionIsCompleted()
                                                               throws Exception
Throws:
Exception

startAction

public abstract void startAction(FcsEnumerations.MobileItemAction action)
                          throws org.lsst.ccs.bus.BadCommandException,
                                 org.lsst.ccs.bus.ErrorInCommandExecutionException,
                                 HardwareException
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

postAction

public abstract void postAction(FcsEnumerations.MobileItemAction action)
                         throws org.lsst.ccs.bus.BadCommandException,
                                org.lsst.ccs.bus.ErrorInCommandExecutionException,
                                HardwareException
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

executeAction

public String executeAction(FcsEnumerations.MobileItemAction action,
                            long timeoutForAction)
                     throws org.lsst.ccs.bus.BadCommandException,
                            org.lsst.ccs.bus.ErrorInCommandExecutionException,
                            HardwareException
This executes an action which moves the MobileItem and waits for the end od this action. The MobileItemAction is an ENUM from the fcs.bus package.

Parameters:
action, - timeout
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

readSensorsUntilActionIsCompleted

public void readSensorsUntilActionIsCompleted(FcsEnumerations.MobileItemAction action,
                                              long beginTime,
                                              long timeout)
Start reading the sensors at a fixed rate (scheduler.scheduleAtFixedRate) until the action is completed or the timeout for this action is past.

Parameters:
action -
beginTime -
timeout -

waitForEndOfAction

public void waitForEndOfAction(FcsEnumerations.MobileItemAction action)
This method waits until the action is completed.


shutdownNow

public void shutdownNow()
This shutdowns the scheduler.

Overrides:
shutdownNow in class org.lsst.ccs.framework.Module


Copyright © 2013 LSST. All Rights Reserved.