Class AbstractApplication

java.lang.Object
org.scictrl.csshell.epics.server.application.AbstractApplication
All Implemented Interfaces:
Application, OnDemandValueProcessor.ValueProvider
Direct Known Subclasses:
AbstractCyclingApplication, ArchiveCounterApplication, ArrayAssemblyApplication, ArrayBufferApplication, CyclingApplicationMaster, DeviceGroupApplication, DeviceTableApplication, EmbeddedApplicationServer, FeedbackLoopApplication, FeedbackLoopMicrotron, OrbitCheckApplication, OrbitServerApplication, PowerSupply, ProcessManagerApplication, ProcessManagerGroupApplication, PSRampingTaskApplication, PSSwitchApplication, RunningCounterApplication, ScanApplication, StateMachine, StepOptimizationApplication, SteppingFeedbackLoopApplication, ValueLevelAlarmApplication, WaveformSumApplication, WigglerRampApplication

public class AbstractApplication extends Object implements Application, OnDemandValueProcessor.ValueProvider

AbstractApplication class.

Author:
igor@scictrl.com
  • Field Details

    • ERROR_SUM

      public static final String ERROR_SUM
      Constant ERROR_SUM="Status:ErrorSum"
      See Also:
    • DEFAULT_NAME_DELIMITER

      public static final String DEFAULT_NAME_DELIMITER
      Constant DEFAULT_NAME_DELIMITER=":"
      See Also:
    • NAME_DELIMITER

      public static final String NAME_DELIMITER
      Constant NAME_DELIMITER="nameDelimiter"
      See Also:
    • log

      protected final org.apache.logging.log4j.Logger log
      Logger.
    • name

      protected String name
      Application name, part of PV.
    • records

      protected Map<String,Record> records
      Application records
    • dynamicRecordCreator

      protected boolean dynamicRecordCreator
      true if can create new records after initialization.
    • nameDelimiter

      protected String nameDelimiter
      PV name delimiter.
    • database

      protected Database database
      PV database.
  • Constructor Details

    • AbstractApplication

      public AbstractApplication()

      Constructor for AbstractApplication.

  • Method Details

    • getStore

      protected static final org.apache.commons.configuration.PropertiesConfiguration getStore(String appName, String fileName)
      Creates new PropertiesConfiguration object, which loads and stores properties from configuration file. Configuration file is assembled from default configuration folder, application name and file name.
      Parameters:
      appName - the application name which is used as folder name within default configuration folder
      fileName - the filename for the configuration within the appName folder
      Returns:
      new PRopertiesConfiguration object with autosave to a config file.
    • store

      protected static final void store(org.apache.commons.configuration.PropertiesConfiguration store, MetaData md)

      store.

      Parameters:
      store - a PropertiesConfiguration object
      md - a MetaData object
    • restore

      protected static final MetaData restore(org.apache.commons.configuration.PropertiesConfiguration store, String name)

      restore.

      Parameters:
      store - a PropertiesConfiguration object
      name - a String object
      Returns:
      a MetaData object
    • fullRecordName

      public final String fullRecordName(String name)

      fullRecordName.

      Specified by:
      fullRecordName in interface Application
      Parameters:
      name - a String object
      Returns:
      a String object
    • log4debug

      public final void log4debug(String message)

      log4debug.

      Parameters:
      message - a String object
    • log4info

      public final void log4info(String message)

      log4info.

      Parameters:
      message - a String object
    • log4error

      public final void log4error(String message, Throwable t)

      log4error.

      Parameters:
      message - a String object
      t - a Throwable object
    • log4error

      public final void log4error(String message)

      log4error.

      Parameters:
      message - a String object
    • processLinkChange

      protected void processLinkChange(String name)

      processLinkChange.

      Parameters:
      name - a name of the registered value link
    • 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
      Parameters:
      name - a String object
      config - configuration with room inside application tag.
    • configure

      public void configure(String name, String nameDelimiter)
      Configures application internals, such as error links. This is called from configure(String, HierarchicalConfiguration).
      Parameters:
      name - a String object
      nameDelimiter - a String object
    • getName

      public String getName()

      getName.

      Specified by:
      getName in interface Application
      Returns:
      a String object
    • getNameDelimiter

      public String getNameDelimiter()

      Getter for the field nameDelimiter.

      Returns:
      a String object
    • getRecordNames

      public String[] getRecordNames()
      Returns array of record names. Important: these are not full PV names, just prefixes valid within context of the application.
      Specified by:
      getRecordNames in interface Application
      Returns:
      array of application relative record names.
    • getRecords

      public Record[] getRecords()
      Return array of configured Record instances with prepared ValueProcessor.
      Specified by:
      getRecords in interface Application
      Returns:
      an array of records
    • getRecord

      public Record getRecord(String name)
      Return configured Record instance with prepared ValueProcessor. Of null if record with this name does not exist. By default a full PV name of returned record should consist of name of application with appended name of the record.
      Specified by:
      getRecord in interface Application
      Parameters:
      name - the record name, appended to application name makes full record name (PV name)
      Returns:
      a record with this name or null
    • isDynamicRecordCreator

      public boolean isDynamicRecordCreator()
      Returns true if this application is capable of creating new records when asked to. Applications which return true, will be asked if they have record, when a EPICS request with PV name arrives and beginning of PV name matches with application name.
      Specified by:
      isDynamicRecordCreator in interface Application
      Returns:
      a boolean
    • addRecord

      protected Record addRecord(String name, Record r)
      Adds a record to internal storage, which manages records, which belongs to this application. Records are stored and retrieved on name base Map.
      Parameters:
      name - the unique name for the record, tow records with same name can not be used
      r - the record to be added
      Returns:
      returns record which was added
    • connectLinks

      protected ValueLinks connectLinks(String name, String... linkNames)
      Starts ValueLink connection to provided list of link names.
      Parameters:
      name - the unique name of ValueLink connection
      linkNames - list of link names to be managed by single ValueLinks connection
      Returns:
      a ValueLinks object
      See Also:
    • reconnectLinks

      protected ValueLinks reconnectLinks(String name, String... linkNames)

      reconnectLinks.

      Parameters:
      name - a String object
      linkNames - a String object
      Returns:
      a ValueLinks object
    • getLinks

      public ValueLinks getLinks(String name)
      Returns ValueLinks object with provided name
      Parameters:
      name - the name of ValueLinks
      Returns:
      the ValueLinks object with requested name
    • 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 addRecord(String, Record)). Implementation class should override this method to intercept the update.
      Parameters:
      name - the name of record, that triggered change.
      alarmOnly - if true then only alarm has been changed
    • 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 addRecord(String, Record)). Implementation class should override this method to intercept the update.
      Parameters:
      name - the name of record, that triggered change.
    • notifyLinkChange

      protected void notifyLinkChange(String name)
      This method is called whenever record value changed for any record, which belongs to this application (it was added to the application addRecord(String, Record)). Implementation class should override this method to intercept the update.
      Parameters:
      name - the name of record, that triggered change.
    • initialize

      public void initialize(Database database)

      initialize.

      Specified by:
      initialize in interface Application
      Parameters:
      database - a Database object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStore

      protected org.apache.commons.configuration.PropertiesConfiguration getStore()
      Returns storage for this object. By default storage is a properties file APP/APP.properties in configuration folder location. To change file name, override and implement method createNewStore().
      Returns:
      lazy created store object.
    • createNewStore

      protected org.apache.commons.configuration.PropertiesConfiguration createNewStore()
      Creates new store configuration object with file APP/APP.properties in configuration folder location. Override this method to provide different file name as storage. NEw store is created by call to getStore(String, String).
      Returns:
      new properties store
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, int count, gov.aps.jca.dbr.DBRType type)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      count - a int
      type - a DBRType object
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, Object... value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      type - a DBRType object
      value - a Object object
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, byte[] value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      value - an array of
      invalid reference
      byte
      objects
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, boolean fixed, boolean undefined, Object... value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      type - a DBRType object
      fixed - a boolean
      undefined - a boolean
      value - a Object object
      Returns:
      a Record object
    • addRecordOfCommandProcessor

      protected Record addRecordOfCommandProcessor(String name, String desc, long timeout)

      addRecordOfCommandProcessor.

      Parameters:
      name - a String object
      desc - a String object
      timeout - a long
      Returns:
      a Record object
    • pushDoneCommandProcessor

      protected void pushDoneCommandProcessor(String name)

      pushDoneCommandProcessor.

      Parameters:
      name - a String object
    • resetOnDemandProcessor

      protected void resetOnDemandProcessor(String key)

      resetOnDemandProcessor.

      Parameters:
      key - a String object
    • addRecordOfOnDemandProcessor

      protected Record addRecordOfOnDemandProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, int count)

      addRecordOfOnDemandProcessor.

      Parameters:
      name - a String object
      desc - a String object
      type - a DBRType object
      count - a int
      Returns:
      a Record object
    • addRecordOfOnLinkValueProcessor

      protected Record addRecordOfOnLinkValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, String link)

      addRecordOfOnLinkValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      type - a DBRType object
      link - a String object
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, Double value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      min - a Double object
      max - a Double object
      units - a String object
      precision - a short
      value - a Double object
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, Integer value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      min - a Integer object
      max - a Integer object
      units - a String object
      value - a Integer object
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, double[] value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      min - a Double object
      max - a Double object
      units - a String object
      precision - a short
      value - an array of
      invalid reference
      double
      objects
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, int[] value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      min - a Integer object
      max - a Integer object
      units - a String object
      value - an array of
      invalid reference
      int
      objects
      Returns:
      a Record object
    • addRecordOfMemoryValueProcessor

      protected Record addRecordOfMemoryValueProcessor(String name, String desc, String[] labels, short value)

      addRecordOfMemoryValueProcessor.

      Parameters:
      name - a String object
      desc - a String object
      labels - an array of String objects
      value - a short
      Returns:
      a Record object
    • 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
    • isActivated

      public boolean isActivated()
      Activate has been called, application has reference to Database.
      Specified by:
      isActivated in interface Application
      Returns:
      if true application has been activated
    • updateLinkError

      protected void updateLinkError(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status, String errorString)

      updateLinkError.

      Parameters:
      severity - a Severity object
      status - a Status object
      errorString - a String object
    • updateLinkError

      protected void updateLinkError(boolean error, String errorString)

      updateLinkError.

      Parameters:
      error - a boolean
      errorString - a String object
    • updateErrorSum

      protected void updateErrorSum(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status)

      updateErrorSum.

      Parameters:
      severity - a Severity object
      status - a Status object
    • updateErrorSum

      protected void updateErrorSum()

      updateErrorSum.

    • getValue

      public Object getValue(Object key)
      Returns new value associated with the provided key.
      Specified by:
      getValue in interface OnDemandValueProcessor.ValueProvider
      Parameters:
      key - a key object to recognize the value if there is more then one processor asking
      Returns:
      the new value
    • getRecordErrorSum

      protected Record getRecordErrorSum()

      getRecordErrorSum.

      Returns:
      a Record object
    • getRecordLinkError

      protected Record getRecordLinkError()

      getRecordLinkError.

      Returns:
      a Record object
    • getNotNull

      protected String getNotNull(String prop, org.apache.commons.configuration.HierarchicalConfiguration config, String def)

      getNotNull.

      Parameters:
      prop - a String object
      config - a HierarchicalConfiguration object
      def - a String object
      Returns:
      a String object
      Throws:
      IllegalArgumentException - if config does not contain property