Package gov.aps.jca.cas
Class ProcessVariable
- java.lang.Object
-
- gov.aps.jca.cas.ProcessVariable
-
- Direct Known Subclasses:
EnumProcessVariable,MemoryProcessVariable,NumericProcessVariable,StringProcessVariable
public abstract class ProcessVariable extends Object
Process variable (PV).- Version:
- $Id: ProcessVariable.java,v 1.12 2007-12-04 12:57:40 msekoranja Exp $
- Author:
- Matej Sekoranja
-
-
Field Summary
Fields Modifier and Type Field Description protected SeverityackSAlarm Acknowledge Severity.protected booleanackTAlarm Acknowledge Transient.protected intchannelCountChannel count (number of clients).protected ProcessVariableEventCallbackeventCallbackProcess variable event callback.protected booleaninterestInteress flag.protected StringnameProcess variable name.
-
Constructor Summary
Constructors Constructor Description ProcessVariable(String name, ProcessVariableEventCallback eventCallback)Create process variable with given name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ServerChannelcreateChannel(int cid, int sid, String userName, String hostName)This method is called each time that a PV is attached to by a client.voiddestroy()Destory process variable.SeveritygetAckS()Get acknowledged alarm severity.intgetDimensionSize(int dimension)The methodgetDimensionSize(dimension)returns the maximum number of elements in a particular dimension of the hypercube as follows:String[]getEnumLabels()Get enum string labels.ProcessVariableEventCallbackgetEventCallback()Get event callback.intgetMaxDimension()Returns the maximum bounding box for all present and future data stored within the PV.StringgetName()Get process variable name.abstract DBRTypegetType()The best type for clients to use when accessing the value of the PV.voidinterestDelete()Called by the server library each time that it wishes to remove its subscription for PV value change events from the server tool viaProcessVariableEventCallback.postEvent()method.voidinterestRegister()Called by the server libary each time that it wishes to subscribe for PV change notification from the server tool viaProcessVariableEventCallback.postEvent()method.booleanisAckT()Get acknowledged alarm transient flag.voidprintInfo()Prints detailed information about the Context to the standard output stream.voidprintInfo(PrintStream out)Prints detailed information about the Context to the specified output stream.abstract CAStatusread(DBR value, ProcessVariableReadCallback asyncReadCallback)Read process variable value.voidregisterChannel(ServerChannel channel)Register channel to this process variable.voidsetAckS(Severity ackS)Set acknowledged alarm severity.voidsetAckT(boolean ackT)Set acknowledged alarm transient flag.voidsetEventCallback(ProcessVariableEventCallback eventCallback)Set event callback.voidunregisterChannel(ServerChannel channel)Unregister channel from this process variable.abstract CAStatuswrite(DBR value, ProcessVariableWriteCallback asyncWriteCallback)Write process variable value.
-
-
-
Field Detail
-
name
protected String name
Process variable name.
-
eventCallback
protected ProcessVariableEventCallback eventCallback
Process variable event callback.
-
interest
protected volatile boolean interest
Interess flag.- See Also:
interestRegister()
-
channelCount
protected int channelCount
Channel count (number of clients).
-
ackS
protected volatile Severity ackS
Alarm Acknowledge Severity.
-
ackT
protected volatile boolean ackT
Alarm Acknowledge Transient.
-
-
Constructor Detail
-
ProcessVariable
public ProcessVariable(String name, ProcessVariableEventCallback eventCallback)
Create process variable with given name.- Parameters:
name- process variable name.eventCallback- event callback, can benull.
-
-
Method Detail
-
getName
public String getName()
Get process variable name. If there are several aliases for the same PV this routine should return the canonical (base) name for the PV.- Returns:
- process variable name.
-
getType
public abstract DBRType getType()
The best type for clients to use when accessing the value of the PV. Only basic types e.g. BYTE, INTEGER and not STS_BYTE have to be returned.- Returns:
- best type for clients.
-
getMaxDimension
public int getMaxDimension()
Returns the maximum bounding box for all present and future data stored within the PV. The methodgetDimensionCount()returns the maximum number of dimensions in the hypercube (0=scalar, 1=array, 2=plane, 3=cube ...). The default (base) "getDimensionCount()" returns zero (scalar). Clients will see that the PV's data is scalar if these routines are not supplied in the derived class. If the "dimension" argument to getDimensionSize() is set to zero then the bound on the first dimension is being fetched. If the "dimension" argument to getDimensionSize() is set to one then the bound on the second dimension are being fetched...- Returns:
- number of dimensions presenting the data.
-
getDimensionSize
public int getDimensionSize(int dimension)
The methodgetDimensionSize(dimension)returns the maximum number of elements in a particular dimension of the hypercube as follows:scalar - getDimensionCount() returns 0 array - getDimensionCount() returns 1 getDimensionSize(0) supplies number of elements in array plane - getDimensionCount() returns 2 getDimensionSize(0) supplies number of elements in X dimension getDimensionSize(1) supplies number of elements in Y dimension cube - getDimensionCount() returns 3 getDimensionSize(0) supplies number of elements in X dimension getDimensionSize(1) supplies number of elements in Y dimension getDimensionSize(2) supplies number of elements in Z dimension ...The default (base) "getDimensionSize()" returns one (scalar bounds) for all dimensions.- Parameters:
dimension- dimension for which to fecth its size.- Returns:
- requested dimenstion size.
-
getEnumLabels
public String[] getEnumLabels()
Get enum string labels. If process variable is type ofENUMit should override this method and return labels.- Returns:
- enum string labels.
-
getAckS
public Severity getAckS()
Get acknowledged alarm severity.- Returns:
- acknowledged alarm severity.
-
setAckS
public void setAckS(Severity ackS)
Set acknowledged alarm severity.- Parameters:
ackS- acknowledged alarm severity to set.
-
isAckT
public boolean isAckT()
Get acknowledged alarm transient flag.- Returns:
- acknowledged alarm transient flag
-
setAckT
public void setAckT(boolean ackT)
Set acknowledged alarm transient flag.- Parameters:
ackT- acknowledged alarm transient flag to set
-
interestRegister
public void interestRegister()
Called by the server libary each time that it wishes to subscribe for PV change notification from the server tool viaProcessVariableEventCallback.postEvent()method.
-
interestDelete
public void interestDelete()
Called by the server library each time that it wishes to remove its subscription for PV value change events from the server tool viaProcessVariableEventCallback.postEvent()method.
-
read
public abstract CAStatus read(DBR value, ProcessVariableReadCallback asyncReadCallback) throws CAException
Read process variable value. The request is allowed to complete asynchronously.The incoming DBR value is always (at least) of type DBR_TIME_[type] where type is of
getType(). If DBR_GR_or DBR_CTRL_ is requested then valueis instance of requested type.Special cases:
DBR_TIME_Enumtype is "upgraded" to an "artificial"TIMEtypeDBR_TIME_LABELS_Enum. This enables PV to set labels and time.
DBR_TIME_DoubleandDBR_TIME_Floatare "upgraded" to an "artificial"TIMEtype which also implementsPRECISIONinterface,DBR_PRECISION_DoubleandDBR_PRECISION_Float. This enables PV to set precision (-1, by default, means no precision set).- Parameters:
value- value of type (at least) DBR_TIME_where type is of getType().asyncReadCallback- if asynchronous completion is required method should returnnulland callProcessVariableReadCallback.processVariableReadCompleted()method.- Returns:
- CA status,
nullif request will complete asynchronously by calling method. - Throws:
CAException
-
write
public abstract CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
Write process variable value. The request is allowed to complete asynchronously. The incoming DBR is always of typegetType().- Parameters:
value- value of typegetType().asyncWriteCallback- if asynchronous completion is required method should returnnulland callProcessVariableWriteCallback.processVariableWriteCompleted()method.- Returns:
- CA status,
nullif request will complete asynchronously by calling method. - Throws:
CAException
-
createChannel
public ServerChannel createChannel(int cid, int sid, String userName, String hostName) throws CAException
This method is called each time that a PV is attached to by a client. This method can be overriden to specialize access to PV (e.g. for particular client, setting access rights, ...).- Parameters:
cid- channel CID.sid- channel SID.userName- client user name.hostName- client host name.- Returns:
ServerChannelinstance.- Throws:
CAException
-
registerChannel
public void registerChannel(ServerChannel channel)
Register channel to this process variable.- Parameters:
channel- channel to register.
-
unregisterChannel
public void unregisterChannel(ServerChannel channel)
Unregister channel from this process variable.- Parameters:
channel- channel to unregister.
-
destroy
public void destroy()
Destory process variable. This method is called:
- each time that a PV transitions from a situation where clients are attached to a situation where no clients are attached.
- once for all PVs that exist when the server is deleted
-
printInfo
public void printInfo() throws IllegalStateExceptionPrints detailed information about the Context to the standard output stream.- Throws:
IllegalStateException- if the context has been destroyed.
-
printInfo
public void printInfo(PrintStream out) throws IllegalStateException
Prints detailed information about the Context to the specified output stream.- Parameters:
out- the output stream.- Throws:
IllegalStateException- if the context has been destroyed.
-
getEventCallback
public ProcessVariableEventCallback getEventCallback()
Get event callback.- Returns:
- the eventCallback
-
setEventCallback
public void setEventCallback(ProcessVariableEventCallback eventCallback)
Set event callback.- Parameters:
eventCallback- the eventCallback to set
-
-