Class LocoIOData

    • Constructor Detail

      • LocoIOData

        public LocoIOData​(int unitAddr,
                          int unitSubAddr,
                          LnTrafficController tc)
        Create a new instance of LocoIOData.
        Parameters:
        unitAddr - unit address.
        unitSubAddr - unit SubAddress.
        tc - system connection traffic controller.
    • Method Detail

      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • setUnitAddress

        public void setUnitAddress​(int unit,
                                   int unitSub)
        Address and SubAddress of this device.

        High byte of the Address is fixed to 0x01
        Low byte Address must be in the range of 0x01 .. 0x4F, 0x51 .. 0x7F
        (0x50 is reserved for the LocoBuffer)
        The subAddress is in the range of 0x01 .. 0x7E
        (0x7F is reserved)

        Parameters:
        unit - unit address.
        unitSub - unit subAddress.
      • setUnitConfig

        public void setUnitConfig​(int portRefresh,
                                  int altCodePBs,
                                  int isServo,
                                  int blinkRate)
        No LocoIO Board level configuration.
         Bit 0: 0 = default, 1 = Port Refresh
         Bit 1: 0 = Fixed code PBs, 1 = Alternated code PBs
         Bit 2: 0 = default - Not used
         Bit 3: 0 = default, 1 = Ports 5-12 are Servo Ports
         Bit 4-7: Blink Rate
        
         Add/support the additional config options for HDL boards -
         Work has moved to xml decoder definition Public_Domain_HDL_LocoIO, is included there since 4.21.2
         
        Parameters:
        portRefresh - port refresh value, bit 0.
        altCodePBs - alternated code PBs, bit 1.
        isServo - servo port, bit 3.
        blinkRate - blink rate, bits 4-7.
      • setLBVersion

        public void setLBVersion​(java.lang.String version)
      • setLIOVersion

        public void setLIOVersion​(java.lang.String version)
      • setStatus

        public void setStatus​(java.lang.String msg)
      • getStatus

        public java.lang.String getStatus()
      • setSV

        public void setSV​(int channel,
                          int value)
      • getSV

        public int getSV​(int channel)
      • setV1

        public void setV1​(int channel,
                          int value)
      • getV1

        public int getV1​(int channel)
      • setV2

        public void setV2​(int channel,
                          int value)
      • getV2

        public int getV2​(int channel)
      • setAddr

        public void setAddr​(int channel,
                            int value)
        Set new value in addr field (for the address info used in each LocoIO channel).
        Parameters:
        channel - integer value of the addresses in use for this row (0 = invalid)
        value - channel value.
      • getAddr

        public int getAddr​(int channel)
      • setMode

        public void setMode​(int channel,
                            java.lang.String m)
      • getMode

        public java.lang.String getMode​(int channel)
      • setLIM

        public void setLIM​(int channel,
                           java.lang.String s)
      • setLIM

        public void setLIM​(int channel)
      • readValues

        public void readValues​(int channel)
      • writeValues

        public void writeValues​(int channel)
      • readAll

        public void readAll()
        Start reading all rows back.
      • writeAll

        public void writeAll()
        Start writing all rows out.
      • highPart

        protected int highPart​(int value)
      • lowPart

        protected int lowPart​(int value)
      • message

        public void message​(LocoNetMessage m)
        Listen to the LocoNet. We're listening for incoming OPC_PEER_XFR messages, which might be part of a read or write sequence. We're also _sometimes_ listening for commands as part of a "capture" operation.

        The incoming LocoNet OPC_PEER_XFR messages don't retain any information about the CV number or whether it was a read or write operation. We store the data regardless of whether it was read or write, but we need to remember the cv number in the lastOpCv member.

        Specified by:
        message in interface LocoNetListener
        Parameters:
        m - Incoming message
      • replyReceived

        protected void replyReceived()
        A valid reply has been received, so the read/write worked, and the state should be advanced.
      • issueNextOperation

        protected void issueNextOperation()
        Look through the table to find the next thing that needs to be read.
      • timeout

        protected void timeout()
        Internal routine to handle a timeout during read/write by retrying the same operation.
      • startTimer

        protected void startTimer()
        Internal routine to start timer to protect the mode-change.
      • stopTimer

        protected void stopTimer()
        Internal routine to stop timer, as all is well.
      • restartTimer

        protected void restartTimer​(int delay)
        Internal routine to handle timer starts and restarts.
        Parameters:
        delay - Milliseconds to wait
      • sendReadCommand

        void sendReadCommand​(int locoIOAddress,
                             int locoIOSubAddress,
                             int cv)
        Read an SV from a given LocoIO device.
        Parameters:
        locoIOAddress - primary board address
        locoIOSubAddress - subaddress within board
        cv - CV number to access
      • sendWriteCommand

        void sendWriteCommand​(int locoIOAddress,
                              int locoIOSubAddress,
                              int cv,
                              int data)
        Write an SV to a given LocoIO device.
        Parameters:
        locoIOAddress - primary board address
        locoIOSubAddress - subaddress within board
        cv - CV number to access
        data - value to be written