Class SerialNode
public class SerialNode extends AbstractNode
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
Fields Modifier and Type Field Description protected int
bitsPerCard
protected byte[]
cardTypeLocation
protected int[]
cmrinetOptions
protected String
cmriNodeDesc
static int
CPMEGA
static int
CPNODE
protected int[]
cpnodeOptions
protected boolean
hasActiveSensors
static int
INITMSGLEN
static byte
INPUT_CARD
protected int
lastUsedSensor
protected byte[]
locSearchLightBits
static int
MAXCARDLOCATIONBYTES
static int
MAXSEARCHLIGHTBYTES
(package private) static int
MAXSENSORS
Maximum number of sensors a node can carry.protected boolean
monitorNodePackets
protected boolean[]
monitorPacketBits
static int
NDP_CPMEGA
static int
NDP_CPNODE
static int
NDP_SMINI
static int
NDP_USICSUSIC24
static int
NDP_USICSUSIC32
static byte
NO_CARD
protected int
nodeType
protected int
num2LSearchLights
static int
NUMCMRINETOPTS
static int
NUMCPNODEOPTS
static int
optbitNet_AUTOPOLL
static int
optbitNet_BIT15
static int
optbitNet_BIT8
static int
optbitNet_USEBCC
static int
optbitNet_USECMRIX
static int
optbitNode_BIT15
static int
optbitNode_BIT8
static int
optbitNode_SENDEOT
static int
optbitNode_USEBCC
static int
optbitNode_USECMRIX
static byte
OUTPUT_CARD
protected byte[]
outputArray
protected int
pollListPosition
int
pollStatus
static int
POLLSTATUS_ERROR
static int
POLLSTATUS_IDLE
static int
POLLSTATUS_INIT
static int
POLLSTATUS_POLLING
static int
POLLSTATUS_TIMEOUT
protected int
pulseWidth
protected Sensor[]
sensorArray
protected int[]
sensorLastSetting
protected int[]
sensorTempSetting
static int
SMINI
(package private) int
timeout
protected int
transmissionDelay
static int
USIC_SUSIC
(package private) boolean
warned
-
Constructor Summary
Constructors Constructor Description SerialNode(int address, int type, SerialTrafficController tc)
Creates a new SerialNode and initialize default instance variables.SerialNode(SerialTrafficController tc)
Assumes a node address of 0, and a node type of SMINI. -
Method Summary
Modifier and Type Method Description protected boolean
checkNodeAddress(int address)
Check valid node address, must match value in dip switches (0 - 127).void
clear2LeadSearchLight(int bit)
Clear location of SearchLightBits (SMINI only).AbstractMRMessage
createInitPacket()
Create an Initialization packet (SerialMessage) for this nodeAbstractMRMessage
createOutPacket()
Create an Transmit packet (SerialMessage)byte[]
getCardTypeLocation()
int
getCMRInetOpts(int optionbit)
Get CMRInet options.String
getcmriNodeDesc()
Get node description.int
getcpnodeOpts(int optionbit)
Get cpNode options.int
getInputCardIndex(int cardNum)
Get 'Input Card Index'.byte[]
getLocSearchLightBits()
boolean
getMonitorNodePackets()
Get packet monitoring for the node .boolean
getMonitorPacketBit(int pktTypeBit)
int
getNodeType()
Get node type Current types are: SMINI, USIC_SUSIC,int
getNum2LSearchLights()
int
getNumBitsPerCard()
Get number of bits per card.boolean
getOptNet_AUTOPOLL()
Get if Autopoll bit set.boolean
getOptNet_BIT15()
boolean
getOptNet_BIT8()
int
getOptNet_byte0()
int
getOptNet_byte1()
boolean
getOptNet_USEBCC()
boolean
getOptNet_USECMRIX()
boolean
getOptNode_BIT15()
boolean
getOptNode_BIT8()
int
getOptNode_byte0()
int
getOptNode_byte1()
boolean
getOptNode_SENDEOT()
Get Node Option SENDEOT.boolean
getOptNode_USEBCC()
boolean
getOptNode_USECMRIX()
boolean
getOutputBit(int bitNumber)
Get the current state of a single output bit.int
getOutputCardIndex(int cardNum)
Get 'Output Card Index'.boolean
getPollingEnabled()
Check cpNode polling enabled state.int
getPollListPosition()
Get cpNode poll list position.int
getPollStatus()
Get cpNode polling status.int
getPulseWidth()
Get pulse width.boolean
getSensorsActive()
Get state of Sensor polling.int
getTransmissionDelay()
Get transmission delay.boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.boolean
isCMRInetBit(int optionbit)
boolean
iscpnodeBit(int optionbit)
boolean
isInputCard(int cardNum)
Test for INPUT_CARD type.boolean
isOutputCard(int cardNum)
Test for OUTPUT_CARD type.boolean
isPollingOK()
boolean
isSearchLightBit(int bit)
Query SearchLightBits by bit number (SMINI only).void
markChanges(SerialReply l)
Use the contents of the poll reply to mark changesint
numInputCards()
Get number of input cards.int
numOutputCards()
Get number of output cards.void
registerSensor(Sensor s, int i)
The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS.void
resetTimeout(AbstractMRMessage m)
A reply was received, so there was no timeout, do any needed processing.void
set2LeadSearchLight(int bit)
Set location of SearchLightBits (SMINI only).void
setCardTypeByAddress(int address, int type)
Set the type of one card.void
setCardTypeLocation(int num, int value)
void
setCMRInetOpts(int optionbit, int val)
void
setcmriNodeDesc(String nodeDesc)
void
setcpnodeOpts(int optionbit, int val)
void
setLocSearchLightBits(int num, int value)
void
setMonitorNodePackets(boolean onoff)
void
setMonitorPacketBit(int pktTypeBit, boolean onoff)
Set the specific packet monitoring enable bit.void
setNodeType(int type)
Set node type.void
setNum2LSearchLights(int n)
void
setNumBitsPerCard(int bits)
Set number of bits per card.void
setOptNet_AUTOPOLL(int val)
void
setOptNet_BIT15(int val)
void
setOptNet_BIT8(int val)
void
setOptNet_USEBCC(int val)
void
setOptNet_USECMRIX(int val)
void
setOptNode_BIT15(int val)
void
setOptNode_BIT8(int val)
void
setOptNode_SENDEOT(int val)
void
setOptNode_USEBCC(int val)
void
setOptNode_USECMRIX(int val)
void
setOutputBit(int bitNumber, boolean state)
Set a single output bit.void
setPollingEnabled(boolean isEnabled)
void
setPollListPosition(int pos)
void
setPollStatus(int status)
void
setPulseWidth(int width)
Set pulse width.void
setSensorsActive(boolean flag)
Set state of Sensor polling.void
setTransmissionDelay(int delay)
Set transmission delay.(package private) void
warn(String s)
Methods 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:
- Constant Field Values
-
MAXSEARCHLIGHTBYTES
- See Also:
- Constant Field Values
-
MAXCARDLOCATIONBYTES
- See Also:
- Constant Field Values
-
SMINI
- See Also:
- Constant Field Values
-
USIC_SUSIC
- See Also:
- Constant Field Values
-
CPNODE
- See Also:
- Constant Field Values
-
CPMEGA
- See Also:
- Constant Field Values
-
NDP_USICSUSIC24
- See Also:
- Constant Field Values
-
NDP_USICSUSIC32
- See Also:
- Constant Field Values
-
NDP_SMINI
- See Also:
- Constant Field Values
-
NDP_CPNODE
- See Also:
- Constant Field Values
-
NDP_CPMEGA
- See Also:
- Constant Field Values
-
INPUT_CARD
- See Also:
- Constant Field Values
-
OUTPUT_CARD
- See Also:
- Constant Field Values
-
NO_CARD
- See Also:
- Constant Field Values
-
nodeType
-
bitsPerCard
-
transmissionDelay
-
pulseWidth
-
num2LSearchLights
-
locSearchLightBits
-
cardTypeLocation
-
INITMSGLEN
- See Also:
- Constant Field Values
-
NUMCMRINETOPTS
- See Also:
- Constant Field Values
-
NUMCPNODEOPTS
- See Also:
- Constant Field Values
-
cmrinetOptions
-
cpnodeOptions
-
cmriNodeDesc
-
pollListPosition
-
pollStatus
-
POLLSTATUS_ERROR
- See Also:
- Constant Field Values
-
POLLSTATUS_IDLE
- See Also:
- Constant Field Values
-
POLLSTATUS_POLLING
- See Also:
- Constant Field Values
-
POLLSTATUS_TIMEOUT
- See Also:
- Constant Field Values
-
POLLSTATUS_INIT
- See Also:
- Constant Field Values
-
optbitNet_AUTOPOLL
- See Also:
- Constant Field Values
-
optbitNet_USECMRIX
- See Also:
- Constant Field Values
-
optbitNet_USEBCC
- See Also:
- Constant Field Values
-
optbitNet_BIT8
- See Also:
- Constant Field Values
-
optbitNet_BIT15
- See Also:
- Constant Field Values
-
optbitNode_USECMRIX
- See Also:
- Constant Field Values
-
optbitNode_SENDEOT
- See Also:
- Constant Field Values
-
optbitNode_USEBCC
- See Also:
- Constant Field Values
-
optbitNode_BIT8
- See Also:
- Constant Field Values
-
optbitNode_BIT15
- See Also:
- Constant Field Values
-
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:
getSensorsActive
in 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.
-
setCMRInetOpts
-
isCMRInetBit
-
getcpnodeOpts
Get cpNode options.- Parameters:
optionbit
- option index.- Returns:
- option value.
-
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
-
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:
checkNodeAddress
in 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:
createInitPacket
in classAbstractNode
- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
Create an Transmit packet (SerialMessage)- Specified by:
createOutPacket
in 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:AbstractNode
Deal with a timeout in the transmission controller.- Specified by:
handleTimeout
in 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:AbstractNode
A reply was received, so there was no timeout, do any needed processing.- Specified by:
resetTimeout
in classAbstractNode
- Parameters:
m
- message received that has reset the timeout and is waiting to be handled
-