Class CbusThrottle

    • Constructor Detail

      • CbusThrottle

        public CbusThrottle​(CanSystemConnectionMemo memo,
                            LocoAddress address,
                            int handle)
        Constructor
        Parameters:
        memo - System Connection
        address - The address this throttle relates to.
        handle - the Session ID for the Throttle
    • Method Detail

      • throttleInit

        protected void throttleInit​(int speed,
                                    int f0f4,
                                    int f5f8,
                                    int f9f12)
        Set initial throttle values as taken from PLOC reply from hardware
        Parameters:
        speed - including direction flag
        f0f4 - Functions 0-4
        f5f8 - Functions 5-8
        f9f12 - Functions 9-12
      • setSpeedStepMode

        public void setSpeedStepMode​(SpeedStepMode Mode)
        setSpeedStepMode - set the speed step value.

        Overridden to capture mode changes to be forwarded to the hardware. New throttles default to 128 step mode. CBUS Command stations also default to 128SS so this does not need to be sent if unchanged.

        Specified by:
        setSpeedStepMode in interface DccThrottle
        Overrides:
        setSpeedStepMode in class AbstractThrottle
        Parameters:
        Mode - the current speed step mode - default should be 128 speed step mode in most cases
      • floatSpeed

        protected float floatSpeed​(int lSpeed)
        Convert a CBUS speed integer to a float speed value
        Parameters:
        lSpeed - -1 to 127
        Returns:
        float value -1 to 1
      • updateSpeedSetting

        protected void updateSpeedSetting​(int speed)
        Update the throttles speed setting without sending to hardware. Used to support CBUS sharing by taking speed received from the hardware in an OPC_DSPD message.

        No compensation required for a direction flag

        Parameters:
        speed - integer speed value
      • setIsForward

        public void setIsForward​(boolean forward)
        Set the direction and reset speed. Forwards to the layout Implementing functions should override this function, but should either make a call to super.setIsForward() to notify the listeners, or should notify the listeners themselves.
        Specified by:
        setIsForward in interface Throttle
        Overrides:
        setIsForward in class AbstractThrottle
        Parameters:
        forward - true if forward; false otherwise
      • updateIsForward

        protected void updateIsForward​(boolean forward)
        Update the throttles direction without sending to hardware.Used to support CBUS sharing by taking direction received from the hardware in an OPC_DSPD message.
        Parameters:
        forward - True if Forward, else False
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getHandle

        protected int getHandle()
        Return the handle for this throttle
        Returns:
        integer session handle
      • setHandle

        protected void setHandle​(int newHandle)
        Set the handle for this throttle

        This is normally done on Throttle Construction but certain operations, eg. recovering from an external steal may need to change this.

        Parameters:
        newHandle - session handle
      • setStolen

        protected void setStolen​(boolean isStolen)
        Set Throttle Stolen Flag

        This is false on Throttle Construction but certain operations may need to change this, eg. an external steal.

        Sends IsAvailable Property Change Notification

        Parameters:
        isStolen - true if Throttle has been stolen, else false
      • isStolen

        protected boolean isStolen()
        Get Throttle Stolen Flag

        This is false on Throttle Construction but certain operations may need to change this, eg. an external steal.

        Returns:
        true if Throttle has been stolen, else false
      • getNumRecoverAttempts

        protected int getNumRecoverAttempts()
        Get the number of external steal recovery attempts
        Returns:
        Number of attempts since last reset
      • releaseFromCommandStation

        protected void releaseFromCommandStation()
        Release session from a command station ie. throttle with clean full dispose called from releaseThrottle
      • getLocoAddress

        public LocoAddress getLocoAddress()
        Locomotive address. The exact format is defined by the specific implementation, as subclasses of LocoAddress will contain different information.

        This is an unbound property.

        Returns:
        The locomotive address
      • setDispatchActive

        protected void setDispatchActive​(boolean newval)
        Adds extra check for num of this JMRI throttle users before notifying and makes sure these always get sent as a pair the abstracts only send to ThrottleListeners if value has been changed
        Parameters:
        newval - set true if dispatch can be enabled, else false