Package com.cosylab.epics.caj.cas.util
Class NumericProcessVariable
- java.lang.Object
-
- gov.aps.jca.cas.ProcessVariable
-
- com.cosylab.epics.caj.cas.util.NumericProcessVariable
-
- Direct Known Subclasses:
CounterProcessVariable,FloatingDecimalProcessVariable
public abstract class NumericProcessVariable extends ProcessVariable
Enum process variable implementation. Implementation does not handle status, severity and alarms.
-
-
Field Summary
-
Fields inherited from class gov.aps.jca.cas.ProcessVariable
ackS, ackT, channelCount, eventCallback, interest, name
-
-
Constructor Summary
Constructors Constructor Description NumericProcessVariable(String name, ProcessVariableEventCallback eventCallback)Numeric PV constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidfillInDBR(DBR value)Set data (units, limits, ...) to DBR.NumbergetLowerAlarmLimit()Get lower alarm limit.NumbergetLowerCtrlLimit()Get lower control limit.NumbergetLowerDispLimit()Get lower display limit.NumbergetLowerWarningLimit()Get lower warning limit.StringgetUnits()Get units.NumbergetUpperAlarmLimit()Get upper alarm limit.NumbergetUpperCtrlLimit()Get upper control limit.NumbergetUpperDispLimit()Get upper display limit.NumbergetUpperWarningLimit()Get upper warning limit.CAStatusread(DBR value, ProcessVariableReadCallback asyncReadCallback)Read process variable value.protected abstract CAStatusreadValue(DBR value, ProcessVariableReadCallback asyncReadCallback)Read value.CAStatuswrite(DBR value, ProcessVariableWriteCallback asyncWriteCallback)Write process variable value.protected abstract CAStatuswriteValue(DBR value, ProcessVariableWriteCallback asyncWriteCallback)Write value.-
Methods inherited from class gov.aps.jca.cas.ProcessVariable
createChannel, destroy, getAckS, getDimensionSize, getEnumLabels, getEventCallback, getMaxDimension, getName, getType, interestDelete, interestRegister, isAckT, printInfo, printInfo, registerChannel, setAckS, setAckT, setEventCallback, unregisterChannel
-
-
-
-
Constructor Detail
-
NumericProcessVariable
public NumericProcessVariable(String name, ProcessVariableEventCallback eventCallback)
Numeric PV constructor.- Parameters:
name- process variable name.eventCallback- event callback, can benull.
-
-
Method Detail
-
getUnits
public String getUnits()
Get units. Default implementation, returns empty string.- Returns:
- get units,
non-null.
-
getUpperDispLimit
public Number getUpperDispLimit()
Get upper display limit. Default implementation, returns zero.- Returns:
- upper display limit,
non-null.
-
getLowerDispLimit
public Number getLowerDispLimit()
Get lower display limit. Default implementation, returns zero.- Returns:
- lower display limit,
non-null.
-
getUpperAlarmLimit
public Number getUpperAlarmLimit()
Get upper alarm limit. Default implementation, returns zero.- Returns:
- upper alarm limit,
non-null.
-
getUpperWarningLimit
public Number getUpperWarningLimit()
Get upper warning limit. Default implementation, returns zero.- Returns:
- upper warning limit,
non-null.
-
getLowerWarningLimit
public Number getLowerWarningLimit()
Get lower warning limit. Default implementation, returns zero.- Returns:
- lower warning limit,
non-null.
-
getLowerAlarmLimit
public Number getLowerAlarmLimit()
Get lower alarm limit. Default implementation, returns zero.- Returns:
- lower alarm limit,
non-null.
-
getUpperCtrlLimit
public Number getUpperCtrlLimit()
Get upper control limit. Default implementation, returns zero.- Returns:
- upper control limit,
non-null.
-
getLowerCtrlLimit
public Number getLowerCtrlLimit()
Get lower control limit. Default implementation, returns zero.- Returns:
- lower control limit,
non-null.
-
read
public CAStatus read(DBR value, ProcessVariableReadCallback asyncReadCallback) throws CAException
Description copied from class:ProcessVariableRead 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).- Specified by:
readin classProcessVariable- 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
-
fillInDBR
public void fillInDBR(DBR value)
Set data (units, limits, ...) to DBR. GR and CTRL data is filled only ifisCTRLSupportedreturnstrue.- Parameters:
value- DBR to fill-in.
-
readValue
protected abstract CAStatus readValue(DBR value, ProcessVariableReadCallback asyncReadCallback) throws CAException
Read value. Reference implementation:{ // for async. completion, returnnull, // set value (and status) toenumValueand // report completion usingasyncReadCallbackcallback. // return null;// BEGIN optional (to override defaults) // set status and severity value.setStatus(Status.<status>); value.setSeverity(Severity.<severity>); // set timestamp value.setTimestamp(timestamp); // END optional (to override defaults) // set value to given DBR (example of copying value for DOUBLE type process variable) // given DBR has already allocated an array of elements client has requested // it contains maximum number of elements to fill double[] arrayValue = (DBR_Double)value.getDoubleValue(); int elementCount = Math.min(<fromDoubleArray>.length, arrayValue.length); System.arraycopy(<fromDoubleArray>, 0, arrayValue, 0, elementCount); // return read completion status return CAStatus.NORMAL;}
-
write
public CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
Description copied from class:ProcessVariableWrite process variable value. The request is allowed to complete asynchronously. The incoming DBR is always of typegetType().- Specified by:
writein classProcessVariable- 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
-
writeValue
protected abstract CAStatus writeValue(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
Write value. Reference implementation:{ // for async. completion, returnnull, // set value (and status) fromenumValue, // notify if there is an interest and // report completion usingasyncWriteCallbackcallback. // return null;// set value from given DBR here ... // notify, set appropirate Monitor mask (VALUE, LOG, ALARM) if (status == CAStatus.NORMAL && interest) { DBR monitorDBR = AbstractCASResponseHandler.createDBRforReading(this); ((DBR_Double)monitorDBR).getDoubleValue()[0] = this.value; fillInDBR(monitorDBR); fillInStatusAndTime((TIME)monitorDBR); eventCallback.postEvent(Monitor.VALUE|Monitor.LOG, value); } // return read completion status return CAStatus.NORMAL;}
-
-