com.cosylab.epics.caj.cas.util
Class NumericProcessVariable

java.lang.Object
  extended by gov.aps.jca.cas.ProcessVariable
      extended by com.cosylab.epics.caj.cas.util.NumericProcessVariable
Direct Known Subclasses:
CounterProcessVariable, FloatingDecimalProcessVariable

public abstract class NumericProcessVariable
extends gov.aps.jca.cas.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
NumericProcessVariable(String name, gov.aps.jca.cas.ProcessVariableEventCallback eventCallback)
          Numeric PV constructor.
 
Method Summary
 void fillInDBR(gov.aps.jca.dbr.DBR value)
          Set data (units, limits, ...) to DBR.
 Number getLowerAlarmLimit()
          Get lower alarm limit.
 Number getLowerCtrlLimit()
          Get lower control limit.
 Number getLowerDispLimit()
          Get lower display limit.
 Number getLowerWarningLimit()
          Get lower warning limit.
 String getUnits()
          Get units.
 Number getUpperAlarmLimit()
          Get upper alarm limit.
 Number getUpperCtrlLimit()
          Get upper control limit.
 Number getUpperDispLimit()
          Get upper display limit.
 Number getUpperWarningLimit()
          Get upper warning limit.
 gov.aps.jca.CAStatus read(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
           
protected abstract  gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
          Read value.
 gov.aps.jca.CAStatus write(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableWriteCallback asyncWriteCallback)
           
protected abstract  gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericProcessVariable

public NumericProcessVariable(String name,
                              gov.aps.jca.cas.ProcessVariableEventCallback eventCallback)
Numeric PV constructor.

Parameters:
name - process variable name.
eventCallback - event callback, can be null.
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 gov.aps.jca.CAStatus read(gov.aps.jca.dbr.DBR value,
                                 gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
                          throws gov.aps.jca.CAException
Specified by:
read in class gov.aps.jca.cas.ProcessVariable
Throws:
gov.aps.jca.CAException

fillInDBR

public void fillInDBR(gov.aps.jca.dbr.DBR value)
Set data (units, limits, ...) to DBR. GR and CTRL data is filled only if isCTRLSupported returns true.

Parameters:
value - DBR to fill-in.

readValue

protected abstract gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR value,
                                                  gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
                                           throws gov.aps.jca.CAException
Read value. Reference implementation:
        {
 
                // for async. completion, return null,
                // set value (and status) to enumValue and
                // report completion using asyncReadCallback callback.
                // return null;
        
                // BEGIN optional (to override defaults) 
                
                // set status and severity
                value.setStatus(Status.);
                value.setSeverity(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(.length, arrayValue.length);
                System.arraycopy(, 0, arrayValue, 0, elementCount);
 
                // return read completion status
                return CAStatus.NORMAL;
        } 
 
 

Throws:
gov.aps.jca.CAException
See Also:
ProcessVariable.read(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableReadCallback)

write

public gov.aps.jca.CAStatus write(gov.aps.jca.dbr.DBR value,
                                  gov.aps.jca.cas.ProcessVariableWriteCallback asyncWriteCallback)
                           throws gov.aps.jca.CAException
Specified by:
write in class gov.aps.jca.cas.ProcessVariable
Throws:
gov.aps.jca.CAException

writeValue

protected abstract gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR value,
                                                   gov.aps.jca.cas.ProcessVariableWriteCallback asyncWriteCallback)
                                            throws gov.aps.jca.CAException
Write value. Reference implementation:
        {
 
                // for async. completion, return null,
                // set value (and status) from enumValue,
                // notify if there is an interest and
                // report completion using asyncWriteCallback callback.
                // 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;
 }
 

Throws:
gov.aps.jca.CAException
See Also:
ProcessVariable.write(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableWriteCallback)


Copyright © 2004-2013 Cosylab. All Rights Reserved.