Exemplo n.º 1
0
  public static void main(String[] args) {

    Thread thread = new Thread(new Download(args));
    thread.setDaemon(true);
    thread.start();
    try {
      thread.join();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  public void run() {

    // setup advertisement message
    advMsg.set_sourceAddr(TOS_UART_ADDR);

    if (reboot) {
      advMsg.set_summary_vNum(0x0);
      advMsg.set_runningVNum(0xffff);
    } else {
      advMsg.set_summary_vNum(0xffff);
      advMsg.set_runningVNum(0x0);
    }
    advMsg.set_summary_numPgsComplete((byte) numPgs);

    while (true) {
      try {
        // send an advertisement message every second
        if (printAllMsgs) System.out.print(advMsg);
        send(advMsg);
        Thread.currentThread().sleep(1000);
        if (reboot) {
          System.exit(0);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 3
0
  public static void main(String args[]) {

    if (args.length < 2) {
      usage();
    }

    WakeupMsg wakeupMsg = new WakeupMsg();

    DripDaemon dd = new DripDaemon(WakeupMsg.AM_TYPE);

    String source = args[0];
    if (source.equals("both")) {
      wakeupMsg.set_source(WakeupConsts.WAKEUP_SOURCE_BOTH);
    }
    if (source.equals("bat")) {
      wakeupMsg.set_source(WakeupConsts.WAKEUP_SOURCE_BAT);
    }
    if (source.equals("cap")) {
      wakeupMsg.set_source(WakeupConsts.WAKEUP_SOURCE_CAP);
    }

    int wakeupPeriod = Integer.parseInt(args[1]);
    System.out.println("Wakeup period = " + (wakeupPeriod) + " secs");
    System.out.println("Source = " + source + " (" + wakeupMsg.get_source() + ")");

    wakeupMsg.set_wakeupPeriod(wakeupPeriod * 100);

    while (true) {
      System.out.println("Renewing lease for " + (wakeupPeriod) + " secs");
      dd.storeForever(wakeupMsg, WakeupMsg.DEFAULT_MESSAGE_SIZE);
      try {
        if (wakeupPeriod < 1) {
          Thread.sleep(1000 / 2);
        } else {
          Thread.sleep(wakeupPeriod * 1000 / 2);
        }
      } catch (InterruptedException e) {
      }
    }
  }
Exemplo n.º 4
0
  public void sendPackets() {
    int counter = 0;
    BlinkToRadioMsg payload = new BlinkToRadioMsg();

    try {
      while (true) {
        System.out.println("Sending packet " + counter);
        payload.set_counter(counter);
        moteIF.send(0, payload);
        counter++;
        try {
          Thread.sleep(1000);
        } catch (InterruptedException exception) {
        }
      }
    } catch (IOException exception) {
      System.err.println("Exception thrown when sending packets. Exiting.");
      System.err.println(exception);
    }
  }
  public static void main(String[] args) {
    TestTtsp ttsp = new TestTtsp();

    JFrame jframe = new JFrame("TTSP - Time Precision Error");
    ttsp.setPrecisionErrorChart(new PrecisionErrorChart());
    jframe.getContentPane().add(ttsp.getPrecisionErrorChart(), "Center");
    jframe.setBounds(200, 120, 600, 280);
    jframe.setVisible(true);
    jframe.addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent windowevent) {
            System.exit(0);
          }
        });

    JFrame jframe2 = new JFrame("TTSP - Synchronization Period");
    ttsp.setSyncPeriodChart(new SyncPeriodChart());
    jframe2.getContentPane().add(ttsp.getSyncPeriodChart(), "Center");
    jframe2.setBounds(200, 120, 600, 280);
    jframe2.setVisible(true);
    jframe2.addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent windowevent) {
            System.exit(0);
          }
        });

    try {
      Thread.sleep(10000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
  }