Class OlcbSensor

    • Constructor Detail

    • Method Detail

      • finishLoad

        void finishLoad()
        Helper function that will be invoked after construction once the properties have been loaded. Used specifically for preventing double initialization when loading sensors from XML.
      • getEventName

        public java.lang.String getEventName​(boolean isActive)
        Computes the display name of a given event to be entered into the Event Table.
        Parameters:
        isActive - true for sensor active, false for inactive.
        Returns:
        user-visible string to represent this event.
      • requestUpdateFromLayout

        public void requestUpdateFromLayout()
        Request an update on status by sending an OpenLCB message.
      • setKnownState

        public void setKnownState​(int s)
        User request to set the state, which means that we broadcast that to all listeners by putting it out on CBUS. In turn, the code in this class should use setOwnState to handle internal sets and bean notifies.
        Specified by:
        setKnownState in interface Sensor
        Overrides:
        setKnownState in class AbstractSensor
        Parameters:
        s - the state to set
      • setTimeout

        void setTimeout()
        Have sensor return to inactive after delay, used if no inactive event was specified
      • setAuthoritative

        public void setAuthoritative​(boolean authoritative)
        Changes how the turnout reacts to inquire state events. With authoritative == false the state will always be reported as UNKNOWN to the layout when queried.
        Parameters:
        authoritative - whether we should respond true state or unknown to the layout event state inquiries.
      • isAuthoritative

        public boolean isAuthoritative()
        Returns:
        whether this producer/consumer is enabled to return state to the layout upon queries.
      • setProperty

        public void setProperty​(@Nonnull
                                java.lang.String key,
                                java.lang.Object value)
        Description copied from class: AbstractNamedBean
        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.

        Prior to JMRI 4.3, the key was of Object type. It was constrained to String to make these more like normal Java Beans.

        Specified by:
        setProperty in interface NamedBean
        Overrides:
        setProperty in class AbstractNamedBean
        Parameters:
        key - the property to set
        value - the value of the property
      • isListeningToStateMessages

        public boolean isListeningToStateMessages()
        Returns:
        whether this producer/consumer is always listening to state declaration messages.
      • setListeningToStateMessages

        public void setListeningToStateMessages​(boolean listen)
        Changes how the turnout reacts to state declaration messages. With listen == true state declarations will update local state at all times. With listen == false state declarations will update local state only if local state is unknown.
        Parameters:
        listen - whether we should always listen to state declaration messages.
      • dispose

        public void dispose()
        Description copied from class: AbstractNamedBean
        Deactivate this object, so that it releases as many resources as possible and no longer effects others.

        For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

        It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

        Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

        Specified by:
        dispose in interface NamedBean
        Specified by:
        dispose in interface Sensor
        Overrides:
        dispose in class AbstractSensor
      • 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. Sorts by decoded EventID(s)
        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.