Package jmri.jmrix.acela
Class AcelaTrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.AbstractMRNodeTrafficController
jmri.jmrix.acela.AcelaTrafficController
- All Implemented Interfaces:
AcelaInterface
public class AcelaTrafficController
extends AbstractMRNodeTrafficController
implements AcelaInterface
Converts Stream-based I/O to/from Acela messages.
The "SerialInterface" side sends/receives message objects.
The connection to an AcelaPortController is via a pair of Streams, which then carry sequences of characters for transmission. Note that this processing is handled in an independent thread.
This handles the state transitions, based on the necessary state in each message.
Handles initialization, polling, output, and input for multiple Serial Nodes.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) AcelaSystemConnectionMemoReference to the system connection memo.(package private) AcelaSensorManager(package private) AcelaTurnoutManagerFields inherited from class jmri.jmrix.AbstractMRNodeTrafficController
curSerialNodeIndex, maxNode, minNode, nodeArray, numNodesFields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, AUTORETRYSTATE, cmdListeners, connectionError, controller, flushReceiveChars, IDLESTATE, istream, listenerQueue, maxRcvExceptionCount, mCurrentMode, mCurrentState, mLastSender, msgQueue, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, POLLSTATE, PROGRAMINGMODE, rcvException, rcvThread, replyInDispatch, threadStopRequest, timeoutFlag, timeouts, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable, xmtThread -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleanprotected AbstractMRMessageSets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageSet the system to programming mode.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m) Forward an AcelaMessage to all registered AcelaInterface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply m) Forward an AcelaReply to all registered AcelaInterface listeners.intbooleanbooleanintGet maximum number of Acela nodes as set on this TrafficController.intGet minimum address of an Acela node as set on this TrafficController.booleanbooleanGet access to the system connection memo associated with this traffic controller.protected voidvoidvoidinitializeAcelaNode(AcelaNode node) Public method to set up for initialization of an Acela node.protected voidloadChars(AbstractMRReply msg, DataInputStream istream) Get characters from the input source, and file a message.intlookupAcelaNodeAddress(int bitAddress, boolean isSensor) Public method to identify an AcelaNode from its bit address.protected AbstractMRReplynewReply()protected AbstractMRMessageHandle initialization, output and polling for Acela Nodes from within the running thread.protected AbstractMRListenervoidregisterAcelaNode(AcelaNode node) Public method to register an Acela node.voidvoidprotected voidvoidsendAcelaMessage(AcelaMessage m, AcelaListener reply) Forward a pre-formatted message to the actual interface.voidsetAcelaSensorsState(boolean newstate) voidsetAcelaTrafficControllerState(boolean newstate) voidsetNeedToPollNodes(boolean newstate) voidsetReallyReadyToPoll(boolean newstate) voidvoidSet the system connection memo associated with this traffic controller.voidvoidFor each sensor node call markChanges.protected voidwaitForStartOfReply(DataInputStream istream) Dummy routine, to be filled by protocols that have to skip some start-of-message characters.Methods inherited from class jmri.jmrix.AbstractMRNodeTrafficController
deleteNode, getMustInit, getNode, getNodeFromAddress, getNumNodes, init, registerNode, setMustInit, setMustInitMethods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, hasTimeouts, lengthOfByteStream, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, warnOnTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrix.acela.AcelaInterface
status
-
Field Details
-
curAcelaNodeIndex
-
mMemo
Reference to the system connection memo. -
mSensorManager
-
mTurnoutManager
-
-
Constructor Details
-
AcelaTrafficController
public AcelaTrafficController()Create a new AcelaTrafficController instance.
-
-
Method Details
-
addAcelaListener
- Specified by:
addAcelaListenerin interfaceAcelaInterface
-
removeAcelaListener
- Specified by:
removeAcelaListenerin interfaceAcelaInterface
-
getMinimumNodeAddress
Get minimum address of an Acela node as set on this TrafficController.- Returns:
- minimum node address.
-
getMaximumNumberOfNodes
Get maximum number of Acela nodes as set on this TrafficController.- Returns:
- max number of nodes.
-
getAcelaTrafficControllerState
-
setAcelaTrafficControllerState
-
resetStartingAddresses
-
getAcelaSensorsState
-
setAcelaSensorsState
-
incrementAcelaSensorInitCount
-
getAcelaSensorInitCount
-
getNeedToPollNodes
-
setNeedToPollNodes
-
getReallyReadyToPoll
-
setReallyReadyToPoll
-
getSystemConnectionMemo
Get access to the system connection memo associated with this traffic controller.- Returns:
- associated systemConnectionMemo object
-
setSystemConnectionMemo
Set the system connection memo associated with this traffic controller.- Parameters:
m- associated systemConnectionMemo object
-
registerAcelaNode
Public method to register an Acela node.- Parameters:
node- which node to register.
-
initializeAcelaNode
Public method to set up for initialization of an Acela node.- Parameters:
node- which node to initialize.
-
lookupAcelaNodeAddress
Public method to identify an AcelaNode from its bit address.Note: nodeAddress is numbered from 0
- Parameters:
bitAddress- address to query.isSensor- true to use start sensor address, false to use start output address.- Returns:
- '-1' if an AcelaNode with the specified address was not found
-
enterProgMode
Description copied from class:AbstractMRTrafficControllerSet the system to programming mode.- Specified by:
enterProgModein classAbstractMRTrafficController- Returns:
- any message that needs to be returned to the Command Station to change modes. If no message is needed, returns null.
- See Also:
-
enterNormalMode
Description copied from class:AbstractMRTrafficControllerSets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()returns true, enterNormalMode() is called after a timeout.- Specified by:
enterNormalModein classAbstractMRTrafficController- Returns:
- any message that needs to be returned to the Command Station to change modes. If no message is needed, returns null.
- See Also:
-
forwardMessage
Forward an AcelaMessage to all registered AcelaInterface listeners. Implement this to forward a specific message type to a protocol-specific listener interface. This puts the casting into the concrete class.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
Forward an AcelaReply to all registered AcelaInterface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
setSensorManager
-
setTurnoutManager
-
pollMessage
Handle initialization, output and polling for Acela Nodes from within the running thread.- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
handleTimeout
- Overrides:
handleTimeoutin classAbstractMRTrafficController
-
resetTimeout
- Overrides:
resetTimeoutin classAbstractMRTrafficController
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendAcelaMessage
Forward a pre-formatted message to the actual interface.- Specified by:
sendAcelaMessagein interfaceAcelaInterface
-
newReply
- Specified by:
newReplyin classAbstractMRTrafficController
-
endOfMessage
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
loadChars
Description copied from class:AbstractMRTrafficControllerGet characters from the input source, and file a message.Returns only when the message is complete.
Only used in the Receive thread.
Handles timeouts on read by ignoring zero-length reads.
- Overrides:
loadCharsin classAbstractMRTrafficController- Parameters:
msg- message to fillistream- character source.- Throws:
IOException- when presented by the input source.
-
waitForStartOfReply
Description copied from class:AbstractMRTrafficControllerDummy routine, to be filled by protocols that have to skip some start-of-message characters.- Overrides:
waitForStartOfReplyin classAbstractMRTrafficController- Parameters:
istream- input source- Throws:
IOException- from underlying operations
-
updateSensorsFromPoll
For each sensor node call markChanges.- Parameters:
r- reply to use in sensor update.
-