org.lsst.ccs.subsystems.fcs
Class CarouselSocket

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

public class CarouselSocket
extends MobileItemModule

This is a socket on the carousel : there is 5 sockets on a carousel. When a filter is on the carousel, it is attached at a socket. A socket has a clamp on each side : - clampX- (clampXminus) - clampX+ (clampXplus) clampX+ and clampX- are the same except for the method isLocked() See FilterClampXminusModule and FilterClampXplusModule The main job of this class CarouselSocket is to synchronize the actions on the 2 clamps. The state of the CarouselSocket is the state of the clamps when both clamps state are identical. To synchonize an action (updateSateWithSensor, unlock or release) on both clamps, we use a CyclicBarrier : we start 2 threads and they wait for each other action completion with a CyclicBarrier. During an action on both clamps, we want to lock the CarouselSocket so no other thread can try to access this object before the completion of action. We do that with a Lock and Condition. (see java.util.concurrent). CarouselSocket extends MobileItemModule because we want to lock or release the clamps when the carousel is at standby position and we want to wait until the action is completed. We know if the action is completed in reading the clamps sensors. So we use the general mechanism provided by the MobileItemModule.

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
 
Fields inherited from class org.lsst.ccs.subsystems.fcs.common.MobileItemModule
itemMoving, lock, motionCompleted
 
Fields inherited from class org.lsst.ccs.framework.Module
environment, log, name, nObserverThreads, registry, tickMillis
 
Constructor Summary
CarouselSocket()
           
CarouselSocket(double position)
          This constructor is for tests.
 
Method Summary
 BridgeToHardware getBridge()
           
 FcsEnumerations.FilterClampState getClampsState()
           
 FilterClampModule getClampXminus()
           
 FilterClampModule getClampXplus()
           
 Filter getFilter()
           
 double getPosition()
           
 double getStandbyPosition()
           
 boolean isActionCompleted(FcsEnumerations.MobileItemAction action)
           
 boolean isClampedOnFilter()
           
 boolean isEmpty()
           
 boolean isReadyToClamp()
           
 boolean isUnclampedEmpty()
           
 boolean isUnclampedOnFilter()
           
 void postAction(FcsEnumerations.MobileItemAction action)
           
 void putFilterOnSocket(Filter filter)
           
 String releaseClamps()
          Releases the 2 clamps of the socket.
 String releaseClampsWithThreadSleep()
          Deprecated. 
 void removeFilter()
          Software removing
 void setBridge(BridgeToHardware bridge)
           
 void setClampXminus(FilterClampModule clampXminus)
           
 void setClampXplus(FilterClampModule clampXplus)
           
protected  void setFilter(Filter filter)
           
 void setPosition(double position)
           
 void setStandbyPosition(double standbyPosition)
           
 void startAction(FcsEnumerations.MobileItemAction action)
           
 String toString()
           
 String unlockClamps()
          This method unclamp the 2 clamps at standby position.
 String unlockClampsWithThreadSleep()
          Deprecated. 
 void updateClampsStateWithSensors()
           
 void updateClampsStateWithSensors(CanOpenProxy.PDOStorage pdoStorage)
           
 void updateClampsStateWithSensorsFromSDO()
          Deprecated. 
 void updateStateWithSensorsToCheckIfActionIsCompleted()
           
 
Methods inherited from class org.lsst.ccs.subsystems.fcs.common.MobileItemModule
cancelReadingSensors, executeAction, readSensorsUntilActionIsCompleted, shutdownNow, waitForEndOfAction
 
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, wait, wait, wait
 

Constructor Detail

CarouselSocket

public CarouselSocket()

CarouselSocket

public CarouselSocket(double position)
This constructor is for tests.

Parameters:
position -
Method Detail

getBridge

public BridgeToHardware getBridge()

setBridge

public void setBridge(BridgeToHardware bridge)

getClampXminus

public FilterClampModule getClampXminus()

setClampXminus

public void setClampXminus(FilterClampModule clampXminus)

getClampXplus

public FilterClampModule getClampXplus()

setClampXplus

public void setClampXplus(FilterClampModule clampXplus)

getPosition

public double getPosition()

setPosition

public void setPosition(double position)

getFilter

public Filter getFilter()

setFilter

protected void setFilter(Filter filter)

getStandbyPosition

public double getStandbyPosition()

setStandbyPosition

public void setStandbyPosition(double standbyPosition)

getClampsState

public FcsEnumerations.FilterClampState getClampsState()

updateClampsStateWithSensorsFromSDO

