added saved config plugin specifics support
This commit is contained in:
parent
a8c35677bd
commit
54e8dd9547
|
@ -26,7 +26,7 @@
|
||||||
* 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: Simulation.java,v 1.3 2006/11/08 21:28:51 fros4943 Exp $
|
* $Id: Simulation.java,v 1.4 2006/11/30 14:25:44 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -300,6 +300,11 @@ public class Simulation extends Observable implements Runnable {
|
||||||
int moteNr = Integer.parseInt(moteNrString);
|
int moteNr = Integer.parseInt(moteNrString);
|
||||||
Mote mote = newSim.getMote(moteNr);
|
Mote mote = newSim.getMote(moteNr);
|
||||||
openedPlugin = visPluginClass.getConstructor(new Class[]{Mote.class}).newInstance(mote);
|
openedPlugin = visPluginClass.getConstructor(new Class[]{Mote.class}).newInstance(mote);
|
||||||
|
|
||||||
|
// Tag plugin with mote
|
||||||
|
openedPlugin.putClientProperty("mote", mote);
|
||||||
|
|
||||||
|
// Show plugin
|
||||||
GUI.currentGUI.showPlugin(openedPlugin);
|
GUI.currentGUI.showPlugin(openedPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +323,7 @@ public class Simulation extends Observable implements Runnable {
|
||||||
} else if (pluginSubElement.getName().equals("minimized")) {
|
} else if (pluginSubElement.getName().equals("minimized")) {
|
||||||
openedPlugin.setIcon(Boolean.parseBoolean(pluginSubElement.getText()));
|
openedPlugin.setIcon(Boolean.parseBoolean(pluginSubElement.getText()));
|
||||||
} else if (pluginSubElement.getName().equals("visplugin_config")) {
|
} else if (pluginSubElement.getName().equals("visplugin_config")) {
|
||||||
logger.fatal("NOT IMPLEMENTED: Not passing plugin specific data yet: " + pluginSubElement.getText());
|
openedPlugin.setConfigXML(pluginSubElement.getChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -375,16 +380,16 @@ public class Simulation extends Observable implements Runnable {
|
||||||
pluginType == VisPluginType.SIM_STANDARD_PLUGIN) {
|
pluginType == VisPluginType.SIM_STANDARD_PLUGIN) {
|
||||||
pluginSubElement.setText("sim");
|
pluginSubElement.setText("sim");
|
||||||
pluginElement.addContent(pluginSubElement);
|
pluginElement.addContent(pluginSubElement);
|
||||||
} else if (pluginType == VisPluginType.MOTE_PLUGIN) {
|
} else if (pluginType == VisPluginType.MOTE_PLUGIN && openedPlugin.getClientProperty("mote") != null) {
|
||||||
if (openedPlugin.getClientProperty("mote") != null) {
|
Mote taggedMote = (Mote) openedPlugin.getClientProperty("mote");
|
||||||
Mote taggedMote = (Mote) openedPlugin.getClientProperty("mote");
|
for (int moteNr = 0; moteNr < getMotesCount(); moteNr++) {
|
||||||
for (int moteNr = 0; moteNr < getMotesCount(); moteNr++) {
|
if (getMote(moteNr) == taggedMote) {
|
||||||
if (getMote(moteNr) == taggedMote) {
|
pluginSubElement.setText("mote: " + moteNr);
|
||||||
pluginSubElement.setText("mote: " + moteNr);
|
pluginElement.addContent(pluginSubElement);
|
||||||
pluginElement.addContent(pluginSubElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.fatal("Warning! Could not write visplugin constructor information: " + pluginType + "@" + openedPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginSubElement = new Element("width");
|
pluginSubElement = new Element("width");
|
||||||
|
|
|
@ -26,14 +26,17 @@
|
||||||
* 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: MoteInterfaceViewer.java,v 1.1 2006/08/21 12:13:09 fros4943 Exp $
|
* $Id: MoteInterfaceViewer.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Vector;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ public class MoteInterfaceViewer extends VisPlugin {
|
||||||
private Mote mote;
|
private Mote mote;
|
||||||
private MoteInterface selectedMoteInterface = null;
|
private MoteInterface selectedMoteInterface = null;
|
||||||
private JPanel currentInterfaceVisualizer = null;
|
private JPanel currentInterfaceVisualizer = null;
|
||||||
|
private JComboBox selectInterfaceComboBox = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new mote interface viewer.
|
* Create a new mote interface viewer.
|
||||||
|
@ -71,7 +75,7 @@ public class MoteInterfaceViewer extends VisPlugin {
|
||||||
|
|
||||||
label = new JLabel("Select interface:");
|
label = new JLabel("Select interface:");
|
||||||
|
|
||||||
final JComboBox selectInterfaceComboBox = new JComboBox();
|
selectInterfaceComboBox = new JComboBox();
|
||||||
final JPanel interfacePanel = new JPanel();
|
final JPanel interfacePanel = new JPanel();
|
||||||
|
|
||||||
for (int i=0; i < mote.getInterfaces().getAllActiveInterfaces().size(); i++) {
|
for (int i=0; i < mote.getInterfaces().getAllActiveInterfaces().size(); i++) {
|
||||||
|
@ -149,4 +153,30 @@ public class MoteInterfaceViewer extends VisPlugin {
|
||||||
selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer);
|
selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<Element> getConfigXML() {
|
||||||
|
Vector<Element> config = new Vector<Element>();
|
||||||
|
|
||||||
|
Element element;
|
||||||
|
|
||||||
|
// Selected variable name
|
||||||
|
element = new Element("interface");
|
||||||
|
element.setText((String) selectInterfaceComboBox.getSelectedItem());
|
||||||
|
config.add(element);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setConfigXML(Collection<Element> configXML) {
|
||||||
|
for (Element element : configXML) {
|
||||||
|
if (element.getName().equals("interface")) {
|
||||||
|
for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) {
|
||||||
|
if (selectInterfaceComboBox.getItemAt(i).equals(element.getText())) {
|
||||||
|
selectInterfaceComboBox.setSelectedIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* 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: VariableWatcher.java,v 1.1 2006/08/21 12:13:07 fros4943 Exp $
|
* $Id: VariableWatcher.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -35,7 +35,10 @@ import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Vector;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ public class VariableWatcher extends VisPlugin {
|
||||||
private JPanel lengthPane;
|
private JPanel lengthPane;
|
||||||
private JPanel valuePane;
|
private JPanel valuePane;
|
||||||
private JComboBox varName;
|
private JComboBox varName;
|
||||||
|
private JComboBox varType;
|
||||||
private JFormattedTextField[] varValues;
|
private JFormattedTextField[] varValues;
|
||||||
private JFormattedTextField varLength;
|
private JFormattedTextField varLength;
|
||||||
private JButton writeButton;
|
private JButton writeButton;
|
||||||
|
@ -122,7 +126,7 @@ public class VariableWatcher extends VisPlugin {
|
||||||
label.setPreferredSize(new Dimension(LABEL_WIDTH,LABEL_HEIGHT));
|
label.setPreferredSize(new Dimension(LABEL_WIDTH,LABEL_HEIGHT));
|
||||||
smallPane.add(BorderLayout.WEST, label);
|
smallPane.add(BorderLayout.WEST, label);
|
||||||
|
|
||||||
final JComboBox varType = new JComboBox();
|
varType = new JComboBox();
|
||||||
varType.addItem("Byte (1 byte)"); // BYTE_INDEX = 0
|
varType.addItem("Byte (1 byte)"); // BYTE_INDEX = 0
|
||||||
varType.addItem("Integer (4 bytes)"); // INT_INDEX = 1
|
varType.addItem("Integer (4 bytes)"); // INT_INDEX = 1
|
||||||
varType.addItem("Byte array (x bytes)"); // ARRAY_INDEX = 2
|
varType.addItem("Byte array (x bytes)"); // ARRAY_INDEX = 2
|
||||||
|
@ -307,4 +311,63 @@ public class VariableWatcher extends VisPlugin {
|
||||||
public void closePlugin() {
|
public void closePlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<Element> getConfigXML() {
|
||||||
|
// Return currently watched variable and type
|
||||||
|
Vector<Element> config = new Vector<Element>();
|
||||||
|
|
||||||
|
Element element;
|
||||||
|
|
||||||
|
// Selected variable name
|
||||||
|
element = new Element("varname");
|
||||||
|
element.setText((String) varName.getSelectedItem());
|
||||||
|
config.add(element);
|
||||||
|
|
||||||
|
// Selected variable type
|
||||||
|
if (varType.getSelectedIndex() == BYTE_INDEX) {
|
||||||
|
element = new Element("vartype");
|
||||||
|
element.setText("byte");
|
||||||
|
config.add(element);
|
||||||
|
} else if (varType.getSelectedIndex() == INT_INDEX) {
|
||||||
|
element = new Element("vartype");
|
||||||
|
element.setText("int");
|
||||||
|
config.add(element);
|
||||||
|
} else if (varType.getSelectedIndex() == ARRAY_INDEX) {
|
||||||
|
element = new Element("vartype");
|
||||||
|
element.setText("array");
|
||||||
|
config.add(element);
|
||||||
|
element = new Element("array_length");
|
||||||
|
element.setText(varLength.getValue().toString());
|
||||||
|
config.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setConfigXML(Collection<Element> configXML) {
|
||||||
|
lengthPane.setVisible(false);
|
||||||
|
setNumberOfValues(1);
|
||||||
|
varLength.setValue(1);
|
||||||
|
|
||||||
|
for (Element element : configXML) {
|
||||||
|
if (element.getName().equals("varname")) {
|
||||||
|
varName.setSelectedItem(element.getText());
|
||||||
|
} else if (element.getName().equals("vartype")) {
|
||||||
|
if (element.getText().equals("byte")) {
|
||||||
|
varType.setSelectedIndex(BYTE_INDEX);
|
||||||
|
} else if (element.getText().equals("int")) {
|
||||||
|
varType.setSelectedIndex(INT_INDEX);
|
||||||
|
} else if (element.getText().equals("array")) {
|
||||||
|
varType.setSelectedIndex(ARRAY_INDEX);
|
||||||
|
lengthPane.setVisible(true);
|
||||||
|
}
|
||||||
|
} else if (element.getName().equals("array_length")) {
|
||||||
|
int nrValues = Integer.parseInt(element.getText());
|
||||||
|
setNumberOfValues(nrValues);
|
||||||
|
varLength.setValue(nrValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue