jmri.jmrix.cmri.serial
Class SerialNode

java.lang.Object
  extended by jmri.jmrix.AbstractNode
      extended by jmri.jmrix.cmri.serial.SerialNode

public class SerialNode
extends AbstractNode

Models a serial C/MRI node, consisting of a (S)USIC and attached cards.

Nodes are numbered ala the UA number, from 1 to 63. 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.

The SMINI is defined as having 1 input and 2 outputs cards.
USIC/SUSIC nodes can have 0-63 inputs and 0-63 output cards, but no more than 64 total cards.

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

Field Summary
protected  int bitsPerCard
           
protected  byte[] cardTypeLocation
           
protected  boolean hasActiveSensors
           
static byte INPUT_CARD
           
protected  int lastUsedSensor
           
protected  byte[] locSearchLightBits
           
static int MAXCARDLOCATIONBYTES
           
static int MAXSEARCHLIGHTBYTES
           
static byte NO_CARD
           
protected  int nodeType
           
protected  int num2LSearchLights
           
static byte OUTPUT_CARD
           
protected  byte[] outputArray
           
protected  int pulseWidth
           
protected  Sensor[] sensorArray
           
protected  int[] sensorLastSetting
           
protected  int[] sensorTempSetting
           
static int SMINI
           
protected  int transmissionDelay
           
static int USIC_SUSIC
           
 
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
 
Constructor Summary
SerialNode()
          Assumes a node address of 0, and a node type of SMINI 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 CMRI serial bus (0-127) type - SMINI, USIC_SUSIC,
 
Method Summary
protected  boolean checkNodeAddress(int address)
          Check valid node address, must match value in dip switches (0 - 127)
 void clear2LeadSearchLight(int bit)
          Public Method to clear location of SearchLightBits (SMINI only) bit - bitNumber of the low bit of an oscillating search light bit pair Notes: Bits are numbered from 0 Two bits are cleared by each call - bit and bit + 1.
 AbstractMRMessage createInitPacket()
          Public Method to create an Initialization packet (SerialMessage) for this node
 AbstractMRMessage createOutPacket()
          Public Method to create an Transmit packet (SerialMessage)
 byte[] getCardTypeLocation()
           
 int getInputCardIndex(int cardNum)
          Public method to return 'Input Card Index' Returns the index this input card would have in an array of input cards for this node.
 byte[] getLocSearchLightBits()
           
 int getNodeType()
          Public method to return node type Current types are: SMINI, USIC_SUSIC,
 int getNum2LSearchLights()
           
 int getNumBitsPerCard()
          Public method to return number of bits per card.
 boolean getOutputBit(int bitNumber)
          Public method get the current state of an output bit.
 int getOutputCardIndex(int cardNum)
          Public method to return 'Output Card Index' Returns the index this output card would have in an array of output cards for this node.
 int getPulseWidth()
          Public method to return pulse width.
 boolean getSensorsActive()
          Public method to return state of Sensors.
 int getTransmissionDelay()
          Public method to return transmission delay.
 boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
          Deal with a timeout in the transmission controller.
 boolean isInputCard(int cardNum)
          Public method to test for INPUT_CARD type.
 boolean isOutputCard(int cardNum)
          Public method to test for OUTPUT_CARD type.
 boolean isSearchLightBit(int bit)
          Public Method to query SearchLightBits by bit number (SMINI only) bit - bitNumber of the either bit of an oscillating search light bit pair Note: returns 'true' if bit is an oscillating SearchLightBit, otherwise 'false' is returned
 void markChanges(SerialReply l)
          Use the contents of the poll reply to mark changes
 int numInputCards()
          Public method to return number of input cards.
 int numOutputCards()
          Public method to return number of output cards.
 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.
 void set2LeadSearchLight(int bit)
          Public Method to set location of SearchLightBits (SMINI only) bit - bitNumber of the low bit of an oscillating search light bit pair Notes: Bits are numbered from 0 Two bits are set by each call - bit and bit + 1.
 void setCardTypeByAddress(int address, int type)
          Public method to set the type of one card.
 void setCardTypeLocation(int num, int value)
           
 void setLocSearchLightBits(int num, int value)
           
 void setNodeType(int type)
          Public method to set node type Current types are: SMINI, USIC_SUSIC, For SMINI, also sets cardTypeLocation[] and bitsPerCard For USIC_SUSIC, also clears cardTypeLocation
 void setNum2LSearchLights(int n)
           
 void setNumBitsPerCard(int bits)
          Public method to set number of bits per card.
 void setOutputBit(int bitNumber, boolean state)
          Public method setting an output bit.
 void setPulseWidth(int width)
          Public method to set pulse width.
 void setSensorsActive(boolean flag)
          Public method to set state of Sensors.
 void setTransmissionDelay(int delay)
          Public method to set transmission delay.
 
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

MAXSEARCHLIGHTBYTES

public static final int MAXSEARCHLIGHTBYTES
See Also:
Constant Field Values

MAXCARDLOCATIONBYTES

public static final int MAXCARDLOCATIONBYTES
See Also:
Constant Field Values

SMINI

public static final int SMINI
See Also:
Constant Field Values

USIC_SUSIC

public static final int USIC_SUSIC
See Also:
Constant Field Values

INPUT_CARD

public static final byte INPUT_CARD
See Also:
Constant Field Values

