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 actual PortMetrics 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

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    HandshakePortController.Builder<PM extends org.refcodes.serial.PortMetrics>
    Builder for building a HandshakePortController 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.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

    Constructors
    Constructor
    Description
    HandshakePortController(org.refcodes.serial.Port<PM> aPort)
    Decorates the given Port with full duplex Segment multiplexer functionality.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity)
    Decorates the given Port with full duplex Segment multiplexer functionality.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity, ExecutorService aExecutorService)
    Decorates the given Port with full duplex Segment multiplexer functionality.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, ExecutorService aExecutorService)
    Decorates the given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics)
    Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity)
    Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity, ExecutorService aExecutorService)
    Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
    HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService)
    Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    static <PM extends org.refcodes.serial.PortMetrics>
    HandshakePortController.Builder<PM>
    Creates builder to build HandshakePortController.
    void
    <SEGMENT extends org.refcodes.serial.Segment>
    org.refcodes.serial.SegmentResult<SEGMENT>
    doTransmitSegment(SEGMENT aSegment)
    <SEGMENT extends org.refcodes.serial.Segment>
    void
    doTransmitSegment(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
    onPing(Runnable aPingHandler)
    Registers a handler invoked upon incoming remote ping requests (via a remote's invocation of ping() or similar).
    <SEGMENT extends org.refcodes.serial.Segment>
    org.refcodes.serial.SegmentResult<SEGMENT>
    onReceiveSegment(SEGMENT aSegment)
    <SEGMENT extends org.refcodes.serial.Segment>
    void
    onReceiveSegment(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer)
    <REQUEST extends org.refcodes.serial.Segment>
    boolean
    onRequest(REQUEST aRequest, RequestHandler<REQUEST> aRequestHandler)
    Adds a RequestHandler for processing requests issued as of requestSegment(Segment, Segment) (and the like methods).
    <SEGMENT extends org.refcodes.serial.Segment>
    boolean
    onSegment(SEGMENT aSegment, org.refcodes.serial.SegmentConsumer<SEGMENT> aSegmentConsumer)
    Adds a SegmentConsumer for receiving and handling transmissions.
    void
    void
    open(PM aPortMetrics)
    void
    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>
    void
    pingWithin(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>
    void
    receiveSegment(SEGMENT aSegment)
    <SEGMENT extends org.refcodes.serial.Segment>
    void
    receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment)
    <REQUEST extends org.refcodes.serial.Segment, RESPONSE extends org.refcodes.serial.Segment>
    void
    requestSegment(REQUEST aRequest, RESPONSE aResponse)
    Sends a request expecting a response.
    <REQUEST extends org.refcodes.serial.Segment, RESPONSE extends org.refcodes.serial.Segment>
    void
    requestSegment(REQUEST aRequest, RESPONSE aResponse, boolean isAcknowledgeable)
    Sends a request expecting a response.
    <REQUEST extends org.refcodes.serial.Segment, RESPONSE extends org.refcodes.serial.Segment>
    void
    requestSegmentWithin(long aTimeoutMillis, REQUEST aRequest, RESPONSE aResponse)
    Sends a request expecting a response.
    <REQUEST extends org.refcodes.serial.Segment, RESPONSE extends org.refcodes.serial.Segment>
    void
    requestSegmentWithin(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>
    void
    transmitSegment(SEGMENT aSegment)
    <SEGMENT extends org.refcodes.serial.Segment>
    void
    transmitSegment(SEGMENT aSegment, boolean isAcknowledgeable)
    Transmits a Segment (and blocks this thread) till all it's Sequence data (as of Transmission.toSequence()) has been sent.
    <SEGMENT extends org.refcodes.serial.Segment>
    void
    transmitSegmentWithin(long aTimeoutMillis, int aRetryNumber, SEGMENT aSegment)
    Transmits a Segment (and blocks this thread) till all it's Sequence data (as of Transmission.toSequence()) has been sent.
    void
    transmitSequence(org.refcodes.serial.Sequence aSequence)
    void
    transmitSequence(org.refcodes.serial.Sequence aSequence, boolean isAcknowledgeable)
    Transmits a Sequence (and blocks this thread) till all it's data (as of Transmission.toSequence()) has been sent.
    void
    transmitSequenceWithin(long aTimeoutMillis, int aRetryNumber, org.refcodes.serial.Sequence aSequence)
    Transmits a Sequence (and blocks this thread) till all it's data (as of Transmission.toSequence()) has been sent.
    withOpen(PM aPortMetrics)
    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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aTransmissionMetrics - The HandshakeTransmissionMetrics to be used for configuring this instance.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, ExecutorService aExecutorService)
      Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aTransmissionMetrics - The HandshakeTransmissionMetrics to be used for configuring this instance.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort)
      Decorates the given Port with full duplex Segment multiplexer functionality.
      Parameters:
      aPort - The Port 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm to be used for CRC checksum calculation.
      aChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
      aExecutorService - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
      aChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
      aExecutorService - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort, ExecutorService aExecutorService)
      Decorates the given Port with full duplex Segment multiplexer functionality.
      Parameters:
      aPort - The Port to be decorated.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort, HandshakeTransmissionMetrics aTransmissionMetrics, int aInboundQueueCapacity)
      Decorates the given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aTransmissionMetrics - The HandshakeTransmissionMetrics to be used for configuring this instance.
      aInboundQueueCapacity - The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity)
      Decorates the given Port with full duplex Segment multiplexer functionality.
      Parameters:
      aPort - The Port 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm 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 - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess to use when calculating the CRC checksum.
      aCrcAlgorithm - The CrcAlgorithm to be used for CRC checksum calculation.
      aInboundQueueCapacity - The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
    • HandshakePortController

      public HandshakePortController(org.refcodes.serial.Port<PM> aPort, int aInboundQueueCapacity, ExecutorService aExecutorService)
      Decorates the given Port with full duplex Segment multiplexer functionality.
      Parameters:
      aPort - The Port to be decorated.
      aInboundQueueCapacity - The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
      aExecutorService - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm to be used for CRC checksum calculation.
      aChecksumValidationMode - The mode of operation when validating provided CRC checksums against calculated ones.
      aExecutorService - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aEndianess - The Endianess 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 - The CrcAlgorithm 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 - The ExecutorService to be used when creating Thread 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 given Port with full duplex Segment multiplexer functionality as of the given arguments.
      Parameters:
      aPort - The Port to be decorated.
      aTransmissionMetrics - The HandshakeTransmissionMetrics to be used for configuring this instance.
      aInboundQueueCapacity - The capacity of the inbound queue, any exceeding inbound transmissions are skipped.
      aExecutorService - The ExecutorService to be used when creating Thread instances for handling input and output data simultaneously.
  • Method Details

    • ping

      public void ping() 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).
      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

      public void onPing(Runnable aPingHandler)
      Registers a handler invoked upon incoming remote ping requests (via a remote's invocation of ping() 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 a SegmentConsumer for receiving and handling transmissions.
      Type Parameters:
      SEGMENT - The type of Segment for which to register.
      Parameters:
      aSegment - The Segment used for deserializing the transmission. A good practice is to use some kind of AssertMagicBytesSegment for uniquely identifying a responsible SegmentConsumer for an according Segment.
      aSegmentConsumer - The SegmentConsumer processing the according transmission.
      Returns:
      True in case the SegmentConsumer has been registered to the given Segment, 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 a RequestHandler for processing requests issued as of requestSegment(Segment, Segment) (and the like methods).
      Type Parameters:
      REQUEST - The type of Segment for which to register.
      Parameters:
      aRequest - The request Segment used for deserialize the request. A good practice is to use some kind of AssertMagicBytesSegment for uniquely identify a responsible RequestHandler for an according Segment.
      aRequestHandler - The RequestHandler processing the according request.
      Returns:
      True in case the RequestHandler has been registered to the given Segment, false in case a handler has already been registered to the given request.
    • available

      public int available() throws IOException
      Specified by:
      available in interface org.refcodes.io.Availability
      Specified by:
      available in interface org.refcodes.serial.SerialReceiver
      Specified by:
      available in interface org.refcodes.io.Skippable
      Overrides:
      available in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Specified by:
      close in interface org.refcodes.serial.SerialReceiver
      Overrides:
      close in class org.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 interface org.refcodes.serial.SegmentTransmitter
      Overrides:
      doTransmitSegment in class org.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 interface org.refcodes.serial.SegmentTransmitter
      Overrides:
      doTransmitSegment in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • getAcknowledgeMagicBytes

      public byte[] getAcknowledgeMagicBytes()
      Specified by:
      getAcknowledgeMagicBytes in interface org.refcodes.serial.AcknowledgeMagicBytesAccessor
    • getAcknowledgeRetryNumber

      public int getAcknowledgeRetryNumber()
      Specified by:
      getAcknowledgeRetryNumber in interface org.refcodes.serial.AcknowledgeRetryNumberAccessor
    • getAcknowledgeTimeoutMillis

      public long getAcknowledgeTimeoutMillis()
      Specified by:
      getAcknowledgeTimeoutMillis in interface org.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 interface ReplyRetryNumberAccessor
      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 interface ReplyTimeoutMillisAccessor
      Returns:
      An long integer with the timeout in milliseconds.
    • getCrcAlgorithm

      public org.refcodes.numerical.CrcAlgorithm getCrcAlgorithm()
      Specified by:
      getCrcAlgorithm in interface org.refcodes.numerical.CrcAlgorithmAccessor
    • getChecksumValidationMode

      public org.refcodes.numerical.ChecksumValidationMode getChecksumValidationMode()
      Specified by:
      getChecksumValidationMode in interface org.refcodes.numerical.ChecksumValidationModeAccessor
    • getEndianess

      public org.refcodes.numerical.Endianess getEndianess()
      Specified by:
      getEndianess in interface org.refcodes.numerical.EndianessAccessor
    • getInputStream

      public InputStream getInputStream()
      Specified by:
      getInputStream in interface org.refcodes.io.BytesReceiver
      Specified by:
      getInputStream in interface org.refcodes.mixin.InputStreamAccessor
      Overrides:
      getInputStream in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
    • getInputStream

      public org.refcodes.io.TimeoutInputStream getInputStream(long aTimeoutMillis)
      Specified by:
      getInputStream in interface org.refcodes.io.BytesReceiver
      Specified by:
      getInputStream in interface org.refcodes.io.TimeoutInputStreamAccessor
      Overrides:
      getInputStream in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
    • getSequenceNumber

      public int getSequenceNumber()
      Specified by:
      getSequenceNumber in interface org.refcodes.serial.SequenceNumberAccessor
    • getSequenceNumberInitValue

      public int getSequenceNumberInitValue()
      Specified by:
      getSequenceNumberInitValue in interface org.refcodes.serial.SequenceNumberInitValueAccessor
    • getSequenceNumberWidth

      public int getSequenceNumberWidth()
      Specified by:
      getSequenceNumberWidth in interface org.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 interface org.refcodes.serial.SegmentReceiver
      Overrides:
      onReceiveSegment in class org.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 interface org.refcodes.serial.SegmentReceiver
      Overrides:
      onReceiveSegment in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • open

      public void open() throws IOException
      Specified by:
      open in interface org.refcodes.component.Openable
      Specified by:
      open in interface org.refcodes.serial.SerialReceiver
      Overrides:
      open in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • open

      public void open(PM aPortMetrics) throws IOException
      Specified by:
      open in interface org.refcodes.component.ConnectionOpenable<PM extends org.refcodes.serial.PortMetrics>
      Overrides:
      open in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • receiveByte

      public byte receiveByte() throws IOException
      Specified by:
      receiveByte in interface org.refcodes.io.ByteDestination
      Specified by:
      receiveByte in interface org.refcodes.io.BytesDestination
      Specified by:
      receiveByte in interface org.refcodes.serial.SerialReceiver
      Overrides:
      receiveByte in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • transmitByte

      public void transmitByte(byte aByte) throws IOException
      Specified by:
      transmitByte in interface org.refcodes.io.ByteSource
      Specified by:
      transmitByte in interface org.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 interface org.refcodes.serial.SegmentDestination
      Specified by:
      receiveSegment in interface org.refcodes.serial.SerialReceiver
      Specified by:
      receiveSegment in interface org.refcodes.serial.SerialTransceiver
      Overrides:
      receiveSegment in class org.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 interface org.refcodes.serial.SegmentReceiver
      Specified by:
      receiveSegmentWithin in interface org.refcodes.serial.SerialReceiver
      Overrides:
      receiveSegmentWithin in class org.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 - The Segment (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 - The Segment (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 - The Segment (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 - The Segment (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 interface org.refcodes.serial.SegmentSource
      Specified by:
      transmitSegment in interface org.refcodes.serial.SerialTransceiver
      Specified by:
      transmitSegment in interface org.refcodes.serial.SerialTransmitter
      Overrides:
      transmitSegment in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • transmitSequence

      public void transmitSequence(org.refcodes.serial.Sequence aSequence) throws IOException
      Specified by:
      transmitSequence in interface org.refcodes.serial.SerialTransmitter
      Overrides:
      transmitSequence in class org.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 a Segment (and blocks this thread) till all it's Sequence data (as of Transmission.toSequence()) has been sent.
      Type Parameters:
      SEGMENT - The Segment type describing the Segment 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 - The Segment'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 a Sequence (and blocks this thread) till all it's data (as of Transmission.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 - The Sequence 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 a Segment (and blocks this thread) till all it's Sequence data (as of Transmission.toSequence()) has been sent.
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass used.
      Parameters:
      aSegment - The Segment'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 a Sequence (and blocks this thread) till all it's data (as of Transmission.toSequence()) has been sent.
      Parameters:
      aSequence - The Sequence 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

      public void transmitBytes(byte[] aBytes, int aOffset, int aLength) throws IOException
      Specified by:
      transmitBytes in interface org.refcodes.io.BytesSource
      Specified by:
      transmitBytes in interface org.refcodes.io.BytesTransmitter
      Specified by:
      transmitBytes in interface org.refcodes.serial.SerialTransmitter
      Overrides:
      transmitBytes in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • withOpen

      public HandshakePortController<PM> withOpen() throws IOException
      Specified by:
      withOpen in interface org.refcodes.component.Openable.OpenBuilder<PM extends org.refcodes.serial.PortMetrics>
      Overrides:
      withOpen in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • withOpen

      public HandshakePortController<PM> withOpen(PM aPortMetrics) throws IOException
      Specified by:
      withOpen in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<PM extends org.refcodes.serial.PortMetrics,org.refcodes.serial.Port<PM extends org.refcodes.serial.PortMetrics>>
      Overrides:
      withOpen in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
      Throws:
      IOException
    • withOpenUnchecked

      public HandshakePortController<PM> withOpenUnchecked(PM aPortMetrics)
      Specified by:
      withOpenUnchecked in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<PM extends org.refcodes.serial.PortMetrics,org.refcodes.serial.Port<PM extends org.refcodes.serial.PortMetrics>>
      Overrides:
      withOpenUnchecked in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
    • withOpenUnchecked

      public HandshakePortController<PM> withOpenUnchecked()
      Specified by:
      withOpenUnchecked in interface org.refcodes.component.Openable.OpenBuilder<PM extends org.refcodes.serial.PortMetrics>
      Overrides:
      withOpenUnchecked in class org.refcodes.serial.AbstractPortDecorator<PM extends org.refcodes.serial.PortMetrics>
    • builder

      public static <PM extends org.refcodes.serial.PortMetrics> HandshakePortController.Builder<PM> builder()
      Creates builder to build HandshakePortController.
      Type Parameters:
      PM - The actual PortMetrics type to use.
      Returns:
      The accordingly created builder.