Class SerialNode
Nodes are numbered ala their address, from 0 to 255. Node number 1 carries sensors 1 to 999, node 2 carries 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 TypeFieldDescription(package private) OakTreeSystemConnectionMemoprotected boolean(package private) static final int[]static final intstatic final intprotected int(package private) static final intMaximum number of sensors a node can carry.protected intstatic final intprotected byte[]protected boolean[](package private) static final int[]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, OakTreeSystemConnectionMemo memo) Create a new SerialNode and initialize default instance variablesCreate a new SerialNode without a name supplied. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckNodeAddress(int address) Check for valid node address.Create an Initialization packet (SerialMessage) for this node.Create an Transmit packet (SerialMessage).static String[]intGet Node type.booleanGet state of Sensors.booleanDeal with a timeout in the transmission controller.voidUse the contents of the poll reply to mark changes.voidregisterSensor(Sensor s, int i) The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS.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.(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:
-
IO24
- See Also:
-
IO48
- See Also:
-
O48
- See Also:
-
outputBytes
-
inputBytes
-
nodeType
-
outputArray
-
outputByteChanged
-
hasActiveSensors
-
lastUsedSensor
-
sensorArray
-
sensorLastSetting
-
sensorTempSetting
-
_memo
-
warned
boolean warned -
timeout
int timeout
-
-
Constructor Details
-
SerialNode
Create a new SerialNode without a name supplied.Assumes a node address of 0, and a node type of 0 (IO24). If this constructor is used, actual node address must be set using setNodeAddress, and actual node type using 'setNodeType'
- Parameters:
memo- system connection.
-
SerialNode
Create a new SerialNode and initialize default instance variables- Parameters:
address- Address of node on serial bus (0-255).type- type constant from the class.memo- system connection.
-
-
Method Details
-
getBoardNames
-
setOutputBit
Set an output bit.- Parameters:
bitNumber- bit id, 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.Current types are: IO24, I048, O48.
- Returns:
- node type.
-
setNodeType
Set Node type.- Parameters:
type- node type e.g. IO48 , IO24
-
checkNodeAddress
Check for valid node address.- Specified by:
checkNodeAddressin classAbstractNode- Parameters:
address- node number to check.- Returns:
- true if valid
-
createInitPacket
Create an Initialization packet (SerialMessage) for this node. There are currently no Oak Tree boards that need an init message, so this returns null.- Specified by:
createInitPacketin classAbstractNode- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
Create an Transmit packet (SerialMessage).- Specified by:
createOutPacketin classAbstractNode- Returns:
- packet to send current node state.
-
warn
-
markChanges
Use the contents of the poll reply to mark changes.- Parameters:
l- Reply to a poll operation
-
registerSensor
The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS.- Parameters:
s- sensor objecti- number of sensor's input bit on this node (0 to MAXSENSORS)
-
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 is required
-
resetTimeout
Description copied from class:AbstractNodeA reply was received, so there was no timeout, do any needed processing.- Specified by:
resetTimeoutin classAbstractNode- Parameters:
m- message received that has reset the timeout and is waiting to be handled
-