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
Modifier and TypeClassDescriptionstatic enum
Operational state of this state machine. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ConstantABORT="Cmd:Abort"
static final String
ConstantACTIVATE="Cmd:Activate"
static final String
Constant for PV with description of state machine,DESCRIPTION="Description"
.static final String
Constant for PV with enableENABLED="Enabled"
static final String
Constant for PV with enableENABLED="Enabled"
static final String
ConstantPREPARE="Cmd:Prepare"
static final String
Constant for PV with progress in precentage,PROGRESS="Progress"
.static final String
ConstantSTATE="State"
static final String
ConstantSTATE_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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Application has now reference to Database.void
Configures the internals of this application, provides reference to configuration with root inside applications tag.double
getProgress.getState()
getState.Getter for the fieldstatus
.long
Getter for the fieldtimeout
.boolean
Iftrue
sequence should abort if this step fails.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.boolean
If not enabled, sequence executor will skip this step.boolean
isInitializationFailed.protected void
notifyRecordChange
(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 void
notifyRecordWrite
(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)
).void
setEnabled
(boolean b) Sets enabled flag, if it is enabledFixed on, then fixed value is set, otherwise enable PV.void
setProgress
(double d) setProgress.void
setState.void
This is to be used by extending class, once this is sate, the State Machine is not usable.void
Setter for the fieldstatus
.void
setTimeout
(long timeout) Setter for the fieldtimeout
.void
stateMachineAbort.void
stateMachineActivate
(boolean dryrun) Activates state machine.void
stateMachinePrepare.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:
configure
in interfaceApplication
- Overrides:
configure
in classAbstractApplication
- Parameters:
name
- aString
objectconfig
- 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:
activate
in interfaceApplication
- Overrides:
activate
in classAbstractApplication
-
setStatus
Setter for the field
status
.- Parameters:
status
- aString
object
-
getStatus
Getter for the field
status
.- Returns:
- a
String
object
-
setState
setState.
- Parameters:
st
- aStateMachine.State
object
-
getState
getState.
- Returns:
- a
StateMachine.State
object
-
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
true
is 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:
notifyRecordWrite
in 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:
notifyRecordChange
in classAbstractApplication
- Parameters:
name
- the name of record, that triggered change.alarmOnly
- iftrue
then 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()Iftrue
sequence should abort if this step fails.- Returns:
- if
true
sequence 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
-