Class AcelaNode
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- jmri.jmrix.acela.AcelaNode
-
public class AcelaNode extends AbstractNode
Models an Acela node.Nodes are numbered from 0. The first watchman node carries the first 8 sensors 0 to 7, 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.
Same applies to the outputs (Dash-8s and Signalmen)
-
-
Field Summary
Fields Modifier and Type Field Description static byteACstatic intBLINKstatic intBPOLARstatic byteD8static intDOUBLEprotected intendingOutputAddressprotected intendingSensorAddressprotected booleanhasActiveSensorsprotected intlastUsedSensor(package private) static intMAXNODE(package private) static intMAXOUTPUTBITS(package private) static intMAXSENSORBITSMaximum number of sensors/outputs any node of any type can carry.(package private) static java.lang.String[]moduleNames(package private) static java.lang.String[]moduleTipsstatic java.lang.StringmoduleTypesprotected booleanneedInit(package private) static java.lang.String[]nodeNamesprotected intnodeTypestatic intONOFFprotected byte[]outputArrayprotected intoutputbitsPerCardprotected int[]outputInitstatic java.lang.StringoutputInitsstatic java.lang.StringoutputLEN0protected int[]outputLengthprotected boolean[]outputNeedToSendstatic java.lang.StringoutputNOstatic java.lang.StringoutputONOFFprotected int[]outputSignalHeadTypestatic java.lang.StringoutputSignalHeadTypesprotected int[]outputSpecialprotected int[]outputTypestatic java.lang.StringoutputTypesprotected int[]outputWiredstatic java.lang.StringoutputWiredsstatic intPULSEstatic byteSCprotected Sensor[]sensorArrayprotected intsensorbitsPerCardprotected byte[]sensorConfigArrayprotected boolean[]sensorHasBeenInitprotected int[]sensorLastSettingprotected boolean[]sensorNeedInitstatic java.lang.StringsensorPolaritiesprotected int[]sensorPolarityprotected int[]sensorThresholdprotected int[]sensorTypestatic java.lang.StringsensorTypesstatic byteSMprotected intstartingOutputAddressprotected intstartingSensorAddressstatic byteSWstatic byteSYstatic byteTB(package private) inttimeoutprotected inttransmissionDelaystatic intTRIPLEstatic intUKNOWNstatic byteUN(package private) booleanwarnedstatic intWIGWAGstatic byteWMstatic byteYM-
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
-
-
Constructor Summary
Constructors Constructor Description AcelaNode()Create a new AcelaNode instance on the TrafficController associated with the default AcelaSystemConnectionMemo.AcelaNode(int address, int type, AcelaTrafficController tc)Create a new AcelaNode instance and initialize default instance variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckNodeAddress(int address)Check for valid address with respect to range, etc.AbstractMRMessagecreateInitPacket()Create the needed Initialization packet (AbstractMRMessage) for this node.AbstractMRMessagecreateOutPacket()Create a Transmit packet (SerialMessage) to send current state.intgetEndingOutputAddress()Get ending output address for range.intgetEndingSensorAddress()Get ending sensor addresses for range.static java.lang.String[]getModuleNames()static java.lang.String[]getNodeNames()intgetNodeType()Public method to return node type.java.lang.StringgetNodeTypeString()intgetNumOutputBitsPerCard()Public method to return number of bits per card.intgetNumSensorBitsPerCard()booleangetOutputBit(int bitNumber)Get the current state of an output bit.intgetOutputInit(int circuitnum)java.lang.StringgetOutputInitString(int circuitnum)intgetOutputLength(int circuitnum)intgetOutputSignalHeadType(int circuitnum)java.lang.StringgetOutputSignalHeadTypeString(int circuitnum)intgetOutputSpecial(int circuitnum)intgetOutputType(int circuitnum)java.lang.StringgetOutputTypeString(int circuitnum)intgetOutputWired(int circuitnum)Get Output configuration values.java.lang.StringgetOutputWiredString(int circuitnum)intgetSensorBitsPerCard()Get the number of sensor bits per node.intgetSensorPolarity(int circuitnum)java.lang.StringgetSensorPolarityString(int circuitnum)booleangetSensorsActive()Are any sensors present, and hence will this node need to be polled?intgetSensorThreshold(int circuitnum)intgetSensorType(int circuitnum)Public method to set and return Sensor configuration values.java.lang.StringgetSensorTypeString(int circuitnum)intgetStartingOutputAddress()Get starting output address for range.intgetStartingSensorAddress()Get starting sensor addresses for range.intgetTransmissionDelay()Get the transmission delay on this node.booleanhandleTimeout(AbstractMRMessage m, AbstractMRListener l)Deal with a timeout in the transmission controller.voidinitNode()voidmarkChanges(AcelaReply l)Use the contents of the poll reply to mark changes.voidregisterSensor(Sensor s, int rawaddr)Register a sensor on an Acela node.voidresetTimeout(AbstractMRMessage m)A reply was received, so there was no timeout, do any needed processing.voidsetEndingOutputAddress(int endingAddress)Set ending output address for range.voidsetEndingSensorAddress(int endingAddress)Set ending sensor addresses for range.voidsetNodeType(int type)voidsetNodeTypeString(java.lang.String stringtype)Public method to set node type.voidsetOutputBit(int bitNumber, boolean state)Set an output bit on this node.voidsetOutputInit(int circuitnum, int type)voidsetOutputInitString(int circuitnum, java.lang.String stringtype)voidsetOutputLength(int circuitnum, int newlength)voidsetOutputSignalHeadType(int circuitnum, int type)voidsetOutputSignalHeadTypeString(int circuitnum, java.lang.String stringtype)voidsetOutputSpecial(int circuitnum, int type)voidsetOutputType(int circuitnum, int type)voidsetOutputTypeString(int circuitnum, java.lang.String stringtype)voidsetOutputWired(int circuitnum, int type)Set Output configuration values.voidsetOutputWiredString(int circuitnum, java.lang.String stringtype)voidsetSensorPolarity(int circuitnum, int polarity)voidsetSensorPolarityString(int circuitnum, java.lang.String stringpolarity)voidsetSensorThreshold(int circuitnum, int threshold)voidsetSensorType(int circuitnum, int type)voidsetSensorTypeString(int circuitnum, java.lang.String stringtype)voidsetStartingOutputAddress(int startingAddress)Set starting output address for range.voidsetStartingSensorAddress(int startingAddress)Set starting sensor address for range.voidsetTransmissionDelay(int delay)Set transmission delay.-
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, resetMustSend, setMustSend, setNodeAddress
-
-
-
-
Field Detail
-
MAXSENSORBITS
static final int MAXSENSORBITS
Maximum number of sensors/outputs any node of any type can carry.- See Also:
- Constant Field Values
-
MAXOUTPUTBITS
static final int MAXOUTPUTBITS
- See Also:
- Constant Field Values
-
MAXNODE
static final int MAXNODE
- See Also:
- Constant Field Values
-
AC
public static final byte AC
- See Also:
- Constant Field Values
-
TB
public static final byte TB
- See Also:
- Constant Field Values
-
D8
public static final byte D8
- See Also:
- Constant Field Values
-
WM
public static final byte WM
- See Also:
- Constant Field Values
-
SM
public static final byte SM
- See Also:
- Constant Field Values
-
SC
public static final byte SC
- See Also:
- Constant Field Values
-
SW
public static final byte SW
- See Also:
- Constant Field Values
-
YM
public static final byte YM
- See Also:
- Constant Field Values
-
SY
public static final byte SY
- See Also:
- Constant Field Values
-
UN
public static final byte UN
- See Also:
- Constant Field Values
-
moduleTypes
public static final java.lang.String moduleTypes
- See Also:
- Constant Field Values
-
nodeNames
static final java.lang.String[] nodeNames
-
moduleNames
static final java.lang.String[] moduleNames
-
moduleTips
static final java.lang.String[] moduleTips
-
nodeType
protected int nodeType
-
outputbitsPerCard
protected int outputbitsPerCard
-
sensorbitsPerCard
protected int sensorbitsPerCard
-
transmissionDelay
protected int transmissionDelay
-
needInit
protected boolean needInit
-
outputArray
protected byte[] outputArray
-
outputSpecial
protected int[] outputSpecial
-
outputSignalHeadType
protected int[] outputSignalHeadType
-
hasActiveSensors
protected boolean hasActiveSensors
-
lastUsedSensor
protected int lastUsedSensor
-
sensorArray
protected Sensor[] sensorArray
-
sensorNeedInit
protected boolean[] sensorNeedInit
-
sensorHasBeenInit
protected boolean[] sensorHasBeenInit
-
sensorLastSetting
protected int[] sensorLastSetting
-
sensorType
protected int[] sensorType
-
sensorPolarity
protected int[] sensorPolarity
-
sensorThreshold
protected int[] sensorThreshold
-
sensorConfigArray
protected byte[] sensorConfigArray
-
outputWired
protected int[] outputWired
-
outputInit
protected int[] outputInit
-
outputType
protected int[] outputType
-
outputLength
protected int[] outputLength
-
outputNeedToSend
protected boolean[] outputNeedToSend
-
sensorTypes
public static final java.lang.String sensorTypes
- See Also:
- Constant Field Values
-
sensorPolarities
public static final java.lang.String sensorPolarities
- See Also:
- Constant Field Values
-
outputWireds
public static final java.lang.String outputWireds
- See Also:
- Constant Field Values
-
outputInits
public static final java.lang.String outputInits
- See Also:
- Constant Field Values
-
outputTypes
public static final java.lang.String outputTypes
- See Also:
- Constant Field Values
-
ONOFF
public static final int ONOFF
- See Also:
- Constant Field Values
-
PULSE
public static final int PULSE
- See Also:
- Constant Field Values
-
BLINK
public static final int BLINK
- See Also:
- Constant Field Values
-
outputSignalHeadTypes
public static final java.lang.String outputSignalHeadTypes
- See Also:
- Constant Field Values
-
UKNOWN
public static final int UKNOWN
- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
- See Also:
- Constant Field Values
-
TRIPLE
public static final int TRIPLE
- See Also:
- Constant Field Values
-
BPOLAR
public static final int BPOLAR
- See Also:
- Constant Field Values
-
WIGWAG
public static final int WIGWAG
- See Also:
- Constant Field Values
-
outputONOFF
public static final java.lang.String outputONOFF
- See Also:
- Constant Field Values
-
outputLEN0
public static final java.lang.String outputLEN0
- See Also:
- Constant Field Values
-
outputNO
public static final java.lang.String outputNO
- See Also:
- Constant Field Values
-
startingOutputAddress
protected int startingOutputAddress
-
endingOutputAddress
protected int endingOutputAddress
-
startingSensorAddress
protected int startingSensorAddress
-
endingSensorAddress
protected int endingSensorAddress
-
warned
boolean warned
-
timeout
int timeout
-
-
Constructor Detail
-
AcelaNode
public AcelaNode()
Create a new AcelaNode instance on the TrafficController associated with the default AcelaSystemConnectionMemo.Assumes a node address of 0, and a node type of NO_CARD. If this constructor is used, actual node address must be set using
AbstractNode.setNodeAddress(int)and actual node type usingsetNodeType(int)
-
AcelaNode
public AcelaNode(int address, int type, AcelaTrafficController tc)
Create a new AcelaNode instance and initialize default instance variables.- Parameters:
address- the address of first bit on Acela bus (0-1023) type - D8, SM, WMtype- a type constant from the classtc- the TrafficControllerfor this connection
-
-
Method Detail
-
getNodeNames
public static java.lang.String[] getNodeNames()
-
getModuleNames
public static java.lang.String[] getModuleNames()
-
initNode
public void initNode()
-
setStartingOutputAddress
public void setStartingOutputAddress(int startingAddress)
Set starting output address for range. Used to help linear address search.- Parameters:
startingAddress- starting output address for range.
-
getStartingOutputAddress
public int getStartingOutputAddress()
Get starting output address for range. Used to help linear address search.- Returns:
- starting output address.
-
setEndingOutputAddress
public void setEndingOutputAddress(int endingAddress)
Set ending output address for range. Used to help linear address search.- Parameters:
endingAddress- end output address for range.
-
getEndingOutputAddress
public int getEndingOutputAddress()
Get ending output address for range. Used to help linear address search.- Returns:
- end output address for range.
-
setStartingSensorAddress
public void setStartingSensorAddress(int startingAddress)
Set starting sensor address for range. Used to help linear address search.- Parameters:
startingAddress- start sensor address for range.
-
getStartingSensorAddress
public int getStartingSensorAddress()
Get starting sensor addresses for range. Used to help linear address search.- Returns:
- starting sensor address for range.
-
setEndingSensorAddress
public void setEndingSensorAddress(int endingAddress)
Set ending sensor addresses for range. Used to help linear address search.- Parameters:
endingAddress- end sensor address.
-
getEndingSensorAddress
public int getEndingSensorAddress()
Get ending sensor addresses for range. Used to help linear address search.- Returns:
- end of range sensor address.
-
setOutputBit
public void setOutputBit(int bitNumber, boolean state)
Set an output bit on this node.- Parameters:
bitNumber- the bit to setstate- bit state to set: 'true' for 0, 'false' for 1
-
getOutputBit
public boolean getOutputBit(int bitNumber)
Get the current state of an output bit.- Parameters:
bitNumber- the bit. Bits are numbered from 0 for Acela- Returns:
- 'true' for 0, 'false' for 1
-
getSensorsActive
public boolean getSensorsActive()
Are any sensors present, and hence will this node need to be polled?- Specified by:
getSensorsActivein classAbstractNode- Returns:
- 'true' if at least one sensor is active for this node
-
getOutputWired
public int getOutputWired(int circuitnum)
Get Output configuration values.- Parameters:
circuitnum- wired output index number.- Returns:
- configuration value.
-
getOutputWiredString
public java.lang.String getOutputWiredString(int circuitnum)
-
setOutputWired
public void setOutputWired(int circuitnum, int type)
Set Output configuration values.- Parameters:
circuitnum- output index number.type- output type.
-
setOutputWiredString
public void setOutputWiredString(int circuitnum, java.lang.String stringtype)
-
getOutputInit
public int getOutputInit(int circuitnum)
-
getOutputInitString
public java.lang.String getOutputInitString(int circuitnum)
-
setOutputInit
public void setOutputInit(int circuitnum, int type)
-
setOutputInitString
public void setOutputInitString(int circuitnum, java.lang.String stringtype)
-
getOutputType
public int getOutputType(int circuitnum)
-
getOutputTypeString
public java.lang.String getOutputTypeString(int circuitnum)
-
setOutputType
public void setOutputType(int circuitnum, int type)
-
setOutputTypeString
public void setOutputTypeString(int circuitnum, java.lang.String stringtype)
-
getOutputLength
public int getOutputLength(int circuitnum)
-
setOutputLength
public void setOutputLength(int circuitnum, int newlength)
-
getOutputSpecial
public int getOutputSpecial(int circuitnum)
-
setOutputSpecial
public void setOutputSpecial(int circuitnum, int type)
-
getOutputSignalHeadType
public int getOutputSignalHeadType(int circuitnum)
-
getOutputSignalHeadTypeString
public java.lang.String getOutputSignalHeadTypeString(int circuitnum)
-
setOutputSignalHeadType
public void setOutputSignalHeadType(int circuitnum, int type)
-
setOutputSignalHeadTypeString
public void setOutputSignalHeadTypeString(int circuitnum, java.lang.String stringtype)
-
getSensorType
public int getSensorType(int circuitnum)
Public method to set and return Sensor configuration values.- Parameters:
circuitnum- sensor type array index number.- Returns:
- sensor index value.
-
getSensorTypeString
public java.lang.String getSensorTypeString(int circuitnum)
-
setSensorType
public void setSensorType(int circuitnum, int type)
-
setSensorTypeString
public void setSensorTypeString(int circuitnum, java.lang.String stringtype)
-
getSensorPolarity
public int getSensorPolarity(int circuitnum)
-
getSensorPolarityString
public java.lang.String getSensorPolarityString(int circuitnum)
-
setSensorPolarity
public void setSensorPolarity(int circuitnum, int polarity)
-
setSensorPolarityString
public void setSensorPolarityString(int circuitnum, java.lang.String stringpolarity)
-
getSensorThreshold
public int getSensorThreshold(int circuitnum)
-
setSensorThreshold
public void setSensorThreshold(int circuitnum, int threshold)
-
getNodeType
public int getNodeType()
Public method to return node type.- Returns:
- node type number.
-
getNodeTypeString
public java.lang.String getNodeTypeString()
-
setNodeTypeString
public void setNodeTypeString(java.lang.String stringtype)
Public method to set node type.- Parameters:
stringtype- string form of node type.
-
setNodeType
public void setNodeType(int type)
-
getNumOutputBitsPerCard
public int getNumOutputBitsPerCard()
Public method to return number of bits per card.- Returns:
- number of output bits per card.
-
getNumSensorBitsPerCard
public int getNumSensorBitsPerCard()
-
checkNodeAddress
public boolean checkNodeAddress(int address)
Check for valid address with respect to range, etc.- Specified by:
checkNodeAddressin classAbstractNode- Parameters:
address- node number to check.- Returns:
- true if valid
-
getSensorBitsPerCard
public int getSensorBitsPerCard()
Get the number of sensor bits per node.- Returns:
- sensorbitsPerCard
-
getTransmissionDelay
public int getTransmissionDelay()
Get the transmission delay on this node.- Returns:
- delay in 10s of microseconds.
-
setTransmissionDelay
public void setTransmissionDelay(int delay)
Set transmission delay.Note: two bytes are used, so range is 0-65,535. If delay is out of range, it is restricted to the allowable range.
- Parameters:
delay- a delay between bytes on receive (units of 10 microsec.)
-
createInitPacket
public AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.- Specified by:
createInitPacketin classAbstractNode- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
public AbstractMRMessage createOutPacket()
Create a Transmit packet (SerialMessage) to send current state.- Specified by:
createOutPacketin classAbstractNode- Returns:
- packet to send current node state.
-
markChanges
public void markChanges(AcelaReply 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 rawaddr)
Register a sensor on an Acela node. The numbers here are 0 to MAXSENSORBITS, not 1 to MAXSENSORBITS.- Parameters:
s- Sensor objectrawaddr- index number of sensor's input bit on this node, valid range from 0 to MAXSENSORBITS
-
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
-
-