Package xal.app.knobs

Class KnobElement

  • All Implemented Interfaces:
    xal.tools.data.DataListener

    public class KnobElement
    extends Object
    implements xal.tools.data.DataListener
    Represents a knob element
    • 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
      • 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
      • 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
      • _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
    • Constructor Detail

      • KnobElement

        public KnobElement()
        Constructor
    • Method Detail

      • toString

        public String toString()
        Get the string representation of this element.
        Overrides:
        toString in class Object
        Returns:
        the element's PV
      • 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:
        dataLabel in interface xal.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 references
        adaptor - 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 references
        adaptor - 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:
        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 external storage.
        Specified by:
        write in interface xal.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 coefficient
        notify - 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 coefficient
        notify - 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 function
        notify - 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