Class 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
AbstractApplication class.
- Author:
- igor@scictrl.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DatabasePV database.static final StringConstantDEFAULT_NAME_DELIMITER=":"protected booleantrueif can create new records after initialization.static final StringConstantERROR_SUM="Status:ErrorSum"static final StringConstantLINK_ERROR="Status:LinkError"static final StringConstantLINK_ERROR_STRING="Status:LinkError:String"protected Map<String, ValueLinks> Application linksprotected final org.apache.logging.log4j.LoggerLogger.protected StringApplication name, part of PV.static final StringConstantNAME_DELIMITER="nameDelimiter"protected StringPV name delimiter.Application records -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Application has now reference to Database.protected RecordAdds a record to internal storage, which manages records, which belongs to this application.protected RecordaddRecordOfCommandProcessor(String name, String desc, long timeout) addRecordOfCommandProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, byte[] value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, int count, gov.aps.jca.dbr.DBRType type) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, boolean fixed, boolean undefined, Object... value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, Object... value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, double[] value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, Double value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, int[] value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, Integer value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfMemoryValueProcessor(String name, String desc, String[] labels, short value) addRecordOfMemoryValueProcessor.protected RecordaddRecordOfOnDemandProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, int count) addRecordOfOnDemandProcessor.protected RecordaddRecordOfOnLinkValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, String link) addRecordOfOnLinkValueProcessor.voidConfigures application internals, such as error links.voidConfigures the internals of this application, provides reference to configuration with root inside applications tag.protected ValueLinksconnectLinks(String name, String... linkNames) Starts ValueLink connection to provided list of link names.protected org.apache.commons.configuration.PropertiesConfigurationCreates new store configuration object with file APP/APP.properties in configuration folder location.final StringfullRecordName(String name) fullRecordName.Returns ValueLinks object with provided namegetName()getName.Getter for the fieldnameDelimiter.protected StringgetNotNull(String prop, org.apache.commons.configuration.HierarchicalConfiguration config, String def) getNotNull.Return configured Record instance with prepared ValueProcessor.protected RecordgetRecordErrorSum.protected RecordgetRecordLinkError.String[]Returns array of record names.Record[]Return array of configured Record instances with prepared ValueProcessor.protected org.apache.commons.configuration.PropertiesConfigurationgetStore()Returns storage for this object.protected static final org.apache.commons.configuration.PropertiesConfigurationCreates new PropertiesConfiguration object, which loads and stores properties from configuration file.Returns new value associated with the provided key.voidinitialize(Database database) initialize.booleanActivate has been called, application has reference to Database.booleanReturns true if this application is capable of creating new records when asked to.final voidlog4debug.final voidlog4error.final voidlog4error.final voidlog4info.protected voidnotifyLinkChange(String name) This method is called whenever record value changed for any record, which belongs to this application (it was added to the applicationaddRecord(String, Record)).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 applicationaddRecord(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 applicationaddRecord(String, Record)).protected voidprocessLinkChange(String name) processLinkChange.protected voidpushDoneCommandProcessor.protected ValueLinksreconnectLinks(String name, String... linkNames) reconnectLinks.protected voidresetOnDemandProcessor.protected static final MetaDatarestore.protected static final voidstore.toString()protected voidupdateErrorSum.protected voidupdateErrorSum(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status) updateErrorSum.protected voidupdateLinkError(boolean error, String errorString) updateLinkError.protected voidupdateLinkError(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status, String errorString) updateLinkError.
-
Field Details
-
LINK_ERROR
ConstantLINK_ERROR="Status:LinkError"- See Also:
-
LINK_ERROR_STRING
ConstantLINK_ERROR_STRING="Status:LinkError:String"- See Also:
-
ERROR_SUM
ConstantERROR_SUM="Status:ErrorSum"- See Also:
-
DEFAULT_NAME_DELIMITER
ConstantDEFAULT_NAME_DELIMITER=":"- See Also:
-
NAME_DELIMITER
ConstantNAME_DELIMITER="nameDelimiter"- See Also:
-
log
protected final org.apache.logging.log4j.Logger logLogger. -
name
Application name, part of PV. -
records
Application records -
links
Application links -
dynamicRecordCreator
protected boolean dynamicRecordCreatortrueif can create new records after initialization. -
nameDelimiter
PV name delimiter. -
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 folderfileName- 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- aPropertiesConfigurationobjectmd- aMetaDataobject
-
restore
protected static final MetaData restore(org.apache.commons.configuration.PropertiesConfiguration store, String name) restore.
-
fullRecordName
fullRecordName.
- Specified by:
fullRecordNamein interfaceApplication- Parameters:
name- aStringobject- Returns:
- a
Stringobject
-
log4debug
log4debug.
- Parameters:
message- aStringobject
-
log4info
log4info.
- Parameters:
message- aStringobject
-
log4error
log4error.
-
log4error
log4error.
- Parameters:
message- aStringobject
-
processLinkChange
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:
configurein interfaceApplication- Parameters:
name- aStringobjectconfig- configuration with room inside application tag.
-
configure
Configures application internals, such as error links. This is called fromconfigure(String, HierarchicalConfiguration). -
getName
getName.
- Specified by:
getNamein interfaceApplication- Returns:
- a
Stringobject
-
getNameDelimiter
Getter for the field
nameDelimiter.- Returns:
- a
Stringobject
-
getRecordNames
Returns array of record names. Important: these are not full PV names, just prefixes valid within context of the application.- Specified by:
getRecordNamesin interfaceApplication- Returns:
- array of application relative record names.
-
getRecords
Return array of configured Record instances with prepared ValueProcessor.- Specified by:
getRecordsin interfaceApplication- Returns:
- an array of records
-
getRecord
Return configured Record instance with prepared ValueProcessor. Ofnullif 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:
getRecordin interfaceApplication- 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:
isDynamicRecordCreatorin interfaceApplication- Returns:
- a boolean
-
addRecord
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 usedr- the record to be added- Returns:
- returns record which was added
-
connectLinks
Starts ValueLink connection to provided list of link names.- Parameters:
name- the unique name of ValueLink connectionlinkNames- list of link names to be managed by single ValueLinks connection- Returns:
- a
ValueLinksobject - See Also:
-
reconnectLinks
reconnectLinks.
- Parameters:
name- aStringobjectlinkNames- aStringobject- Returns:
- a
ValueLinksobject
-
getLinks
Returns ValueLinks object with provided name- Parameters:
name- the name of ValueLinks- Returns:
- the ValueLinks object with requested name
-
notifyRecordChange
This method is called whenever record value changed for any record, which belongs to this application (it was added to the applicationaddRecord(String, Record)). Implementation class should override this method to intercept the update.- Parameters:
name- the name of record, that triggered change.alarmOnly- iftruethen only alarm has been changed
-
notifyRecordWrite
This method is called whenever record value has been written for any record, which belongs to this application (it was added to the applicationaddRecord(String, Record)). Implementation class should override this method to intercept the update.- Parameters:
name- the name of record, that triggered change.
-
notifyLinkChange
This method is called whenever record value changed for any record, which belongs to this application (it was added to the applicationaddRecord(String, Record)). Implementation class should override this method to intercept the update.- Parameters:
name- the name of record, that triggered change.
-
initialize
initialize.
- Specified by:
initializein interfaceApplication- Parameters:
database- aDatabaseobject
-
toString
-
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 methodcreateNewStore().- 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 togetStore(String, String).- Returns:
- new properties store
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, int count, gov.aps.jca.dbr.DBRType type) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, Object... value) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, boolean fixed, boolean undefined, Object... value) addRecordOfMemoryValueProcessor.
-
addRecordOfCommandProcessor
addRecordOfCommandProcessor.
-
pushDoneCommandProcessor
pushDoneCommandProcessor.
- Parameters:
name- aStringobject
-
resetOnDemandProcessor
resetOnDemandProcessor.
- Parameters:
key- aStringobject
-
addRecordOfOnDemandProcessor
protected Record addRecordOfOnDemandProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, int count) addRecordOfOnDemandProcessor.
-
addRecordOfOnLinkValueProcessor
protected Record addRecordOfOnLinkValueProcessor(String name, String desc, gov.aps.jca.dbr.DBRType type, String link) addRecordOfOnLinkValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, Double value) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, Integer value) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, Double min, Double max, String units, short precision, double[] value) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, Integer min, Integer max, String units, int[] value) addRecordOfMemoryValueProcessor.
-
addRecordOfMemoryValueProcessor
protected Record addRecordOfMemoryValueProcessor(String name, String desc, String[] labels, short value) addRecordOfMemoryValueProcessor.
-
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
-
isActivated
public boolean isActivated()Activate has been called, application has reference to Database.- Specified by:
isActivatedin interfaceApplication- Returns:
- if
trueapplication has been activated
-
updateLinkError
protected void updateLinkError(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status, String errorString) updateLinkError.
- Parameters:
severity- aSeverityobjectstatus- aStatusobjecterrorString- aStringobject
-
updateLinkError
updateLinkError.
- Parameters:
error- a booleanerrorString- aStringobject
-
updateErrorSum
protected void updateErrorSum(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status) updateErrorSum.
- Parameters:
severity- aSeverityobjectstatus- aStatusobject
-
updateErrorSum
protected void updateErrorSum()updateErrorSum.
-
getValue
Returns new value associated with the provided key.- Specified by:
getValuein interfaceOnDemandValueProcessor.ValueProvider- Parameters:
key- a key object to recognize the value if there is more then one processor asking- Returns:
- the new value
-
getRecordErrorSum
getRecordErrorSum.
- Returns:
- a
Recordobject
-
getRecordLinkError
getRecordLinkError.
- Returns:
- a
Recordobject
-
getNotNull
protected String getNotNull(String prop, org.apache.commons.configuration.HierarchicalConfiguration config, String def) getNotNull.
- Parameters:
prop- aStringobjectconfig- aHierarchicalConfigurationobjectdef- aStringobject- Returns:
- a
Stringobject - Throws:
IllegalArgumentException- if config does not contain property
-