Class SerialNode
Nodes are numbered ala their address, from 0 to 255. Node number 1 carries sensors 1 to 999, node 2 1001 to 1999 etc.
The array of sensor states is used to update sensor known state only when there's a change on the serial bus. This allows for the sensor state to be updated within the program, keeping this updated state until the next change on the serial bus. E.g. you can manually change a state via an icon, and not have it change back the next time that node is polled.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean(package private) static final int[]protected int(package private) static final intMaximum number of sensors a node can carry.static final intstatic final intstatic final intprotected int(package private) static final int(package private) static final int(package private) static final int(package private) static final intprotected byte[](package private) static final int[]protected boolean[]protected Sensor[]protected int[]protected int[](package private) int(package private) booleanFields inherited from class jmri.jmrix.AbstractNode
nodeAddress -
Constructor Summary
ConstructorsConstructorDescriptionSerialNode(int address, int type, SerialTrafficController tc) Create a new SerialNode and initialize default instance variables.SerialNode(int address, SerialTrafficController tc) Assumes a node address of 1, and a node type of 0 (NODE2002V6). -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckNodeAddress(int address) Check for valid node address.Create Initialization packets (SerialMessage) for this node.Public method to create a Transmit packet (SerialMessage).static String[]intGet node type.booleanGet state of Sensors.booleanDeal with a timeout in the transmission controller.(package private) voidmarkBit(boolean input, int sensorNum) Mark and act on a single input bit.voidUse the contents of a reply from the Grapevine to mark changes in the sensors on the layout.voidregisterSensor(Sensor s, int i) Register a sensor on a node.voidReset state of needSend flag.voidA reply was received, so there was no timeout, do any needed processing.voidsetNodeType(int type) Set node type.voidsetOutputBit(int bitNumber, boolean state) Set an output bit on this node.(package private) voidMethods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, setMustSend, setNodeAddress
-
Field Details
-
MAXSENSORS
Maximum number of sensors a node can carry.Note this is less than a current SUSIC motherboard can have, but should be sufficient for all reasonable layouts.
Must be less than, and is general one less than,
SerialSensorManager.SENSORSPERNODE- See Also:
-
NODE2002V6
- See Also:
-
NODE2002V1
- See Also:
-
NODE2000
- See Also:
-
outputBits
-
inputBits
-
nodeType
-
outputArray
-
outputByteChanged
-
hasActiveSensors
-
lastUsedSensor
-
sensorArray
-
sensorLastSetting
-
sensorTempSetting
-
warned
boolean warned -
offsetA
- See Also:
-
offsetM
- See Also:
-
offsetP
- See Also:
-
offsetS
- See Also:
-
timeout
int timeout
-
-
Constructor Details
-
SerialNode
Assumes a node address of 1, and a node type of 0 (NODE2002V6). If this constructor is used, actual node address must be set using 'setNodeAddress()', and actual node type using 'setNodeType()'- Parameters:
tc- system connection traffic controller.
-
SerialNode
-
SerialNode
Create a new SerialNode and initialize default instance variables.- Parameters:
address- the address of node on serial bus (1-127)type- a type constant from the classtc- the TrafficController for this connection
-
-
Method Details
-
getBoardNames
-
setOutputBit
Set an output bit on this node.- Parameters:
bitNumber- the bit index. Bits are numbered from 1 (not 0)state- 'true' for 0, 'false' for 1.
-
getSensorsActive
Get state of Sensors.- Specified by:
getSensorsActivein classAbstractNode- Returns:
- 'true' if at least one sensor is active for this node
-
resetMustSend
Reset state of needSend flag. Can only reset if there are no bytes that need to be sent.- Overrides:
resetMustSendin classAbstractNode
-
getNodeType
Get node type.- Returns:
- node type, e.g. NODE2002V1 or NODE2002V6.
-
setNodeType
Set node type.- Parameters:
type- node type, e.g. NODE2002V1 or NODE2002V6.
-
checkNodeAddress
Check for valid node address.- Specified by:
checkNodeAddressin classAbstractNode- Parameters:
address- node number to check.- Returns:
- true if valid
-
createInitPacket
Create Initialization packets (SerialMessage) for this node. Initialization consists of multiple parts:- Turn on the ASD input 0x71 to bank 0
- After a wait, another ASD message 0x73 to bank 0
As an Ugly Hack to keep these separate, only the first is put in the reply from this. The other(s) are sent via the usual output methods.
- Specified by:
createInitPacketin classAbstractNode- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
Public method to create a Transmit packet (SerialMessage).- Specified by:
createOutPacketin classAbstractNode- Returns:
- packet to send current node state.
-
warn
-
markChanges
Use the contents of a reply from the Grapevine to mark changes in the sensors on the layout.- Parameters:
l- Reply to a poll operation
-
markBit
Mark and act on a single input bit.- Parameters:
input- true if sensor says activesensorNum- from 1 to lastUsedSensor+1 on this node
-
registerSensor
Register a sensor on a node.The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS. E.g. the integer argument is one less than the name of the sensor object.
- Parameters:
s- Sensor objecti- bit number corresponding, a 1-based value corresponding to the low digits of the system name
-
handleTimeout
Deal with a timeout in the transmission controller.- Specified by:
handleTimeoutin classAbstractNode- Parameters:
m- message that didn't receive a replyl- listener that sent the message- Returns:
- true if initialization required
-
resetTimeout
A reply was received, so there was no timeout, do any needed processing.- Specified by:
resetTimeoutin classAbstractNode- Parameters:
m- GrapevineSerialMessage (ignored)
-