Class DefaultMaleAnalogExpressionSocket

java.lang.Object
jmri.jmrit.logixng.implementation.AbstractMaleSocket
jmri.jmrit.logixng.implementation.DefaultMaleAnalogExpressionSocket
All Implemented Interfaces:
Comparable<NamedBean>, PropertyChangeProvider, AnalogExpression, AnalogExpressionBean, Base, Debugable, MaleAnalogExpressionSocket, MaleSocket, NamedBean

Every AnalogExpressionBean has an DefaultMaleAnalogExpressionSocket as its parent.
  • Constructor Details

  • Method Details

    • getTriggerOnChange

      public boolean getTriggerOnChange()
      Get whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.
      Specified by:
      getTriggerOnChange in interface AnalogExpression
      Returns:
      true if trigger on change, false otherwise
    • setTriggerOnChange

      public void setTriggerOnChange(boolean triggerOnChange)
      Set whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.
      Specified by:
      setTriggerOnChange in interface AnalogExpression
      Parameters:
      triggerOnChange - true if trigger on change, false otherwise
    • evaluate

      public double evaluate() throws JmriException
      Evaluate this expression.

      This method must ensure that the result is not a Double.NaN, negative infinity or positive infinity. If that is the case, it must throw an IllegalArgumentException before checking if an error has occured.

      If the socket is not enabled, the method returns the value 0.0f.

      If an error occurs and are handled, the method returns the value 0.0f.

      Specified by:
      evaluate in interface AnalogExpression
      Specified by:
      evaluate in interface MaleAnalogExpressionSocket
      Returns:
      the result of the evaluation. The male socket that holds this expression throws an exception if this value is a Double.NaN or an infinite number.
      Throws:
      JmriException - when an exception occurs
    • getState

      public int getState()
      Description copied from interface: NamedBean
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.

      Specified by:
      getState in interface NamedBean
      Returns:
      the state
    • getDisplayName

      Description copied from interface: NamedBean
      Get user name if it exists, otherwise return System name.
      Specified by:
      getDisplayName in interface NamedBean
      Returns:
      the user name or system-specific name
    • disposeMe

      public void disposeMe()
      Description copied from class: AbstractMaleSocket
      Disposes this object. This must remove _all_ connections!
      Specified by:
      disposeMe in class AbstractMaleSocket
    • registerListenersForThisClass

      Register listeners if this object needs that.
      Specified by:
      registerListenersForThisClass in class AbstractMaleSocket
    • unregisterListenersForThisClass

      Register listeners if this object needs that.
      Specified by:
      unregisterListenersForThisClass in class AbstractMaleSocket
    • setState

      public void setState(int s) throws JmriException
      Description copied from interface: NamedBean
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.

      Specified by:
      setState in interface NamedBean
      Parameters:
      s - the state
      Throws:
      JmriException - general error when setting the state fails
    • describeState

      public String describeState(int state)
      Description copied from interface: NamedBean
      Provide human-readable, localized version of state value.

      This method is intended for use when presenting to a human operator.

      Specified by:
      describeState in interface NamedBean
      Parameters:
      state - the state to describe
      Returns:
      the state in localized form
    • getComment

      public String getComment()
      Description copied from interface: Base
      Get associated comment text. A LogixNG comment can have multiple lines, separated with \n.
      Specified by:
      getComment in interface Base
      Specified by:
      getComment in interface NamedBean
      Overrides:
      getComment in class AbstractMaleSocket
      Returns:
      the comment or null
    • setComment

      public void setComment(String comment)
      Description copied from interface: Base
      Set associated comment text.

      Comments can be any valid text.

      Specified by:
      setComment in interface Base
      Specified by:
      setComment in interface NamedBean
      Overrides:
      setComment in class AbstractMaleSocket
      Parameters:
      comment - the comment or null to remove an existing comment
    • setProperty

      public void setProperty(String key, Object value)
      Description copied from interface: NamedBean
      Attach a key/value pair to the NamedBean, which can be retrieved later. These are not bound properties as yet, and don't throw events on modification. Key must not be null.

      The key is constrained to String to make these behave like normal Java Beans.

      Specified by:
      setProperty in interface NamedBean
      Parameters:
      key - the property to set
      value - the value of the property
    • getProperty

      public Object getProperty(String key)
      Description copied from interface: NamedBean
      Retrieve the value associated with a key. If no value has been set for that key, returns null.
      Specified by:
      getProperty in interface NamedBean
      Parameters:
      key - the property to get
      Returns:
      The value of the property or null.
    • removeProperty

      public void removeProperty(String key)
      Description copied from interface: NamedBean
      Remove the key/value pair against the NamedBean.
      Specified by:
      removeProperty in interface NamedBean
      Parameters:
      key - the property to remove
    • getPropertyKeys

      Description copied from interface: NamedBean
      Retrieve the complete current set of keys.
      Specified by:
      getPropertyKeys in interface NamedBean
      Returns:
      empty set if none
    • getBeanType

      public String getBeanType()
      Description copied from interface: NamedBean
      For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.
      Specified by:
      getBeanType in interface NamedBean
      Returns:
      a string of the bean type, eg Turnout, Sensor etc
    • compareSystemNameSuffix

      public int compareSystemNameSuffix(String suffix1, String suffix2, NamedBean n2)
      Description copied from interface: NamedBean
      Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for the NamedBean.compareTo(jmri.NamedBean) operation. This is intended to be a system-specific comparison that understands the various formats, etc.
      Specified by:
      compareSystemNameSuffix in interface NamedBean
      Parameters:
      suffix1 - The suffix for the 1st bean in the comparison
      suffix2 - The suffix for the 2nd bean in the comparison
      n2 - The other (second) NamedBean in the comparison
      Returns:
      -1,0,+1 for ordering if the names are well-formed; may not provide proper ordering if the names are not well-formed.
    • setDebugConfig

      public void setDebugConfig(Debugable.DebugConfig config)
      Set the debug configuration for this male socket.

      Each implementation of MaleSocket has their own implementation of DebugConfig. Use reflection to get the proper class <package-name>.debug.<ClassName>Debug that returns a JPanel that can configure debugging for this male socket.

      Specified by:
      setDebugConfig in interface Debugable
      Parameters:
      config - the new configuration or null to turn off debugging
    • getDebugConfig

      Get the debug configuration for this male socket.
      Specified by:
      getDebugConfig in interface Debugable
      Returns:
      the configuration or null if debugging is turned off for this male socket
    • createDebugConfig

      Create a debug configuration for this male socket.
      Specified by:
      createDebugConfig in interface Debugable
      Returns:
      the new configuration
    • setEnabled

      public void setEnabled(boolean enable)
      Set whenether this male socket is enabled or disabled.

      This method must call registerListeners() / unregisterListeners().

      Specified by:
      setEnabled in interface MaleSocket
      Parameters:
      enable - true if this male socket should be enabled, false otherwise
    • setEnabledFlag

      public void setEnabledFlag(boolean enable)
      Set whenether this male socket is enabled or disabled, without activating the male socket. This is used when loading the xml file and when copying an item.

      This method must call registerListeners() / unregisterListeners().

      Specified by:
      setEnabledFlag in interface MaleSocket
      Parameters:
      enable - true if this male socket should be enabled, false otherwise
    • isEnabled

      public boolean isEnabled()
      Determines whether this male socket is enabled.
      Specified by:
      isEnabled in interface Base
      Specified by:
      isEnabled in interface MaleSocket
      Returns:
      true if the male socket is enabled, false otherwise