use of com.neuronrobotics.replicator.driver.NRPrinter in project java-bowler by NeuronRobotics.
the class DeviceManager method addConnection.
public static void addConnection(BowlerAbstractConnection connection) {
if (connection == null) {
return;
}
GenericDevice gen = new GenericDevice(connection);
try {
if (!gen.connect()) {
throw new InvalidConnectionException("Connection is invalid");
}
if (!gen.ping(true)) {
throw new InvalidConnectionException("Communication failed");
}
} catch (Exception e) {
// connection.disconnect();
ThreadUtil.wait(1000);
BowlerDatagram.setUseBowlerV4(false);
if (!gen.connect()) {
throw new InvalidConnectionException("Connection is invalid");
}
if (!gen.ping()) {
connection = null;
throw new InvalidConnectionException("Communication failed");
}
throw new RuntimeException(e);
}
if (gen.hasNamespace("neuronrobotics.dyio.*")) {
DyIO dyio = new DyIO(gen.getConnection());
dyio.connect();
String name = "dyio";
addConnection(dyio, name);
} else if (gen.hasNamespace("bcs.cartesian.*")) {
BowlerBoardDevice delt = new BowlerBoardDevice();
delt.setConnection(gen.getConnection());
delt.connect();
String name = "bowlerBoard";
addConnection(delt, name);
addConnection(new NRPrinter(delt), "cnc");
} else if (gen.hasNamespace("bcs.pid.*")) {
GenericPIDDevice delt = new GenericPIDDevice();
delt.setConnection(gen.getConnection());
delt.connect();
String name = "pid";
addConnection(delt, name);
} else if (gen.hasNamespace("bcs.bootloader.*") || gen.hasNamespace("neuronrobotics.bootloader.*")) {
NRBootLoader delt = new NRBootLoader(gen.getConnection());
String name = "bootloader";
addConnection(delt, name);
} else if (gen.hasNamespace("neuronrobotics.bowlercam.*")) {
BowlerCamDevice delt = new BowlerCamDevice();
delt.setConnection(gen.getConnection());
delt.connect();
String name = "bowlercam";
addConnection(delt, name);
} else {
addConnection(gen, "device");
}
}
Aggregations