Class NceTurnout

All Implemented Interfaces:
PropertyChangeListener, Comparable<NamedBean>, EventListener, PropertyChangeProvider, DigitalIO, NamedBean, Turnout, VariableControlSpanBean

public class NceTurnout extends AbstractTurnout
Implement a Turnout via NCE communications.

This object doesn't listen to the NCE communications. This is because it should be the only object that is sending messages for this turnout; more than one Turnout object pointing to a single device is not allowed.

  • Field Details

  • Constructor Details

    • NceTurnout

      public NceTurnout(NceTrafficController tc, String p, int i)
      NCE turnouts use the NMRA number (0-2044) as their numerical identification.
      Parameters:
      tc - traffic controller for connection
      p - system connection prefix
      i - NMRA turnout number
  • Method Details

    • getNumber

      public int getNumber()
    • getNumNtTurnouts

      public static int getNumNtTurnouts()
    • forwardCommandChangeToLayout

      protected void forwardCommandChangeToLayout(int newState)
      Handle a request to change state, typically by sending a message to the layout in some child class. Public version (used by TurnoutOperator) sends the current commanded state without changing it. Implementing classes will typically check the value of s and send a system specific sendMessage command.
      Specified by:
      forwardCommandChangeToLayout in class AbstractTurnout
      Parameters:
      newState - new state value
    • turnoutPushbuttonLockout

      protected void turnoutPushbuttonLockout(boolean pushButtonLockout)
      Send a message to the layout to lock or unlock the turnout pushbuttons if true, pushbutton lockout enabled.
      Specified by:
      turnoutPushbuttonLockout in class AbstractTurnout
    • setCommandedStateFromCS

      void setCommandedStateFromCS(int state)
      Set the turnout known state to reflect what's been observed from the command station polling. A change there means that somebody commanded a state change (by using a throttle), and that command has already taken effect. Hence we use "newCommandedState" to indicate it's taken place. Must be followed by "newKnownState" to complete the turnout action.
      Parameters:
      state - Observed state, updated state from command station
    • setKnownStateFromCS

      void setKnownStateFromCS(int state)
      Set the turnout known state to reflect what's been observed from the command station polling. A change there means that somebody commanded a state change (by using a throttle), and that command has already taken effect. Hence we use "newKnownState" to indicate it's taken place.
      Parameters:
      state - Observed state, updated state from command station
    • canInvert

      public boolean canInvert()
      NCE turnouts can be inverted.
      Specified by:
      canInvert in interface Turnout
      Overrides:
      canInvert in class AbstractTurnout
      Returns:
      invert supported
    • getPossibleLockModes

      public int getPossibleLockModes()
      NCE turnouts can provide both modes when properly configured.
      Specified by:
      getPossibleLockModes in interface Turnout
      Overrides:
      getPossibleLockModes in class AbstractTurnout
      Returns:
      Both cab and pushbutton (decoder) modes
    • canLock

      public boolean canLock(int turnoutLockout)
      NCE turnouts support two types of lockouts, pushbutton and cab. Cab lockout requires the feedback mode to be Monitoring. This implementation by itself doesn't provide locking support. Override this in subclasses that do.
      Specified by:
      canLock in interface Turnout
      Overrides:
      canLock in class AbstractTurnout
      Parameters:
      turnoutLockout - the type of lock, one of CABLOCKOUT, PUSHBUTTONLOCKOUT or BOTH = CABLOCKOUT | PUSHBUTTONLOCKOUT
      Returns:
      false for not supported
    • enableLockOperation

      public void enableLockOperation(int turnoutLockout, boolean enabled)
      Control which turnout locks are enabled. Enable turnout lock operators. A turnout can be locked to prevent it being thrown from a cab or push button on the layout if supported by the protocol. Not implemented in AbstractTurnout.
      Specified by:
      enableLockOperation in interface Turnout
      Overrides:
      enableLockOperation in class AbstractTurnout
      Parameters:
      turnoutLockout - the type of lock
      enabled - true if locking is enabled for the given type; false otherwise
    • sendMessage

      protected void sendMessage(boolean closed)