Class SerialNode
Nodes are numbered ala the UA number, from 1 to 63. 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.
The SMINI is defined as having 1 input and 2 outputs cards.
USIC/SUSIC nodes can have 0-63 inputs and 0-63 output cards, but no more than
64 total cards.
A CPNODE (Control Point Node) is defined as having 2 inputs and 2 outputs //c2
on the node board and 0-128 bits of input or output (in 8 bit increments)
for added I/O extender cards IOX16,IOX32.
A CPMEGA (Open Source Node) is defined as having 8 bytes of input or output //c2
on the node board and 0-128 bits of input or output (in 8 bit increments)
for added I/O extender cards IOX16,IOX32.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected byte[]protected int[]protected Stringstatic final intstatic final intprotected int[]protected booleanstatic final intstatic final byteprotected intprotected byte[]static final intstatic final int(package private) static final intMaximum number of sensors a node can carry.protected booleanprotected boolean[]static final intstatic final intstatic final intstatic final intstatic final intstatic final byteprotected intprotected intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final byteprotected byte[]protected intintstatic final intstatic final intstatic final intstatic final intstatic final intprotected intprotected Sensor[]protected int[]protected int[]static final int(package private) intprotected intstatic final int(package private) booleanFields inherited from class jmri.jmrix.AbstractNode
nodeAddress -
Constructor Summary
ConstructorsConstructorDescriptionSerialNode(int address, int type, SerialTrafficController tc) Creates a new SerialNode and initialize default instance variables.Assumes a node address of 0, and a node type of SMINI. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckNodeAddress(int address) Check valid node address, must match value in dip switches (0 - 127).voidclear2LeadSearchLight(int bit) Clear location of SearchLightBits (SMINI only).Create an Initialization packet (SerialMessage) for this nodeCreate an Transmit packet (SerialMessage)byte[]intgetCMRInetOpts(int optionbit) Get CMRInet options.Get node description.intgetcpnodeOpts(int optionbit) Get cpNode options.intgetInputCardIndex(int cardNum) Get 'Input Card Index'.byte[]booleanGet packet monitoring for the node .booleangetMonitorPacketBit(int pktTypeBit) intGet node type Current types are: SMINI, USIC_SUSIC,intintGet number of bits per card.booleanGet if Autopoll bit set.booleanbooleanintintbooleanbooleanbooleanbooleanintintbooleanGet Node Option SENDEOT.booleanbooleanbooleangetOutputBit(int bitNumber) Get the current state of a single output bit.intgetOutputCardIndex(int cardNum) Get 'Output Card Index'.booleanCheck cpNode polling enabled state.intGet cpNode poll list position.intGet cpNode polling status.intGet pulse width.booleanGet state of Sensor polling.intGet transmission delay.booleanDeal with a timeout in the transmission controller.booleanisCMRInetBit(int optionbit) booleaniscpnodeBit(int optionbit) booleanisInputCard(int cardNum) Test for INPUT_CARD type.booleanisOutputCard(int cardNum) Test for OUTPUT_CARD type.booleanbooleanisSearchLightBit(int bit) Query SearchLightBits by bit number (SMINI only).voidUse the contents of the poll reply to mark changesintGet number of input cards.intGet number of output cards.voidregisterSensor(Sensor s, int i) The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS.voidA reply was received, so there was no timeout, do any needed processing.voidset2LeadSearchLight(int bit) Set location of SearchLightBits (SMINI only).voidsetCardTypeByAddress(int address, int type) Set the type of one card.voidsetCardTypeLocation(int num, int value) voidsetCMRInetOpts(int optionbit, int val) voidsetcmriNodeDesc(String nodeDesc) voidsetcpnodeOpts(int optionbit, int val) voidsetLocSearchLightBits(int num, int value) voidsetMonitorNodePackets(boolean onoff) voidsetMonitorPacketBit(int pktTypeBit, boolean onoff) Set the specific packet monitoring enable bit.voidsetNodeType(int type) Set node type.voidsetNum2LSearchLights(int n) voidsetNumBitsPerCard(int bits) Set number of bits per card.voidsetOptNet_AUTOPOLL(int val) update Autopoll bitvoidsetOptNet_BIT15(int val) voidsetOptNet_BIT8(int val) voidsetOptNet_USEBCC(int val) voidsetOptNet_USECMRIX(int val) voidsetOptNode_BIT15(int val) voidsetOptNode_BIT8(int val) voidsetOptNode_SENDEOT(int val) voidsetOptNode_USEBCC(int val) voidsetOptNode_USECMRIX(int val) voidsetOutputBit(int bitNumber, boolean state) Set a single output bit.voidsetPollingEnabled(boolean isEnabled) voidsetPollListPosition(int pos) voidsetPollStatus(int status) voidsetPulseWidth(int width) Set pulse width.voidsetSensorsActive(boolean flag) Set state of Sensor polling.voidsetTransmissionDelay(int delay) Set transmission delay.(package private) voidMethods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, resetMustSend, 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.SENSORSPERUA- See Also:
-
MAXSEARCHLIGHTBYTES
- See Also:
-
MAXCARDLOCATIONBYTES
- See Also:
-
SMINI
- See Also:
-
USIC_SUSIC
- See Also:
-
CPNODE
- See Also:
-
CPMEGA
- See Also:
-
NDP_USICSUSIC24
- See Also:
-
NDP_USICSUSIC32
- See Also:
-
NDP_SMINI
- See Also:
-
NDP_CPNODE
- See Also:
-
NDP_CPMEGA
- See Also:
-
INPUT_CARD
- See Also:
-
OUTPUT_CARD
- See Also:
-
NO_CARD
- See Also:
-
nodeType
-
bitsPerCard
-
transmissionDelay
-
pulseWidth
-
num2LSearchLights
-
locSearchLightBits
-
cardTypeLocation
-
INITMSGLEN
- See Also:
-
NUMCMRINETOPTS
- See Also:
-
NUMCPNODEOPTS
- See Also:
-
cmrinetOptions
-
cpnodeOptions
-
cmriNodeDesc
-
pollListPosition
-
pollStatus
-
POLLSTATUS_ERROR
- See Also:
-
POLLSTATUS_IDLE
- See Also:
-
POLLSTATUS_POLLING
- See Also:
-
POLLSTATUS_TIMEOUT
- See Also:
-
POLLSTATUS_INIT
- See Also:
-
optbitNet_AUTOPOLL
- See Also:
-
optbitNet_USECMRIX
- See Also:
-
optbitNet_USEBCC
- See Also:
-
optbitNet_BIT8
- See Also:
-
optbitNet_BIT15
- See Also:
-
optbitNode_USECMRIX
- See Also:
-
optbitNode_SENDEOT
- See Also:
-
optbitNode_USEBCC
- See Also:
-
optbitNode_BIT8
- See Also:
-
optbitNode_BIT15
- See Also:
-
outputArray
-
hasActiveSensors
-
lastUsedSensor
-
sensorArray
-
sensorLastSetting
-
sensorTempSetting
-
monitorNodePackets
-
monitorPacketBits
-
warned
boolean warned -
timeout
int timeout
-
-
Constructor Details
-
SerialNode
Assumes a node address of 0, and a node type of SMINI. 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
Creates a new SerialNode and initialize default instance variables.- Parameters:
address- Address of node on CMRI serial bus (0-127).type- Node type, e.g. SMINI or USIC_SUSIC.tc- system connection traffic controller.
-
-
Method Details
-
getNum2LSearchLights
-
setNum2LSearchLights
-
getLocSearchLightBits
-
setLocSearchLightBits
-
getCardTypeLocation
-
setCardTypeLocation
-
setOutputBit
Set a single output bit.- Parameters:
bitNumber- bit number, bits are numbered from 1 (not 0).state- true for 0, false for 1.
-
getOutputBit
Get the current state of a single output bit.- Parameters:
bitNumber- bit number, bits are numbered from 1 (not 0).- Returns:
- true for 0, false for 1.
-
getSensorsActive
Get state of Sensor polling. Note: returns 'true' if at least one sensor is active for this node- Specified by:
getSensorsActivein classAbstractNode- Returns:
- 'true' if at least one sensor is active for this node
-
setSensorsActive
Set state of Sensor polling. Used to disable polling for test purposes only.- Parameters:
flag- true to set active flag, else false.
-
numInputCards
Get number of input cards.- Returns:
- number of input cards.
-
numOutputCards
Get number of output cards.- Returns:
- number of output cards.
-
getNodeType
Get node type Current types are: SMINI, USIC_SUSIC,- Returns:
- node type, e.g. USIC_SUSIC.
-
setNodeType
Set node type.Current types are: SMINI, USIC_SUSIC For SMINI, also sets cardTypeLocation[] and bitsPerCard. For USIC_SUSIC, also clears cardTypeLocation.
- Parameters:
type- node type, e.g. USIC_SUSIC.
-
getNumBitsPerCard
Get number of bits per card.- Returns:
- number of bits per card.
-
setNumBitsPerCard
Set number of bits per card.- Parameters:
bits- number of bits.
-
getCMRInetOpts
Get CMRInet options.- Parameters:
optionbit- option index.- Returns:
- option value: meaning depends on option
-
setCMRInetOpts
-
isCMRInetBit
-
getcpnodeOpts
Get cpNode options.- Parameters:
optionbit- option index.- Returns:
- option value: meaning depends on option
-
setcpnodeOpts
-
iscpnodeBit
-
getOptNet_AUTOPOLL
Get if Autopoll bit set.- Returns:
- true if set, else false.
-
getOptNet_USECMRIX
-
getOptNet_USEBCC
-
getOptNet_BIT8
-
getOptNet_BIT15
-
setOptNet_AUTOPOLL
update Autopoll bit- Parameters:
val- 1 sets autopoll on, 0 sets it off
-
setOptNet_USECMRIX
-
setOptNet_USEBCC
-
setOptNet_BIT8
-
setOptNet_BIT15
-
getOptNet_byte0
-
getOptNet_byte1
-
getOptNode_SENDEOT
Get Node Option SENDEOT.- Returns:
- true if SENDEOT, else false.
-
getOptNode_USECMRIX
-
getOptNode_USEBCC
-
getOptNode_BIT8
-
getOptNode_BIT15
-
setOptNode_SENDEOT
-
setOptNode_USECMRIX
-
setOptNode_USEBCC
-
setOptNode_BIT8
-
setOptNode_BIT15
-
getOptNode_byte0
-
getOptNode_byte1
-
getcmriNodeDesc
Get node description.- Returns:
- node description.
-
setcmriNodeDesc
-
getPollListPosition
Get cpNode poll list position.- Returns:
- poll list position.
-
setPollListPosition
-
getPollStatus
Get cpNode polling status.- Returns:
- true if polling status flag set, else false.
-
setPollStatus
-
getPollingEnabled
Check cpNode polling enabled state.- Returns:
- true if polling is enabled.
-
setPollingEnabled
-
getMonitorNodePackets
Get packet monitoring for the node .- Returns:
- true if packet monitoring flag set true, else false.
-
setMonitorNodePackets
-
setMonitorPacketBit
Set the specific packet monitoring enable bit.- Parameters:
pktTypeBit- index.onoff- true enables, false disabled.
-
getMonitorPacketBit
-
checkNodeAddress
Check valid node address, must match value in dip switches (0 - 127). Check for valid address with respect to range, etc.- Specified by:
checkNodeAddressin classAbstractNode- Parameters:
address- node number to check.- Returns:
- true if valid
-
getTransmissionDelay
Get transmission delay.- Returns:
- delay, ms.
-
setTransmissionDelay
Set transmission delay.two bytes are used, so range is 0-65,535. If delay is out of range, it is restricted to the allowable range.
- Parameters:
delay- - delay between bytes on receive (units of 10 microsec.)
-
getPulseWidth
Get pulse width. Used with pulsed turnout control.- Returns:
- pulse width, ms.
-
setPulseWidth
Set pulse width.- Parameters:
width- width of pulse used for pulse controlled turnout control (millisec.) Note: Pulse width must be between 100 and 10000 milliseconds. If width is out of range, it is restricted to the allowable range
-
setCardTypeByAddress
Set the type of one card.- Parameters:
address- address recognized for this card by the node hardware. for USIC_SUSIC address set in card's dip switches (0 - 63)type- INPUT_CARD, OUTPUT_CARD, or NO_CARD
-
isOutputCard
Test for OUTPUT_CARD type.- Parameters:
cardNum- index number.- Returns:
- true if card with 'cardNum' is an output card. false if card is not an output card, or if 'cardNum' is out of range.
-
isInputCard
Test for INPUT_CARD type.- Parameters:
cardNum- index number.- Returns:
- true if card with 'cardNum' is an input card, false if card is not an input card, or if 'cardNum' is out of range.
-
getOutputCardIndex
Get 'Output Card Index'.Can be used to locate this card's bytes in an output message. Array is ordered by increasing node address.
- Parameters:
cardNum- index number.- Returns:
- the index this output card would have in an array of output cards for this node.
-
getInputCardIndex
Get 'Input Card Index'.Can be used to locate this card's bytes in an receive message. Array is ordered by increasing node address.
- Parameters:
cardNum- index number.- Returns:
- the index this input card would have in an array of input cards for this node.
-
set2LeadSearchLight
Set location of SearchLightBits (SMINI only).- Parameters:
bit- - bitNumber of the low bit of an oscillating search light bit pairBits are numbered from 0. Two bits are set by each call - bit and bit + 1. If either bit is already set, an error is logged and no bits are set.
-
clear2LeadSearchLight
Clear location of SearchLightBits (SMINI only).- Parameters:
bit- - bitNumber of the low bit of an oscillating search light bit pairNotes: Bits are numbered from 0 Two bits are cleared by each call - bit and bit + 1. If either bit is already clear, an error is logged and no bits are set.
-
isSearchLightBit
Query SearchLightBits by bit number (SMINI only).- Parameters:
bit- bitNumber of the either bit of an oscillating search light bit pair.- Returns:
- true if bit is an oscillating SearchLightBit, otherwise false.
-
createInitPacket
Create an Initialization packet (SerialMessage) for this node- 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- 0 to MAXSENSORS number of sensor's input bit on this node
-
isPollingOK
- Returns:
- true if polling active and currently OK
-
handleTimeout
Description copied from class:AbstractNodeDeal 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
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
-