Search in sources :

Example 1 with DyIOCommunicationException

use of com.neuronrobotics.sdk.dyio.DyIOCommunicationException in project java-bowler by NeuronRobotics.

the class ConnectionDialog method getBowlerDevice.

/**
 * @param dev
 * @return Returns if the device has been found
 */
public static boolean getBowlerDevice(BowlerAbstractDevice dev, AbstractConnectionPanel panel) {
    if (dev == null) {
        return false;
    }
    BowlerAbstractConnection connection = null;
    while (connection == null) {
        Log.info("Select connection:");
        connection = ConnectionDialog.promptConnection(panel);
        if (connection == null) {
            Log.info("No connection selected...");
            return false;
        }
        Log.info("setting connection");
        try {
            dev.setConnection(connection);
            dev.connect();
            Log.info("Connected");
        } catch (DyIOCommunicationException e1) {
            String m = "The DyIO has not reported back to the library. \nCheck your connection and ensure you are attempting to talk to a DyIO, not another Bowler Device\nThis program will now exit.";
            JOptionPane.showMessageDialog(null, m, "DyIO Not Responding" + e1.getMessage(), JOptionPane.ERROR_MESSAGE);
            continue;
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, e.getMessage(), "DyIO Connection problem ", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        Log.info("Attempting to ping");
        if (dev.ping()) {
            Log.info("Ping OK!");
            break;
        } else {
            connection = null;
            JOptionPane.showMessageDialog(null, "No device on that port", "", JOptionPane.ERROR_MESSAGE);
        }
    }
    return true;
}
Also used : BowlerAbstractConnection(com.neuronrobotics.sdk.common.BowlerAbstractConnection) DyIOCommunicationException(com.neuronrobotics.sdk.dyio.DyIOCommunicationException) DyIOCommunicationException(com.neuronrobotics.sdk.dyio.DyIOCommunicationException)

Aggregations

BowlerAbstractConnection (com.neuronrobotics.sdk.common.BowlerAbstractConnection)1 DyIOCommunicationException (com.neuronrobotics.sdk.dyio.DyIOCommunicationException)1