java.lang.Object
org.refcodes.serial.LoopbackPortHub
org.refcodes.serial.CrossoverLoopbackPortHub
- All Implemented Interfaces:
PortHub<LoopbackPort,PortMetrics>
A
CrossoverLoopbackPortHub is an in-memory implementation of a
PortHub which's Port instances loop their output directly to
the "connected" LoopbackPortHub counterpart Port instances
("other end of the wire"). The counterpart Port instances have the
same alias so it is easy to retrieve the crossover LoopbackPort
instances. This is suitable for cases using a some kind of frequent handshake
between a transmitter and a receiver on the same line where we have to
simulate a bidirectional in-memory communication between two ports.-
Field Summary
Fields inherited from class org.refcodes.serial.LoopbackPortHub
_ports -
Constructor Summary
ConstructorsConstructorDescriptionCrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub) Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart.CrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub, String... aPorts) Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart and the given ports (e.g. ports with the given port aliases). -
Method Summary
Methods inherited from class org.refcodes.serial.LoopbackPortHub
toPort
-
Constructor Details
-
CrossoverLoopbackPortHub
Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart.- Parameters:
aCrossoverPortHub- TheCrossoverLoopbackPortHub's counterpartLoopbackPortHub.
-
CrossoverLoopbackPortHub
Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart and the given ports (e.g. ports with the given port aliases).- Parameters:
aCrossoverPortHub- TheCrossoverLoopbackPortHub's counterpartLoopbackPortHub.aPorts- The ports to be created initially.
-
-
Method Details
-
toPort
Returns thePortidentified by the given alias.- Specified by:
toPortin interfacePortHub<LoopbackPort,PortMetrics> - Overrides:
toPortin classLoopbackPortHub- Parameters:
aAlias- The alias identifying the givenPort.- Returns:
- The given
Port. - Throws:
IOException- Thrown in case accessing the list ofPortinstances failed due to I/O problems.
-
ports
Lists the available ports of the system.- Specified by:
portsin interfacePortHub<LoopbackPort,PortMetrics> - Overrides:
portsin classLoopbackPortHub- Returns:
- An array of available
Portinstances, if there are no ports than an empty array (size 0) is returned. - Throws:
IOException- Thrown in case accessing the list ofPortinstances failed due to I/O problems.
-