Class StateMachine
java.lang.Object
org.scictrl.csshell.epics.server.application.AbstractApplication
org.scictrl.csshell.epics.server.application.automata.StateMachine
- All Implemented Interfaces:
Application,OnDemandValueProcessor.ValueProvider
- Direct Known Subclasses:
DelayStateMachine,DummyStateMachine,OperationModeStateMachine,SequenceStateMachine,ValueStateMachine
Basic unit of automation control. State machine is either in ON state either in OFF state either
BUSY while going from OFF to ON. Or can be in error.
It has two functions:
prepare: issued to all relevant machines in combined statement before going to be activated
activate: set ON.
It goes to off only if conditions changes by some outside process.
So for going off, some other State machine should go to ON.
Also has a link to the next State machine that sould be activated after this one is done.
- Author:
- igor@scictrl.com
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOperational state of this state machine. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstantABORT="Cmd:Abort"static final StringConstantACTIVATE="Cmd:Activate"static final StringConstant for PV with description of state machine,DESCRIPTION="Description".static final StringConstant for PV with enableENABLED="Enabled"static final StringConstant for PV with enableENABLED="Enabled"static final StringConstantPREPARE="Cmd:Prepare"static final StringConstant for PV with progress in precentage,PROGRESS="Progress".static final StringConstantSTATE="State"static final StringConstantSTATE_STRING="State:String"Fields inherited from class org.scictrl.csshell.epics.server.application.AbstractApplication
database, DEFAULT_NAME_DELIMITER, dynamicRecordCreator, ERROR_SUM, LINK_ERROR, LINK_ERROR_STRING, links, log, name, NAME_DELIMITER, nameDelimiter, records -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Application has now reference to Database.voidConfigures the internals of this application, provides reference to configuration with root inside applications tag.doublegetProgress.getState()getState.Getter for the fieldstatus.longGetter for the fieldtimeout.booleanIftruesequence should abort if this step fails.booleanisDryRun()If this step is in dru-run mode, this means that when activated pretends that actions has been successfully completed without actually doing something.booleanIf not enabled, sequence executor will skip this step.booleanisInitializationFailed.protected voidnotifyRecordChange(String name, boolean alarmOnly) This method is called whenever record value changed for any record, which belongs to this application (it was added to the applicationAbstractApplication.addRecord(String, Record)).protected voidnotifyRecordWrite(String name) This method is called whenever record value has been written for any record, which belongs to this application (it was added to the applicationAbstractApplication.addRecord(String, Record)).voidsetEnabled(boolean b) Sets enabled flag, if it is enabledFixed on, then fixed value is set, otherwise enable PV.voidsetProgress(double d) setProgress.voidsetState.voidThis is to be used by extending class, once this is sate, the State Machine is not usable.voidSetter for the fieldstatus.voidsetTimeout(long timeout) Setter for the fieldtimeout.voidstateMachineAbort.voidstateMachineActivate(boolean dryrun) Activates state machine.voidstateMachinePrepare.Methods inherited from class org.scictrl.csshell.epics.server.application.AbstractApplication
addRecord, addRecordOfCommandProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfMemoryValueProcessor, addRecordOfOnDemandProcessor, addRecordOfOnLinkValueProcessor, configure, connectLinks, createNewStore, fullRecordName, getLinks, getName, getNameDelimiter, getNotNull, getRecord, getRecordErrorSum, getRecordLinkError, getRecordNames, getRecords, getStore, getStore, getValue, initialize, isActivated, isDynamicRecordCreator, log4debug, log4error, log4error, log4info, notifyLinkChange, processLinkChange, pushDoneCommandProcessor, reconnectLinks, resetOnDemandProcessor, restore, store, toString, updateErrorSum, updateErrorSum, updateLinkError, updateLinkError
-
Field Details
-
DESCRIPTION
Constant for PV with description of state machine,DESCRIPTION="Description".- See Also:
-
PROGRESS
Constant for PV with progress in precentage,PROGRESS="Progress".- See Also:
-
ENABLED
Constant for PV with enableENABLED="Enabled"- See Also:
-
DRYRUN
Constant for PV with enableENABLED="Enabled"- See Also:
-
STATE
ConstantSTATE="State"- See Also:
-
STATE_STRING
ConstantSTATE_STRING="State:String"- See Also:
-
ABORT
ConstantABORT="Cmd:Abort"- See Also:
-
ACTIVATE
ConstantACTIVATE="Cmd:Activate"- See Also:
-
PREPARE
ConstantPREPARE="Cmd:Prepare"- See Also:
-
-
Constructor Details
-
StateMachine
public StateMachine()Constructor for StateMachine.
-
-
Method Details
-
configure
public void configure(String name, org.apache.commons.configuration.HierarchicalConfiguration config) Configures the internals of this application, provides reference to configuration with root inside applications tag. Server structure is not yet initialized, so does not have reference to Database, the Database reference will be available during activate call.- Specified by:
configurein interfaceApplication- Overrides:
configurein classAbstractApplication- Parameters:
name- aStringobjectconfig- configuration with room inside application tag.
-
activate
public void activate()Application has now reference to Database. Application might want to connect to other records on this server or PVs on other servers. This can not be done until all records from configuration has been loaded. Call to this method signals application that records has been loaded and linking to other values can be commenced.- Specified by:
activatein interfaceApplication- Overrides:
activatein classAbstractApplication
-
setStatus
Setter for the field
status.- Parameters:
status- aStringobject
-
getStatus
Getter for the field
status.- Returns:
- a
Stringobject
-
setState
setState.
- Parameters:
st- aStateMachine.Stateobject
-
getState
getState.
- Returns:
- a
StateMachine.Stateobject
-
isInitializationFailed
public boolean isInitializationFailed()isInitializationFailed.
- Returns:
- a boolean
-
setStateInitializationFailed
public void setStateInitializationFailed()This is to be used by extending class, once this is sate, the State Machine is not usable. Indicates serious configuration problem, which can not be remedied by itself. -
stateMachinePrepare
public void stateMachinePrepare()stateMachinePrepare.
-
stateMachineActivate
public void stateMachineActivate(boolean dryrun) Activates state machine. If this state machine is in dry-run mode or dry-run parameter with
trueis called, then this step is activate in dry-run mode.- Parameters:
dryrun- dry-run mode request
-
stateMachineAbort
public void stateMachineAbort()stateMachineAbort.
-
notifyRecordWrite
This method is called whenever record value has been written for any record, which belongs to this application (it was added to the applicationAbstractApplication.addRecord(String, Record)). Implementation class should override this method to intercept the update.- Overrides:
notifyRecordWritein classAbstractApplication- Parameters:
name- the name of record, that triggered change.
-
notifyRecordChange
This method is called whenever record value changed for any record, which belongs to this application (it was added to the applicationAbstractApplication.addRecord(String, Record)). Implementation class should override this method to intercept the update.- Overrides:
notifyRecordChangein classAbstractApplication- Parameters:
name- the name of record, that triggered change.alarmOnly- iftruethen only alarm has been changed
-
setProgress
public void setProgress(double d) setProgress.
- Parameters:
d- a double
-
getProgress
public double getProgress()getProgress.
- Returns:
- a double
-
getTimeout
public long getTimeout()Getter for the field
timeout.- Returns:
- a long
-
setTimeout
public void setTimeout(long timeout) Setter for the field
timeout.- Parameters:
timeout- a long
-
isAbortOnFail
public boolean isAbortOnFail()Iftruesequence should abort if this step fails.- Returns:
- if
truesequence should abort if this step fails
-
isEnabled
public boolean isEnabled()If not enabled, sequence executor will skip this step.- Returns:
- is enabled
-
setEnabled
public void setEnabled(boolean b) Sets enabled flag, if it is enabledFixed on, then fixed value is set, otherwise enable PV.- Parameters:
b- new enable flag
-
isDryRun
public boolean isDryRun()If this step is in dru-run mode, this means that when activated pretends that actions has been successfully completed without actually doing something.- Returns:
- if this step is in dru-run mode
-