Class SerialTrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.powerline.SerialTrafficController
-
- All Implemented Interfaces:
SerialInterface
- Direct Known Subclasses:
SpecificTrafficController,SpecificTrafficController,SpecificTrafficController,SpecificTrafficController,SpecificTrafficController
public abstract class SerialTrafficController extends AbstractMRTrafficController implements SerialInterface
Converts Stream-based I/O to/from messages. The "SerialInterface" side sends/receives message objects.The connection to a SerialPortController 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 maintains a list of nodes, but doesn't currently do anything with it.
This implementation is complete and can be instantiated, but is not functional. It will be created e.g. when a default object is needed for configuring nodes, etc, during the initial configuration. A subclass must be instantiated to actually communicate with an adapter.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleancountingBytes(package private) booleanexpectLengthprotected booleanlogDebugprotected SerialSystemConnectionMemomemo(package private) SerialSensorManagermSensorManager(package private) intremainingBytes(package private) SerialTrafficControllerself(package private) booleansendInterlock-
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 Constructor Description SerialTrafficController()Create a new TrafficController instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSerialListener(SerialListener l)protected booleanendOfMessage(AbstractMRReply msg)This is a default, null implementation, which must be overridden in an adapter-specific subclass.protected AbstractMRMessageenterNormalMode()Sets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageenterProgMode()Set the system to programming mode.protected intenterProgModeDelayTime()Get the delay (wait time) after enabling the programming track.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m)Forward a SerialMessage to all registered SerialInterface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply r)Forward a reply to all registered SerialInterface listeners.protected voidforwardToPort(AbstractMRMessage m, AbstractMRListener reply)Actually transmit the next message to the port.SerialSystemConnectionMemogetAdapterMemo()intgetNumberOfIntensitySteps()Provide the maximum number of dimming steps available.SerialSensorManagergetSensorManager()SerialMessagegetSerialMessage(int length)Get a message of a specific length for filling in.protected AbstractMRReplynewReply()This is a default, null implementation, which must be overridden in an adapter-specific subclass.protected AbstractMRMessagepollMessage()Eventually, do initialization if neededprotected AbstractMRListenerpollReplyHandler()voidremoveSerialListener(SerialListener l)booleansendDmxSequence(int unitid, byte newStep)Send a sequence of DMX messages to an adapter.voidsendInsteonSequence(InsteonSequence s, SerialListener l)Send a sequence of Insteon messages to an adapter.voidsendSerialMessage(SerialMessage m, SerialListener reply)Forward a preformatted message to the actual interface.voidsendX10Sequence(X10Sequence s, SerialListener l)Send a sequence of X10 messages to an adapter.voidsetAdapterMemo(SerialSystemConnectionMemo adaptermemo)voidsetSensorManager(SerialSensorManager m)-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, 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, warnOnTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.powerline.SerialInterface
status
-
-
-
-
Field Detail
-
logDebug
protected boolean logDebug
-
mSensorManager
SerialSensorManager mSensorManager
-
memo
protected SerialSystemConnectionMemo memo
-
sendInterlock
boolean sendInterlock
-
expectLength
boolean expectLength
-
countingBytes
boolean countingBytes
-
remainingBytes
int remainingBytes
-
-
Constructor Detail
-
SerialTrafficController
public SerialTrafficController()
Create a new TrafficController instance. Simple implementation.
-
-
Method Detail
-
sendX10Sequence
public void sendX10Sequence(X10Sequence s, SerialListener l)
Send a sequence of X10 messages to an adapter.Makes them into the local messages and then queues in order.
This is a default, null implementation, which must be overridden in an adapter-specific subclass.
- Parameters:
s- sequence to sendl- listener for reply
-
sendInsteonSequence
public void sendInsteonSequence(InsteonSequence s, SerialListener l)
Send a sequence of Insteon messages to an adapter.Makes them into the local messages and then queues in order.
This is a default, null implementation, which must be overridden in an adapter-specific subclass.
- Parameters:
s- sequence to sendl- listener for reply
-
sendDmxSequence
public boolean sendDmxSequence(int unitid, byte newStep)
Send a sequence of DMX messages to an adapter.Makes them into the local messages and then queues in order.
This is a default, null implementation, which must be overridden in an adapter-specific subclass. DMX does work with a sequence, it directly updates the data array
- Parameters:
unitid- which lightnewStep- new intesity value- Returns:
- true on success
-
getNumberOfIntensitySteps
public int getNumberOfIntensitySteps()
Provide the maximum number of dimming steps available.- Returns:
- By default, dimming not available.
-
getSerialMessage
public SerialMessage getSerialMessage(int length)
Get a message of a specific length for filling in.This is a default, null implementation, which must be overridden in an adapter-specific subclass.
- Parameters:
length- message size- Returns:
- null
-
addSerialListener
public void addSerialListener(SerialListener l)
- Specified by:
addSerialListenerin interfaceSerialInterface
-
removeSerialListener
public void removeSerialListener(SerialListener l)
- Specified by:
removeSerialListenerin interfaceSerialInterface
-
enterProgModeDelayTime
protected int 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
-
forwardMessage
protected void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a SerialMessage to all registered SerialInterface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
protected void forwardReply(AbstractMRListener client, AbstractMRReply r)
Forward a reply to all registered SerialInterface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
setSensorManager
public void setSensorManager(SerialSensorManager m)
-
getSensorManager
public SerialSensorManager getSensorManager()
-
pollMessage
protected AbstractMRMessage pollMessage()
Eventually, do initialization if needed- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
protected AbstractMRListener pollReplyHandler()
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendSerialMessage
public void sendSerialMessage(SerialMessage m, SerialListener reply)
Forward a preformatted message to the actual interface.- Specified by:
sendSerialMessagein interfaceSerialInterface
-
forwardToPort
protected void forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
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:
AbstractMRTrafficController.sendMessage(AbstractMRMessage, AbstractMRListener)
-
enterProgMode
protected AbstractMRMessage 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:
AbstractMRTrafficController.enterNormalMode()
-
enterNormalMode
protected AbstractMRMessage 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:
AbstractMRTrafficController.enterProgMode()
-
setAdapterMemo
public void setAdapterMemo(SerialSystemConnectionMemo adaptermemo)
-
getAdapterMemo
public SerialSystemConnectionMemo getAdapterMemo()
-
endOfMessage
protected boolean endOfMessage(AbstractMRReply msg)
This is a default, null implementation, which must be overridden in an adapter-specific subclass.- Specified by:
endOfMessagein classAbstractMRTrafficController
-
newReply
protected AbstractMRReply newReply()
This is a default, null implementation, which must be overridden in an adapter-specific subclass.- Specified by:
newReplyin classAbstractMRTrafficController
-
-