From 1917ea574ff2c3841aa0ae7ba0e44995ae7e7712 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Wed, 14 Aug 2013 12:34:52 +0200 Subject: [PATCH] added methods to more easily extract runtime statistics from simulation scripts --- .../apps/powertracker/java/PowerTracker.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/cooja/apps/powertracker/java/PowerTracker.java b/tools/cooja/apps/powertracker/java/PowerTracker.java index f67df3baa..35a6b8c2d 100644 --- a/tools/cooja/apps/powertracker/java/PowerTracker.java +++ b/tools/cooja/apps/powertracker/java/PowerTracker.java @@ -222,6 +222,15 @@ public class PowerTracker extends VisPlugin { repaintTimer.start(); } + public MoteTracker getMoteTrackerOf(Mote mote) { + for (MoteTracker mt : moteTrackers) { + if (mt.mote == mote) { + return mt; + } + } + return null; + } + private Action resetAction = new AbstractAction("Reset") { public void actionPerformed(ActionEvent e) { Runnable r = new Runnable() { @@ -288,7 +297,7 @@ public class PowerTracker extends VisPlugin { return sb.toString(); } - private static class MoteTracker implements Observer { + public static class MoteTracker implements Observer { /* last radio state */ private boolean radioWasOn; private RadioState lastRadioState; @@ -379,19 +388,19 @@ public class PowerTracker extends VisPlugin { radioInterfered += t; } - protected double getRadioOnRatio() { + public double getRadioOnRatio() { return 1.0*radioOn/duration; } - protected double getRadioTxRatio() { + public double getRadioTxRatio() { return 1.0*radioTx/duration; } - protected double getRadioInterferedRatio() { + public double getRadioInterferedRatio() { return 1.0*radioInterfered/duration; } - protected double getRadioRxRatio() { + public double getRadioRxRatio() { return 1.0*radioRx/duration; }