|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
OCSEPICS.EPICSAction
OCSEPICS.OCSAction
class OCSAction
This class will be used to perform a specific action upon a mechanism in the ISISP/WYFFOS/INTEGRAL EPICS system. The INTEGRAL/ISISP/WYFFOS EPICS system is controlled slightly differently to those which use CAD/CAR so there is a need to specialise in order to control these mechanisms. The class is data driven from source data that originates in the OCS database.
It will interrogate the ICS database in order to establish the names of the PVs which it will need to use in order to execute OCS related actions upon the IOC. The protocol used in initiating actions upon the ISISP mechanisms is outlined in the document wht-isis-9. ISISP does not have CAD/CAR/SIR support, there are a series of PVs associated with a given subaction which must be manipulated and monitored in ordered to successfully execute an operation on the IOC. It should be noted that the documentation is not strictly correct and to acheive a full understanding of the protocol the user should read through the source code also.
The class employs a state machine in order to maintain the state of the underlying hardware which it is controlling. Due to the nature of the implmentation of the underlying controlling software which not orthogonal, this is at times a little chaotic.
The state machine has the following states associated with it :
State | Transition Method | Description |
---|---|---|
UNINITIALISED | OCSAction(JICSCore.MessageHandler, java.sql.Connection, java.lang.String, java.lang.String, java.lang.String, java.util.Hashtable | Initial state of the action until it is initialised. |
INACTIVE | actionInactive(java.lang.String) | Action is inactive, action is not controlling it's associated mechanism in anyway |
COMMAND_PROCESSING | commandProcessing(java.lang.String, ing.status.StatusItemValue) | CORBA request has been received from external client and IOC has been instructed to perform the action and it is currently analyzing the command request to ensure that it is a valid demand i.e. demand argument is in the correct type and range. |
COMMAND_ACCEPTED | commandAccepted(java.lang.String, ing.status.StatusItemValue) | IOC has verified that the command request which was received through an external CORBA client and that it will attempt to execute the command. |
ACTIVE | actionActive(java.lang.String, ing.status.StatusItemValue) | The IOC is performing the request command. A mechanism in the IOC may or may not be moving at this point. An example action might be a move, stop or datum. |
TIMED_OUT | actionTimedOut() | The IOC has taken longer than the timeout period which is associated with this action to complete. |
COMPLETED | actionCompleted(java.lang.String, ing.status.StatusItemValue, boolean) | The IOC has completed the requested action and the CORBA client will be informed of it's completion. The action may or may not have completed successfully (for example in the case of a mechanism error). |
Field Summary | |
---|---|
private OCSEPICSConsts.OCSActionStatesType |
ActionState
This is the current state that the action has reached in the state machine. |
private java.lang.String |
CommStat
This is the last value for the COMMSTAT PV which indicates whether or not the last command was accepted OK or not. |
private java.lang.String |
CommStr
This is the last value for the COMMSTR PV which indicates whether or not the last command to be attempted was accepted without problems or not. |
private java.lang.String |
CommStrOkValue
This is the value which indicates that the commstr does not contain an error. |
private java.lang.String |
ErrStr
This is the current ERRSTR which is associated with the mechanism. |
private java.util.Hashtable<OCSEPICSConsts.PVTypes,ProcessVariable> |
IOCProcessVariables
This hashtable contains a reference to all of the process variables which will be needed in order to perform actions on the mechanisms on the IOC. |
private EPICSMechanism |
Mechanism
The EPICS mechanism. |
private int |
MechStat
This is the current MECHSTAT which is associated with the mechanism which is the basis for the action. |
private OCSEPICSConsts.OCSActionStatesType |
NextEventTriggeredState
This is the next expected state that the state machine should move to should the expected transition take place. |
private OCSEPICSConsts.PrematureClStatStates |
PrematureCLStatState
Whether we have a received a clstat transition between ACTIVE and DONE before command processing has been completed by the IOC. |
Fields inherited from interface OCSEPICS.CAEventListener |
---|
UnitOfInterest |
Constructor Summary | |
---|---|
OCSAction(MessageHandler SyslogMessageHandler,
java.sql.Connection DBConnection,
java.lang.String SubactionName,
java.lang.String MechName,
java.lang.String InstrumentName,
java.util.Hashtable<java.lang.String,ProcessVariable> ActionRelatedPVs,
OCSCORBAHelper CORBAHelper,
int SubactionTimeout,
FourMS.FourMSParameterConverter ParameterConvertor,
EPICSMechanism Mechanism)
The constructor for the class. |
Method Summary | |
---|---|
private boolean |
actionActive(java.lang.String PVName,
ing.status.StatusItemValue StatusItem)
This is the part of the state machine for the OCS actions and performs the actions required once the EPICS action is active in the IOC. |
private boolean |
actionCompleted(java.lang.String PVName,
ing.status.StatusItemValue StatusItem,
boolean ForceState)
This is the part of the state machine for the OCS actions and performs the actions required when the action in the IOC completes successfully. |
private boolean |
actionInactive(java.lang.String ReasonForTransition)
This method forms part of the action state machine and will be called when the action is in state inactive. |
protected boolean |
actionTimedOut()
This is the part of the state machine for the OCS actions and performs the actions required should the command that we issued to the IOC timeout in it's execution. |
boolean |
cancelAction()
Cancels an existing subaction if it is running but raises an exception otherwise. |
void |
channelAccessEvent(java.lang.String PVName,
ing.status.StatusItemValue StatusItem)
Obligation of the CAEventListener interface. |
private boolean |
commandAccepted(java.lang.String PVName,
ing.status.StatusItemValue StatusItem)
This is the part of the state machine for the OCSAction and performs the actions required when we are expecting to go to state COMMAND_ACCEPTED from state COMMAND_PROCESSING. |
private boolean |
commandProcessing(java.lang.String PVName,
ing.status.StatusItemValue StatusValue)
This method will be called as part of the event driven transition of the action state machine. |
void |
finalize()
|
private void |
initiateEPICSCommand()
This is the part of the state machine for the OCS actions and performs the action required when the command has been issued to IOC and we are waiting for it to accept the command. |
private void |
initiateEPICSCommand(java.lang.String demandValue)
This is the part of the state machine for the OCS actions. |
void |
observerUnableToListen(java.lang.String PVName,
java.lang.String reason)
Obligation of the CAEventListener interface.This method is called when the observer is unable to listen a PV any longer |
void |
resetStateMachine(java.lang.String Reason)
Resets the state machine which models the OCS action. |
void |
setCommStrOkValue(java.lang.String CommStrOkValue)
Used to set the value of the COMMSTR PV which is used to indicate that the command was requested was validated successfully. |
boolean |
startAction(java.lang.String[] SubActionArgs,
FourMSControllerInterfaces.SubActionCompletionListener SubActionInitiatorCB)
This is the obligation of the SubActionOperations IDL interface which will be used by an external CORBA client to invoke this subaction. |
Methods inherited from class OCSEPICS.EPICSAction |
---|
run |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private EPICSMechanism Mechanism
private OCSEPICSConsts.PrematureClStatStates PrematureCLStatState
private java.lang.String ErrStr
private int MechStat
private java.lang.String CommStr
private java.lang.String CommStat
private java.lang.String CommStrOkValue
private OCSEPICSConsts.OCSActionStatesType ActionState
private OCSEPICSConsts.OCSActionStatesType NextEventTriggeredState
private java.util.Hashtable<OCSEPICSConsts.PVTypes,ProcessVariable> IOCProcessVariables
Constructor Detail |
---|
public OCSAction(MessageHandler SyslogMessageHandler, java.sql.Connection DBConnection, java.lang.String SubactionName, java.lang.String MechName, java.lang.String InstrumentName, java.util.Hashtable<java.lang.String,ProcessVariable> ActionRelatedPVs, OCSCORBAHelper CORBAHelper, int SubactionTimeout, FourMS.FourMSParameterConverter ParameterConvertor, EPICSMechanism Mechanism) throws java.lang.Exception
SubactionName
- This is the name which is associated with subaction.SyslogMessageHandler
- This will be used for reporting information to
the syslog which is running on the whtics.DBConnection
- This is an open JDBC connection to the whtics database.MechName
- This is the name of the mechanism with which this action is associated.InstrumentName
- This is the name of the instrument with which this action is associated.ActionRelatedPVs
- This is a hashtable of PVs within which
we can expect to find all of the PVs which this subaction is
going to need to use in order to perform it's tasks.CORBAHelper
- This will be used to perform OCS related CORBA activities.SubactionTimeout
- This is the timeout before the subaction is deemed to have failed.ParameterConvertor
- This will be used to convert parameters between logical and engineering units.
java.lang.Exception
- Should there be an error when initialising the object.Method Detail |
---|
public void setCommStrOkValue(java.lang.String CommStrOkValue)
public void finalize() throws java.lang.Throwable
finalize
in class EPICSAction
java.lang.Throwable
private boolean actionInactive(java.lang.String ReasonForTransition)
ReasonForTransition
- This is the reason that we have been requested to move to this state.
private void initiateEPICSCommand(java.lang.String demandValue) throws StateMachineException
In order to transition to this state there are a number of preconditions which are listed as follows;
Once the preconditions have been met, we can then write to the demand value PV (if required) and if this is successfully performed we can then finally transition to the state COMMAND_PROCESSING.
demandValue
- This is the demand value for the move. It
can be null if there is no demand value associated with this
IOC action.
StateMachineException
- Should there be any problem transitioning to the state COMMAND_PROCESSINGprivate void initiateEPICSCommand() throws StateMachineException
StateMachineException
private boolean commandAccepted(java.lang.String PVName, ing.status.StatusItemValue StatusItem) throws StateMachineException
StatusItem
- This is the details of an event on the commstat PV.PVName
- This is the name of the PV upon which the event occurred.
StateMachineException
- If we have been requested to
transition from illegal states.private boolean actionActive(java.lang.String PVName, ing.status.StatusItemValue StatusItem) throws StateMachineException
PVName
- This is the name of the PV upon which the event occurred.StatusItem
- This should hold the details of an event on the clstat PV which is associated with this OCS action.
StateMachineException
- This is an exception which is thrown if the state machine finds itself in an illegal state.private boolean commandProcessing(java.lang.String PVName, ing.status.StatusItemValue StatusValue) throws StateMachineException
Unfortunately not everything is as it seems. In the wyffos code at least there is the possibility of the clstat PV going to ACTIVE and back to DONE before the commstat PV has been set. This happens in the case of the lamps when they are switched off by the user. We need to deal with this as an exceptional case. Perhaps in time we can change the WYFFOS EPICS code so that this case is handled as other actions are handled.
PVName
- This the name of the PV upon which the event occurred.StatusValue
- This holds the data associated with the event
StateMachineException
- When there is some error detacted
when we attempt to establish whether or not we should
transition the state machine.protected boolean actionTimedOut() throws StateMachineException
actionTimedOut
in class EPICSAction
StateMachineException
- Should there be an irregularity detected with state machine.private boolean actionCompleted(java.lang.String PVName, ing.status.StatusItemValue StatusItem, boolean ForceState) throws StateMachineException
PVName
- The name of the PV that the event occurred on.StatusItem
- This is the details of the event .ForceState
- Force a state change without checking for the
legality of the transition request. Sometimes there will be a
need to force our way into this state if we have two actions
for the same mechanism running. This is certainly in teh case
of the MOVE and the STOP command which both be active at the
same time.
StateMachineException
- If there is a problem performing
the state transition.public void observerUnableToListen(java.lang.String PVName, java.lang.String reason)
observerUnableToListen
in interface CAEventListener
PVName
- This is the name of the PV.reason
- This is the reason why the observer cannot listen any longer.public void channelAccessEvent(java.lang.String PVName, ing.status.StatusItemValue StatusItem)
The values of other events on PVs which are not directly associated with state transitions are recorded as they will be needed later. For instance, the value of the MECHSTAT, ERRSTR and COMMSTR PVs which are associated with an action will be recorded.
channelAccessEvent
in interface CAEventListener
PVName
- This is the name of the PV which was responsible for the eventStatusItem
- This contains the details of the event. The
status item holds the logical value of the event after being
converted from engineering units.public boolean startAction(java.lang.String[] SubActionArgs, FourMSControllerInterfaces.SubActionCompletionListener SubActionInitiatorCB) throws FourMSControllerInterfaces.SubActionInProgressException, FourMSControllerInterfaces.UnableToStartSubactionException
startAction
in interface FourMSControllerInterfaces.SubActionOperations
SubActionArgs
- The arguments which need to be passed into this subactionSubActionInitiatorCB
- A CORBA object which will be called when the subaction completes.
FourMSControllerInterfaces.SubActionInProgressException
- When the action is already in progress.
FourMSControllerInterfaces.UnableToStartSubactionException
- Unable to start the exception for the reason which is specifiedpublic boolean cancelAction() throws FourMSControllerInterfaces.SubActionNotInProgressException
cancelAction
in interface FourMSControllerInterfaces.SubActionOperations
FourMSControllerInterfaces.SubActionNotInProgressException
- SubActionNotInProgressExceptionpublic void resetStateMachine(java.lang.String Reason)
Reason
- The reason why the state machine is being reset.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |