Class StringProcessVariable


  • public abstract class StringProcessVariable
    extends ProcessVariable
    Abstract convenient string process variable implementation.
    • Constructor Detail

      • StringProcessVariable

        public StringProcessVariable​(String name,
                                     ProcessVariableEventCallback eventCallback)
        String PV constructor.
        Parameters:
        name - process variable name.
        eventCallback - event callback, can be null.
    • Method Detail

      • readValue

        protected abstract CAStatus readValue​(DBR_TIME_String value,
                                              ProcessVariableReadCallback asyncReadCallback)
                                       throws 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(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;
              
                } 
         
         
        Throws:
        CAException
        See Also:
        ProcessVariable.read(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableReadCallback)
      • writeValue

        protected abstract CAStatus writeValue​(DBR_String value,
                                               ProcessVariableWriteCallback asyncWriteCallback)
                                        throws 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:
        CAException
        See Also:
        ProcessVariable.write(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableWriteCallback)