com.cosylab.epics.caj.cas.util.examples
Class CounterProcessVariable

java.lang.Object
  extended by gov.aps.jca.cas.ProcessVariable
      extended by com.cosylab.epics.caj.cas.util.NumericProcessVariable
          extended by com.cosylab.epics.caj.cas.util.examples.CounterProcessVariable
All Implemented Interfaces:
Runnable

public class CounterProcessVariable
extends NumericProcessVariable
implements Runnable

Example implementation of process variable - counter. Counter starts counting at startValue incrementing by incrementValue every periodInMS milliseconds. When counter value riches envValue counter is reset to startValue. Implementation also triggers alarms (seting status and severity) regarding to set warning and alarm limits.

Author:
msekoranja

Field Summary
protected  int endValue
          Counter end (stop) value.
protected  int incrementValue
          Increment value (counter stepping).
protected  Number lowerAlarmValue
          Lower alarm value.
protected  Number lowerControlValue
          Lower control value (= start value).
protected  Number lowerDisplayValue
          Lower display value (= start value).
protected  Number lowerWarningValue
          Lower warning value.
protected  int periodInMS
          Period between value increments.
protected  gov.aps.jca.dbr.Severity severity
          Value status severity.
protected  int startValue
          Counter start value.
protected  gov.aps.jca.dbr.Status status
          Value status.
protected  gov.aps.jca.dbr.TimeStamp timestamp
          Timestamp of last value change.
protected  Number upperAlarmValue
          Upper alarm value.
protected  Number upperControlValue
          Upper control value (= end value).
protected  Number upperDisplayValue
          Upper display value (= end value).
protected  Number upperWarningValue
          Upper warning value.
protected  int value
          Counter value.
 
Fields inherited from class gov.aps.jca.cas.ProcessVariable
ackS, ackT, channelCount, eventCallback, interest, name
 
Constructor Summary
CounterProcessVariable(String name, gov.aps.jca.cas.ProcessVariableEventCallback eventCallback, int startValue, int endValue, int incrementValue, int periodInMS, int lowerWarningValue, int upperWarningValue, int lowerAlarmValue, int upperAlarmValue)
          Construct a counter PV instance.
 
Method Summary
protected  void checkForAlarms()
          Checks for alarms (sets status and severity).
protected  void fillInStatusAndTime(gov.aps.jca.dbr.TIME timeDBR)
          Fill-in status and time to DBR.
 Number getLowerAlarmLimit()
          Get lower alarm limit.
 Number getLowerCtrlLimit()
          Get lower control limit.
 Number getLowerDispLimit()
          Get lower display limit.
 Number getLowerWarningLimit()
          Get lower warning limit.
 gov.aps.jca.dbr.DBRType getType()
          Return DBRType.INT type as native type.
 String getUnits()
          Get units.
 Number getUpperAlarmLimit()
          Get upper alarm limit.
 Number getUpperCtrlLimit()
          Get upper control limit.
 Number getUpperDispLimit()
          Get upper display limit.
 Number getUpperWarningLimit()
          Get upper warning limit.
protected  void initialize()
          Initialize PV.
protected  gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
          Read value.
 void run()
          Couting (external trigger) is done in this separate thread.
protected  gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR value, gov.aps.jca.cas.ProcessVariableWriteCallback asyncWriteCallback)
          Write value.
 
Methods inherited from class com.cosylab.epics.caj.cas.util.NumericProcessVariable
fillInDBR, read, write
 
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
 

Field Detail

startValue

protected int startValue
Counter start value.


endValue

protected int endValue
Counter end (stop) value.


incrementValue

protected int incrementValue
Increment value (counter stepping).


periodInMS

protected int periodInMS
Period between value increments.


lowerWarningValue

protected Number lowerWarningValue
Lower warning value.


upperWarningValue

protected Number upperWarningValue
Upper warning value.


lowerAlarmValue

protected Number lowerAlarmValue
Lower alarm value.


upperAlarmValue

protected Number upperAlarmValue
Upper alarm value.


lowerDisplayValue

protected Number lowerDisplayValue
Lower display value (= start value).


upperDisplayValue

protected Number upperDisplayValue
Upper display value (= end value).


lowerControlValue

protected Number lowerControlValue
Lower control value (= start value).


upperControlValue

protected Number upperControlValue
Upper control value (= end value).


value

protected int value
Counter value.


timestamp

protected gov.aps.jca.dbr.TimeStamp timestamp
Timestamp of last value change.


status

protected gov.aps.jca.dbr.Status status
Value status.


severity

protected gov.aps.jca.dbr.Severity severity
Value status severity.

Constructor Detail

CounterProcessVariable

public CounterProcessVariable(String name,
                              gov.aps.jca.cas.ProcessVariableEventCallback eventCallback,
                              int startValue,
                              int endValue,
                              int incrementValue,
                              int periodInMS,
                              int lowerWarningValue,
                              int upperWarningValue,
                              int lowerAlarmValue,
                              int upperAlarmValue)
