Package jmri.jmrix.secsi
Class SerialNode
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- jmri.jmrix.secsi.SerialNode
-
public class SerialNode extends AbstractNode
Models a serial node.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
Fields Modifier and Type Field Description static int
CABDRIVER
static int
DAUGHTER
protected boolean
hasActiveSensors
(package private) static int[]
inputBits
protected int
lastUsedSensor
(package private) static int
MAXSENSORS
Maximum number of sensors a node can carry.(package private) static int
MAXTURNOUTS
protected int
nodeType
protected boolean[]
outputArray
protected boolean[]
outputBitChanged
(package private) static int[]
outputBits
protected Sensor[]
sensorArray
protected int[]
sensorLastSetting
protected int[]
sensorTempSetting
(package private) int
timeout
(package private) boolean
warned
-
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
-
-
Constructor Summary
Constructors Constructor Description SerialNode(int address, int type, SerialTrafficController _tc)
Create a new SerialNode and initialize default instance variables.SerialNode(SerialTrafficController _tc)
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'
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkNodeAddress(int address)
Check for valid node address.AbstractMRMessage
createInitPacket()
Create an Initialization packet (SerialMessage) for this node.AbstractMRMessage
createOutPacket()
Create a Transmit packet (SerialMessage).static java.lang.String[]
getBoardNames()
int
getNodeType()
Public method to return node type.boolean
getSensorsActive()
Get state of Sensors.boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.void
markChanges(SerialReply l)
Use the contents of the poll reply to mark changes.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
setNodeType(int type)
Set node type.void
setOutputBit(int bitNumber, boolean state)
Set an output bit on this node.(package private) void
warn(java.lang.String s)
-
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, resetMustSend, setMustSend, setNodeAddress
-
-
-
-
Field Detail
-
MAXSENSORS
static final int 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,
SerialSensorManager.SENSORSPERNODE
- See Also:
- Constant Field Values
-
MAXTURNOUTS
static final int MAXTURNOUTS
- See Also:
- Constant Field Values
-
DAUGHTER
public static final int DAUGHTER
- See Also:
- Constant Field Values
-
CABDRIVER
public static final int CABDRIVER
- See Also:
- Constant Field Values
-
outputBits
static final int[] outputBits
-
inputBits
static final int[] inputBits
-
nodeType
protected int nodeType
-
outputArray
protected boolean[] outputArray
-
outputBitChanged
protected boolean[] outputBitChanged
-
hasActiveSensors
protected boolean hasActiveSensors
-
lastUsedSensor
protected int lastUsedSensor
-
sensorArray
protected Sensor[] sensorArray
-
sensorLastSetting
protected int[] sensorLastSetting
-
sensorTempSetting
protected int[] sensorTempSetting
-
warned
boolean warned
-
timeout
int timeout
-
-
Constructor Detail
-
SerialNode
public SerialNode(SerialTrafficController _tc)
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:
_tc
- system connection traffic controller.
-
SerialNode
public SerialNode(int address, int type, SerialTrafficController _tc)
Create a new SerialNode and initialize default instance variables.- Parameters:
address
- address of node on serial bus (0-255)type
- a type constant from the class_tc
- connected TafficController
-
-
Method Detail
-
getBoardNames
public static java.lang.String[] getBoardNames()
-
setOutputBit
public void setOutputBit(int bitNumber, boolean state)
Set an output bit on this node.- Parameters:
bitNumber
- the bit on node to set (numbered from 1; not 0)state
- 'true' for 0, 'false' for 1.
-
getSensorsActive
public boolean getSensorsActive()
Get state of Sensors.- Specified by:
getSensorsActive
in classAbstractNode
- Returns:
- 'true' if at least one sensor is active for this node
-
getNodeType
public int getNodeType()
Public method to return node type. Current types are: DAUGHTER, CABDRIVER- Returns:
- node type.
-
setNodeType
public void setNodeType(int type)
Set node type.- Parameters:
type
- node type, e.g. DAUGHTER or CABDRIVER
-
checkNodeAddress
protected boolean checkNodeAddress(int address)
Check for valid node address.- Specified by:
checkNodeAddress
in classAbstractNode
- Parameters:
address
- node number to check.- Returns:
- true if valid
-
createInitPacket
public AbstractMRMessage createInitPacket()
Create an Initialization packet (SerialMessage) for this node.- Specified by:
createInitPacket
in classAbstractNode
- Returns:
- null as there are currently no SECSI boards that need an init message
-
createOutPacket
public AbstractMRMessage createOutPacket()
Create a Transmit packet (SerialMessage).- Specified by:
createOutPacket
in classAbstractNode
- Returns:
- packet to send current node state.
-
warn
void warn(java.lang.String s)
-
markChanges
public void markChanges(SerialReply l)
Use the contents of the poll reply to mark changes. TODO For Secsi Simulator, needs more work to create correct reply.- Parameters:
l
- Reply to a poll operation
-
registerSensor
public void registerSensor(Sensor s, int i)
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
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
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 is required
-
resetTimeout
public void resetTimeout(AbstractMRMessage m)
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
-
-