Class NceTrafficController
- All Implemented Interfaces:
CommandStation,NceInterface
The connection to a NcePortController 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longLimit max accy decoder to addr 250static final longAll Connections Support commandsstatic final longSupports read AIU status commands0x9Bstatic final longSupport Clock commands0x82 -> 0x87static final longSupports USB read/write memory commands0xB3 -> 0xB5static final longInitializer for supported command groupsstatic final longDisable for USB commandsstatic final longSupport Ops Mode Pgm commands0xAE -> 0xAFstatic final longSupports programming track and related commandsstatic final longSupport USB Interface commands0xB1boolean(package private) boolean(package private) NceSensorManagerstatic final intCreate commands compatible with the 1.28 EPROM.static final intCreate commands compatible with the 1.65 EPROM.static final intCreate commands compatible with the 1999 EPROM.static final intCreate commands compatible with the 2004 EPROM.static final intCreate commands compatible with the 2006 EPROM.static final intCreate all commands in the ASCII format.static final intCreate all commands in the binary format.static final intCreate commands compatible with the PH5.(package private) NceAIUChecker(package private) NceConnectionStatus(package private) NceTurnoutMonitorprotected booleanprotected intprotected booleanstatic final intDefault when a NCE USB isn't selected in user system preferences.static final intCreate commands compatible with a NCE USB connected to a PowerCab.static final intCreate commands compatible with a NCE USB connected to a PowerPro.static final intCreate commands compatible with a NCE USB connected to a Smart Booster.static final intCreate commands compatible with a NCE USB with SB5.static final intCreate commands compatible with a NCE USB with >=7.* connected to a Twin.Fields 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 booleanOverride in the system specific code if necessaryprotected booleanprotected AbstractMRMessageSets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageSet the system to programming mode.protected intGet the delay (wait time) after enabling the programming track.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m) Forward a NceMessage to all registered NceInterface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply r) Forward a NceReply to all registered NceInterface listeners.protected voidforwardToPort(AbstractMRMessage m, AbstractMRListener reply) Actually transmit the next message to the port.longGet the types of commands valid for the NCE USB and connected systemCMDS_NONECMDS_ACCYADDR250CMDS_PROGTRACKCMDS_AUI_READCMDS_MEMCMDS_OPS_PGMCMDS_CLOCKCMDS_USBCMDS_NOT_USBCMDS_ALL_SYSintDetermine which command format should be used for various commands: ASCII or binary.booleanGets the state of the command stationReturn the Power Pro firmware version as user-friendly hex text.intGet the type of system the NCE USB is connected toUSB_SYSTEM_NONEUSB_SYSTEM_POWERCABUSB_SYSTEM_SB3USB_SYSTEM_POWERPROUSB_SYSTEM_TWINUSB_SYSTEM_SB5booleanbooleanAsk whether Power Pro firmware version is 6.2.3 or later.booleanprotected AbstractMRReplynewReply()protected AbstractMRMessageCheck NCE EPROM and start NCE CS accessory memory pollprotected AbstractMRListenervoidvoidsendNceMessage(NceMessage m, NceListener reply) Forward a preformatted message to the actual interface.booleansendPacket(byte[] packet, int count) CommandStation implementationvoidsetAdapterMemo(NceSystemConnectionMemo adaptermemo) voidsetCmdGroups(long val) Set the types of commands valid connected systemCMDS_NONECMDS_ACCYADDR250CMDS_PROGTRACKCMDS_AUI_READCMDS_MEMCMDS_OPS_PGMCMDS_CLOCKCMDS_USBCMDS_NOT_USBCMDS_ALL_SYSvoidsetCommandOptions(int val) Control which command format should be used for various commands: ASCII or binary.voidsetNceEpromMarch2007(boolean b) voidsetNceProgMode(boolean b) Sets the state of the command stationvoidsetPwrProVer060203orLater(boolean isTrue) Specify whether Power Pro firmware version is 6.2.3 or later.voidsetPwrProVers(byte VV, byte MM, byte mm) Store the Power Pro firmware version.voidvoidsetSimulatorRunning(boolean b) voidsetUsbSystem(int val) Set the type of system the NCE USB is connected toUSB_SYSTEM_NONEUSB_SYSTEM_POWERCABUSB_SYSTEM_SB3USB_SYSTEM_POWERPROUSB_SYSTEM_TWINUSB_SYSTEM_SB5Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, connectionWarn, connectPort, disconnectPort, distributeReply, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.CommandStation
sendAccSignalDecoderPkt, sendAltAccSignalDecoderPktMethods inherited from interface jmri.jmrix.nce.NceInterface
status
-
Field Details
-
mSensorManager
-
OPTION_FORCE_ASCII
Create all commands in the ASCII format.- See Also:
-
OPTION_1999
Create commands compatible with the 1999 EPROM.This is binary for everything except service-mode CV programming operations.
- See Also:
-
OPTION_2004
Create commands compatible with the 2004 EPROM.This is binary for everything except service-mode CV programming operations.
- See Also:
-
OPTION_2006
Create commands compatible with the 2006 EPROM.This is binary for everything, including service-mode CV programming operations.
- See Also:
-
OPTION_1_28
Create commands compatible with the 1.28 EPROM.For PowerCab/SB3 original pre-Nov 2012
- See Also:
-
OPTION_1_65
Create commands compatible with the 1.65 EPROM.For PowerCab/SB5/Twin update post-Nov 2012
- See Also:
-
OPTION_PH5
Create commands compatible with the PH5.For PH5
- See Also:
-
OPTION_FORCE_BINARY
Create all commands in the binary format.- See Also:
-
commandOptionSet
-
USB_SYSTEM_NONE
Default when a NCE USB isn't selected in user system preferences. Also the case when Serial or Simulator is selected.- See Also:
-
USB_SYSTEM_POWERCAB
Create commands compatible with a NCE USB connected to a PowerCab.- See Also:
-
USB_SYSTEM_SB3
Create commands compatible with a NCE USB connected to a Smart Booster.- See Also:
-
USB_SYSTEM_POWERPRO
Create commands compatible with a NCE USB connected to a PowerPro.- See Also:
-
USB_SYSTEM_TWIN
Create commands compatible with a NCE USB with >=7.* connected to a Twin.- See Also:
-
USB_SYSTEM_SB5
Create commands compatible with a NCE USB with SB5.- See Also:
-
CMDS_NONE
Initializer for supported command groups- See Also:
-
CMDS_ACCYADDR250
Limit max accy decoder to addr 250- See Also:
-
CMDS_PROGTRACK
Supports programming track and related commands- See Also:
-
CMDS_AUI_READ
Supports read AIU status commands0x9B- See Also:
-
CMDS_MEM
Supports USB read/write memory commands0xB3 -> 0xB5- See Also:
-
CMDS_OPS_PGM
Support Ops Mode Pgm commands0xAE -> 0xAF- See Also:
-
CMDS_CLOCK
Support Clock commands0x82 -> 0x87- See Also:
-
CMDS_USB
Support USB Interface commands0xB1- See Also:
-
CMDS_NOT_USB
Disable for USB commands- See Also:
-
CMDS_ALL_SYS
All Connections Support commands- See Also:
-
pollEprom
-
pollAiuStatus
-
pollHandler
-
expectReplyEprom
boolean expectReplyEprom -
replyLen
-
replyBinary
-
unsolicitedSensorMessageSeen
-
csm
-
-
Constructor Details
-
NceTrafficController
public NceTrafficController()Create a new NCE SerialTrafficController instance. Simple implementation.
-
-
Method Details
-
addNceListener
- Specified by:
addNceListenerin interfaceNceInterface
-
removeNceListener
- Specified by:
removeNceListenerin interfaceNceInterface
-
enterProgModeDelayTime
Description copied from class:AbstractMRTrafficControllerGet the delay (wait time) after enabling the programming track. Override in subclass to add a longer delay.- Overrides:
enterProgModeDelayTimein classAbstractMRTrafficController- Returns:
- 0 as default delay
-
sendPacket
CommandStation implementation- Specified by:
sendPacketin interfaceCommandStation- Parameters:
packet- Byte array representing the packet, including the error-correction byte.count- Number of times to repeat the transmission.- Returns:
trueif the operation succeeds,falseotherwise.
-
forwardMessage
Forward a NceMessage to all registered NceInterface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
Forward a NceReply to all registered NceInterface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
setSensorManager
-
getSensorManager
-
getPwrProVersHexText
Return the Power Pro firmware version as user-friendly hex text.- Returns:
- period-separated firmware version
-
setPwrProVers
Store the Power Pro firmware version.- Parameters:
VV- major versionMM- intermediate versionmm- minor version
-
isPwrProVer060203orLater
Ask whether Power Pro firmware version is 6.2.3 or later.- Returns:
trueif it does, otherwisefalse
-
setPwrProVer060203orLater
Specify whether Power Pro firmware version is 6.2.3 or later.- Parameters:
isTrue-trueif it does, otherwisefalse
-
isNceEpromMarch2007
-
setNceEpromMarch2007
-
isSimulatorRunning
-
setSimulatorRunning
-
setCommandOptions
Control which command format should be used for various commands: ASCII or binary.The valid argument values are the class "OPTION" constants, which are interpreted in the various methods to get a particular message.
- Parameters:
val- command station options
-
getCommandOptions
Determine which command format should be used for various commands: ASCII or binary.The valid return values are the class "OPTION" constants, which are interpreted in the various methods to get a particular message.
- Returns:
- command station options value
-
setUsbSystem
Set the type of system the NCE USB is connected to- Parameters:
val- usb command station options
-
getUsbSystem
Get the type of system the NCE USB is connected to- Returns:
- usb command station options
-
setCmdGroups
Set the types of commands valid connected system- Parameters:
val- command group supported options
-
getCmdGroups
Get the types of commands valid for the NCE USB and connected system- Returns:
- command group supported options
-
getNceProgMode
Gets the state of the command station- Returns:
- true if in programming mode
-
setNceProgMode
Sets the state of the command station- Parameters:
b- when true, set programming mode
-
pollMessage
Check NCE EPROM and start NCE CS accessory memory poll- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendNceMessage
Forward a preformatted message to the actual interface.- Specified by:
sendNceMessagein interfaceNceInterface- Parameters:
m- Message to be sent.reply- Listener to be notified of reply.
-
forwardToPort
Description copied from class:AbstractMRTrafficControllerActually transmit the next message to the port.- Overrides:
forwardToPortin classAbstractMRTrafficController- Parameters:
m- the message to sendreply- the Listener sending the message, often provided as 'this'- See Also:
-
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:
-
setAdapterMemo
- Parameters:
adaptermemo- the SystemConnectionMemo to associate with this TrafficController
-
getAdapterMemo
-
newReply
- Specified by:
newReplyin classAbstractMRTrafficController
-
canReceive
Description copied from class:AbstractMRTrafficControllerOverride in the system specific code if necessary- Overrides:
canReceivein classAbstractMRTrafficController- Returns:
- true if it is okay to buffer receive characters into a reply message. When false, discard char received
-
endOfMessage
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
getUserName
- Specified by:
getUserNamein interfaceCommandStation
-
getSystemPrefix
- Specified by:
getSystemPrefixin interfaceCommandStation
-