jmri.jmrix
Class AbstractNode

java.lang.Object
  extended by jmri.jmrix.AbstractNode
Direct Known Subclasses:
AcelaNode, SerialNode, SerialNode, SerialNode, SerialNode

public abstract class AbstractNode
extends Object

Basic implementation of a node for JMRI protocol support.

Integrated with AbstractMRNodeTrafficController.

Author:
Bob Jacobsen Copyright 2008

Field Summary
 int nodeAddress
           
 
Constructor Summary
AbstractNode()
          Creates a new instance of AbstractNode
 
Method Summary
protected abstract  boolean checkNodeAddress(int address)
          Check for valid address with respect to range, etc.
abstract  AbstractMRMessage createInitPacket()
          Create the needed Initialization packet (AbstractMRMessage) for this node.
abstract  AbstractMRMessage createOutPacket()
          Create an Transmit packet (AbstractMRMessage) to send current state
 int getNodeAddress()
          Public method to return the node address.
abstract  boolean handleTimeout(AbstractMRMessage m)
          Deal with a timeout in the transmission controller.
 boolean mustSend()
          Return state of needSend flag.
 void resetMustSend()
          Public to reset state of needSend flag.
abstract  void resetTimeout(AbstractMRMessage m)
          A reply was received, so there was not timeout, do any needed processing.
abstract  boolean sensorsActive()
          Are there sensors present, and hence this node will need to be polled?
 void setMustSend()
          Public to set state of needSend flag.
 void setNodeAddress(int address)
          Public method to set the node address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeAddress

public int nodeAddress
Constructor Detail

AbstractNode

public AbstractNode()
Creates a new instance of AbstractNode

Method Detail

getNodeAddress

public int getNodeAddress()
Public method to return the node address.


setNodeAddress

public void setNodeAddress(int address)
Public method to set the node address. Address range is checked in subclasses.

Throws:
IllegalArgumentException - if out of range

checkNodeAddress

protected abstract boolean checkNodeAddress(int address)
Check for valid address with respect to range, etc.

Returns:
true if valid

createInitPacket

public abstract AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node. Returns null if not needed.


createOutPacket

public abstract AbstractMRMessage createOutPacket()
Create an Transmit packet (AbstractMRMessage) to send current state


sensorsActive

public abstract boolean sensorsActive()
Are there sensors present, and hence this node will need to be polled? Note: returns 'true' if at least one sensor is active for this node


handleTimeout

public abstract boolean handleTimeout(AbstractMRMessage m)
Deal with a timeout in the transmission controller.

Parameters:
m - message that didn't receive a reply
Returns:
true if initialization required

resetTimeout

public abstract void resetTimeout(AbstractMRMessage m)
A reply was received, so there was not timeout, do any needed processing.


mustSend

public boolean mustSend()
Return state of needSend flag.


resetMustSend

public void resetMustSend()
Public to reset state of needSend flag. Subclasses may override to enforce conditions.


setMustSend

public void setMustSend()
Public to set state of needSend flag.



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