Class CbusThrottleManager

    • Method Detail

      • singleUse

        protected boolean singleUse()
        CBUS allows Throttle sharing, both internally within JMRI and externally by command stations

        Does this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?

        Overrides:
        singleUse in class AbstractThrottleManager
        Returns:
        true or false
      • message

        public void message​(CanMessage m)
        Called when an outgoing message is sent to the CAN Network.
        Specified by:
        message in interface CanListener
        Parameters:
        m - the CanMessage being sent.
      • reply

        public void reply​(CanReply m)
        Called when an incoming CanFrame is received from the CAN Network.
        Specified by:
        reply in interface CanListener
        Parameters:
        m - the CanReply being received.
      • canBeLongAddress

        public boolean canBeLongAddress​(int address)
        Any address is potentially a long address. Test if a specific number is a valid long address on this system.
        Specified by:
        canBeLongAddress in interface ThrottleManager
        Parameters:
        address - address number to test
        Returns:
        true if address can be long; false otherwise
      • canBeShortAddress

        public boolean canBeShortAddress​(int address)
        Address 127 and below is a short address. Test if a specific number is a valid short address on this system.
        Specified by:
        canBeShortAddress in interface ThrottleManager
        Parameters:
        address - address number to test
        Returns:
        true if address can be short; false otherwise
      • addressTypeUnique

        public boolean addressTypeUnique()
        Short and long address spaces overlap and are not unique.
        Specified by:
        addressTypeUnique in interface ThrottleManager
        Returns:
        always false. true if ambiguous addresses are not allowed; false otherwise
      • isLongAddress

        static boolean isLongAddress​(int num)
        Local method for deciding short/long address.
        Parameters:
        num - the address number
        Returns:
        true if address equal to or greater than 128.
      • makeHardwareDecision

        protected void makeHardwareDecision​(LocoAddress address,
                                            ThrottleListener.DecisionType question)
        CBUS Hardware will make its own decision on preferred option.

        This is the default for scripts that do NOT have a GUI for asking what to do when a steal / share decision is required. For when a steal / share decision is needed and the ThrottleListener has delegated this decision to the ThrottleManager.

        Responds to the question by requesting a Throttle "Steal" by default.

        Can be overridden by hardware types which do not wish the default behaviour to Steal.

        This applies only to those systems where "stealing" or "sharing" applies, such as LocoNet.

        Overrides:
        makeHardwareDecision in class AbstractThrottleManager
        Parameters:
        address - The LocoAddress the steal / share question relates to
        question - The Question to be put to the ThrottleListener
      • supportedSpeedModes

        public java.util.EnumSet<SpeedStepModesupportedSpeedModes()
        MERG CBUS Throttle sessions default to 128 SS. This can be changed by a subsequent message from Throttle to CS, or by message from Command Station to CbusThrottle. Supported modes are 128, 28 and 14. What speed modes are supported by this system? value should be xor of possible modes specifed by the DccThrottle interface
        Specified by:
        supportedSpeedModes in interface ThrottleManager
        Overrides:
        supportedSpeedModes in class AbstractThrottleManager
        Returns:
        an XOR of the possible modes specified in the throttle interface
      • forceDisposeThrottle

        protected void forceDisposeThrottle​(LocoAddress la)
        Throttle can no longer be relied upon, potentially from an external forced steal or hardware error.

        Normally, #releaseThrottle should be used to close throttles.

        Removes locoaddress from list to force new throttle requests to request new sessions where the Command station model implements a dynamic stack, not a static stack.

        Managers still need to advise listeners that the session has been cancelled and actually dispose of the throttle

        Overrides:
        forceDisposeThrottle in class AbstractThrottleManager
        Parameters:
        la - address release
      • updateNumUsers

        protected void updateNumUsers​(LocoAddress la,
                                      int numUsers)
        The number of users of this throttle has been updated

        Typically used to update dispatch / release availablility specific implementations can override this function to get updates

        Overrides:
        updateNumUsers in class AbstractThrottleManager
        Parameters:
        la - the Loco Address which has been updated
        numUsers - current number of users