Class AbstractAnalogIO

    • Constructor Detail

      • AbstractAnalogIO

        public AbstractAnalogIO​(@Nonnull
                                java.lang.String systemName,
                                boolean commandedValueSetsKnownValue)
        Abstract constructor for new AnalogIO with system name
        Parameters:
        systemName - AnalogIO system name
        commandedValueSetsKnownValue - true if setCommandedValue() also sets known value, false othervise
      • AbstractAnalogIO

        public AbstractAnalogIO​(@Nonnull
                                java.lang.String systemName,
                                @CheckForNull
                                java.lang.String userName,
                                boolean commandedValueSetsKnownValue)
        Abstract constructor for new AnalogIO with system name and user name
        Parameters:
        systemName - AnalogIO system name
        userName - AnalogIO user name
        commandedValueSetsKnownValue - true if setCommandedValue() also sets known value, false othervise
    • Method Detail

      • sendValueToLayout

        protected abstract void sendValueToLayout​(double value)
                                           throws JmriException
        Sends the string to the layout. The string [u]must not[/u] be longer than the value of getMaximumLength() unless that value is zero. Some microcomputers have little memory and it's very important that this method is never called with too long strings.
        Parameters:
        value - the desired string value
        Throws:
        JmriException - general error when setting the value fails
      • setValue

        protected void setValue​(double newValue)
        Set the value of this AnalogIO. Called from the implementation class when the layout updates this AnalogIO.
        Parameters:
        newValue - the new value
      • setCommandedAnalogValue

        public void setCommandedAnalogValue​(double value)
                                     throws JmriException
        Change the commanded value, which results in the relevant command(s) being sent to the hardware. The exception is thrown if there are problems communicating with the layout hardware.

        The value must be a valid number, not a NaN or infinity number.

        Specified by:
        setCommandedAnalogValue in interface AnalogIO
        Parameters:
        value - the desired analog value
        Throws:
        JmriException - general error when setting the value fails
      • getCommandedAnalogValue

        public double getCommandedAnalogValue()
        Query the commanded value. This is a bound parameter, so you can also register a listener to be informed of changes.

        The result must be a valid number, not a NaN or infinity number.

        Specified by:
        getCommandedAnalogValue in interface AnalogIO
        Returns:
        the analog value
      • getKnownAnalogValue

        public double getKnownAnalogValue()
        Query the known analog value. This is a bound parameter, so you can also register a listener to be informed of changes. A result is always returned; if no other feedback method is available, the commanded value will be used.

        The result must be a valid number, not a NaN or infinity number.

        Specified by:
        getKnownAnalogValue in interface AnalogIO
        Returns:
        the known analog value
      • cutOutOfBoundsValues

        protected abstract boolean cutOutOfBoundsValues()
        Cut out of bounds values instead of throwing an exception? For example, if the AnalogIO is a display, it could be desired to accept too long strings. On the other hand, if the AnalogIO is used to send a command, a too long string is an error.
        Returns:
        true if long strings should be cut
      • getState

        public double getState​(double v)
        Provide generic access to internal state.

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

        Specified by:
        getState in interface AnalogIO
        Parameters:
        v - only used to select this method which returns an analog value. It's recommended to use 0.0 as the parameter.
        Returns:
        the state
      • setState

        public void setState​(double value)
                      throws JmriException
        Provide generic access to internal state.

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

        Specified by:
        setState in interface AnalogIO
        Parameters:
        value - the analog value
        Throws:
        JmriException - general error when setting the state fails
      • getBeanType

        @Nonnull
        public java.lang.String getBeanType()
        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

        @CheckReturnValue
        public int compareSystemNameSuffix​(@Nonnull
                                           java.lang.String suffix1,
                                           @Nonnull
                                           java.lang.String suffix2,
                                           @Nonnull
                                           NamedBean n)
        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. By default, does an alphanumeric-by-chunks comparison. Do a string comparison.
        Specified by:
        compareSystemNameSuffix in interface NamedBean
        Overrides:
        compareSystemNameSuffix in class AbstractNamedBean
        Parameters:
        suffix1 - The suffix for the 1st bean in the comparison
        suffix2 - The suffix for the 2nd bean in the comparison
        n - 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.