Esempio n. 1
0
  public static void main(String[] args) throws InterruptedException {

    LoggingFactory.getInstance().configure();
    LoggingFactory.getInstance().setLevel(Level.DEBUG);

    Servo right = new Servo("servo01");

    right.map(5, 180, 5, 180);
    log.info("{}", right.calc(1));
    log.info("{}", right.calc(3));
    right.map(180, 0, 0, 180);
    log.info("{}", right.calc(3));
    right.map(0, 180, 5, 178);
    log.info("{}", right.calc(0));

    right.startService();
    right.test();

    // FIXME - routing of servo.attach("arduino", 3);

    Arduino arduino = (Arduino) Runtime.createAndStart("arduino", "Arduino");

    arduino.connect("COM4");

    arduino.servoAttach(right.getName(), 13);

    right.test();

    Runtime.createAndStart("gui", "GUIService");

    // right.attach(serviceName)
    /*
     * Servo left = new Servo("left"); left.startService();
     *
     * //Servo neck = new Servo("neck"); //neck.startService();
     *
     * for (int i = 0; i < 30; ++i) {
     *
     * right.attach("arduino", 2); left.attach("arduino", 3);
     *
     * right.moveTo(120); // 70 back left.moveTo(70); // 118 back
     *
     * Thread.sleep(10000);
     *
     * right.moveTo(90); left.moveTo(90);
     *
     * //right.detach(); //left.detach(); }
     */

  }
 public boolean connect(String port) {
   return arduino.connect(port);
 }