Package xal.app.knobs
Class KnobElement
- java.lang.Object
-
- xal.app.knobs.KnobElement
-
- All Implemented Interfaces:
xal.tools.data.DataListener
public class KnobElement extends Object implements xal.tools.data.DataListener
Represents a knob element
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classKnobElement.CALimitsHandlerCA limits handlerprotected classKnobElement.ConnectionHandlerConnection handlerprotected classKnobElement.CustomLimitsHandlerCustom limits handlerprotected static interfaceKnobElement.LimitsHandlerHandle limitsprotected classKnobElement.MonitorHandlerMonitor handlerprotected classKnobElement.PutHandlerPut handler
-
Field Summary
Fields Modifier and Type Field Description protected xal.ca.Channel_channelthe channel whose setting is tracked/changed as the knob changesprotected double_coefficientAthe knob coefficient for this elementprotected double_coefficientBthe knob coefficient for this elementprotected String_functionthe knob function for this elementprotected String[]_functionTypeslist possible element functions typesprotected double_initialValuethe cannel initial valueprotected boolean_isPutPendingspecifies whether a put operation is currently pendingprotected Date_lastMonitorTimewall clock time when the last monitor event was receivedprotected Date_lastSettingTimewall clock time when the setting was last changedprotected double_latestValuelatest value from either the monitor or the settingprotected KnobElement.LimitsHandler_limitsHandlerthe handler of lower and upper limitsprotected double_lowerLimitlower limitprotected xal.ca.Monitor_monitorthe channel monitorprotected double_monitoredValuelatest value from the monitorprotected xal.smf.NodeChannelRef_nodeChannelRefan optional node channel reference which identifies the channel with respect to a nodeprotected double_settingValuelatest setting valueprotected double_upperLimitupper limitprotected KnobElement.CALimitsHandlerCA_LIMITS_HANDLERmonitor limits from channel accessprotected KnobElement.ConnectionHandlerCONNECTION_HANDLERhandles connection eventsprotected KnobElement.CustomLimitsHandlerCUSTOM_LIMITS_HANDLERcustom limits handlerstatic StringDATA_LABELThe DataAdaptor labelprotected static doubleDEFAULT_LIMITdefault limitprotected KnobElementListenerEVENT_PROXYforwards events to registered listenersprotected static booleanHAS_DEFAULT_LIMITSindicates if default limits has been suppliedprotected xal.tools.messaging.MessageCenterMESSAGE_CENTERmessage center for posting eventsprotected xal.ca.IEventSinkValueMONITOR_HANDLERhandles monitor eventsprotected xal.ca.PutListenerPUT_HANDLERhandle the channel's put events
-
Constructor Summary
Constructors Constructor Description KnobElement()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKnobElementListener(KnobElementListener listener)Add the specified listener as a receiver of notifications from this element.voidchangeValueAndScale(double value, double delta)Change the element's value and scale it by the element's coefficient.StringdataLabel()dataLabel() provides the name used to identify the class in an external data source.xal.ca.ChannelgetChannel()Get a this element's channelStringgetChannelString()Get a string representation of the channeldoublegetCoefficientA()Get the knob coefficientAdoublegetCoefficientB()Get the knob coefficientBdoublegetEffectiveLowerLimit()Get the effective lower limit of the channel's value.doublegetEffectiveUpperLimit()Get the channel's upper limit.StringgetFunction()Get the knob functionintgetFunctionIndex()Get the knob function indexStringgetInactiveExcuse()Determine the reason for not being ready.static KnobElementgetInstance(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)Instantiate a new KnobElement from the specified adaptordoublegetLatestValue()Get the latest value.doublegetLowerLimit()Get the lower limit of the channel's value.StringgetPV()Get the element's name.doublegetSettingValue()Get the latest value which was set.doublegetUpperLimit()Get the channel's upper limit.booleanisConnected()Determine if this element is connectedbooleanisPutPending()Determine if a put operation is pending.booleanisReady()Determine if this element is ready (i.e.booleanisSettingValueWithinLimits()Determine whether the element's current value is within its limitsprotected booleanisTracking()Determine if this element's setting value is tracking with its monitored value.booleanisUsingCustomLimits()Determine if custom limits are being usedvoidremoveKnobElementListener(KnobElementListener listener)Remove the specified listener from receiving notifications from this element.voidresync()Resynchronize the setting value to the latest monitored valuevoidsetAccelerator(xal.smf.Accelerator accelerator)update the channel reference if any with the new acceleratorvoidsetChannel(xal.ca.Channel channel)Set a new channel for this elementvoidsetCoefficientA(double coefficientA)Set the knob coefficientA.voidsetCoefficientA(double coefficientA, boolean notify)Set the knob coefficientA.voidsetCoefficientB(double coefficientB)Set the knob coefficientB.voidsetCoefficientB(double coefficientB, boolean notify)Set the knob coefficientA.voidsetCustomLowerLimit(double lowerLimit)Set the custom lower limitvoidsetCustomUpperLimit(double upperLimit)Set the custom upper limitvoidsetFunction(int functionIndex)Set the knob function.voidsetFunction(String functionName)Set the knob function.voidsetFunction(String function, boolean notify)Set the knob function.voidsetFunctionType(String[] funcType)Set Function Type.voidsetInitialValue(double initialVal)Set the Initial Value.voidsetNodeChannelRef(xal.smf.NodeChannelRef nodeChannelRef)Set the node channel reference.voidsetPV(String name)Set the element's PV.voidsetUsingCustomLimits(boolean useCustomLimits)Set whether to use custom limits or CA limits.voidsetValue(double value)Set the channel to the value specified wrapping to the limits if configured to do so.voidsetWrapsValueAroundLimits(boolean wrapsAround)Sets whether values wrap around limitsStringtoString()Get the string representation of this element.voidupdate(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)Update the data based on the given adaptor.voidupdate(xal.tools.data.DataAdaptor adaptor)Update the data based on the given adaptor.booleanwrapsValueAroundLimits()Indicates whether this elements wraps the value around the limitsvoidwrite(xal.tools.data.DataAdaptor adaptor)Write the data to the adaptor for external storage.
-
-
-
Field Detail
-
DEFAULT_LIMIT
protected static final double DEFAULT_LIMIT
default limit
-
HAS_DEFAULT_LIMITS
protected static final boolean HAS_DEFAULT_LIMITS
indicates if default limits has been supplied
-
DATA_LABEL
public static final String DATA_LABEL
The DataAdaptor label- See Also:
- Constant Field Values
-
MESSAGE_CENTER
protected final xal.tools.messaging.MessageCenter MESSAGE_CENTER
message center for posting events
-
EVENT_PROXY
protected final KnobElementListener EVENT_PROXY
forwards events to registered listeners
-
CONNECTION_HANDLER
protected final KnobElement.ConnectionHandler CONNECTION_HANDLER
handles connection events
-
MONITOR_HANDLER
protected final xal.ca.IEventSinkValue MONITOR_HANDLER
handles monitor events
-
PUT_HANDLER
protected final xal.ca.PutListener PUT_HANDLER
handle the channel's put events
-
_channel
protected xal.ca.Channel _channel
the channel whose setting is tracked/changed as the knob changes
-
_nodeChannelRef
protected xal.smf.NodeChannelRef _nodeChannelRef
an optional node channel reference which identifies the channel with respect to a node
-
_monitor
protected xal.ca.Monitor _monitor
the channel monitor
-
_coefficientA
protected double _coefficientA
the knob coefficient for this element
-
_coefficientB
protected double _coefficientB
the knob coefficient for this element
-
_function
protected String _function
the knob function for this element
-
_functionTypes
protected String[] _functionTypes
list possible element functions types
-
_initialValue
protected double _initialValue
the cannel initial value
-
_monitoredValue
protected double _monitoredValue
latest value from the monitor
-
_lastMonitorTime
protected Date _lastMonitorTime
wall clock time when the last monitor event was received
-
_settingValue
protected double _settingValue
latest setting value
-
_lastSettingTime
protected Date _lastSettingTime
wall clock time when the setting was last changed
-
_latestValue
protected double _latestValue
latest value from either the monitor or the setting
-
_limitsHandler
protected KnobElement.LimitsHandler _limitsHandler
the handler of lower and upper limits
-
CA_LIMITS_HANDLER
protected final KnobElement.CALimitsHandler CA_LIMITS_HANDLER
monitor limits from channel access
-
CUSTOM_LIMITS_HANDLER
protected final KnobElement.CustomLimitsHandler CUSTOM_LIMITS_HANDLER
custom limits handler
-
_lowerLimit
protected double _lowerLimit
lower limit
-
_upperLimit
protected double _upperLimit
upper limit
-
_isPutPending
protected volatile boolean _isPutPending
specifies whether a put operation is currently pending
-
-
Method Detail
-
toString
public String toString()
Get the string representation of this element.
-
addKnobElementListener
public void addKnobElementListener(KnobElementListener listener)
Add the specified listener as a receiver of notifications from this element.- Parameters:
listener- the listener to be notified
-
removeKnobElementListener
public void removeKnobElementListener(KnobElementListener listener)
Remove the specified listener from receiving notifications from this element.- Parameters:
listener- the listener to remove from receiving notifications
-
dataLabel
public String dataLabel()
dataLabel() provides the name used to identify the class in an external data source.- Specified by:
dataLabelin interfacexal.tools.data.DataListener- Returns:
- The tag for this data node.
-
getInstance
public static KnobElement getInstance(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)
Instantiate a new KnobElement from the specified adaptor- Parameters:
accelerator- the accelerator to use for node channel referencesadaptor- the adaptor from which to instantiate the element- Returns:
- a new knob element
-
update
public void update(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)Update the data based on the given adaptor.- Parameters:
accelerator- the accelerator to use for node channel referencesadaptor- The data adaptor corresponding to this object's data node.
-
update
public void update(xal.tools.data.DataAdaptor adaptor)
Update the data based on the given adaptor.- Specified by:
updatein interfacexal.tools.data.DataListener- Parameters:
adaptor- The data adaptor corresponding to this object's data node.
-
write
public void write(xal.tools.data.DataAdaptor adaptor)
Write the data to the adaptor for external storage.- Specified by:
writein interfacexal.tools.data.DataListener- Parameters:
adaptor- The data adaptor corresponding to this object's data node.
-
setFunctionType
public void setFunctionType(String[] funcType)
Set Function Type.
-
getPV
public String getPV()
Get the element's name.- Returns:
- this element's name
-
setPV
public void setPV(String name)
Set the element's PV.- Parameters:
name- the name for the PV
-
getChannelString
public String getChannelString()
Get a string representation of the channel- Returns:
- a string representation of the channel
-
setNodeChannelRef
public void setNodeChannelRef(xal.smf.NodeChannelRef nodeChannelRef)
Set the node channel reference.- Parameters:
nodeChannelRef- channel reference
-
setAccelerator
public void setAccelerator(xal.smf.Accelerator accelerator)
update the channel reference if any with the new accelerator
-
getChannel
public xal.ca.Channel getChannel()
Get a this element's channel- Returns:
- this element's channel
-
setChannel
public void setChannel(xal.ca.Channel channel)
Set a new channel for this element- Parameters:
channel- the new channel to set
-
setUsingCustomLimits
public void setUsingCustomLimits(boolean useCustomLimits)
Set whether to use custom limits or CA limits.- Parameters:
useCustomLimits- true to use custom limits and false to use CA limits
-
isUsingCustomLimits
public boolean isUsingCustomLimits()
Determine if custom limits are being used- Returns:
- true if custom limits are being used and false if not
-
setCustomLowerLimit
public void setCustomLowerLimit(double lowerLimit)
Set the custom lower limit- Parameters:
lowerLimit- the new custom lower limit
-
setCustomUpperLimit
public void setCustomUpperLimit(double upperLimit)
Set the custom upper limit- Parameters:
upperLimit- the new custom upper limit
-
isConnected
public boolean isConnected()
Determine if this element is connected
-
isReady
public boolean isReady()
Determine if this element is ready (i.e. the channel is connected and we have a new value)
-
isSettingValueWithinLimits
public boolean isSettingValueWithinLimits()
Determine whether the element's current value is within its limits
-
getInactiveExcuse
public String getInactiveExcuse()
Determine the reason for not being ready.- Returns:
- the excuse for not being ready
-
setInitialValue
public void setInitialValue(double initialVal)
Set the Initial Value.- Parameters:
initialVal- initial values of the PV in the knob
-
getCoefficientA
public double getCoefficientA()
Get the knob coefficientA- Returns:
- the knob coefficient
-
setCoefficientA
public void setCoefficientA(double coefficientA)
Set the knob coefficientA.- Parameters:
coefficientA- the new knob coefficient
-
setCoefficientA
public void setCoefficientA(double coefficientA, boolean notify)Set the knob coefficientA.- Parameters:
coefficientA- the new knob coefficientnotify- indicates whether or not to notify listeners
-
getCoefficientB
public double getCoefficientB()
Get the knob coefficientB- Returns:
- the knob coefficient
-
setCoefficientB
public void setCoefficientB(double coefficientB)
Set the knob coefficientB.- Parameters:
coefficientB- the new knob coefficient
-
setCoefficientB
public void setCoefficientB(double coefficientB, boolean notify)Set the knob coefficientA.- Parameters:
coefficientB- the new knob coefficientnotify- indicates whether or not to notify listeners
-
getFunction
public String getFunction()
Get the knob function- Returns:
- the knob function
-
getFunctionIndex
public int getFunctionIndex()
Get the knob function index- Returns:
- the knob function index
-
setFunction
public void setFunction(int functionIndex)
Set the knob function.- Parameters:
functionIndex- the new knob coefficient
-
setFunction
public void setFunction(String functionName)
Set the knob function.- Parameters:
functionName- the new knob coefficient
-
setFunction
public void setFunction(String function, boolean notify)
Set the knob function.- Parameters:
function- the new knob functionnotify- indicates whether or not to notify listeners
-
getLowerLimit
public double getLowerLimit()
Get the lower limit of the channel's value.- Returns:
- the channel's lower value limit
-
getUpperLimit
public double getUpperLimit()
Get the channel's upper limit.- Returns:
- the channel's upper value limit
-
getEffectiveLowerLimit
public double getEffectiveLowerLimit()
Get the effective lower limit of the channel's value.- Returns:
- the channel's lower value limit modified by a factor of 1000 if allows wrapping
-
getEffectiveUpperLimit
public double getEffectiveUpperLimit()
Get the channel's upper limit.- Returns:
- the channel's upper value limit modified by a factor of 1000 if allows wrapping
-
getLatestValue
public double getLatestValue()
Get the latest value.- Returns:
- the value from either the latest setting or the latest monitored value whichever is most current
-
getSettingValue
public double getSettingValue()
Get the latest value which was set.- Returns:
- the latest value which was set
-
isTracking
protected boolean isTracking()
Determine if this element's setting value is tracking with its monitored value.- Returns:
- true if the values are reasonably tracking and false if not
-
isPutPending
public boolean isPutPending()
Determine if a put operation is pending.- Returns:
- true if a put operation is pending and false if all put operations have completed
-
wrapsValueAroundLimits
public boolean wrapsValueAroundLimits()
Indicates whether this elements wraps the value around the limits
-
setWrapsValueAroundLimits
public void setWrapsValueAroundLimits(boolean wrapsAround)
Sets whether values wrap around limits
-
setValue
public void setValue(double value)
Set the channel to the value specified wrapping to the limits if configured to do so.- Parameters:
value- the value for which to set this element
-
resync
public void resync()
Resynchronize the setting value to the latest monitored value
-
changeValueAndScale
public void changeValueAndScale(double value, double delta)Change the element's value and scale it by the element's coefficient.- Parameters:
value- the amount to scale by the coefficient and then change this element's value
-
-