public interface ControlLab extends Closeable
newControlLab()
.
Usage example:
ControlLab controlLab = ControlLab.newControlLab();
List<String>
availablePorts = controlLab.getAvailablePorts();
try {
controlLab.open(availablePorts.get(0));
controlLab.getOutput(OutputId.A).setPowerLevel(PowerLevel.P4).turnOn();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
controlLab.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Modifier and Type | Method and Description |
---|---|
void |
close()
Disconnects from the control lab and releases any resources.
|
List<String> |
getAvailablePorts()
List available serial ports on this machine.
|
String |
getConnectedPortName()
Returns the system specific serial port identifier the control lab is
connected to, or empty string if not connected.
|
Input |
getInput(InputId inputId)
Return a handle for the input specified on this control lab instance.
|
Output |
getOutput(OutputId outputId)
Return a handle for the output specified on this control lab instance.
|
Output |
getOutput(Set<OutputId> outputs)
Return a handle for multiple outputs on this control lab instance.
|
StopButton |
getStopButton()
Return a handle for the stop button on this control lab instance.
|
static ControlLab |
newControlLab()
Returns a new ControlLab instance.
|
void |
open(String portName)
Opens a connection to the control lab on the specified port.
|
void |
setOutputDirection(Direction direction,
Set<OutputId> outputs)
Sets the
Direction of the specified outputs. |
void |
setOutputPowerLevel(PowerLevel powerLevel,
Set<OutputId> outputs)
Sets the
PowerLevel of the specified outputs. |
void |
turnOutputOff(Set<OutputId> outputs)
Stops sending power to the specified outputs.
|
void |
turnOutputOn(Set<OutputId> outputs)
Starts sending power to the specified outputs.
|
static ControlLab newControlLab()
List<String> getAvailablePorts()
void open(String portName) throws IOException
portName
- system specific serial port identifierIOException
- if any number of possible communication issues occursString getConnectedPortName()
void turnOutputOff(Set<OutputId> outputs) throws IOException
outputs
- outputs to stopIOException
- if any number of possible communication issues occursvoid turnOutputOn(Set<OutputId> outputs) throws IOException
outputs
- outputs to startIOException
- if any number of possible communication issues occursvoid setOutputDirection(Direction direction, Set<OutputId> outputs) throws IOException
Direction
of the specified outputs. Direction may be changed
while the outputs are powered or unpowered.direction
- desired directionoutputs
- which outputs to changeIOException
- if any number of possible communication issues occursvoid setOutputPowerLevel(PowerLevel powerLevel, Set<OutputId> outputs) throws IOException
PowerLevel
of the specified outputs. Power level may be changed
while the outputs are powered or unpowered.powerLevel
- desired power leveloutputs
- which outputs to changeIOException
- if any number of possible communication issues occursOutput getOutput(OutputId outputId)
outputId
- identifier of the desired output portOutput getOutput(Set<OutputId> outputs)
outputs
- identifiers of the desired output portsStopButton getStopButton()
Input getInput(InputId inputId)
inputId
- identifier of the desired input portvoid close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
- if any number of possible communication issues occursCopyright © 2016–2023. All rights reserved.