OUTPUT_CARD

public static final byte OUTPUT_CARD
See Also:
Constant Field Values

NO_CARD

public static final byte NO_CARD
See Also:
Constant Field Values

nodeType

protected int nodeType

bitsPerCard

protected int bitsPerCard

transmissionDelay

protected int transmissionDelay

pulseWidth

protected int pulseWidth

num2LSearchLights

protected int num2LSearchLights

locSearchLightBits

protected byte[] locSearchLightBits

cardTypeLocation

protected byte[] cardTypeLocation

outputArray

protected byte[] outputArray

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 SMINI 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 CMRI serial bus (0-127) type - SMINI, USIC_SUSIC,

Method Detail

getNum2LSearchLights

public int getNum2LSearchLights()

setNum2LSearchLights

public void setNum2LSearchLights(int n)

getLocSearchLightBits

public byte[] getLocSearchLightBits()

setLocSearchLightBits

public void setLocSearchLightBits(int num,
                                  int value)

getCardTypeLocation

public byte[] getCardTypeLocation()

setCardTypeLocation

public void setCardTypeLocation(int num,
                                int value)

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)


getOutputBit

public boolean getOutputBit(int bitNumber)
Public method get the current state of an output bit. Note: returns 'true' for 0, 'false' for 1 bits are numbered from 1 (not 0)


getSensorsActive

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

Specified by:
getSensorsActive in class AbstractNode

setSensorsActive

public void setSensorsActive(boolean flag)
Public method to set state of Sensors. Used to disable polling for test purposes only.


numInputCards

public int numInputCards()
Public method to return number of input cards.


numOutputCards

public int numOutputCards()
Public method to return number of output cards.


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 Current types are: SMINI, USIC_SUSIC, For SMINI, also sets cardTypeLocation[] and bitsPerCard For USIC_SUSIC, also clears cardTypeLocation


getNumBitsPerCard

public int getNumBitsPerCard()
Public method to return number of bits per card.


setNumBitsPerCard

public void setNumBitsPerCard(int bits)
Public method to set number of bits per card.


checkNodeAddress

protected boolean checkNodeAddress(int address)
Check valid node address, must match value in dip switches (0 - 127)

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

getTransmissionDelay

public int getTransmissionDelay()
Public method to return transmission delay.


setTransmissionDelay

public void setTransmissionDelay(int delay)
Public method to set transmission delay. delay - delay between bytes on receive (units of 10 microsec.) Note: two bytes are used, so range is 0-65,535. If delay is out of range, it is restricted to the allowable range


getPulseWidth

public int getPulseWidth()
Public method to return pulse width. Used with pulsed turnout control.


setPulseWidth

public void setPulseWidth(int width)
Public method to set pulse width. width - width of pulse used for pulse controlled turnout control (millisec.) Note: Pulse width must be between 100 and 10000 milliseconds. If width is out of range, it is restricted to the allowable range


setCardTypeByAddress

public void setCardTypeByAddress(int address,
                                 int type)
Public method to set the type of one card. address - address recognized for this card by the node hardware. for USIC_SUSIC address set in card's dip switches (0 - 63) type - INPUT_CARD, OUTPUT_CARD, or NO_CARD


isOutputCard

public boolean isOutputCard(int cardNum)
Public method to test for OUTPUT_CARD type. Returns true if card with 'cardNum' is an output card. Returns false if card is not an output card, or if 'cardNum' is out of range.


isInputCard

public boolean isInputCard(int cardNum)
Public method to test for INPUT_CARD type. Returns true if card with 'cardNum' is an input card. Returns false if card is not an input card, or if 'cardNum' is out of range.


getOutputCardIndex

public int getOutputCardIndex(int cardNum)
Public method to return 'Output Card Index' Returns the index this output card would have in an array of output cards for this node. Can be used to locate this card's bytes in an output message. Array is ordered by increasing node address.


getInputCardIndex

public int getInputCardIndex(int cardNum)
Public method to return 'Input Card Index' Returns the index this input card would have in an array of input cards for this node. Can be used to locate this card's bytes in an receive message. Array is ordered by increasing node address.


set2LeadSearchLight

public void set2LeadSearchLight(int bit)
Public Method to set location of SearchLightBits (SMINI only) bit - bitNumber of the low bit of an oscillating search light bit pair Notes: Bits are numbered from 0 Two bits are set by each call - bit and bit + 1. If either bit is already set, an error is logged and no bits are set.


clear2LeadSearchLight

public void clear2LeadSearchLight(int bit)
Public Method to clear location of SearchLightBits (SMINI only) bit - bitNumber of the low bit of an oscillating search light bit pair Notes: Bits are numbered from 0 Two bits are cleared by each call - bit and bit + 1. If either bit is already clear, an error is logged and no bits are set.


isSearchLightBit

public boolean isSearchLightBit(int bit)
Public Method to query SearchLightBits by bit number (SMINI only) bit - bitNumber of the either bit of an oscillating search light bit pair Note: returns 'true' if bit is an oscillating SearchLightBit, otherwise 'false' is returned


createInitPacket

public AbstractMRMessage createInitPacket()
Public Method to create an Initialization packet (SerialMessage) for this node

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,
                             AbstractMRListener l)
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
l - listener that sent the message
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 - 2011 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: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads