Package jmri

Interface Sensor

    • Method Detail

      • isConsistentState

        default boolean isConsistentState()
        Show whether state is stable. For turnouts, a consistent state is one you can safely run trains over. For lights, it's a state which is either on or off, not in between.
        Specified by:
        isConsistentState in interface DigitalIO
        true if state is valid and the known state is the same as commanded
      • setCommandedState

        default void setCommandedState​(int s)
        Change the commanded state, 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.
        Specified by:
        setCommandedState in interface DigitalIO
        s - the desired state
      • getCommandedState

        default int getCommandedState()
        Query the commanded state. This is a bound parameter, so you can also register a listener to be informed of changes.
        Specified by:
        getCommandedState in interface DigitalIO
        the commanded state
      • setKnownState

        void setKnownState​(int newState)
                    throws JmriException
        Set the known state on the layout. This might not always be available, or effective, depending on the limits of the underlying system and implementation.
        newState - the state to set
        JmriException - if unable to set the state
      • setInverted

        void setInverted​(boolean inverted)
        Control whether the actual sensor input is considered to be inverted, such that the normal electrical signal that normally results in an ACTIVE state now results in an INACTIVE state.

        Changing this changes the state from ACTIVE to INACTIVE and vice-versa, with notifications; UNKNOWN and INCONSISTENT are left unchanged.

        inverted - true if the sensor should be inverted; false otherwise
      • getInverted

        boolean getInverted()
        Get the inverted state.
        true if the electrical signal that normally results in an ACTIVE state now results in an INACTIVE state; false otherwise
      • canInvert

        boolean canInvert()
        Determine if sensor can be inverted. When a turnout is inverted the ACTIVE and INACTIVE states are inverted on the layout.
        true if can be inverted; false otherwise
      • dispose

        void dispose()
        Remove references to and from this object, so that it can eventually be garbage-collected.
        Specified by:
        dispose in interface NamedBean
      • getRawState

        int getRawState()
        Used to return the Raw state of a sensor prior to the known state of a sensor being set. The raw state value can be different from the known state when the sensor debounce option is used.
        raw state value
      • setSensorDebounceGoingActiveTimer

        void setSensorDebounceGoingActiveTimer​(long timer)
        Set the active debounce delay.
        timer - delay in milliseconds; set to zero to de-activate debounce
      • setSensorDebounceGoingInActiveTimer

        void setSensorDebounceGoingInActiveTimer​(long timer)
        Set the inactive debounce delay.
        timer - delay in milliseconds; set to zero to de-activate debounce
      • setUseDefaultTimerSettings

        void setUseDefaultTimerSettings​(boolean flag)
        Use the timers specified in the SensorManager for the debounce delay.
        flag - true to set to current defaults if not previously true
      • getUseDefaultTimerSettings

        boolean getUseDefaultTimerSettings()
        Does this sensor use the default timers values? (A remarkably unfortunate name given the one above)
        true if using default debounce values from the SensorManager
      • setReporter

        void setReporter​(@CheckForNull
                         Reporter re)
        Some sensor boards also serve the function of being able to report back train identities via such methods as RailCom. The setting and creation of the reporter against the sensor should be done when the sensor is created. This information is not saved.
        re - the reporter to associate with the sensor
      • getReporter

        Reporter getReporter()
        Retrieve the reporter associated with this sensor if there is one.
        the reporter or null if there is no associated reporter