jmri.jmrix.secsi
Class SerialNode

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

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

Field Summary
static String[] boardNames
           
static int CABDRIVER
           
static int DAUGHTER
           
protected  boolean hasActiveSensors
           
static int[] inputBits
           
protected  int lastUsedSensor
           
protected  int nodeType
           
protected  boolean[] outputArray
           
protected  boolean[] outputBitChanged
           
static int[] outputBits
           
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 (IO24) 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 an Initialization packet (SerialMessage) for this node.
 AbstractMRMessage createOutPacket()
          Public Method to create an Transmit packet (SerialMessage)
 int getNodeType()
          Public method to return node type Current types are: SMINI, USIC_SUSIC,
 boolean handleTimeout(AbstractMRMessage m)
          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 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, resetMustSend, setMustSend, setNodeAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DAUGHTER

public static final int DAUGHTER
See Also:
Constant Field Values

CABDRIVER

public static final int CABDRIVER
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 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
Constructor Detail

SerialNode

public SerialNode()
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'


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

getNodeType

public int getNodeType()
Public method to return node type Current types are: SMINI, USIC_SUSIC,


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 an Initialization packet (SerialMessage) for this node. There are currently no SECSI boards that need an init message, so this returns null.

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 the poll reply to mark changes

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 object
i - - 0 to MAXSENSORS number of sensor's input bit on this node

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