Class NumericProcessVariable

    • Constructor Detail

      • NumericProcessVariable

        public NumericProcessVariable​(String name,
                                      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 CAStatus read​(DBR value,
                             ProcessVariableReadCallback asyncReadCallback)
                      throws CAException
        Description copied from class: ProcessVariable
        Read process variable value. The request is allowed to complete asynchronously.

        The incoming DBR value is always (at least) of type DBR_TIME_[type] where type is of getType(). If DBR_GR_ or DBR_CTRL_ is requested then value is instance of requested type.

        Special cases:
        DBR_TIME_Enum type is "upgraded" to an "artificial" TIME type DBR_TIME_LABELS_Enum. This enables PV to set labels and time.
        DBR_TIME_Double and DBR_TIME_Float are "upgraded" to an "artificial" TIME type which also implements PRECISION interface, DBR_PRECISION_Double and DBR_PRECISION_Float. This enables PV to set precision (-1, by default, means no precision set).

        Specified by:
        read in class ProcessVariable
        Parameters:
        value - value of type (at least) DBR_TIME_ where type is of getType().
        asyncReadCallback - if asynchronous completion is required method should return null and call ProcessVariableReadCallback.processVariableReadCompleted() method.
        Returns:
        CA status, null if request will complete asynchronously by calling method.
        Throws:
        CAException
      • fillInDBR

        public void fillInDBR​(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 CAStatus readValue​(DBR 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(Status.<status>);
         		value.setSeverity(Severity.<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(<fromDoubleArray>.length, arrayValue.length);
         		System.arraycopy(<fromDoubleArray>, 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)
      • write

        public CAStatus write​(DBR value,
                              ProcessVariableWriteCallback asyncWriteCallback)
                       throws CAException
        Description copied from class: ProcessVariable
        Write process variable value. The request is allowed to complete asynchronously. The incoming DBR is always of type getType().
        Specified by:
        write in class ProcessVariable
        Parameters:
        value - value of type getType().
        asyncWriteCallback - if asynchronous completion is required method should return null and call ProcessVariableWriteCallback.processVariableWriteCompleted() method.
        Returns:
        CA status, null if request will complete asynchronously by calling method.
        Throws:
        CAException
      • writeValue

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