Package xal.app.knobs

Class Knob

    • Field Detail

      • 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 channels
        adaptor - 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:
        dataLabel in interface xal.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:
        update in interface xal.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:
        write in interface xal.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
        Overrides:
        toString in class Object
        Returns:
        this knob's name
      • compareTo

        public int compareTo​(Knob knob)
        Compare two instances. The comparison is based on alphebetical sorting of the label.
        Specified by:
        compareTo in interface Comparable<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:
        channelChanged in interface KnobElementListener