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

public abstract class StateMachine extends AbstractApplication
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
  • Field Details

  • 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 interface Application
      Overrides:
      configure in class AbstractApplication
      Parameters:
      name - a String object
      config - 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 interface Application
      Overrides:
      activate in class AbstractApplication
    • setStatus

      public void setStatus(String status)

      Setter for the field status.

      Parameters:
      status - a String object
    • getStatus

      public String getStatus()

      Getter for the field status.

      Returns:
      a String object
    • setState

      public void setState(StateMachine.State st)

      setState.

      Parameters:
      st - a StateMachine.State object
    • getState

      public StateMachine.State 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

      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 application AbstractApplication.addRecord(String, Record)). Implementation class should override this method to intercept the update.
      Overrides:
      notifyRecordWrite in class AbstractApplication
      Parameters:
      name - the name of record, that triggered change.
    • notifyRecordChange

      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 application AbstractApplication.addRecord(String, Record)). Implementation class should override this method to intercept the update.
      Overrides:
      notifyRecordChange in class AbstractApplication
      Parameters:
      name - the name of record, that triggered change.
      alarmOnly - if true 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()
      If true 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