fixed so that Cooja can run in quick mode when having UI

This commit is contained in:
Joakim Eriksson 2016-12-15 11:33:55 +01:00
parent bba5a973ba
commit f069cef73a
14 changed files with 33 additions and 21 deletions

View file

@ -81,7 +81,7 @@ public abstract class AbstractMspMoteType extends MspMoteType {
} }
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -78,7 +78,7 @@ public class CC430MoteType extends MspMoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -114,7 +114,7 @@ public class ESBMoteType extends MspMoteType {
} }
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -36,7 +36,7 @@ public class Eth1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -36,7 +36,7 @@ public class Exp1101MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -37,7 +37,7 @@ public class Exp1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -37,7 +37,7 @@ public class Exp2420MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -78,7 +78,7 @@ public class Exp5438MoteType extends MspMoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -98,7 +98,7 @@ public class SkyMoteType extends MspMoteType {
} }
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -36,7 +36,7 @@ public class Trxeb1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -36,7 +36,7 @@ public class Trxeb2520MoteType extends Exp5438MoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -77,7 +77,7 @@ public class TyndallMoteType extends MspMoteType {
throws MoteTypeCreationException { throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */ /* If visualized, show compile dialog and let user configure */
if (visAvailable) { if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */ /* Create unique identifier */
if (getIdentifier() == null) { if (getIdentifier() == null) {

View file

@ -3378,7 +3378,7 @@ public class Cooja extends Observable {
} }
/* Verify extension directories */ /* Verify extension directories */
boolean projectsOk = verifyProjects(root.getChildren(), isVisualized()); boolean projectsOk = verifyProjects(root.getChildren());
/* GENERATE UNIQUE MOTE TYPE IDENTIFIERS */ /* GENERATE UNIQUE MOTE TYPE IDENTIFIERS */
root.detach(); root.detach();
@ -3429,7 +3429,7 @@ public class Cooja extends Observable {
newSim = new Simulation(this); newSim = new Simulation(this);
System.gc(); System.gc();
boolean createdOK = newSim.setConfigXML(config, isVisualized(), manualRandomSeed); boolean createdOK = newSim.setConfigXML(config, isVisualized(), quick, manualRandomSeed);
if (!createdOK) { if (!createdOK) {
logger.info("Simulation not loaded"); logger.info("Simulation not loaded");
return null; return null;
@ -3438,7 +3438,7 @@ public class Cooja extends Observable {
} }
// Restart plugins from config // Restart plugins from config
setPluginsConfigXML(root.getChildren(), newSim, isVisualized()); setPluginsConfigXML(root.getChildren(), newSim, isVisualized(), quick);
} catch (JDOMException e) { } catch (JDOMException e) {
throw (SimulationCreationException) new SimulationCreationException( throw (SimulationCreationException) new SimulationCreationException(
@ -3600,7 +3600,7 @@ public class Cooja extends Observable {
return config; return config;
} }
public boolean verifyProjects(Collection<Element> configXML, boolean visAvailable) { public boolean verifyProjects(Collection<Element> configXML) {
boolean allOk = true; boolean allOk = true;
/* Match current extensions against extensions in simulation config */ /* Match current extensions against extensions in simulation config */
@ -3642,7 +3642,7 @@ public class Cooja extends Observable {
* @return True if all plugins started, false otherwise * @return True if all plugins started, false otherwise
*/ */
public boolean setPluginsConfigXML(Collection<Element> configXML, public boolean setPluginsConfigXML(Collection<Element> configXML,
Simulation simulation, boolean visAvailable) { Simulation simulation, boolean visAvailable, boolean quick) {
for (final Element pluginElement : configXML.toArray(new Element[0])) { for (final Element pluginElement : configXML.toArray(new Element[0])) {
if (pluginElement.getName().equals("plugin")) { if (pluginElement.getName().equals("plugin")) {

View file

@ -544,6 +544,17 @@ public class Simulation extends Observable implements Runnable {
return config; return config;
} }
/* indicator to components setting up that they need to respect the fast setup mode */
private boolean quick = false;
public boolean isQuickSetup() {
return quick;
}
public void setQuickSetup(boolean q) {
quick = q;
}
/** /**
* Sets the current simulation config depending on the given configuration. * Sets the current simulation config depending on the given configuration.
* *
@ -554,8 +565,9 @@ public class Simulation extends Observable implements Runnable {
* @throws Exception If configuration could not be loaded * @throws Exception If configuration could not be loaded
*/ */
public boolean setConfigXML(Collection<Element> configXML, public boolean setConfigXML(Collection<Element> configXML,
boolean visAvailable, Long manualRandomSeed) throws Exception { boolean visAvailable, boolean quick, Long manualRandomSeed) throws Exception {
setQuickSetup(quick);
// Parse elements // Parse elements
for (Element element : configXML) { for (Element element : configXML) {
@ -623,7 +635,7 @@ public class Simulation extends Observable implements Runnable {
// Show configure simulation dialog // Show configure simulation dialog
boolean createdOK = false; boolean createdOK = false;
if (visAvailable) { if (visAvailable && !quick) {
createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), this); createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), this);
} else { } else {
createdOK = true; createdOK = true;
@ -657,7 +669,7 @@ public class Simulation extends Observable implements Runnable {
} }
/* Try to recreate simulation using a different mote type */ /* Try to recreate simulation using a different mote type */
if (visAvailable) { if (visAvailable && !quick) {
String[] availableMoteTypes = getCooja().getProjectConfig().getStringArrayValue("org.contikios.cooja.Cooja.MOTETYPES"); String[] availableMoteTypes = getCooja().getProjectConfig().getStringArrayValue("org.contikios.cooja.Cooja.MOTETYPES");
String newClass = (String) JOptionPane.showInputDialog( String newClass = (String) JOptionPane.showInputDialog(
Cooja.getTopParentContainer(), Cooja.getTopParentContainer(),