use of com.neuronrobotics.sdk.pid.GenericPIDDevice 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");
}
}
use of com.neuronrobotics.sdk.pid.GenericPIDDevice in project java-bowler by NeuronRobotics.
the class GenericPIDTest method main.
/**
* @param args
*/
public static void main(String[] args) {
Log.enableDebugPrint();
GenericPIDDevice pid = new GenericPIDDevice();
// }
try {
try {
pid.setConnection(new BowlerTCPClient("cortex.wpi.edu", 1965));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// pid.setConnection(new BowlerTCPClient("192.168.0.134", 1965));
pid.GetAllPIDPosition();
pid.GetPIDPosition(2);
pid.disconnect();
System.out.println("All OK!");
System.exit(0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
pid.disconnect();
System.exit(1);
}
}
Aggregations