Class Rs232ControllerBuilder
java.lang.Object
com.thecoderscorner.menu.remote.rs232.Rs232ControllerBuilder
- All Implemented Interfaces:
ConnectorFactory
Creates an instance of a RS232 based controller to a given port, and connects it with the selected menu.
This implements the standard builder pattern, an example of use would be along the lines of:
controller = new Rs232ControllerBuilder()
.withRs232(portName, baud)
.withMenuTree(menuTree)
.withLocalName("myApp")
.withUUID(myAppUUID)
.build();
controller.start();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanattemptPairing(Optional<Consumer<AuthStatus>> maybePairingListener)A pairing connection is purely used to initialise the security between the device and the API.build()Once the above methods have been called to fill in the blanks, then call build to get the actual instance.Optional, defaults to system clock but can be overridenwithExecutor(ScheduledExecutorService executor)Optional, defaults to creating a suitable executor for single connectivitywithLocalName(String name)Optional, Set the name of this connection, defaults to NoNamewithMenuTree(MenuTree tree)Mandatory, the menuTree instance to store the menu items retrieved from the remote side.withProtocol(MenuCommandProtocol protocol)Optional, defaults to the standard protocol.Mandatory, specifies the port name and baud rate for rs232.Mandatory, the UUID for this instance of the application
-
Constructor Details
-
Rs232ControllerBuilder
public Rs232ControllerBuilder()
-
-
Method Details
-
withRs232
Mandatory, specifies the port name and baud rate for rs232.- Parameters:
port- the name of the portbaud- the baud rate- Returns:
- itself, calls can be chained.
-
withClock
Optional, defaults to system clock but can be overriden- Parameters:
clock- the clock to use- Returns:
- itself, can be chained
-
withUUID
Mandatory, the UUID for this instance of the application- Parameters:
uuid- the uuid of this app.- Returns:
- itself, can be chained
-
withExecutor
Optional, defaults to creating a suitable executor for single connectivity- Parameters:
executor- the executor which must implement ScheduledExecutorService- Returns:
- itself, suitable for chaining.
-
withLocalName
Optional, Set the name of this connection, defaults to NoName- Parameters:
name- the name the remote will see.- Returns:
- itself, suitable for chaining.
-
build
Once the above methods have been called to fill in the blanks, then call build to get the actual instance.- Specified by:
buildin interfaceConnectorFactory- Returns:
- the actual instance.
-
attemptPairing
A pairing connection is purely used to initialise the security between the device and the API. Once used it will be closed. However, you can use build on the same builder after a successful pair.- Specified by:
attemptPairingin interfaceConnectorFactory- Parameters:
maybePairingListener- an optional of a consumer that can receive updates, mainly for UI's.- Returns:
- true if paired otherwise false.
-