Search in sources :

Example 1 with NRPrinter

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");
    }
}
Also used : BowlerCamDevice(com.neuronrobotics.sdk.bowlercam.device.BowlerCamDevice) GenericDevice(com.neuronrobotics.sdk.genericdevice.GenericDevice) BowlerBoardDevice(com.neuronrobotics.replicator.driver.BowlerBoardDevice) NRBootLoader(com.neuronrobotics.sdk.bootloader.NRBootLoader) NRPrinter(com.neuronrobotics.replicator.driver.NRPrinter) GenericPIDDevice(com.neuronrobotics.sdk.pid.GenericPIDDevice) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Aggregations

BowlerBoardDevice (com.neuronrobotics.replicator.driver.BowlerBoardDevice)1 NRPrinter (com.neuronrobotics.replicator.driver.NRPrinter)1 NRBootLoader (com.neuronrobotics.sdk.bootloader.NRBootLoader)1 BowlerCamDevice (com.neuronrobotics.sdk.bowlercam.device.BowlerCamDevice)1 DyIO (com.neuronrobotics.sdk.dyio.DyIO)1 GenericDevice (com.neuronrobotics.sdk.genericdevice.GenericDevice)1 GenericPIDDevice (com.neuronrobotics.sdk.pid.GenericPIDDevice)1