Package jmri.jmrix.can.cbus.node
Class CbusNodeNVManager
- java.lang.Object
-
- jmri.jmrix.can.cbus.node.CbusNodeNVManager
-
public class CbusNodeNVManager extends java.lang.Object
Class to manage Node Variables for a CbusNode.
-
-
Constructor Summary
Constructors Constructor Description CbusNodeNVManager(CbusBasicNodeWithManagers node)
Create a new CbusNodeNVManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNV(int index)
Get a specific Node Variableint[]
getNvArray()
Get the Node Variable int Arrayint
getNvDifference(CbusNode testAgainst)
Get number of difference between this and another Nodes Node Variablesjava.lang.String
getNvHexString()
Get the NV String in Hex Byte Formatint
getOutstandingNvCount()
Number of unknown Node Variables.int
getTotalNVs()
Number of Node Variables on the node.protected void
reset()
Reset this CbusNodeNVManager.protected void
sendNextNVToFetch()
Send a request for the next unknown Node Variable.protected void
sendNextNvToNode()
Loop for NV teachingvoid
sendNvsToNode(int[] newnv)
Send and teach updated Node Variables to this nodevoid
setNV(int index, int newnv)
Set a single Node Variablevoid
setNVs(int[] newnvs)
Set the Node Variablesprotected boolean
teachOutstandingNvs()
Get Flag for if any outstanding Teach NV operations are due.java.lang.String
toString()
-
-
-
Constructor Detail
-
CbusNodeNVManager
public CbusNodeNVManager(CbusBasicNodeWithManagers node)
Create a new CbusNodeNVManager- Parameters:
node
- The Node
-
-
Method Detail
-
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 Variables0th 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 Variableso Index 1 is NV1 .. Index 255 is NV255 Index 0 is set by Node Parameter
- Parameters:
index
- NV Indexnewnv
- min 1, max 255
-
getNvArray
public int[] getNvArray()
Get the Node Variable int Array0th 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
public java.lang.String getNvHexString()
Get the NV String in Hex Byte Formateg. for NV array [3,1,2,255] returns "0102FF"
- Returns:
- Full NV String WITHOUT leading number of NVs
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- descriptive string
-
-