public abstract class AbstractIODelegatingDriver extends AbstractDriver<byte[]>
builderFactory, diagnosticsContext, executor, log, nodeManager| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIODelegatingDriver(DriverContext driverContext) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
connect()
A chance for implementations to do anything that is needed before moving into
DriverState.Connected. |
protected abstract Request<byte[]> |
createConnectRequest()
Called after the driver has successfully opened an IO connection but before moving into
DriverState.Connected. |
protected void |
disconnect()
A chance for implementations to do anything that is needed before moving into
DriverState.Disconnected. |
abstract DriverIODelegate |
getIODelegate() |
protected void |
messageArrived(byte[] message)
Notify
AbstractDriver that a messaged arrived. |
protected abstract int |
messageLength(java.nio.ByteBuffer buffer)
Search the given ByteBuffer starting at its current position looking for a message and return the length in bytes
of the next message in the buffer.
|
void |
notifyConnectFailed(java.lang.Exception connectError)
Callback indicating that the result of
AbstractDriver.connect() was a failure. |
void |
notifyConnectionLost()
Notify
AbstractDriver that the connection has unintentionally been lost. |
void |
notifyConnectSucceeded()
Callback indicating that the result of
AbstractDriver.connect() was a success. |
void |
notifyDisconnectDone()
A callback to notify
AbstractDriver that a call to AbstractDriver.disconnect() is done. |
protected void |
reconnect() |
boolean |
writeToChannel(java.nio.ByteBuffer... buffers) |
addDriverTag, browse, createBrowseRequest, createReadRequest, createSubscribeRequest, createWriteRequest, currentGuid, findTag, getConcurrentRequests, getDiagnostics, getDriverContext, getDriverMetrics, getDriverState, getDriverStatus, getDriverTagAddressPrefix, getLogger, getName, getRequestDiagnostics, getRequestKey, isBrowsingSupported, isOfflineBrowsingSupported, nextGuid, optimizeRead, optimizeSubscribe, optimizeWrite, postRequest, readItems, removeDriverTag, reschedule, setConcurrentRequests, setState, shutdown, writeItemsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildNode, getDriverStatusJSLibName, getDriverStatusJSUrlprotected AbstractIODelegatingDriver(DriverContext driverContext)
protected void connect()
AbstractDriverDriverState.Connected. When
done, AbstractDriver.notifyConnectSucceeded() or AbstractDriver.notifyConnectFailed(Exception) must be called.connect in class AbstractDriver<byte[]>protected void disconnect()
AbstractDriverDriverState.Disconnected.
When done, AbstractDriver.notifyDisconnectDone() must be called.disconnect in class AbstractDriver<byte[]>public void notifyConnectSucceeded()
AbstractDriverAbstractDriver.connect() was a success.
Clears the last connect error, sets DriverState.Connected, and starts any subscriptions.notifyConnectSucceeded in class AbstractDriver<byte[]>public void notifyConnectFailed(java.lang.Exception connectError)
AbstractDriverAbstractDriver.connect() was a failure.
The contents of connectError will be displayed to the user on the device status page of the Ignition
gateway.notifyConnectFailed in class AbstractDriver<byte[]>connectError - A user-facing error message that will be displayed on the device status page of
the Ignition gateway.public void notifyConnectionLost()
AbstractDriverAbstractDriver that the connection has unintentionally been lost. It is assumed that because the
connection was lost, AbstractDriver.disconnect() does not need to be called.
If DriverState is not currently DriverState.Disconnected then the following occurs:
DriverState is set to DriverState.Disconnected.ScheduledRequest's are canceled.AbstractDriver.connect() will be scheduled.
notifyConnectionLost in class AbstractDriver<byte[]>public void notifyDisconnectDone()
AbstractDriverAbstractDriver that a call to AbstractDriver.disconnect() is done.
This will move the driver into DriverState.Disconnected and cancel any outstanding
ScheduledRequests.notifyDisconnectDone in class AbstractDriver<byte[]>public boolean writeToChannel(java.nio.ByteBuffer... buffers)
protected void reconnect()
protected void messageArrived(byte[] message)
AbstractDriver that a messaged arrived. This cannot be called on the same
thread that Request.sendMessage() was invoked on.messageArrived in class AbstractDriver<byte[]>message - The message that has arrived.public abstract DriverIODelegate getIODelegate()
DriverIODelegate that communication actions will be delegated to.protected abstract Request<byte[]> createConnectRequest()
DriverState.Connected.
Now is that chance for any requests needed to initialize communications with a device, such as negotiating
PDU size or session handles, to happen.
Return null if no connect Request is necessary.
If a non-null value is returned, then it is the responsibility of the implementation to call notifyConnectSucceeded() or notifyConnectFailed(Exception) when finished connecting.Request to or null if none is necessary.protected abstract int messageLength(java.nio.ByteBuffer buffer)
ByteBuffer.get() and friends. Only the buffer's position should
ever be modified by this function; it should leave the mark and limit alone.buffer - A ByteBuffer containing bytes that have come in off the wire.