Class HandshakePortController<PM extends org.refcodes.serial.PortMetrics>
java.lang.Object
org.refcodes.serial.AbstractPortDecorator<PM>
org.refcodes.serial.ext.handshake.HandshakePortController<PM>
- Type Parameters:
PM
- The actualPortMetrics
type to use.
- All Implemented Interfaces:
Flushable
,Comparable<org.refcodes.serial.Port<?>>
,org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseAutomaton
,org.refcodes.component.ClosedAccessor
,org.refcodes.component.ConnectableComponent
,org.refcodes.component.ConnectableComponent.ConnectableAutomaton
,org.refcodes.component.ConnectionComponent<PM>
,org.refcodes.component.ConnectionComponent.ConnectionAutomaton<PM>
,org.refcodes.component.ConnectionOpenable<PM>
,org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<PM>
,org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<PM,
,org.refcodes.serial.Port<PM>> org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.Flushable
,org.refcodes.component.LinkComponent
,org.refcodes.component.LinkComponent.LinkAutomaton
,org.refcodes.component.Openable
,org.refcodes.component.Openable.OpenAutomaton
,org.refcodes.component.Openable.OpenBuilder<org.refcodes.serial.Port<PM>>
,org.refcodes.component.OpenedAccessor
,org.refcodes.io.Availability
,org.refcodes.io.ByteDestination
,org.refcodes.io.ByteReceiver
,org.refcodes.io.BytesDestination
,org.refcodes.io.ByteSource
,org.refcodes.io.BytesReceiver
,org.refcodes.io.BytesSource
,org.refcodes.io.BytesTransceiver
,org.refcodes.io.BytesTransmitter
,org.refcodes.io.ByteTransceiver
,org.refcodes.io.ByteTransmitter
,org.refcodes.io.Receivable
,org.refcodes.io.Skippable
,org.refcodes.io.TimeoutInputStreamAccessor
,org.refcodes.io.Transmittable
,org.refcodes.mixin.AliasAccessor
,org.refcodes.mixin.InputStreamAccessor
,org.refcodes.mixin.OutputStreamAccessor
,org.refcodes.numerical.ChecksumValidationModeAccessor
,org.refcodes.numerical.CrcAlgorithmAccessor
,org.refcodes.numerical.EndianessAccessor
,org.refcodes.serial.AcknowledgeMagicBytesAccessor
,org.refcodes.serial.AcknowledgeRetryNumberAccessor
,org.refcodes.serial.AcknowledgeTimeoutMillisAccessor
,ReplyRetryNumberAccessor
,ReplyTimeoutMillisAccessor
,org.refcodes.serial.Port<PM>
,org.refcodes.serial.PortMetricsAccessor<PM>
,org.refcodes.serial.SegmentDestination
,org.refcodes.serial.SegmentReceiver
,org.refcodes.serial.SegmentSource
,org.refcodes.serial.SegmentTransceiver
,org.refcodes.serial.SegmentTransmitter
,org.refcodes.serial.SequenceNumberAccessor
,org.refcodes.serial.SequenceNumberInitValueAccessor
,org.refcodes.serial.SequenceNumberWidthAccessor
,org.refcodes.serial.SerialReceiver
,org.refcodes.serial.SerialTransceiver
,org.refcodes.serial.SerialTransmitter
public class HandshakePortController<PM extends org.refcodes.serial.PortMetrics>
extends org.refcodes.serial.AbstractPortDecorator<PM>
implements org.refcodes.serial.Port<PM>, org.refcodes.serial.AcknowledgeMagicBytesAccessor, org.refcodes.serial.AcknowledgeTimeoutMillisAccessor, org.refcodes.serial.AcknowledgeRetryNumberAccessor, ReplyTimeoutMillisAccessor, ReplyRetryNumberAccessor, org.refcodes.serial.SequenceNumberAccessor, org.refcodes.serial.SequenceNumberInitValueAccessor, org.refcodes.serial.SequenceNumberWidthAccessor, org.refcodes.numerical.CrcAlgorithmAccessor, org.refcodes.numerical.ChecksumValidationModeAccessor, org.refcodes.numerical.EndianessAccessor
A
HandshakePortController
decorates a Port
for its usage in
Full-Duplex mode regarding the transmission of Segment
messages (or
any transmission finished off by calling AbstractPortDecorator.flush()
). This is achieved
by giving each Segment
(or transmission) to be transmitted a sequence
number together with magic bytes identifying the transmission as being a
Segment
. Each acknowledge message is given the sequence numbers of
successfully received Segment
transmissions alongside magic bytes
identifying the acknowledge message as such. This way Segment
messages and acknowledge messages can be distinguished from each other and
transmission can take place in Full-Duplex mode. This implementation applies
the Full-Duplex handshake on Segment
messages rather than on packets
(of a defined size) in order to enable microcontroller based implementation
to participate easily in this kind of Full-Duplex. Caution: In case very much
data (long transmissions) is to be transmitted, then the outbound line will
be blocked by the transmission so that for the time of sending the
transmission No-Acknowledge message upon receival of an inbound transmission
can be sent over the outbound line! For such use cases sending much data in a
single transmission, consider chunking a big transmission into packages
(could be done by a https://www.metacodes.proization of the HandshakePortController
).-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
HandshakePortController.Builder<PM extends org.refcodes.serial.PortMetrics>
Builder for building aHandshakePortController
instance.Nested classes/interfaces inherited from interface org.refcodes.serial.AcknowledgeMagicBytesAccessor
org.refcodes.serial.AcknowledgeMagicBytesAccessor.AcknowledgeMagicBytesBuilder<B extends org.refcodes.serial.AcknowledgeMagicBytesAccessor.AcknowledgeMagicBytesBuilder<B>>, org.refcodes.serial.AcknowledgeMagicBytesAccessor.AcknowledgeMagicBytesMutator, org.refcodes.serial.AcknowledgeMagicBytesAccessor.AcknowledgeMagicBytesProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.AcknowledgeRetryNumberAccessor
org.refcodes.serial.AcknowledgeRetryNumberAccessor.AcknowledgeRetryNumberBuilder<B extends org.refcodes.serial.AcknowledgeRetryNumberAccessor.AcknowledgeRetryNumberBuilder<B>>, org.refcodes.serial.AcknowledgeRetryNumberAccessor.AcknowledgeRetryNumberMutator, org.refcodes.serial.AcknowledgeRetryNumberAccessor.AcknowledgeRetryNumberProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.AcknowledgeTimeoutMillisAccessor
org.refcodes.serial.AcknowledgeTimeoutMillisAccessor.AcknowledgeTimeoutMillisBuilder<B extends org.refcodes.serial.AcknowledgeTimeoutMillisAccessor.AcknowledgeTimeoutMillisBuilder<B>>, org.refcodes.serial.AcknowledgeTimeoutMillisAccessor.AcknowledgeTimeoutMillisMutator, org.refcodes.serial.AcknowledgeTimeoutMillisAccessor.AcknowledgeTimeoutMillisProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
Nested classes/interfaces inherited from interface org.refcodes.io.BytesReceiver
org.refcodes.io.BytesReceiver.ReceiverInputStream
Nested classes/interfaces inherited from interface org.refcodes.io.BytesTransmitter
org.refcodes.io.BytesTransmitter.TransmitterOutputStream
Nested classes/interfaces inherited from interface org.refcodes.numerical.ChecksumValidationModeAccessor
org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeBuilder<B extends org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeBuilder<B>>, org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeMutator, org.refcodes.numerical.ChecksumValidationModeAccessor.ChecksumValidationModeProperty
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionComponent
org.refcodes.component.ConnectionComponent.ConnectionAutomaton<CON extends Object>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON extends Object,
B extends org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON, B>> Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionOpenable
org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<CON extends Object>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON extends Object,
B extends org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON, B>> Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
Nested classes/interfaces inherited from interface org.refcodes.numerical.CrcAlgorithmAccessor
org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmBuilder<B extends org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmBuilder<B>>, org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmMutator, org.refcodes.numerical.CrcAlgorithmAccessor.CrcAlgorithmProperty
Nested classes/interfaces inherited from interface org.refcodes.numerical.EndianessAccessor
org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B extends org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B>>, org.refcodes.numerical.EndianessAccessor.EndianessMutator, org.refcodes.numerical.EndianessAccessor.EndianessProperty
Nested classes/interfaces inherited from interface org.refcodes.component.Flushable
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.mixin.InputStreamAccessor
org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<B extends org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<?>>, org.refcodes.mixin.InputStreamAccessor.InputStreamMutator, org.refcodes.mixin.InputStreamAccessor.InputStreamProperty
Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.Openable
org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.OutputStreamAccessor
org.refcodes.mixin.OutputStreamAccessor.OutputStreamBuilder<B extends org.refcodes.mixin.OutputStreamAccessor.OutputStreamBuilder<?>>, org.refcodes.mixin.OutputStreamAccessor.OutputStreamMutator, org.refcodes.mixin.OutputStreamAccessor.OutputStreamProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.PortMetricsAccessor
org.refcodes.serial.PortMetricsAccessor.PortMetricsBuilder<PM extends org.refcodes.serial.PortMetrics,
B extends org.refcodes.serial.PortMetricsAccessor.PortMetricsBuilder<PM, B>>, org.refcodes.serial.PortMetricsAccessor.PortMetricsMutator<PM extends org.refcodes.serial.PortMetrics>, org.refcodes.serial.PortMetricsAccessor.PortMetricsProperty<PM extends org.refcodes.serial.PortMetrics> Nested classes/interfaces inherited from interface org.refcodes.serial.ext.handshake.ReplyRetryNumberAccessor
ReplyRetryNumberAccessor.ReplyRetryNumberBuilder<B extends ReplyRetryNumberAccessor.ReplyRetryNumberBuilder<B>>, ReplyRetryNumberAccessor.ReplyRetryNumberMutator, ReplyRetryNumberAccessor.ReplyRetryNumberProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.ext.handshake.ReplyTimeoutMillisAccessor
ReplyTimeoutMillisAccessor.ReplyTimeoutMillisBuilder<B extends ReplyTimeoutMillisAccessor.ReplyTimeoutMillisBuilder<B>>, ReplyTimeoutMillisAccessor.ReplyTimeoutMillisMutator, ReplyTimeoutMillisAccessor.ReplyTimeoutMillisProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.SequenceNumberAccessor
org.refcodes.serial.SequenceNumberAccessor.SequenceNumberBuilder<B extends org.refcodes.serial.SequenceNumberAccessor.SequenceNumberBuilder<B>>, org.refcodes.serial.SequenceNumberAccessor.SequenceNumberMutator, org.refcodes.serial.SequenceNumberAccessor.SequenceNumberProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.SequenceNumberInitValueAccessor
org.refcodes.serial.SequenceNumberInitValueAccessor.SequenceNumberInitValueBuilder<B extends org.refcodes.serial.SequenceNumberInitValueAccessor.SequenceNumberInitValueBuilder<B>>, org.refcodes.serial.SequenceNumberInitValueAccessor.SequenceNumberInitValueMutator, org.refcodes.serial.SequenceNumberInitValueAccessor.SequenceNumberInitValueProperty
Nested classes/interfaces inherited from interface org.refcodes.serial.SequenceNumberWidthAccessor
org.refcodes.serial.SequenceNumberWidthAccessor.SequenceNumberWidthBuilder<B extends org.refcodes.serial.SequenceNumberWidthAccessor.SequenceNumberWidthBuilder<B>>, org.refcodes.serial.SequenceNumberWidthAccessor.SequenceNumberWidthMutator, org.refcodes.serial.SequenceNumberWidthAccessor.SequenceNumberWidthProperty
Nested classes/interfaces inherited from interface org.refcodes.io.TimeoutInputStreamAccessor
org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<B extends org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<?>>, org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamMutator, org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamProperty
-
Field Summary
Fields inherited from class org.refcodes.serial.AbstractPortDecorator
_port
-
Constructor Summary
ConstructorDescriptionHandshakePortController
(org.refcodes.serial.Port<PM> aPort) Decorates the givenPort
with full duplexSegment
multiplexer functionality.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.HandshakePortController
(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments. -
Method Summary
Modifier and TypeMethodDescriptionint
static <PM extends org.refcodes.serial.PortMetrics>
HandshakePortController.Builder<PM>builder()
Creates builder to buildHandshakePortController
.void
close()
<SEGMENT extends org.refcodes.serial.Segment>
org.refcodes.serial.SegmentResult<SEGMENT>doTransmitSegment
(SEGMENT aSegment) <SEGMENT extends org.refcodes.serial.Segment>
voiddoTransmitSegment
(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) byte[]
int
long
org.refcodes.numerical.ChecksumValidationMode
org.refcodes.numerical.CrcAlgorithm
org.refcodes.numerical.Endianess
org.refcodes.io.TimeoutInputStream
getInputStream
(long aTimeoutMillis) int
Retrieves the number of retries from the reply retry number.long
The reply timeout attribute in milliseconds.int
int
int
void
Registers a handler invoked upon incoming remote ping requests (via a remote's invocation ofping()
or similar).<SEGMENT extends org.refcodes.serial.Segment>
org.refcodes.serial.SegmentResult<SEGMENT>onReceiveSegment
(SEGMENT aSegment) <SEGMENT extends org.refcodes.serial.Segment>
voidonReceiveSegment
(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) <REQUEST extends org.refcodes.serial.Segment>
booleanonRequest
(REQUEST aRequest, RequestHandler<REQUEST> aRequestHandler) Adds aRequestHandler
for processing requests issued as ofrequestSegment(Segment, Segment)
(and the like methods).<SEGMENT extends org.refcodes.serial.Segment>
booleanonSegment
(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) Adds aSegmentConsumer
for receiving and handling transmissions.void
open()
void
void
ping()
Probes the connection by sending a "ping" to the attached remote station (HandshakePortController
) expecting a "pong" reply within a timeout (shorter than the timeout of usual transmissions).<SEGMENT extends org.refcodes.serial.Segment>
voidpingWithin
(long aTimeoutMillis, int aRetryNumber) Probes the connection by sending a "ping" to the attached remote station (HandshakePortController
) expecting a "pong" reply within a timeout (shorter than the timeout of usual transmissions).byte
<SEGMENT extends org.refcodes.serial.Segment>
voidreceiveSegment
(SEGMENT aSegment) <SEGMENT extends org.refcodes.serial.Segment>
voidreceiveSegmentWithin
(long aTimeoutMillis, SEGMENT aSegment) <REQUEST extends org.refcodes.serial.Segment,
RESPONSE extends org.refcodes.serial.Segment>
voidrequestSegment
(REQUEST aRequest, RESPONSE aResponse) Sends a request expecting a response.<REQUEST extends org.refcodes.serial.Segment,
RESPONSE extends org.refcodes.serial.Segment>
voidrequestSegment
(REQUEST aRequest, RESPONSE aResponse, boolean isAcknowledgeable) Sends a request expecting a response.<REQUEST extends org.refcodes.serial.Segment,
RESPONSE extends org.refcodes.serial.Segment>
voidrequestSegmentWithin
(long aTimeoutMillis, REQUEST aRequest, RESPONSE aResponse) Sends a request expecting a response.<REQUEST extends org.refcodes.serial.Segment,
RESPONSE extends org.refcodes.serial.Segment>
voidrequestSegmentWithin
(long aTimeoutMillis, REQUEST aRequest, RESPONSE aResponse, boolean isAcknowledgeable) Sends a request expecting a response.void
transmitByte
(byte aByte) void
transmitBytes
(byte[] aBytes, int aOffset, int aLength) <SEGMENT extends org.refcodes.serial.Segment>
voidtransmitSegment
(SEGMENT aSegment) <SEGMENT extends org.refcodes.serial.Segment>
voidtransmitSegment
(SEGMENT aSegment, boolean isAcknowledgeable) Transmits aSegment
(and blocks this thread) till all it'sSequence
data (as ofTransmission.toSequence()
) has been sent.<SEGMENT extends org.refcodes.serial.Segment>
voidtransmitSegmentWithin
(long aTimeoutMillis, int aRetryNumber, SEGMENT aSegment) Transmits aSegment
(and blocks this thread) till all it'sSequence
data (as ofTransmission.toSequence()
) has been sent.void
transmitSequence
(org.refcodes.serial.Sequence aSequence) void
transmitSequence
(org.refcodes.serial.Sequence aSequence, boolean isAcknowledgeable) Transmits aSequence
(and blocks this thread) till all it's data (as ofTransmission.toSequence()
) has been sent.void
transmitSequenceWithin
(long aTimeoutMillis, int aRetryNumber, org.refcodes.serial.Sequence aSequence) Transmits aSequence
(and blocks this thread) till all it's data (as ofTransmission.toSequence()
) has been sent.withOpen()
withOpenUnchecked
(PM aPortMetrics) Methods inherited from class org.refcodes.serial.AbstractPortDecorator
closeIn, closeQuietly, closeUnchecked, flush, flushUnchecked, getAlias, getConnectionStatus, getOutputStream, getPortMetrics, hasAvailable, isClosable, isClosed, isFlushable, isOpenable, isOpenable, isOpened, openUnchecked, openUnchecked, receiveAllBytes, receiveBytes, receiveBytes, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, receiveSequence, receiveSequenceWithin, skip, skipAvailable, skipAvailableExcept, skipAvailableTill, skipAvailableTillSilenceFor, skipAvailableTillSilenceFor, skipAvailableWithin, skipAvailableWithin, transmitSequence
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.AliasAccessor
getAlias
Methods inherited from interface org.refcodes.io.Availability
hasAvailable
Methods inherited from interface org.refcodes.io.BytesDestination
receiveBytes
Methods inherited from interface org.refcodes.io.BytesReceiver
receiveAllBytes, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, skip
Methods inherited from interface org.refcodes.io.BytesTransmitter
getOutputStream
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
Methods inherited from interface org.refcodes.component.Closable.CloseAutomaton
isClosable
Methods inherited from interface org.refcodes.component.ClosedAccessor
isClosed
Methods inherited from interface org.refcodes.component.ConnectionOpenable
openUnchecked
Methods inherited from interface org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton
isOpenable
Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isOpened
Methods inherited from interface org.refcodes.component.Flushable
flushUnchecked, isFlushable
Methods inherited from interface org.refcodes.component.Openable
openUnchecked
Methods inherited from interface org.refcodes.component.Openable.OpenAutomaton
isOpenable
Methods inherited from interface org.refcodes.serial.Port
compareTo
Methods inherited from interface org.refcodes.serial.PortMetricsAccessor
getPortMetrics
Methods inherited from interface org.refcodes.serial.SegmentTransmitter
flush
Methods inherited from interface org.refcodes.serial.SerialReceiver
receiveBytes, receiveSequence, receiveSequenceWithin
Methods inherited from interface org.refcodes.serial.SerialTransmitter
flush, transmitAllBytes, transmitSequence
Methods inherited from interface org.refcodes.io.Skippable
skipAvailable, skipAvailableExcept, skipAvailableTill, skipAvailableTillSilenceFor, skipAvailableTillSilenceFor, skipAvailableWithin, skipAvailableWithin, skipAvailableWithin
-
Constructor Details
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aTransmissionMetrics
- TheHandshakeTransmissionMetrics
to be used for configuring this instance.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aTransmissionMetrics
- TheHandshakeTransmissionMetrics
to be used for configuring this instance.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
Decorates the givenPort
with full duplexSegment
multiplexer functionality.- Parameters:
aPort
- ThePort
to be decorated.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberInitValue
- The initialization value for the sequence number counter, when -1 then the lower 32 bit of the current time in milliseconds are taken to prevent sequence number collisions upon restarting one of the two communication partners.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality.- Parameters:
aPort
- ThePort
to be decorated.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aTransmissionMetrics
- TheHandshakeTransmissionMetrics
to be used for configuring this instance.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
Decorates the givenPort
with full duplexSegment
multiplexer functionality.- Parameters:
aPort
- ThePort
to be decorated.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberInitValue
- The initialization value for the sequence number counter, when -1 then the lower 32 bit of the current time in milliseconds are taken to prevent sequence number collisions upon restarting one of the two communication partners.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality.- Parameters:
aPort
- ThePort
to be decorated.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberInitValue
- The initialization value for the sequence number counter, when -1 then the lower 32 bit of the current time in milliseconds are taken to prevent sequence number collisions upon restarting one of the two communication partners.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, org.refcodes.numerical.Endianess aEndianess, int aAcknowledgeRetryNumber, long aAcknowledgeTimeoutInMs, int aReplyRetryNumber, long aReplyTimeoutInMs, int aSequenceNumberInitValue, int aSequenceNumberWidth, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.ChecksumValidationMode aChecksumValidationMode, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aEndianess
- TheEndianess
to use when calculating the CRC checksum.aAcknowledgeRetryNumber
- The number of retries waiting for an ACK from the return channel.aAcknowledgeTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aReplyRetryNumber
- The number of retries waiting for a reply from the return channel.aReplyTimeoutInMs
- The timeout in milliseconds to pend till the next retry.aSequenceNumberInitValue
- The initialization value for the sequence number counter, when -1 then the lower 32 bit of the current time in milliseconds are taken to prevent sequence number collisions upon restarting one of the two communication partners.aSequenceNumberWidth
- The width in bytes to be used for the binary sequence number representation.aCrcAlgorithm
- TheCrcAlgorithm
to be used for CRC checksum calculation.aChecksumValidationMode
- The mode of operation when validating provided CRC checksums against calculated ones.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
HandshakePortController
public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity, ExecutorService aExecutorService) Decorates the givenPort
with full duplexSegment
multiplexer functionality as of the given arguments.- Parameters:
aPort
- ThePort
to be decorated.aTransmissionMetrics
- TheHandshakeTransmissionMetrics
to be used for configuring this instance.aInboundQueueCapacity
- The capacity of the inbound queue, any exceeding inbound transmissions are skipped.aExecutorService
- TheExecutorService
to be used when creatingThread
instances for handling input and output data simultaneously.
-
-
Method Details
-
ping
Probes the connection by sending a "ping" to the attached remote station (HandshakePortController
) expecting a "pong" reply within a timeout (shorter than the timeout of usual transmissions).- Throws:
IOException
- thrown in case the "ping" failed, e.g. the remote station (HandshakePortController
) is not ready (available).
-
pingWithin
public <SEGMENT extends org.refcodes.serial.Segment> void pingWithin(long aTimeoutMillis, int aRetryNumber) throws IOException Probes the connection by sending a "ping" to the attached remote station (HandshakePortController
) expecting a "pong" reply within a timeout (shorter than the timeout of usual transmissions).- Type Parameters:
SEGMENT
- the generic type- Parameters:
aTimeoutMillis
- The timeout to wait for sending the ping and receiving the pong till aborting.aRetryNumber
- The number of retries each of the given timeout in milliseconds.- Throws:
IOException
- thrown in case the "ping" failed, e.g. the remote station (HandshakePortController
) is not ready (available).
-
onPing
Registers a handler invoked upon incoming remote ping requests (via a remote's invocation ofping()
or similar). The according acknowledgement ("pong") is sent automatically, though the ping handler should be short running as the ping's acknowledgment timeouts are usually shorter than other transmission related timeouts.- Parameters:
aPingHandler
- The handler to be notified upon incoming ping requests.
-
onSegment
public <SEGMENT extends org.refcodes.serial.Segment> boolean onSegment(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) Adds aSegmentConsumer
for receiving and handling transmissions.- Type Parameters:
SEGMENT
- The type ofSegment
for which to register.- Parameters:
aSegment
- TheSegment
used for deserializing the transmission. A good practice is to use some kind ofAssertMagicBytesSegment
for uniquely identifying a responsibleSegmentConsumer
for an accordingSegment
.aSegmentConsumer
- TheSegmentConsumer
processing the according transmission.- Returns:
- True in case the
SegmentConsumer
has been registered to the givenSegment
, false in case a consumer has already been registered to the given segment.
-
onRequest
public <REQUEST extends org.refcodes.serial.Segment> boolean onRequest(REQUEST aRequest, RequestHandler<REQUEST> aRequestHandler) Adds aRequestHandler
for processing requests issued as ofrequestSegment(Segment, Segment)
(and the like methods).- Type Parameters:
REQUEST
- The type ofSegment
for which to register.- Parameters:
aRequest
- The requestSegment
used for deserialize the request. A good practice is to use some kind ofAssertMagicBytesSegment
for uniquely identify a responsibleRequestHandler
for an accordingSegment
.aRequestHandler
- TheRequestHandler
processing the according request.- Returns:
- True in case the
RequestHandler
has been registered to the givenSegment
, false in case a handler has already been registered to the given request.
-
available
- Specified by:
available
in interfaceorg.refcodes.io.Availability
- Specified by:
available
in interfaceorg.refcodes.serial.SerialReceiver
- Specified by:
available
in interfaceorg.refcodes.io.Skippable
- Overrides:
available
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
close
- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Specified by:
close
in interfaceorg.refcodes.serial.SerialReceiver
- Overrides:
close
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
doTransmitSegment
public <SEGMENT extends org.refcodes.serial.Segment> org.refcodes.serial.SegmentResult<SEGMENT> doTransmitSegment(SEGMENT aSegment) throws IOException - Specified by:
doTransmitSegment
in interfaceorg.refcodes.serial.SegmentTransmitter
- Overrides:
doTransmitSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
doTransmitSegment
public <SEGMENT extends org.refcodes.serial.Segment> void doTransmitSegment(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) throws IOException - Specified by:
doTransmitSegment
in interfaceorg.refcodes.serial.SegmentTransmitter
- Overrides:
doTransmitSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
getAcknowledgeMagicBytes
public byte[] getAcknowledgeMagicBytes()- Specified by:
getAcknowledgeMagicBytes
in interfaceorg.refcodes.serial.AcknowledgeMagicBytesAccessor
-
getAcknowledgeRetryNumber
public int getAcknowledgeRetryNumber()- Specified by:
getAcknowledgeRetryNumber
in interfaceorg.refcodes.serial.AcknowledgeRetryNumberAccessor
-
getAcknowledgeTimeoutMillis
public long getAcknowledgeTimeoutMillis()- Specified by:
getAcknowledgeTimeoutMillis
in interfaceorg.refcodes.serial.AcknowledgeTimeoutMillisAccessor
-
getReplyRetryNumber
public int getReplyRetryNumber()Retrieves the number of retries from the reply retry number. A reply retry number is the overall number of retries to use when counting retries.- Specified by:
getReplyRetryNumber
in interfaceReplyRetryNumberAccessor
- Returns:
- The number of retries stored by the reply retry number.
-
getReplyTimeoutMillis
public long getReplyTimeoutMillis()The reply timeout attribute in milliseconds.- Specified by:
getReplyTimeoutMillis
in interfaceReplyTimeoutMillisAccessor
- Returns:
- An long integer with the timeout in milliseconds.
-
getCrcAlgorithm
public org.refcodes.numerical.CrcAlgorithm getCrcAlgorithm()- Specified by:
getCrcAlgorithm
in interfaceorg.refcodes.numerical.CrcAlgorithmAccessor
-
getChecksumValidationMode
public org.refcodes.numerical.ChecksumValidationMode getChecksumValidationMode()- Specified by:
getChecksumValidationMode
in interfaceorg.refcodes.numerical.ChecksumValidationModeAccessor
-
getEndianess
public org.refcodes.numerical.Endianess getEndianess()- Specified by:
getEndianess
in interfaceorg.refcodes.numerical.EndianessAccessor
-
getInputStream
- Specified by:
getInputStream
in interfaceorg.refcodes.io.BytesReceiver
- Specified by:
getInputStream
in interfaceorg.refcodes.mixin.InputStreamAccessor
- Overrides:
getInputStream
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
-
getInputStream
public org.refcodes.io.TimeoutInputStream getInputStream(long aTimeoutMillis) - Specified by:
getInputStream
in interfaceorg.refcodes.io.BytesReceiver
- Specified by:
getInputStream
in interfaceorg.refcodes.io.TimeoutInputStreamAccessor
- Overrides:
getInputStream
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
-
getSequenceNumber
public int getSequenceNumber()- Specified by:
getSequenceNumber
in interfaceorg.refcodes.serial.SequenceNumberAccessor
-
getSequenceNumberInitValue
public int getSequenceNumberInitValue()- Specified by:
getSequenceNumberInitValue
in interfaceorg.refcodes.serial.SequenceNumberInitValueAccessor
-
getSequenceNumberWidth
public int getSequenceNumberWidth()- Specified by:
getSequenceNumberWidth
in interfaceorg.refcodes.serial.SequenceNumberWidthAccessor
-
onReceiveSegment
public <SEGMENT extends org.refcodes.serial.Segment> org.refcodes.serial.SegmentResult<SEGMENT> onReceiveSegment(SEGMENT aSegment) throws IOException - Specified by:
onReceiveSegment
in interfaceorg.refcodes.serial.SegmentReceiver
- Overrides:
onReceiveSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
onReceiveSegment
public <SEGMENT extends org.refcodes.serial.Segment> void onReceiveSegment(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer) throws IOException - Specified by:
onReceiveSegment
in interfaceorg.refcodes.serial.SegmentReceiver
- Overrides:
onReceiveSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
open
- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Specified by:
open
in interfaceorg.refcodes.serial.SerialReceiver
- Overrides:
open
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
open
- Specified by:
open
in interfaceorg.refcodes.component.ConnectionOpenable<PM extends org.refcodes.serial.PortMetrics>
- Overrides:
open
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
receiveByte
- Specified by:
receiveByte
in interfaceorg.refcodes.io.ByteDestination
- Specified by:
receiveByte
in interfaceorg.refcodes.io.BytesDestination
- Specified by:
receiveByte
in interfaceorg.refcodes.serial.SerialReceiver
- Overrides:
receiveByte
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
transmitByte
- Specified by:
transmitByte
in interfaceorg.refcodes.io.ByteSource
- Specified by:
transmitByte
in interfaceorg.refcodes.io.BytesSource
- Throws:
IOException
-
receiveSegment
public <SEGMENT extends org.refcodes.serial.Segment> void receiveSegment(SEGMENT aSegment) throws org.refcodes.serial.TransmissionException, IOException - Specified by:
receiveSegment
in interfaceorg.refcodes.serial.SegmentDestination
- Specified by:
receiveSegment
in interfaceorg.refcodes.serial.SerialReceiver
- Specified by:
receiveSegment
in interfaceorg.refcodes.serial.SerialTransceiver
- Overrides:
receiveSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
org.refcodes.serial.TransmissionException
IOException
-
receiveSegmentWithin
public <SEGMENT extends org.refcodes.serial.Segment> void receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) throws org.refcodes.serial.TransmissionException, IOException - Specified by:
receiveSegmentWithin
in interfaceorg.refcodes.serial.SegmentReceiver
- Specified by:
receiveSegmentWithin
in interfaceorg.refcodes.serial.SerialReceiver
- Overrides:
receiveSegmentWithin
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
org.refcodes.serial.TransmissionException
IOException
-
requestSegment
public <REQUEST extends org.refcodes.serial.Segment,RESPONSE extends org.refcodes.serial.Segment> void requestSegment(REQUEST aRequest, RESPONSE aResponse) throws IOException Sends a request expecting a response.- Type Parameters:
REQUEST
- TheSegment
(sub-)type of the request.RESPONSE
- the generic type- Parameters:
aRequest
- The request to be sent.aResponse
- The response being provisioned with the response.- Throws:
IOException
- thrown in case of I/O issues while sending.
-
requestSegmentWithin
public <REQUEST extends org.refcodes.serial.Segment,RESPONSE extends org.refcodes.serial.Segment> void requestSegmentWithin(long aTimeoutMillis, REQUEST aRequest, RESPONSE aResponse) throws IOException Sends a request expecting a response.- Type Parameters:
REQUEST
- TheSegment
(sub-)type of the request.RESPONSE
- the generic type- Parameters:
aTimeoutMillis
- The timeout to wait for sending the request and receiving the response till aborting.aRequest
- The request to be sent.aResponse
- The response being provisioned with the response.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
requestSegment
public <REQUEST extends org.refcodes.serial.Segment,RESPONSE extends org.refcodes.serial.Segment> void requestSegment(REQUEST aRequest, RESPONSE aResponse, boolean isAcknowledgeable) throws IOException Sends a request expecting a response.- Type Parameters:
REQUEST
- TheSegment
(sub-)type of the request.RESPONSE
- the generic type- Parameters:
aRequest
- The request to be sent.aResponse
- The response being provisioned with the response.isAcknowledgeable
- True in case an acknowledgment reply is required.- Throws:
IOException
- thrown in case of I/O issues while sending.
-
requestSegmentWithin
public <REQUEST extends org.refcodes.serial.Segment,RESPONSE extends org.refcodes.serial.Segment> void requestSegmentWithin(long aTimeoutMillis, REQUEST aRequest, RESPONSE aResponse, boolean isAcknowledgeable) throws IOException Sends a request expecting a response.- Type Parameters:
REQUEST
- TheSegment
(sub-)type of the request.RESPONSE
- the generic type- Parameters:
aTimeoutMillis
- The timeout to wait for sending the request and receiving the response till aborting.aRequest
- The request to be sent.aResponse
- The response being provisioned with the response.isAcknowledgeable
- True in case an acknowledgment reply is required.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
transmitSegment
public <SEGMENT extends org.refcodes.serial.Segment> void transmitSegment(SEGMENT aSegment) throws IOException - Specified by:
transmitSegment
in interfaceorg.refcodes.serial.SegmentSource
- Specified by:
transmitSegment
in interfaceorg.refcodes.serial.SerialTransceiver
- Specified by:
transmitSegment
in interfaceorg.refcodes.serial.SerialTransmitter
- Overrides:
transmitSegment
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
transmitSequence
- Specified by:
transmitSequence
in interfaceorg.refcodes.serial.SerialTransmitter
- Overrides:
transmitSequence
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
transmitSegmentWithin
public <SEGMENT extends org.refcodes.serial.Segment> void transmitSegmentWithin(long aTimeoutMillis, int aRetryNumber, SEGMENT aSegment) throws IOException Transmits aSegment
(and blocks this thread) till all it'sSequence
data (as ofTransmission.toSequence()
) has been sent.- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass used.- Parameters:
aTimeoutMillis
- The timeout to wait for sending the request and receiving the response till aborting.aRetryNumber
- The number of retries each of the given timeout in milliseconds.aSegment
- TheSegment
's data to be sent.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
transmitSequenceWithin
public void transmitSequenceWithin(long aTimeoutMillis, int aRetryNumber, org.refcodes.serial.Sequence aSequence) throws IOException Transmits aSequence
(and blocks this thread) till all it's data (as ofTransmission.toSequence()
) has been sent.- Parameters:
aTimeoutMillis
- The timeout to wait for sending the request and receiving the response till aborting.aRetryNumber
- The number of retries each of the given timeout in milliseconds.aSequence
- TheSequence
containing the data to be send.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
transmitSegment
public <SEGMENT extends org.refcodes.serial.Segment> void transmitSegment(SEGMENT aSegment, boolean isAcknowledgeable) throws IOException Transmits aSegment
(and blocks this thread) till all it'sSequence
data (as ofTransmission.toSequence()
) has been sent.- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass used.- Parameters:
aSegment
- TheSegment
's data to be sent.isAcknowledgeable
- True in case an acknowledgment reply is required.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
transmitSequence
public void transmitSequence(org.refcodes.serial.Sequence aSequence, boolean isAcknowledgeable) throws IOException Transmits aSequence
(and blocks this thread) till all it's data (as ofTransmission.toSequence()
) has been sent.- Parameters:
aSequence
- TheSequence
containing the data to be send.isAcknowledgeable
- True in case an acknowledgment reply is required.- Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while sending.
-
transmitBytes
- Specified by:
transmitBytes
in interfaceorg.refcodes.io.BytesSource
- Specified by:
transmitBytes
in interfaceorg.refcodes.io.BytesTransmitter
- Specified by:
transmitBytes
in interfaceorg.refcodes.serial.SerialTransmitter
- Overrides:
transmitBytes
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
withOpen
- Specified by:
withOpen
in interfaceorg.refcodes.component.Openable.OpenBuilder<PM extends org.refcodes.serial.PortMetrics>
- Overrides:
withOpen
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
withOpen
- Specified by:
withOpen
in interfaceorg.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<PM extends org.refcodes.serial.PortMetrics,
org.refcodes.serial.Port<PM extends org.refcodes.serial.PortMetrics>> - Overrides:
withOpen
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
- Throws:
IOException
-
withOpenUnchecked
- Specified by:
withOpenUnchecked
in interfaceorg.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<PM extends org.refcodes.serial.PortMetrics,
org.refcodes.serial.Port<PM extends org.refcodes.serial.PortMetrics>> - Overrides:
withOpenUnchecked
in classorg.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
-
withOpenUnchecked
-
builder
public static <PM extends org.refcodes.serial.PortMetrics> HandshakePortController.Builder<PM> builder()Creates builder to buildHandshakePortController
.- Type Parameters:
PM
- The actualPortMetrics
type to use.- Returns:
- The accordingly created builder.
-