Class CounterProcessVariable
- java.lang.Object
-
- gov.aps.jca.cas.ProcessVariable
-
- com.cosylab.epics.caj.cas.util.NumericProcessVariable
-
- 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 atstartValueincrementing byincrementValueeveryperiodInMSmilliseconds. When counter value richesenvValuecounter is reset tostartValue. Implementation also triggers alarms (seting status and severity) regarding to set warning and alarm limits.- Author:
- msekoranja
-
-
Field Summary
Fields Modifier and Type Field Description protected intendValueCounter end (stop) value.protected intincrementValueIncrement value (counter stepping).protected NumberlowerAlarmValueLower alarm value.protected NumberlowerControlValueLower control value (= start value).protected NumberlowerDisplayValueLower display value (= start value).protected NumberlowerWarningValueLower warning value.protected intperiodInMSPeriod between value increments.protected SeverityseverityValue status severity.protected intstartValueCounter start value.protected StatusstatusValue status.protected TimeStamptimestampTimestamp of last value change.protected NumberupperAlarmValueUpper alarm value.protected NumberupperControlValueUpper control value (= end value).protected NumberupperDisplayValueUpper display value (= end value).protected NumberupperWarningValueUpper warning value.protected intvalueCounter value.-
Fields inherited from class gov.aps.jca.cas.ProcessVariable
ackS, ackT, channelCount, eventCallback, interest, name
-
-
Constructor Summary
Constructors Constructor Description CounterProcessVariable(String name, 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckForAlarms()Checks for alarms (setsstatusandseverity).protected voidfillInStatusAndTime(TIME timeDBR)Fill-in status and time to DBR.NumbergetLowerAlarmLimit()Get lower alarm limit.NumbergetLowerCtrlLimit()Get lower control limit.NumbergetLowerDispLimit()Get lower display limit.NumbergetLowerWarningLimit()Get lower warning limit.DBRTypegetType()ReturnDBRType.INTtype as native type.StringgetUnits()Get units.NumbergetUpperAlarmLimit()Get upper alarm limit.NumbergetUpperCtrlLimit()Get upper control limit.NumbergetUpperDispLimit()Get upper display limit.NumbergetUpperWarningLimit()Get upper warning limit.protected voidinitialize()Initialize PV.protected CAStatusreadValue(DBR value, ProcessVariableReadCallback asyncReadCallback)Read value.voidrun()Couting (external trigger) is done in this separate thread.protected CAStatuswriteValue(DBR value, 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
-
-
-
-
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 TimeStamp timestamp
Timestamp of last value change.
-
status
protected Status status
Value status.
-
severity
protected Severity severity
Value status severity.
-
-
Constructor Detail
-
CounterProcessVariable
public CounterProcessVariable(String name, 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 (setsstatusandseverity).
-
getType
public DBRType getType()
ReturnDBRType.INTtype as native type.- Specified by:
getTypein classProcessVariable- Returns:
- best type for clients.
- See Also:
ProcessVariable.getType()
-
getLowerAlarmLimit
public Number getLowerAlarmLimit()
Description copied from class:NumericProcessVariableGet lower alarm limit. Default implementation, returns zero.- Overrides:
getLowerAlarmLimitin classNumericProcessVariable- Returns:
- lower alarm limit,
non-null. - See Also:
NumericProcessVariable.getLowerAlarmLimit()
-
getLowerCtrlLimit
public Number getLowerCtrlLimit()
Description copied from class:NumericProcessVariableGet lower control limit. Default implementation, returns zero.- Overrides:
getLowerCtrlLimitin classNumericProcessVariable- Returns:
- lower control limit,
non-null. - See Also:
NumericProcessVariable.getLowerCtrlLimit()
-
getLowerDispLimit
public Number getLowerDispLimit()
Description copied from class:NumericProcessVariableGet lower display limit. Default implementation, returns zero.- Overrides:
getLowerDispLimitin classNumericProcessVariable- Returns:
- lower display limit,
non-null. - See Also:
NumericProcessVariable.getLowerDispLimit()
-
getLowerWarningLimit
public Number getLowerWarningLimit()
Description copied from class:NumericProcessVariableGet lower warning limit. Default implementation, returns zero.- Overrides:
getLowerWarningLimitin classNumericProcessVariable- Returns:
- lower warning limit,
non-null. - See Also:
NumericProcessVariable.getLowerWarningLimit()
-
getUnits
public String getUnits()
Description copied from class:NumericProcessVariableGet units. Default implementation, returns empty string.- Overrides:
getUnitsin classNumericProcessVariable- Returns:
- get units,
non-null. - See Also:
NumericProcessVariable.getUnits()
-
getUpperAlarmLimit
public Number getUpperAlarmLimit()
Description copied from class:NumericProcessVariableGet upper alarm limit. Default implementation, returns zero.- Overrides:
getUpperAlarmLimitin classNumericProcessVariable- Returns:
- upper alarm limit,
non-null. - See Also:
NumericProcessVariable.getUpperAlarmLimit()
-
getUpperCtrlLimit
public Number getUpperCtrlLimit()
Description copied from class:NumericProcessVariableGet upper control limit. Default implementation, returns zero.- Overrides:
getUpperCtrlLimitin classNumericProcessVariable- Returns:
- upper control limit,
non-null. - See Also:
NumericProcessVariable.getUpperCtrlLimit()
-
getUpperDispLimit
public Number getUpperDispLimit()
Description copied from class:NumericProcessVariableGet upper display limit. Default implementation, returns zero.- Overrides:
getUpperDispLimitin classNumericProcessVariable- Returns:
- upper display limit,
non-null. - See Also:
NumericProcessVariable.getUpperDispLimit()
-
getUpperWarningLimit
public Number getUpperWarningLimit()
Description copied from class:NumericProcessVariableGet upper warning limit. Default implementation, returns zero.- Overrides:
getUpperWarningLimitin classNumericProcessVariable- Returns:
- upper warning limit,
non-null. - See Also:
NumericProcessVariable.getUpperWarningLimit()
-
readValue
protected CAStatus readValue(DBR value, ProcessVariableReadCallback asyncReadCallback) throws CAException
Read value. DBR is already filled-in bycom.cosylab.epics.caj.cas.util.NumericProcessVariable#read()method.- Specified by:
readValuein classNumericProcessVariable- Throws:
CAException- See Also:
NumericProcessVariable.readValue(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableReadCallback)
-
fillInStatusAndTime
protected void fillInStatusAndTime(TIME timeDBR)
Fill-in status and time to DBR.- Parameters:
timeDBR- DBR to fill-in.
-
writeValue
protected CAStatus writeValue(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException
Write value.- Specified by:
writeValuein classNumericProcessVariable- Throws:
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:
runin interfaceRunnable- See Also:
Runnable.run()
-
-