Search in sources :

Example 1 with GenericPIDDevice

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");
    }
}
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)

Example 2 with GenericPIDDevice

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);
    }
}
Also used : GenericPIDDevice(com.neuronrobotics.sdk.pid.GenericPIDDevice) BowlerTCPClient(com.neuronrobotics.sdk.network.BowlerTCPClient)

Aggregations

GenericPIDDevice (com.neuronrobotics.sdk.pid.GenericPIDDevice)2 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 BowlerTCPClient (com.neuronrobotics.sdk.network.BowlerTCPClient)1