Package com.cosylab.epics.caj.cas.util
Class StringProcessVariable
- java.lang.Object
-
- gov.aps.jca.cas.ProcessVariable
-
- com.cosylab.epics.caj.cas.util.StringProcessVariable
-
public abstract class StringProcessVariable extends 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
Constructors Constructor Description StringProcessVariable(String name, ProcessVariableEventCallback eventCallback)String PV constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DBRTypegetType()ReturnDBRType.STRINGtype as native type.CAStatusread(DBR value, ProcessVariableReadCallback asyncReadCallback)CastsDBRtoDBR_TIME_Stringand delegates operation of reading a value toreadValuemethod.protected abstract CAStatusreadValue(DBR_TIME_String value, ProcessVariableReadCallback asyncReadCallback)Read value.CAStatuswrite(DBR value, ProcessVariableWriteCallback asyncWriteCallback)CastsDBRtoDBR_Stringand delegates operation of writing a value towriteValuemethod.protected abstract CAStatuswriteValue(DBR_String value, 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
-
-
-
-
Constructor Detail
-
StringProcessVariable
public StringProcessVariable(String name, ProcessVariableEventCallback eventCallback)
String PV constructor.- Parameters:
name- process variable name.eventCallback- event callback, can benull.
-
-
Method Detail
-
getType
public DBRType getType()
ReturnDBRType.STRINGtype as native type.- Specified by:
getTypein classProcessVariable- Returns:
- best type for clients.
- See Also:
ProcessVariable.getType()
-
read
public CAStatus read(DBR value, ProcessVariableReadCallback asyncReadCallback) throws CAException
CastsDBRtoDBR_TIME_Stringand delegates operation of reading a value toreadValuemethod.- 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- See Also:
ProcessVariable.read(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableReadCallback)
-
readValue
protected abstract CAStatus readValue(DBR_TIME_String 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(gov.aps.jca.dbr.Status); value.setSeverity(gov.aps.jca.dbr.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(\<fromStringArray\>.length, arrayValue.length); System.arraycopy(\<fromStringArray\>, 0, arrayValue, 0, elementCount); // return read completion status return CAStatus.NORMAL;}
-
write
public CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
CastsDBRtoDBR_Stringand delegates operation of writing a value towriteValuemethod.- 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- See Also:
ProcessVariable.write(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableWriteCallback)
-
writeValue
protected abstract CAStatus writeValue(DBR_String 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 (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;}
-
-