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
Modifier and TypeFieldDescriptionprotected Database
PV database.static final String
ConstantDEFAULT_NAME_DELIMITER=":"
protected boolean
true
if can create new records after initialization.static final String
ConstantERROR_SUM="Status:ErrorSum"
static final String
ConstantLINK_ERROR="Status:LinkError"
static final String
ConstantLINK_ERROR_STRING="Status:LinkError:String"
protected Map
<String, ValueLinks> Application linksprotected final org.apache.logging.log4j.Logger
Logger.protected String
Application name, part of PV.static final String
ConstantNAME_DELIMITER="nameDelimiter"
protected String
PV name delimiter.Application records -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Application has now reference to Database.protected Record
Adds a record to internal storage, which manages records, which belongs to this application.protected Record
addRecordOfCommandProcessor
(String name, String desc, long timeout) addRecordOfCommandProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, byte[] value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, int count, gov.aps.jca.dbr.DBRType type) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, gov.aps.jca.dbr.DBRType type, boolean fixed, boolean undefined, Object... value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, gov.aps.jca.dbr.DBRType type, Object... value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, Double min, Double max, String units, short precision, double[] value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, Double min, Double max, String units, short precision, Double value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, Integer min, Integer max, String units, int[] value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, Integer min, Integer max, String units, Integer value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfMemoryValueProcessor
(String name, String desc, String[] labels, short value) addRecordOfMemoryValueProcessor.protected Record
addRecordOfOnDemandProcessor
(String name, String desc, gov.aps.jca.dbr.DBRType type, int count) addRecordOfOnDemandProcessor.protected Record
addRecordOfOnLinkValueProcessor
(String name, String desc, gov.aps.jca.dbr.DBRType type, String link) addRecordOfOnLinkValueProcessor.void
Configures application internals, such as error links.void
Configures the internals of this application, provides reference to configuration with root inside applications tag.protected ValueLinks
connectLinks
(String name, String... linkNames) Starts ValueLink connection to provided list of link names.protected org.apache.commons.configuration.PropertiesConfiguration
Creates new store configuration object with file APP/APP.properties in configuration folder location.final String
fullRecordName
(String name) fullRecordName.Returns ValueLinks object with provided namegetName()
getName.Getter for the fieldnameDelimiter
.protected String
getNotNull
(String prop, org.apache.commons.configuration.HierarchicalConfiguration config, String def) getNotNull.Return configured Record instance with prepared ValueProcessor.protected Record
getRecordErrorSum.protected Record
getRecordLinkError.String[]
Returns array of record names.Record[]
Return array of configured Record instances with prepared ValueProcessor.protected org.apache.commons.configuration.PropertiesConfiguration
getStore()
Returns storage for this object.protected static final org.apache.commons.configuration.PropertiesConfiguration
Creates new PropertiesConfiguration object, which loads and stores properties from configuration file.Returns new value associated with the provided key.void
initialize
(Database database) initialize.boolean
Activate has been called, application has reference to Database.boolean
Returns true if this application is capable of creating new records when asked to.final void
log4debug.final void
log4error.final void
log4error.final void
log4info.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 applicationaddRecord(String, Record)
).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 applicationaddRecord(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 applicationaddRecord(String, Record)
).protected void
processLinkChange
(String name) processLinkChange.protected void
pushDoneCommandProcessor.protected ValueLinks
reconnectLinks
(String name, String... linkNames) reconnectLinks.protected void
resetOnDemandProcessor.protected static final MetaData
restore.protected static final void
store.toString()
protected void
updateErrorSum.protected void
updateErrorSum
(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status) updateErrorSum.protected void
updateLinkError
(boolean error, String errorString) updateLinkError.protected void
updateLinkError
(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 dynamicRecordCreatortrue
if 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
- aPropertiesConfiguration
objectmd
- aMetaData
object
-
restore
protected static final MetaData restore(org.apache.commons.configuration.PropertiesConfiguration store, String name) restore.
-
fullRecordName
fullRecordName.
- Specified by:
fullRecordName
in interfaceApplication
- Parameters:
name
- aString
object- Returns:
- a
String
object
-
log4debug
log4debug.
- Parameters:
message
- aString
object
-
log4info
log4info.
- Parameters:
message
- aString
object
-
log4error
log4error.
-
log4error
log4error.
- Parameters:
message
- aString
object
-
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:
configure
in interfaceApplication
- Parameters:
name
- aString
objectconfig
- configuration with room inside application tag.
-
configure
Configures application internals, such as error links. This is called fromconfigure(String, HierarchicalConfiguration)
. -
getName
getName.
- Specified by:
getName
in interfaceApplication
- Returns:
- a
String
object
-
getNameDelimiter
Getter for the field
nameDelimiter
.- Returns:
- a
String
object
-
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 interfaceApplication
- Returns:
- array of application relative record names.
-
getRecords
Return array of configured Record instances with prepared ValueProcessor.- Specified by:
getRecords
in interfaceApplication
- Returns:
- an array of records
-
getRecord
Return configured Record instance with prepared ValueProcessor. Ofnull
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 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:
isDynamicRecordCreator
in 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
ValueLinks
object - See Also:
-
reconnectLinks
reconnectLinks.
- Parameters:
name
- aString
objectlinkNames
- aString
object- Returns:
- a
ValueLinks
object
-
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
- iftrue
then 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:
initialize
in interfaceApplication
- Parameters:
database
- aDatabase
object
-
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
- aString
object
-
resetOnDemandProcessor
resetOnDemandProcessor.
- Parameters:
key
- aString
object
-
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:
activate
in interfaceApplication
-
isActivated
public boolean isActivated()Activate has been called, application has reference to Database.- Specified by:
isActivated
in interfaceApplication
- 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
- aSeverity
objectstatus
- aStatus
objecterrorString
- aString
object
-
updateLinkError
updateLinkError.
- Parameters:
error
- a booleanerrorString
- aString
object
-
updateErrorSum
protected void updateErrorSum(gov.aps.jca.dbr.Severity severity, gov.aps.jca.dbr.Status status) updateErrorSum.
- Parameters:
severity
- aSeverity
objectstatus
- aStatus
object
-
updateErrorSum
protected void updateErrorSum()updateErrorSum.
-
getValue
Returns new value associated with the provided key.- Specified by:
getValue
in 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
Record
object
-
getRecordLinkError
getRecordLinkError.
- Returns:
- a
Record
object
-
getNotNull
protected String getNotNull(String prop, org.apache.commons.configuration.HierarchicalConfiguration config, String def) getNotNull.
- Parameters:
prop
- aString
objectconfig
- aHierarchicalConfiguration
objectdef
- aString
object- Returns:
- a
String
object - Throws:
IllegalArgumentException
- if config does not contain property
-