Class CbusSensor

All Implemented Interfaces:
Comparable<NamedBean>, EventListener, PropertyChangeProvider, DigitalIO, AbstractMRListener, CanListener, CbusEventInterface, NamedBean, Sensor

public class CbusSensor
extends AbstractSensor
implements CanListener, CbusEventInterface
Extend jmri.AbstractSensor for CBUS controls.
  • Constructor Details

  • Method Details

    • requestUpdateFromLayout

      public void requestUpdateFromLayout()
      Request an update on status by sending CBUS request message to active address. Request an update from the layout soft/hardware. May not even happen, and if it does it will happen later; listen for the result.
      Specified by:
      requestUpdateFromLayout in interface DigitalIO
    • setKnownState

      public void setKnownState​(int s) throws JmriException
      User request to set the state. 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. Unknown / Inconsistent states do not send a message to CBUS, but do update sensor state. Perform setKnownState(int) for implementations that can't actually do it on the layout. Not intended for use by implementations that can.
      Specified by:
      setKnownState in interface Sensor
      setKnownState in class AbstractSensor
      s - the state to set
      JmriException - if unable to set the state
    • canInvert

      public boolean canInvert()
      Returns true, can invert. By default, all implementations based on this can invert
      Specified by:
      canInvert in interface Sensor
      canInvert in class AbstractSensor
      true if can be inverted; false otherwise
    • getAddrActive

      Package method returning CanMessage for the Active Sensor Address
      CanMessage with the Active CBUS Address
    • getAddrInactive

      Package method returning CanMessage for the Inactive Sensor Address
      CanMessage with the InActive CBUS Address
    • getBeanOnMessage

      Get event for primary Bean On Action. e.g. without inversion, Light On.
      Specified by:
      getBeanOnMessage in interface CbusEventInterface
      Event for the Action, may be null
    • getBeanOffMessage

      Get event for primary Bean Off Action. e.g. without Inversion Light Off.
      Specified by:
      getBeanOffMessage in interface CbusEventInterface
      Event for the Action, may be null
    • message

      public void message​(CanMessage f)
      Track layout status from messages being sent to CAN
      Specified by:
      message in interface CanListener
    • reply

      public void reply​(CanReply f)
      Event status from messages being received from CAN
      Specified by:
      reply in interface CanListener
    • dispose

      public void dispose()
      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
      dispose in class AbstractNamedBean