示例#1
0
 public void run() {
   while (true) {
     for (int i = 0; i < note1.length; i += 2) {
       final int tone = (int) note1[i];
       final int b = i + 1;
       final int length = 10 * note1[b];
       Sound.playTone(tone, length);
       try {
         Thread.sleep(length);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
 }
示例#2
0
 public static void main(String[] args) {
   try {
     Thread.setDefaultUncaughtExceptionHandler(new ThreadHandler());
     Sound.playTone(2000, 300);
     BtReceiver btReceiver = new BtReceiver();
     btReceiver.connect();
   } catch (Exception e) {
     Sound.buzz();
     System.out.println("Main: exception");
     System.out.println(e.toString());
     System.out.print(e.getMessage());
     Utils.sleep(1000);
     Button.waitForAnyPress();
     System.exit(0);
   }
 }
示例#3
0
  public void MyTune() {

    // NOTE: This tune was generated from a midi using Guy
    // Truffelli's Brick Music Studio www.aga.it/~guy/lego
    short[] note = {
      2349, 115, 0, 5, 1760, 165, 0, 35, 1760, 28, 0, 13, 1976, 23, 0, 18, 1760, 18, 0, 23, 1568,
      15, 0, 25, 1480, 103, 0, 18, 1175, 180, 0, 20, 1760, 18, 0, 23, 1976, 20, 0, 20, 1760, 15, 0,
      25, 1568, 15, 0, 25, 2217, 98, 0, 23, 1760, 88, 0, 33, 1760, 75, 0, 5, 1760, 20, 0, 20, 1760,
      20, 0, 20, 1976, 18, 0, 23, 1760, 18, 0, 23, 2217, 225, 0, 15, 2217, 218
    };
    for (int i = 0; i < note.length; i += 2) {
      final short w = note[i + 1];
      final int n = note[i];
      if (n != 0) Sound.playTone(n, w * 10);
      try {
        Thread.sleep(w * 2);
      } catch (InterruptedException e) {
      }
    }
  }
示例#4
0
  /** Runs the ai... */
  public void run() {
    Communicator comm = null;
    try {
      comm = Communicator.getInstance(this);
    } catch (Exception e) {
      Console.println("-------------------");
      Console.println("ERROR in Comm");
      Console.println("-------------------");
      Button.waitForPress();
      return;
    }
    while (grid.isWorkToDo()) {
      PathElement p = null;
      if (motion.isObjLoaded()) {
        p = grid.getAWayBackHome(robo);
      } else if ((p = grid.getAWayToNextKnownUnCommon(robo)) == null) {
        if ((p = grid.getAWayToNextUnknown(robo)) == null) {
          /* does not work..
          if ((p = grid.getAWayToNextKnownCommon(robo)) == null) {
          	try {
          		sleep(500);
          	} catch (InterruptedException e) {
          		// can't sleep, so do a busy waiting
          	}
          	continue;	// try again
          }*/
        }
      }
      Console.println("here3"); // TODO
      do {
        orient(p);

        // ask other
        if (!askOther(p)) continue; // try later again

        // if its not for me, i won't go there. (see grid.getway...)
        if (grid.getJunction(p).getType() == Junction.MASTER_OBJ
            || grid.getJunction(p).getType() == Junction.SLAVE_OBJ) {
          // load
          motion.goToNextJunction(true);
          grid.setJunction(new Junction(robo.getMyActualPosition(), Junction.EMPTY), true);
        } else {
          // unloading loaded object
          if (motion.isObjLoaded()
              && grid.getJunction(grid.getNextProjectedPosition(robo)).getType()
                  == Junction.HOME_BASE) {

            motion.goToNextJunction(false);

            // orient to south
            Position orientation = grid.getNextProjectedPosition(robo);
            Position unloadPos =
                new Position(robo.getHomeBase().getX(), robo.getHomeBase().getY() - 1);

            // unload the object
            orient(unloadPos);
            motion.unload();

            // orient back
            orient(orientation);

            // regular move
          } else motion.goToNextJunction(false);
        }

      } while ((p = p.getNextElt()) != null);
    }
    Console.println(" - FIN - ");
    Sound.playTone(400, 1000);
    Button.waitForPress();
  }