Package com.cosylab.epics.caj.cas.util
Class EnumProcessVariable
- java.lang.Object
-
- gov.aps.jca.cas.ProcessVariable
-
- com.cosylab.epics.caj.cas.util.EnumProcessVariable
-
public abstract class EnumProcessVariable extends ProcessVariable
Abstract convenient enumeration 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 EnumProcessVariable(String name, ProcessVariableEventCallback eventCallback)Enum PV constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DBRTypegetType()ReturnDBRType.ENUMtype as native type.CAStatusread(DBR value, ProcessVariableReadCallback asyncReadCallback)CastsDBRtoDBR_TIME_LABELS_Enum, sets labels returned bygetEnumLabels()and delegates operation of reading a value toreadValuemethod.protected abstract CAStatusreadValue(DBR_TIME_LABELS_Enum value, ProcessVariableReadCallback asyncReadCallback)Read value.CAStatuswrite(DBR value, ProcessVariableWriteCallback asyncWriteCallback)CastsDBRtoDBR_Enumand delegates operation of writing a value towriteValuemethod.protected abstract CAStatuswriteValue(DBR_Enum 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
-
EnumProcessVariable
public EnumProcessVariable(String name, ProcessVariableEventCallback eventCallback)
Enum PV constructor.- Parameters:
name- process variable name.eventCallback- event callback, can benull.
-
-
Method Detail
-
getType
public DBRType getType()
ReturnDBRType.ENUMtype 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_LABELS_Enum, sets labels returned bygetEnumLabels()and 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_LABELS_Enum 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 enumValue.setStatus(Status.\<status\>); enumValue.setSeverity(Severity.\<severity\>); // set timestamp enumValue.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 short[] arrayValue = value.getEnumValue(); int elementCount = Math.min(\<fromShortArray\>.length, arrayValue.length); System.arraycopy(\<fromShortArray\>, 0, arrayValue, 0, elementCount); // return read completion status return CAStatus.NORMAL;}
-
write
public CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
CastsDBRtoDBR_Enumand 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_Enum 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 = value.getEnumValue()[0]; // notify, set appropirate Monitor mask (VALUE, LOG, ALARM) if (status == CAStatus.NORMAL && interest) { DBR monitorDBR = AbstractCASResponseHandler.createDBRforReading(this); ((DBR_Enum) monitorDBR).getEnumValue()[0] = this.value; // set labels ((LABELS) monitorDBR).setLabels(getEnumLabels()); // set status, severity and time here (see readValue method // example) fillInStatusAndTime((TIME) monitorDBR); eventCallback.postEvent(Monitor.VALUE | Monitor.LOG, value); } // return read completion status return CAStatus.NORMAL;}
-
-