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

java.lang.Object
  extended by gov.aps.jca.cas.ProcessVariable
      extended by com.cosylab.epics.caj.cas.util.StringProcessVariable

public abstract class StringProcessVariable
extends gov.aps.jca.cas.ProcessVariable

Abstract convenient string process variable implementation.


Field Summary
 
Fields inherited from class gov.aps.jca.cas.ProcessVariable
ackS, ackT, channelCount, eventCallback, interest, name
 
Constructor Summary
StringProcessVariable(String name, gov.aps.jca.cas.ProcessVariableEventCallback eventCallback)
          String PV constructor.
 
Method Summary
 gov.aps.jca.dbr.DBRType getType()
          Return DBRType.STRING type as native type.
 gov.aps.jca.CAStatus read(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
          Casts DBR to DBR_TIME_String and delegates operation of reading a value to readValue method.
protected abstract  gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR_TIME_String 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)
          Casts DBR to DBR_String and delegates operation of writing a value to writeValue method.
protected abstract  gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR_String 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, 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

StringProcessVariable

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

Parameters:
name - process variable name.
eventCallback - event callback, can be null.
Method Detail

getType

public gov.aps.jca.dbr.DBRType getType()
Return DBRType.STRING type as native type.

Specified by:
getType in class gov.aps.jca.cas.ProcessVariable
See Also:
ProcessVariable.getType()

read

public gov.aps.jca.CAStatus read(gov.aps.jca.dbr.DBR value,
                                 gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
                          throws gov.aps.jca.CAException
Casts DBR to DBR_TIME_String and delegates operation of reading a value to readValue method.

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

readValue

protected abstract gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR_TIME_String 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)
                // given DBR has already allocated an array of elements client has requested
                // it contains maximum number of elements to fill
                String[] arrayValue = value.getStringValue();
                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
Casts DBR to DBR_String and delegates operation of writing a value to writeValue method.

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

writeValue

protected abstract gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR_String 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 (scalar example)
      this.value = ((DBR_String)value).getStringValue()[0];
 
            // notify, set appropirate Monitor mask (VALUE, LOG, ALARM)
            if (status == CAStatus.NORMAL && interest)
      {
                        DBR monitorDBR = AbstractCASResponseHandler.createDBRforReading(this);
                        ((DBR_String)monitorDBR).getStringValue()[0] = this.value;
                        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.