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) { } } }
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(); } }