Package xal.app.knobs
Class Knob
- java.lang.Object
-
- xal.app.knobs.Knob
-
- All Implemented Interfaces:
Comparable<Knob>,KnobElementListener,xal.tools.data.DataListener
public class Knob extends Object implements Comparable<Knob>, KnobElementListener, xal.tools.data.DataListener
Knob of PVs
-
-
Field Summary
Fields Modifier and Type Field Description protected xal.smf.Accelerator_acceleratoracceleratorprotected double_currentSettingthis knob's current settingprotected List<KnobElement>_elementslist of knob elementsprotected String[]_functionTypeslist possible element functions typesprotected long_idunique identifier of this knobprotected boolean_limitsNeedUpdatedirty flag indicating whether limits need to be recalculatedprotected double_lowerLimitthe minimum possible knob settingprotected String_namethe name for this knobprotected double_upperLimitthe maximum possible knob settingprotected KnobsMessageListenerBOARD_PROXYProxy for posting messages to the message boardstatic StringDATA_LABELThe DataAdaptor labelprotected KnobListenerEVENT_PROXYThe proxy for posting KnobListener eventsprotected xal.tools.messaging.MessageCenterMESSAGE_CENTERThe message center for this knob's originated eventsprotected ObjectPUBLISH_LOCKlock to block setting values until any previous value was published successfully
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElement()Instantiate an empty element and add it to this knobvoidaddElement(KnobElement element)Add the specified element to this knob.voidaddKnobListener(KnobListener listener)Add a listener of Knob events from this instancevoidaddOffset(double offset)Offset this knob's current value by the specified amount.protected voidcalculateLimits()Calculate the knob value limitsvoidcalculateLimitsIfNeeded()Calculate limits if they need updatingvoidchannelChanged(KnobElement element, xal.ca.Channel channel)event indicating that the knob element's channel has changedvoidcoefficientAChanged(KnobElement element, double coefficientA)event indicating that the element's coefficient has changedvoidcoefficientBChanged(KnobElement element, double coefficientB)event indicating that the element's coefficient has changedintcompareTo(Knob knob)Compare two instances.voidconnectionChanged(KnobElement element, boolean isConnected)connection changed eventStringdataLabel()Provides the name used to identify the class in a persistent storage.voidfunctionChanged(KnobElement element, String function)event indicating that the element's function has changedxal.smf.AcceleratorgetAccelerator()Get the accelerator.doublegetCurrentSetting()Get the current value setting.intgetElementCount()Get the number of elements.List<KnobElement>getElements()Get the list of knob elements.longgetID()Get this knob's unique ID.StringgetInactiveExcuse()Determine the reason for not being ready.static KnobgetInstance(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)Get a knob built from a data adaptordoublegetLowerLimit()Get the lower limitStringgetName()Get the name to display identifying this knobdoublegetUpperLimit()Get the upper limitbooleanhasElements()Determine if this knob has any elements.booleanisReady()Determine if this knob is connected and ready to be used (each element must have a live value).booleanisSetOperationPending()Determine if the current set operation is pending.booleanisTracking()Determine if this knob's elements are tracking.booleanlimitsNeedUpdate()Determine if limits need updatingvoidmakeProportionalCoefficients()make the element coefficients equal to their values and set the knob value to 1.0voidreadyStateChanged(KnobElement element, boolean isReady)ready state changedvoidremoveElement(KnobElement element)Remove the specified element from this knob.voidremoveKnobListener(KnobListener listener)Remove a listener of Knob events from this instancevoidresync()Synchronize each elementvoidsetAccelerator(xal.smf.Accelerator accelerator)Set the acceleratorvoidsetCurrentSetting(double value)Set the current setting to the specified value without changing any of the element valuesvoidsetLimitsNeedUpdating()Indicate that the limits need to be updatedvoidsetName(String name)Set the name of this knobvoidsetValue(double value)Set this knob's current value to the specified value.StringtoString()Get the string representation of this instancevoidupdate(xal.tools.data.DataAdaptor adaptor)Update the data based on the given adaptor.voidvalueChanged(KnobElement element, double value)value changed eventvoidvalueSettingPublished(KnobElement element)value setting publishedvoidwrite(xal.tools.data.DataAdaptor adaptor)Write the data to the adaptor for persistent storage.voidzero()Set the reading to zero
-
-
-
Field Detail
-
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
The message center for this knob's originated events
-
EVENT_PROXY
protected final KnobListener EVENT_PROXY
The proxy for posting KnobListener events
-
BOARD_PROXY
protected final KnobsMessageListener BOARD_PROXY
Proxy for posting messages to the message board
-
_name
protected String _name
the name for this knob
-
_id
protected long _id
unique identifier of this knob
-
_elements
protected final List<KnobElement> _elements
list of knob elements
-
_currentSetting
protected double _currentSetting
this knob's current setting
-
_lowerLimit
protected double _lowerLimit
the minimum possible knob setting
-
_upperLimit
protected double _upperLimit
the maximum possible knob setting
-
_functionTypes
protected final String[] _functionTypes
list possible element functions types
-
_limitsNeedUpdate
protected volatile boolean _limitsNeedUpdate
dirty flag indicating whether limits need to be recalculated
-
PUBLISH_LOCK
protected final Object PUBLISH_LOCK
lock to block setting values until any previous value was published successfully
-
_accelerator
protected xal.smf.Accelerator _accelerator
accelerator
-
-
Constructor Detail
-
Knob
public Knob(long ID, String name)Primary Constructor
-
-
Method Detail
-
getInstance
public static Knob getInstance(xal.smf.Accelerator accelerator, xal.tools.data.DataAdaptor adaptor)
Get a knob built from a data adaptor- Parameters:
accelerator- the accelerator from which to get nodes and their channelsadaptor- The data adaptor for generating the instance- Returns:
- a new instance of Knob built from the adaptor
-
dataLabel
public String dataLabel()
Provides the name used to identify the class in a persistent storage.- Specified by:
dataLabelin interfacexal.tools.data.DataListener- Returns:
- The tag for this 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 persistent storage.- Specified by:
writein interfacexal.tools.data.DataListener- Parameters:
adaptor- The data adaptor corresponding to this object's data node.
-
addKnobListener
public void addKnobListener(KnobListener listener)
Add a listener of Knob events from this instance- Parameters:
listener- The new listener to add
-
removeKnobListener
public void removeKnobListener(KnobListener listener)
Remove a listener of Knob events from this instance- Parameters:
listener- The listener to remove
-
getID
public long getID()
Get this knob's unique ID.- Returns:
- this knob's unique ID
-
getName
public String getName()
Get the name to display identifying this knob- Returns:
- this knob's display name
-
setName
public void setName(String name)
Set the name of this knob- Parameters:
name- the name to set for this knob
-
setAccelerator
public void setAccelerator(xal.smf.Accelerator accelerator)
Set the accelerator- Parameters:
accelerator- the accelerator to use
-
getAccelerator
public xal.smf.Accelerator getAccelerator()
Get the accelerator.- Returns:
- the accelerator
-
addOffset
public void addOffset(double offset)
Offset this knob's current value by the specified amount.- Parameters:
offset- the new offset
-
isReady
public boolean isReady()
Determine if this knob is connected and ready to be used (each element must have a live value).- Returns:
- true if all of this knob's elements are ready
-
getInactiveExcuse
public String getInactiveExcuse()
Determine the reason for not being ready.- Returns:
- the excuse for not being ready
-
getCurrentSetting
public double getCurrentSetting()
Get the current value setting.- Returns:
- the current value setting
-
setCurrentSetting
public void setCurrentSetting(double value)
Set the current setting to the specified value without changing any of the element values
-
zero
public void zero()
Set the reading to zero
-
makeProportionalCoefficients
public void makeProportionalCoefficients()
make the element coefficients equal to their values and set the knob value to 1.0
-
setValue
public void setValue(double value)
Set this knob's current value to the specified value.- Parameters:
value- the target setting
-
isTracking
public boolean isTracking()
Determine if this knob's elements are tracking.- Returns:
- true if they are all tracking and false if any one of them is not tracking.
-
isSetOperationPending
public boolean isSetOperationPending()
Determine if the current set operation is pending.- Returns:
- true if the current set operation is pending and false if not
-
resync
public void resync()
Synchronize each element
-
getLowerLimit
public double getLowerLimit()
Get the lower limit- Returns:
- the lower limit
-
getUpperLimit
public double getUpperLimit()
Get the upper limit- Returns:
- the upper limit
-
limitsNeedUpdate
public boolean limitsNeedUpdate()
Determine if limits need updating
-
setLimitsNeedUpdating
public void setLimitsNeedUpdating()
Indicate that the limits need to be updated
-
calculateLimitsIfNeeded
public void calculateLimitsIfNeeded()
Calculate limits if they need updating
-
calculateLimits
protected void calculateLimits()
Calculate the knob value limits
-
getElements
public List<KnobElement> getElements()
Get the list of knob elements.- Returns:
- this knob's list of elements
-
getElementCount
public int getElementCount()
Get the number of elements.- Returns:
- the number of elements
-
hasElements
public boolean hasElements()
Determine if this knob has any elements.- Returns:
- true if this knob has elements and false if not
-
addElement
public void addElement(KnobElement element)
Add the specified element to this knob.- Parameters:
element- the element to add
-
addElement
public void addElement()
Instantiate an empty element and add it to this knob
-
removeElement
public void removeElement(KnobElement element)
Remove the specified element from this knob.- Parameters:
element- the element to remove
-
toString
public String toString()
Get the string representation of this instance
-
compareTo
public int compareTo(Knob knob)
Compare two instances. The comparison is based on alphebetical sorting of the label.- Specified by:
compareToin interfaceComparable<Knob>- Parameters:
knob- the other knob against which to compare- Returns:
- a positive number if this comes after the argument, negative if this comes before and 0 if they are equal
-
channelChanged
public void channelChanged(KnobElement element, xal.ca.Channel channel)
event indicating that the knob element's channel has changed- Specified by:
channelChangedin interfaceKnobElementListener
-
coefficientAChanged
public void coefficientAChanged(KnobElement element, double coefficientA)
event indicating that the element's coefficient has changed- Specified by:
coefficientAChangedin interfaceKnobElementListener
-
coefficientBChanged
public void coefficientBChanged(KnobElement element, double coefficientB)
event indicating that the element's coefficient has changed- Specified by:
coefficientBChangedin interfaceKnobElementListener
-
functionChanged
public void functionChanged(KnobElement element, String function)
event indicating that the element's function has changed- Specified by:
functionChangedin interfaceKnobElementListener
-
connectionChanged
public void connectionChanged(KnobElement element, boolean isConnected)
connection changed event- Specified by:
connectionChangedin interfaceKnobElementListener
-
readyStateChanged
public void readyStateChanged(KnobElement element, boolean isReady)
ready state changed- Specified by:
readyStateChangedin interfaceKnobElementListener
-
valueChanged
public void valueChanged(KnobElement element, double value)
value changed event- Specified by:
valueChangedin interfaceKnobElementListener
-
valueSettingPublished
public void valueSettingPublished(KnobElement element)
value setting published- Specified by:
valueSettingPublishedin interfaceKnobElementListener
-
-