using firmware specified in applet attribute

This commit is contained in:
fros4943 2008-04-03 14:00:21 +00:00
parent 0ae6a4185a
commit 2691abecaa
3 changed files with 61 additions and 12 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}