@Deprecated
public void updateClampsStateWithSensorsFromSDO()
                                         throws HardwareException
Deprecated. 

This method updates the state of the 2 clamps in reading the values sent by the sensors. The values of the sensors are read clamp by clamp with read SDO commands.

Throws:
HardwareError
HardwareException

updateClampsStateWithSensors

public void updateClampsStateWithSensors(CanOpenProxy.PDOStorage pdoStorage)
                                  throws HardwareException
Throws:
HardwareException

updateClampsStateWithSensors

public void updateClampsStateWithSensors()
                                  throws HardwareException,
                                         org.lsst.ccs.bus.BadCommandException
Throws:
HardwareException
org.lsst.ccs.bus.BadCommandException

isEmpty

public boolean isEmpty()
                throws HardwareException
Throws:
HardwareException

isClampedOnFilter

public boolean isClampedOnFilter()

isUnclampedOnFilter

public boolean isUnclampedOnFilter()

isUnclampedEmpty

public boolean isUnclampedEmpty()

isReadyToClamp

public boolean isReadyToClamp()

releaseClamps

public String releaseClamps()
                     throws org.lsst.ccs.bus.BadCommandException,
                            org.lsst.ccs.bus.ErrorInCommandExecutionException,
                            HardwareException
Releases the 2 clamps of the socket.

Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareError
HardwareException

releaseClampsWithThreadSleep

@Deprecated
public String releaseClampsWithThreadSleep()
                                    throws org.lsst.ccs.bus.BadCommandException,
                                           org.lsst.ccs.bus.ErrorInCommandExecutionException,
                                           HardwareException
Deprecated. 

Releases the 2 clamps of the socket.

Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareError
HardwareException

unlockClamps

public String unlockClamps()
                    throws HardwareException,
                           org.lsst.ccs.bus.BadCommandException,
                           org.lsst.ccs.bus.ErrorInCommandExecutionException
This method unclamp the 2 clamps at standby position. It turn ON the actuators and wait for the end of the unlocking task. The unlock is completed when the clamps sensors notice that the clamps are UNLOCKED. So this method reads the sensors with the method updateClampsStateWithSensors until the clamps are UNLOCKED or the duration of the task is greater than the timeout (timeoutUnlock) To read the sensors at a regular time schedule we use the ScheduledThreadPoolExecutor (scheduler.scheduleAtFixedRate) from the java.util.concurrent package.

Parameters:
bridge -
actuatorXminus -
actuatorXplus -
Returns:
a message for the end user
Throws:
HardwareError
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

unlockClampsWithThreadSleep

@Deprecated
public String unlockClampsWithThreadSleep()
                                   throws org.lsst.ccs.bus.BadCommandException,
                                          org.lsst.ccs.bus.ErrorInCommandExecutionException,
                                          HardwareException
Deprecated. 

Unlock the 2 clamps in the old way : we unlock the clamp one by one, so the reading of the clamps sensors is not optimized.

Parameters:
actuatorXminus -
actuatorXplus -
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

removeFilter

public void removeFilter()
                  throws org.lsst.ccs.bus.BadCommandException
Software removing

Throws:
org.lsst.ccs.bus.BadCommandException

putFilterOnSocket

public void putFilterOnSocket(Filter filter)

toString

public String toString()
Overrides:
toString in class Object

isActionCompleted

public boolean isActionCompleted(FcsEnumerations.MobileItemAction action)
Specified by:
isActionCompleted in class MobileItemModule

updateStateWithSensorsToCheckIfActionIsCompleted

public void updateStateWithSensorsToCheckIfActionIsCompleted()
                                                      throws Exception
Specified by:
updateStateWithSensorsToCheckIfActionIsCompleted in class MobileItemModule
Throws:
Exception

startAction

public void startAction(FcsEnumerations.MobileItemAction action)
                 throws org.lsst.ccs.bus.BadCommandException,
                        org.lsst.ccs.bus.ErrorInCommandExecutionException,
                        HardwareException
Specified by:
startAction in class MobileItemModule
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException

postAction

public void postAction(FcsEnumerations.MobileItemAction action)
                throws org.lsst.ccs.bus.BadCommandException,
                       org.lsst.ccs.bus.ErrorInCommandExecutionException,
                       HardwareException
Specified by:
postAction in class MobileItemModule
Throws:
org.lsst.ccs.bus.BadCommandException
org.lsst.ccs.bus.ErrorInCommandExecutionException
HardwareException


Copyright © 2013 LSST. All Rights Reserved.