Construct a counter PV instance.

Parameters:
name - PV name.
eventCallback - event callback, where to report value change events.
startValue - counter start value, where to start counting.
endValue - counter end value, where to stop counting.
incrementValue - counter increment value, count steps.
periodInMS - period in milliseconds between two increments.
lowerWarningValue - lower warning limit value.
upperWarningValue - upper warning limit value.
lowerAlarmValue - lower alarm limit value.
upperAlarmValue - upper alarm limit value.
Method Detail

initialize

protected void initialize()
Initialize PV. Sets initial counter state and spawns a counter thread.


checkForAlarms

protected void checkForAlarms()
Checks for alarms (sets status and severity).


getType

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

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

getLowerAlarmLimit

public Number getLowerAlarmLimit()
Description copied from class: NumericProcessVariable
Get lower alarm limit. Default implementation, returns zero.

Overrides:
getLowerAlarmLimit in class NumericProcessVariable
Returns:
lower alarm limit, non-null.
See Also:
NumericProcessVariable.getLowerAlarmLimit()

getLowerCtrlLimit

public Number getLowerCtrlLimit()
Description copied from class: NumericProcessVariable
Get lower control limit. Default implementation, returns zero.

Overrides:
getLowerCtrlLimit in class NumericProcessVariable
Returns:
lower control limit, non-null.
See Also:
NumericProcessVariable.getLowerCtrlLimit()

getLowerDispLimit

public Number getLowerDispLimit()
Description copied from class: NumericProcessVariable
Get lower display limit. Default implementation, returns zero.

Overrides:
getLowerDispLimit in class NumericProcessVariable
Returns:
lower display limit, non-null.
See Also:
NumericProcessVariable.getLowerDispLimit()

getLowerWarningLimit

public Number getLowerWarningLimit()
Description copied from class: NumericProcessVariable
Get lower warning limit. Default implementation, returns zero.

Overrides:
getLowerWarningLimit in class NumericProcessVariable
Returns:
lower warning limit, non-null.
See Also:
NumericProcessVariable.getLowerWarningLimit()

getUnits

public String getUnits()
Description copied from class: NumericProcessVariable
Get units. Default implementation, returns empty string.

Overrides:
getUnits in class NumericProcessVariable
Returns:
get units, non-null.
See Also:
NumericProcessVariable.getUnits()

getUpperAlarmLimit

public Number getUpperAlarmLimit()
Description copied from class: NumericProcessVariable
Get upper alarm limit. Default implementation, returns zero.

Overrides:
getUpperAlarmLimit in class NumericProcessVariable
Returns:
upper alarm limit, non-null.
See Also:
NumericProcessVariable.getUpperAlarmLimit()

getUpperCtrlLimit

public Number getUpperCtrlLimit()
Description copied from class: NumericProcessVariable
Get upper control limit. Default implementation, returns zero.

Overrides:
getUpperCtrlLimit in class NumericProcessVariable
Returns:
upper control limit, non-null.
See Also:
NumericProcessVariable.getUpperCtrlLimit()

getUpperDispLimit

public Number getUpperDispLimit()
Description copied from class: NumericProcessVariable
Get upper display limit. Default implementation, returns zero.

Overrides:
getUpperDispLimit in class NumericProcessVariable
Returns:
upper display limit, non-null.
See Also:
NumericProcessVariable.getUpperDispLimit()

getUpperWarningLimit

public Number getUpperWarningLimit()
Description copied from class: NumericProcessVariable
Get upper warning limit. Default implementation, returns zero.

Overrides:
getUpperWarningLimit in class NumericProcessVariable
Returns:
upper warning limit, non-null.
See Also:
NumericProcessVariable.getUpperWarningLimit()

readValue

protected gov.aps.jca.CAStatus readValue(gov.aps.jca.dbr.DBR value,
                                         gov.aps.jca.cas.ProcessVariableReadCallback asyncReadCallback)
                                  throws gov.aps.jca.CAException
Read value. DBR is already filled-in by com.cosylab.epics.caj.cas.util.NumericProcessVariable#read() method.

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

fillInStatusAndTime

protected void fillInStatusAndTime(gov.aps.jca.dbr.TIME timeDBR)
Fill-in status and time to DBR.

Parameters:
timeDBR - DBR to fill-in.

writeValue

protected gov.aps.jca.CAStatus writeValue(gov.aps.jca.dbr.DBR value,
                                          gov.aps.jca.cas.ProcessVariableWriteCallback asyncWriteCallback)
                                   throws gov.aps.jca.CAException
Write value.

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

run

public void run()
Couting (external trigger) is done in this separate thread.

Specified by:
run in interface Runnable
See Also:
Runnable.run()


Copyright © 2004-2013 Cosylab. All Rights Reserved.