Class CbusNodeNVManager

java.lang.Object
jmri.jmrix.can.cbus.node.CbusNodeNVManager

public class CbusNodeNVManager extends Object
Class to manage Node Variables for a CbusNode.
  • Constructor Details

  • Method Details

    • reset

      protected void reset()
      Reset this CbusNodeNVManager. Array is set to null and NV SendError Count 0.
    • teachOutstandingNvs

      protected boolean teachOutstandingNvs()
      Get Flag for if any outstanding Teach NV operations are due.
      Returns:
      true if outstanding teaches, else false.
    • setNVs

      public void setNVs(@Nonnull int[] newnvs)
      Set the Node Variables

      0th NV is total NVs so length of newnvs should already be num. of NV's +1

      Parameters:
      newnvs - an int array, the first value being the total number
    • setNV

      public void setNV(int index, int newnv)
      Set a single Node Variable

      so Index 1 is NV1 .. Index 255 is NV255 Index 0 is set by Node Parameter

      Parameters:
      index - NV Index
      newnv - min 1, max 255
    • getNvArray

      public int[] getNvArray()
      Get the Node Variable int Array

      0th Index is total NVs so Index 1 is NV1 .. Index 255 is NV255

      Returns:
      Array of NV's, first in index is Total NV's
    • getTotalNVs

      public int getTotalNVs()
      Number of Node Variables on the node.
      Returns:
      0 if number of NV's unknown, else number of NV's.
    • getNV

      public int getNV(int index)
      Get a specific Node Variable
      Parameters:
      index - NV Index
      Returns:
      -1 if NV's unknown, else Node Variable value.
    • getNvDifference

      public int getNvDifference(CbusNode testAgainst)
      Get number of difference between this and another Nodes Node Variables
      Parameters:
      testAgainst - The CBUS Node to test against
      Returns:
      number of different NV's
    • getOutstandingNvCount

      public int getOutstandingNvCount()
      Number of unknown Node Variables. i.e. not yet fetched from a physical node.
      Returns:
      -1 if number of NV's unknown, 0 if all NV's known, else number of outstanding.
    • sendNextNVToFetch

      protected void sendNextNVToFetch()
      Send a request for the next unknown Node Variable.

      Only triggered from CBUS Node Manager.

      Does NOT send if the node has existing outstanding requests. Expected response from node NVANS

    • sendNvsToNode

      public void sendNvsToNode(int[] newnv)
      Send and teach updated Node Variables to this node
      Parameters:
      newnv - array of variables, index 0 i the array is total variables
    • sendNextNvToNode

      protected void sendNextNvToNode()
      Loop for NV teaching
    • getNvHexString

      Get the NV String in Hex Byte Format

      eg. for NV array [3,1,2,255] returns "0102FF"

      Returns:
      Full NV String WITHOUT leading number of NVs
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      descriptive string