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 intCABDRIVERstatic intDAUGHTERprotected booleanhasActiveSensors(package private) static int[]inputBitsprotected intlastUsedSensor(package private) static intMAXSENSORSMaximum number of sensors a node can carry.(package private) static intMAXTURNOUTSprotected intnodeTypeprotected boolean[]outputArrayprotected boolean[]outputBitChanged(package private) static int[]outputBitsprotected Sensor[]sensorArrayprotected int[]sensorLastSettingprotected int[]sensorTempSetting(package private) inttimeout(package private) booleanwarned-
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 booleancheckNodeAddress(int address)Check for valid node address.AbstractMRMessagecreateInitPacket()Create an Initialization packet (SerialMessage) for this node.AbstractMRMessagecreateOutPacket()Create a Transmit packet (SerialMessage).static java.lang.String[]getBoardNames()intgetNodeType()Public method to return node type.booleangetSensorsActive()Get state of Sensors.booleanhandleTimeout(AbstractMRMessage m, AbstractMRListener l)Deal with a timeout in the transmission controller.voidmarkChanges(SerialReply l)Use 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.voidresetTimeout(AbstractMRMessage m)A 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) voidwarn(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:
getSensorsActivein 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:
checkNodeAddressin 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:
createInitPacketin 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:
createOutPacketin 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:
handleTimeoutin 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:
resetTimeoutin classAbstractNode- Parameters:
m- message received that has reset the timeout and is waiting to be handled
-
-