jmri.jmrix.grapevine
Class SerialNode

java.lang.Object
  extended by jmri.jmrix.AbstractNode
      extended by jmri.jmrix.grapevine.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.

Author:
Bob Jacobsen Copyright (C) 2003, 2006, 2007, 2008, Bob Jacobsen, Dave Duchamp, multiNode extensions, 2004

Field Summary
static String[] boardNames
           
protected  boolean hasActiveSensors
           
static int[] inputBits
           
protected  int lastUsedSensor
           
static int NODE2000
           
static int NODE2002V1
           
static int NODE2002V6
           
protected  int nodeType
           
protected  byte[] outputArray
           
static int[] outputBits
           
protected  boolean[] outputByteChanged
           
protected  Sensor[] sensorArray
           
protected  int[] sensorLastSetting
           
protected  int[] sensorTempSetting
           
 
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
 
Constructor Summary
SerialNode()
          Assumes a node address of 0, and a node type of 0 (NODE2002V6) If this constructor is used, actual node address must be set using setNodeAddress, and actual node type using 'setNodeType'
SerialNode(int address, int type)
          Creates a new SerialNode and initialize default instance variables address - Address of node on serial bus (0-255) type - a type constant from the class
 
Method Summary
protected  boolean checkNodeAddress(int address)
          Check for valid node address
 AbstractMRMessage createInitPacket()
          Public Method to create Initialization packets (SerialMessage) for this node.
 AbstractMRMessage createOutPacket()
          Public Method to create an Transmit packet (SerialMessage)
 int getNodeType()
          Public method to return node type
 boolean handleTimeout(AbstractMRMessage m)
          Deal with a timeout in the transmission controller.
 void markChanges(SerialReply l)
          Use the contents of a reply from the Grapevine to mark changes in the sensors on the layout.
 void registerSensor(Sensor s, int i)
          The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS.
 void resetMustSend()
          Public to reset state of needSend flag.
 void resetTimeout(AbstractMRMessage m)
          A reply was received, so there was not timeout, do any needed processing.
 boolean sensorsActive()
          Public method to return state of Sensors.
 void setNodeType(int type)
          Public method to set node type.
 void setOutputBit(int bitNumber, boolean state)
          Public method setting an output bit.
 
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, setMustSend, setNodeAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE2002V6

public static final int NODE2002V6
See Also:
Constant Field Values

NODE2002V1

public static final int NODE2002V1
See Also:
Constant Field Values

NODE2000

public static final int NODE2000
See Also:
Constant Field Values

boardNames

public static final String[] boardNames

outputBits

public static final int[] outputBits

inputBits

public static final int[] inputBits

nodeType

protected int nodeType

outputArray

protected byte[] outputArray

outputByteChanged

protected boolean[] outputByteChanged

hasActiveSensors

protected boolean hasActiveSensors

lastUsedSensor

protected int lastUsedSensor

sensorArray

protected Sensor[] sensorArray

sensorLastSetting

protected int[] sensorLastSetting

sensorTempSetting

protected int[] sensorTempSetting
Constructor Detail

SerialNode

public SerialNode()
Assumes a node address of 0, and a node type of 0 (NODE2002V6) If this constructor is used, actual node address must be set using setNodeAddress, and actual node type using 'setNodeType'


SerialNode

public SerialNode(int address,
                  int type)
Creates a new SerialNode and initialize default instance variables address - Address of node on serial bus (0-255) type - a type constant from the class

Method Detail

setOutputBit

public void setOutputBit(int bitNumber,
                         boolean state)
Public method setting an output bit. Note: state = 'true' for 0, 'false' for 1 bits are numbered from 1 (not 0)


sensorsActive

public boolean sensorsActive()
Public method to return state of Sensors. Note: returns 'true' if at least one sensor is active for this node

Specified by:
sensorsActive in class AbstractNode

resetMustSend

public void resetMustSend()
Public to reset state of needSend flag. Can only reset if there are no bytes that need to be sent

Overrides:
resetMustSend in class AbstractNode

getNodeType

public int getNodeType()
Public method to return node type


setNodeType

public void setNodeType(int type)
Public method to set node type.


checkNodeAddress

protected boolean checkNodeAddress(int address)
Check for valid node address

Specified by:
checkNodeAddress in class AbstractNode
Returns:
true if valid

createInitPacket

public AbstractMRMessage createInitPacket()
Public Method to create Initialization packets (SerialMessage) for this node. Initialization consists of multiple parts: (Eventually, it should also request input values, once we know what message does that)

As an Ugly Hack to keep these separate, only the first is put in the reply from this. The other(s) are sent via the usual output methods.

Specified by:
createInitPacket in class AbstractNode

createOutPacket

public AbstractMRMessage createOutPacket()
Public Method to create an Transmit packet (SerialMessage)

Specified by:
createOutPacket in class AbstractNode

markChanges

public void markChanges(SerialReply l)
Use the contents of a reply from the Grapevine to mark changes in the sensors on the layout.

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. E.g. the integer argument is one less than the name of the sensor object.

Parameters:
s - Sensor object
i - bit number corresponding, a 1-based value corresponding to the low digits of the system name

handleTimeout

public boolean handleTimeout(AbstractMRMessage m)
Description copied from class: AbstractNode
Deal with a timeout in the transmission controller.

Specified by:
handleTimeout in class AbstractNode
Parameters:
m - message that didn't receive a reply
Returns:
true if initialization required

resetTimeout

public void resetTimeout(AbstractMRMessage m)
Description copied from class: AbstractNode
A reply was received, so there was not timeout, do any needed processing.

Specified by:
resetTimeout in class AbstractNode


Copyright © 1997 - 2008 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: SourceForge_Logo