Added chart with average routing metric

This commit is contained in:
Niclas Finne 2011-09-21 16:17:42 +02:00
parent 3017f92a55
commit 57ae779373
2 changed files with 43 additions and 9 deletions

View file

@ -26,16 +26,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: CollectServer.java,v 1.5 2010/12/07 22:46:13 adamdunkels Exp $
*
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
* CollectServer * CollectServer
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 3 jul 2008 * Created : 3 jul 2008
* Updated : $Date: 2010/12/07 22:46:13 $
* $Revision: 1.5 $
*/ */
package se.sics.contiki.collect; package se.sics.contiki.collect;
@ -367,6 +363,44 @@ public class CollectServer implements SerialConnectionListener {
return data.getValue(SensorData.RTMETRIC); return data.getValue(SensorData.RTMETRIC);
} }
}, },
new AggregatedTimeChartPanel<boolean[]>(this, NETWORK, "Avg Routing Metric (Over Time)", "Time",
"Average Routing Metric") {
private int nodeCount;
{
ValueAxis axis = chart.getXYPlot().getRangeAxis();
((NumberAxis)axis).setAutoRangeIncludesZero(true);
axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}
@Override
protected boolean[] createState(Node node) {
return new boolean[1];
}
@Override
protected void clearState(Map<Node,boolean[]> map) {
nodeCount = 0;
for(boolean[] value : map.values()) {
value[0] = false;
}
}
@Override
protected String getTitle(int selectedCount, int dataCount, int duplicateCount) {
return "Average Routing Metric (" + dataCount + " packets from " + nodeCount + " node"
+ (nodeCount > 1 ? "s" : "") + ')';
}
@Override
protected int getTotalDataValue(int value) {
// Return average value
return nodeCount > 0 ? (value / nodeCount) : value;
}
@Override
protected int getSensorDataValue(SensorData data, boolean[] nodeState) {
if (!nodeState[0]) {
nodeCount++;
nodeState[0] = true;
}
return data.getValue(SensorData.RTMETRIC);
}
},
new TimeChartPanel(this, NETWORK, "ETX (Over Time)", "ETX to Next Hop", "Time", "ETX") { new TimeChartPanel(this, NETWORK, "ETX (Over Time)", "ETX to Next Hop", "Time", "ETX") {
{ {
ValueAxis axis = chart.getXYPlot().getRangeAxis(); ValueAxis axis = chart.getXYPlot().getRangeAxis();

View file

@ -26,16 +26,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: AggregatedTimeChartPanel.java,v 1.1 2010/11/03 14:53:05 adamdunkels Exp $
*
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
* PacketChartPanel * PacketChartPanel
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 6 sep 2010 * Created : 6 sep 2010
* Updated : $Date: 2010/11/03 14:53:05 $
* $Revision: 1.1 $
*/ */
package se.sics.contiki.collect.gui; package se.sics.contiki.collect.gui;
@ -175,7 +171,7 @@ public abstract class AggregatedTimeChartPanel<T> extends JPanel implements Visu
series.add(new Minute(new Date((minute - 1) * 60000L)), 0); series.add(new Minute(new Date((minute - 1) * 60000L)), 0);
} }
} }
series.add(new Minute(new Date(minute * 60000L)), count); series.add(new Minute(new Date(minute * 60000L)), getTotalDataValue(count));
count = 0; count = 0;
lastMinute = minute + 1; lastMinute = minute + 1;
minute = min; minute = min;
@ -198,6 +194,10 @@ public abstract class AggregatedTimeChartPanel<T> extends JPanel implements Visu
protected void clearState(Map<Node,T> map) { protected void clearState(Map<Node,T> map) {
} }
protected int getTotalDataValue(int value) {
return value;
}
protected abstract int getSensorDataValue(SensorData sd, T nodeState); protected abstract int getSensorDataValue(SensorData sd, T nodeState);
public boolean getBaseShapeVisible() { public boolean getBaseShapeVisible() {