From 2691abecaae58c927c0b5afc463130066f38f86e Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 3 Apr 2008 14:00:21 +0000 Subject: [PATCH] using firmware specified in applet attribute --- .../se/sics/cooja/mspmote/ESBMoteType.java | 18 ++++++++- .../se/sics/cooja/mspmote/MspMoteType.java | 37 ++++++++++++++----- .../se/sics/cooja/mspmote/SkyMoteType.java | 18 ++++++++- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java index d834210ca..605c570ab 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ESBMoteType.java,v 1.3 2008/02/12 15:12:38 fros4943 Exp $ + * $Id: ESBMoteType.java,v 1.4 2008/04/03 14:01:33 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -35,6 +35,7 @@ import java.awt.Container; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; +import java.io.File; import java.net.URL; import javax.swing.*; import org.apache.log4j.Logger; @@ -81,6 +82,21 @@ public class ESBMoteType extends MspMoteType { public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) throws MoteTypeCreationException { + if (GUI.isVisualizedInApplet()) { + String firmware = GUI.getExternalToolsSetting("ESB_FIRMWARE", ""); + if (!firmware.equals("")) { + setELFFile(new File(firmware)); + JOptionPane.showMessageDialog(GUI.getTopParentContainer(), + "Creating mote type from precompiled firmware: " + firmware, + "Compiled firmware file available", JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(GUI.getTopParentContainer(), + "No precompiled firmware found", + "Compiled firmware file not available", JOptionPane.ERROR_MESSAGE); + return false; + } + } + return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice); } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java index 629c240c4..9efe782ec 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspMoteType.java,v 1.4 2008/02/12 15:12:38 fros4943 Exp $ + * $Id: MspMoteType.java,v 1.5 2008/04/03 14:00:21 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -179,14 +179,19 @@ public abstract class MspMoteType implements MoteType { + "If you want to use an already existing file, click 'Select'.\n\n" + "To compile this file from source, click 'Compile'"; String title = "Select or compile " + targetNice + " firmware"; - int answer = JOptionPane.showOptionDialog(GUI.getTopParentContainer(), - question, title, JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, null, options, options[0]); - if (answer != JOptionPane.YES_OPTION && answer != JOptionPane.NO_OPTION) { - return false; + if (GUI.isVisualizedInApplet()) { + compileFromSource = false; + } else { + int answer = JOptionPane.showOptionDialog(GUI.getTopParentContainer(), + question, title, JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, null, options, options[0]); + + if (answer != JOptionPane.YES_OPTION && answer != JOptionPane.NO_OPTION) { + return false; + } + compileFromSource = answer != JOptionPane.YES_OPTION; } - compileFromSource = answer != JOptionPane.YES_OPTION; } /* Description */ @@ -234,6 +239,10 @@ public abstract class MspMoteType implements MoteType { } } + if (GUI.isVisualizedInApplet()) { + return true; + } + // Check dependency files if (getELFFile() == null || !getELFFile().exists()) { if (!visAvailable) { @@ -884,6 +893,7 @@ public abstract class MspMoteType implements MoteType { smallPane = new JPanel(new BorderLayout()); label = new JLabel("Source file"); smallPane.add(BorderLayout.WEST, label); + logger.debug(">>>> " + getSourceFile()); if (getSourceFile() != null) { label = new JLabel(getSourceFile().getName()); label.setToolTipText(getSourceFile().getPath()); @@ -894,10 +904,17 @@ public abstract class MspMoteType implements MoteType { panel.add(smallPane); // Icon (if available) - Icon moteTypeIcon = getMoteTypeIcon(); - if (moteTypeIcon != null) { + if (!GUI.isVisualizedInApplet()) { + Icon moteTypeIcon = getMoteTypeIcon(); + if (moteTypeIcon != null) { + smallPane = new JPanel(new BorderLayout()); + label = new JLabel(moteTypeIcon); + smallPane.add(BorderLayout.CENTER, label); + panel.add(smallPane); + } + } else { smallPane = new JPanel(new BorderLayout()); - label = new JLabel(moteTypeIcon); + label = new JLabel("No icon available in applet mode"); smallPane.add(BorderLayout.CENTER, label); panel.add(smallPane); } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java index cdc0ff37b..32e01a4a4 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/SkyMoteType.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkyMoteType.java,v 1.2 2008/02/12 15:12:38 fros4943 Exp $ + * $Id: SkyMoteType.java,v 1.3 2008/04/03 14:00:21 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -35,6 +35,7 @@ import java.awt.Container; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; +import java.io.File; import java.net.URL; import javax.swing.*; import org.apache.log4j.Logger; @@ -81,6 +82,21 @@ public class SkyMoteType extends MspMoteType { public boolean configureAndInit(Container parentContainer, Simulation simulation, boolean visAvailable) throws MoteTypeCreationException { + if (GUI.isVisualizedInApplet()) { + String firmware = GUI.getExternalToolsSetting("SKY_FIRMWARE", ""); + if (!firmware.equals("")) { + setELFFile(new File(firmware)); + JOptionPane.showMessageDialog(GUI.getTopParentContainer(), + "Creating mote type from precompiled firmware: " + firmware, + "Compiled firmware file available", JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(GUI.getTopParentContainer(), + "No precompiled firmware found", + "Compiled firmware file not available", JOptionPane.ERROR_MESSAGE); + return false; + } + } + return configureAndInitMspType(parentContainer, simulation, visAvailable, target, targetNice); }