added possibility to add radio logger analyzers from cooja projects

This commit is contained in:
fros4943 2010-03-12 16:02:47 +00:00
parent 7c5eed6bda
commit 5877528f3a
2 changed files with 65 additions and 1 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: RadioLogger.java,v 1.31 2010/03/07 20:44:40 joxe Exp $
* $Id: RadioLogger.java,v 1.32 2010/03/12 16:02:47 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -47,6 +47,7 @@ import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
import java.util.Properties;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
@ -81,6 +82,7 @@ import se.sics.cooja.plugins.analyzers.ICMPv6Analyzer;
import se.sics.cooja.plugins.analyzers.IEEE802154Analyzer;
import se.sics.cooja.plugins.analyzers.IPHCPacketAnalyzer;
import se.sics.cooja.plugins.analyzers.PacketAnalyzer;
import se.sics.cooja.plugins.analyzers.RadioLoggerAnalyzerSuite;
import se.sics.cooja.util.StringUtils;
/**
@ -297,6 +299,29 @@ public class RadioLogger extends VisPlugin {
group.add(rbMenuItem);
popupMenu.add(rbMenuItem);
/* Load additional analyzers specified by projects (cooja.config) */
String[] projectAnalyzerSuites =
gui.getProjectConfig().getStringArrayValue(RadioLogger.class, "ANALYZERS");
if (projectAnalyzerSuites != null) {
for (String suiteName: projectAnalyzerSuites) {
Class<? extends RadioLoggerAnalyzerSuite> suiteClass =
gui.tryLoadClass(RadioLogger.this, RadioLoggerAnalyzerSuite.class, suiteName);
try {
RadioLoggerAnalyzerSuite suite = suiteClass.newInstance();
ArrayList<PacketAnalyzer> suiteAnalyzers = suite.getAnalyzers();
rbMenuItem = new JRadioButtonMenuItem(createAnalyzerAction(
suite.getDescription(), suiteName, suiteAnalyzers, false));
group.add(rbMenuItem);
popupMenu.add(rbMenuItem);
logger.debug("Loaded radio logger analyzers: " + suite.getDescription());
} catch (InstantiationException e1) {
logger.warn("Failed to load analyzer suite '" + suiteName + "': " + e1.getMessage());
} catch (IllegalAccessException e1) {
logger.warn("Failed to load analyzer suite '" + suiteName + "': " + e1.getMessage());
}
}
}
dataTable.setComponentPopupMenu(popupMenu);
dataTable.setFillsViewportHeight(true);

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2010, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: RadioLoggerAnalyzerSuite.java,v 1.1 2010/03/12 16:02:47 fros4943 Exp $
*/
package se.sics.cooja.plugins.analyzers;
import java.util.ArrayList;
public interface RadioLoggerAnalyzerSuite {
public String getDescription();
public ArrayList<PacketAnalyzer> getAnalyzers();
}