|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
OCSEPICS.StatusVariable
OCSEPICS.ProcessVariable
public class ProcessVariable
This class wraps up an EPICS process variable (PV) into a object which can be used throughout an OCS EPICS application. It will allow the setting and reading back of the process variable in addition to being able to convert the units backwards and forwards between engineering and logical units. Conversion between logical and engineering units is done automatically by the system before data is sent to the PV and sent up to the noticeboard.
Clients can request to be informed when there is an event on the PV
by means of a callback mechanism. They need to register themselves
as a listener using the CAEventListener
interface.
It's worth pointing out that I have done the best I can with the Java EPICS interface, the documentation is completely rubbish and I have had to work out how to use it myself rather from a definitive source.
The class will listen for events on the monitored PV (if specified), and convert from engineering values to logical units and then write the value into the parameter noticeboard.
Field Summary | |
---|---|
(package private) gov.aps.jca.Monitor |
ChannelMonitor
This the monitor on the PV if it is being monitored |
private static int |
ConversionUniqueSeqCode
Static variable which is used for indexing the parameter conversions |
private java.sql.Connection |
DBConnection
This is a live connection to the database |
private java.lang.String |
EngineeringArgType
This is the argument type of the PV when it is to be written into the noticeboard |
private gov.aps.jca.Context |
EPICSContext
This is the EPICS context which we will use |
private java.util.ArrayList<CAEventListener> |
EventListeners
A list of listeners which are interested on events which occur on this PV. |
private java.lang.String |
HostName
This is the name of the EPICS host which is home to the process variable which is to be monitored by this class |
private java.lang.String |
InstrumentName
This is the name of the instrument which is associated with this PV |
private java.lang.String |
LogicalArgType
This is the logical type of the PV once it has been converted from it's engineering value into a logical value. |
private java.lang.String |
LogicalNBParameterName
This is the name of the parameter which is to be written into the noticeboard. |
private java.lang.String |
MechName
This is the name of the mechanism which is associated with this PV if there is one |
(package private) boolean |
MonitorCreated
Whether a monitor has been created on this PV |
private int |
ParameterConversionCode
This code will be used to uniquely identify the parameter conversion to be used (if at all) on this PV. |
private gov.aps.jca.Channel |
PVChannel
This is the EPICS channel which is associated with the PV |
private boolean |
PVConnected
Indicates whether we are connected to the PV in the IOC or not. |
private java.util.Timer |
PVInitialisationTimer
This is a timer object which will be used for scheduling the intialisation of the PV |
private boolean |
PVMonitoringInitialised
Whether we have intialised the class or not |
private java.lang.String |
PVName
This is the textual name of the PV |
private java.lang.String |
RawUnitsLabel
This is raw units which are associated with the engineering value |
private java.lang.Boolean |
ToBeMonitored
Whether the PV is to be monitored by the class |
Fields inherited from class OCSEPICS.StatusVariable |
---|
OCSCorba, ParameterConvertor, ParameterNoticeBoard, StatusVariableName, SyslogMessageHandler, UnitConversionMethod |
Constructor Summary | |
---|---|
ProcessVariable(java.sql.Connection DBConnection,
java.lang.String PVName,
gov.aps.jca.Context EPICSContext,
MessageHandler SyslogMessageHandler,
FourMS.FourMSParameterConverter ParameterConvertor,
OCSCORBAHelper OCSCorba)
This is the constructor for this class. |
Method Summary | |
---|---|
boolean |
addPVListener(CAEventListener listener)
Add external listener to be informed when there are events on the PV. |
private org.omg.CORBA.Any |
castConvertedParameter(java.lang.String ParameterToConvert,
java.lang.String ConversionType)
This is responsible for casting the input value to the type which is indicated by the conversiontype parameter and then packaging it up into an a CORBA Any which can then be used to update the noticeboard by the caller. |
void |
connectionChanged(gov.aps.jca.event.ConnectionEvent ev)
This is the obligation of the ConnectionListener interface. |
private java.lang.String |
convertDBRType(gov.aps.jca.dbr.DBR valueToConvert)
This method will be called to convert the EPICS DBR type specified to a string. |
void |
finalize()
|
java.lang.String |
getLogicalArgType()
Used to get the type of the logical argument |
java.lang.String |
getPVName()
Gets the name of the process variable |
ing.status.StatusItemValue[] |
getStatusValue()
This method will be used for getting the value of the PV from the IOC, updating the noticeboard accordingly and returning the value to the caller. |
private void |
informListeners(ing.status.StatusItemValue statusValue)
Informs the PV listeners of a change in the value of a PV when there is an event. |
private void |
informListeners(ing.status.StatusItemValue[] statusValues)
Informs the PV listeners of a change in the value of a PV when there is an event. |
static void |
main(java.lang.String[] args)
main() method which can be used to run some tests on the process variable class. |
void |
monitorChanged(gov.aps.jca.event.MonitorEvent ev)
This is the obligation to the MonitorListener interface which will be called when the value of the underlying monitored PV changes. |
ing.status.StatusItemValue[] |
performEngineeringToLogicalUnitConversion(gov.aps.jca.dbr.DBR rawValue)
Converts the input parameter which is an EPICS DBR type from it's engineering value to it's logical value if required and then update noticeboard with both the engineering and the logical values. |
java.lang.String |
performLogicalToEngineeringUnitConversion(java.lang.String InputValue)
This method can be used to convert a logical value to an engineering value. |
void |
putProcessVariable(java.lang.String ValueToWrite)
This will be used for putting a value into the PV on the IOC. |
void |
run()
This is the obligation of the TimerTask base class. |
Methods inherited from class OCSEPICS.StatusVariable |
---|
updateParameterNoticeboard, updateParameterNoticeboard |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int ConversionUniqueSeqCode
private int ParameterConversionCode
boolean MonitorCreated
gov.aps.jca.Monitor ChannelMonitor
private gov.aps.jca.Channel PVChannel
private final java.util.Timer PVInitialisationTimer
private java.sql.Connection DBConnection
private boolean PVConnected
private java.lang.String PVName
private java.lang.String HostName
private java.lang.String MechName
private java.lang.String InstrumentName
private java.lang.String RawUnitsLabel
private java.lang.String LogicalArgType
private java.lang.String EngineeringArgType
private java.lang.String LogicalNBParameterName
private java.lang.Boolean ToBeMonitored
private gov.aps.jca.Context EPICSContext
private boolean PVMonitoringInitialised
private java.util.ArrayList<CAEventListener> EventListeners
Constructor Detail |
---|
public ProcessVariable(java.sql.Connection DBConnection, java.lang.String PVName, gov.aps.jca.Context EPICSContext, MessageHandler SyslogMessageHandler, FourMS.FourMSParameterConverter ParameterConvertor, OCSCORBAHelper OCSCorba) throws UnableToInitiatePVException, java.lang.Exception
DBConnection
- This is an active connection to the database so that
the class can look up the details of the PV from the WHT ICS database. The
behaviour of the class is data driven by the contents of the
ProcessVariable table in the database.PVName
- This is the name of PV which is to be controlled using this
class.EPICSContext
- This is EPICS context within which we will create the
process variable.SyslogMessageHandler
- This will be used to write information into the
syslog message handler.ParameterConvertor
- This will be used sued to convert PV values between engineering and logical unitsOCSCorba
- Helper object for performing CORBA related activity.
UnableToInitiatePVException
java.lang.Exception
Method Detail |
---|
public void finalize() throws java.lang.Throwable
finalize
in class StatusVariable
java.lang.Throwable
private void informListeners(ing.status.StatusItemValue statusValue)
statusValue
- A status item which contains the status
value to be returned to the listener. Normally this verison of
the method will be called when an error status item is to be
returned to the caller.private void informListeners(ing.status.StatusItemValue[] statusValues)
statusValues
- An arry of status items which contains the
raw and the engineering value which is associated with the
event on the PV. The method will determine which of the two
values that the client is registered for and return only one of
the status items.public boolean addPVListener(CAEventListener listener)
listener
- This is an object which is to be informed when
there is an event on the PV.
public void connectionChanged(gov.aps.jca.event.ConnectionEvent ev)
connectionChanged
in interface gov.aps.jca.event.ConnectionListener
ev
- This contains the details of the eventpublic void run()
Should we fail in our attempt to initialise the PV, as part of the timer task, the method will be called again in 15 seconds time.
run
in interface java.lang.Runnable
run
in class StatusVariable
public void monitorChanged(gov.aps.jca.event.MonitorEvent ev)
Any errors will result in both the engineering and the logical noticeboard items being set to an error state.
monitorChanged
in interface gov.aps.jca.event.MonitorListener
ev
- This contains the details of the channel access eventpublic java.lang.String performLogicalToEngineeringUnitConversion(java.lang.String InputValue) throws FourMS.ConversionFailedException
InputValue
- This is the value which is to be
converted. It is expressed always as a string representation of
the value.
ConversionFailedException
- Should the conversion fail.public ing.status.StatusItemValue[] performEngineeringToLogicalUnitConversion(gov.aps.jca.dbr.DBR rawValue) throws UnableToPerformConversion
rawValue
- This is the EPICS value which is to be converted logical units.
UnableToPerformConversion
- When a conversion cannot be performed.private org.omg.CORBA.Any castConvertedParameter(java.lang.String ParameterToConvert, java.lang.String ConversionType) throws FourMS.ConversionFailedException
ParameterToConvert
- This is the value which needs to be
convertedConversionType
- The is the code which dictates the type of
the value which will be returned by the method. This should
agree with one of the standard 4MS types such as r,h,s,x,d.
ConversionFailedException
- This is thrown if there is an
error converting the parameterpublic ing.status.StatusItemValue[] getStatusValue() throws gov.aps.jca.CAException
gov.aps.jca.CAException
- If unable to get the value and perform unit conversion on the raw engineering unit.public void putProcessVariable(java.lang.String ValueToWrite) throws gov.aps.jca.CAException
ValueToWrite
- This is the raw value which is to be
written to the PV. All unit conversions should have been
performed by this point so the value represented here should be in engineering units.
gov.aps.jca.CAException
- Whenever there is a problem attempting to write the PV to the IOC.private java.lang.String convertDBRType(gov.aps.jca.dbr.DBR valueToConvert) throws UnableToConvertDBRTypeException
valueToConvert
- This is the EPICS DBR type which is to have it's value converted to a string
UnableToConvertDBRTypeException
- Thrown when unable to
convert the value which is entered into the method.public static void main(java.lang.String[] args)
public java.lang.String getPVName()
public java.lang.String getLogicalArgType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |