Package org.contikios.cooja

Examples of org.contikios.cooja.Simulation


    /* Load simulation */
    logger.info("Loading " + config);
    Cooja.externalToolsUserSettingsFile = new File(
        System.getProperty("user.home"),
        Cooja.EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
    Simulation s = Cooja.quickStartSimulationConfig(config, false, null);
    if (s == null) {
      throw new RuntimeException(
          "Error when creating simulation"
      );
    }
    s.stopSimulation();

    try {
      buildExecutableJAR(s.getCooja(), jar);
    } catch (RuntimeException e) {
      logger.fatal(e.getMessage(), e);
      System.exit(1);
    }
    System.exit(0);
View Full Code Here


      return;
    }

    logger.info("Starting simulation");
    Cooja.setLookAndFeel();
    Simulation sim = Cooja.quickStartSimulationConfig(new File(executeDir, SIMCONFIG_FILENAME), false, null);
    if (sim != null){
        /* Set simulation speed to maximum and start simulation */
        sim.setSpeedLimit(null);
        sim.startSimulation();
    } else {
        logger.fatal("Cannot load simulation, aborting");
        System.exit(1);
    }
  }
View Full Code Here

    if (!executeDir.endsWith(".jar")) {
      throw new RuntimeException("Not a proper JAR archive: " + executeDir);
    }
    executeDir = executeDir.substring(0, executeDir.length()-".jar".length());

    Simulation simulation = gui.getSimulation();
    if (simulation == null) {
      throw new RuntimeException(
          "No simulation active"
      );
    }

    /* Check dependencies: mote type */
    for (MoteType t: simulation.getMoteTypes()) {
      if (!t.getClass().getName().contains("SkyMoteType")) {
        throw new RuntimeException(
            "You simulation contains the mote type: " + Cooja.getDescriptionOf(t.getClass()) + "\n" +
            "Only the Sky Mote Type is currently supported.\n"
        );
View Full Code Here

      return "Show LEDs on " + mote;
    }

    @Override
    public void doAction(Visualizer visualizer, Mote mote) {
      Simulation simulation = mote.getSimulation();
      LED led = mote.getInterfaces().getLED();
      if (led == null) {
        return;
      }

      /* Extract description (input to plugin) */
      String desc = Cooja.getDescriptionOf(mote.getInterfaces().getLED());

      MoteInterfaceViewer viewer
              = (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
                      MoteInterfaceViewer.class,
                      simulation.getCooja(),
                      simulation,
                      mote);
      if (viewer == null) {
        return;
      }
View Full Code Here

      return "Show serial port on " + mote;
    }

    @Override
    public void doAction(Visualizer visualizer, Mote mote) {
      Simulation simulation = mote.getSimulation();
      SerialPort serialPort = null;
      for (MoteInterface intf : mote.getInterfaces().getInterfaces()) {
        if (intf instanceof SerialPort) {
          serialPort = (SerialPort) intf;
          break;
        }
      }

      if (serialPort == null) {
        return;
      }

      /* Extract description (input to plugin) */
      String desc = Cooja.getDescriptionOf(serialPort);

      MoteInterfaceViewer viewer
              = (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
                      MoteInterfaceViewer.class,
                      simulation.getCooja(),
                      simulation,
                      mote);
      if (viewer == null) {
        return;
      }
View Full Code Here

    }

    public void doAction(Visualizer visualizer, Mote mote) {
      /* Remove all motes of this type */
      /* TODO Confirm? */
      Simulation simulation = mote.getSimulation();
      Mote[] motes = simulation.getMotes();
      for (Mote m: motes) {
        if (m.getType() == mote.getType()) {
          simulation.removeMote(m);
        }
      }
    }
View Full Code Here

    /* Load simulation */
    logger.info("Loading " + config);
    Cooja.externalToolsUserSettingsFile = new File(
        System.getProperty("user.home"),
        Cooja.EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
    Simulation s = Cooja.quickStartSimulationConfig(config, false, null);
    if (s == null) {
      throw new RuntimeException(
          "Error when creating simulation"
      );
    }
    s.stopSimulation();

    try {
      buildExecutableJAR(s.getCooja(), jar);
    } catch (RuntimeException e) {
      logger.fatal(e.getMessage(), e);
      System.exit(1);
    }
    System.exit(0);
View Full Code Here

      return;
    }

    logger.info("Starting simulation");
    Cooja.setLookAndFeel();
    Simulation sim = Cooja.quickStartSimulationConfig(new File(executeDir, SIMCONFIG_FILENAME), false, null);
    if (sim != null){
        /* Set simulation speed to maximum and start simulation */
        sim.setSpeedLimit(null);
        sim.startSimulation();
    } else {
        logger.fatal("Cannot load simulation, aborting");
        System.exit(1);
    }
  }
View Full Code Here

    if (!executeDir.endsWith(".jar")) {
      throw new RuntimeException("Not a proper JAR archive: " + executeDir);
    }
    executeDir = executeDir.substring(0, executeDir.length()-".jar".length());

    Simulation simulation = gui.getSimulation();
    if (simulation == null) {
      throw new RuntimeException(
          "No simulation active"
      );
    }

    /* Check dependencies: mote type */
    for (MoteType t: simulation.getMoteTypes()) {
      if (!t.getClass().getName().contains("SkyMoteType")) {
        throw new RuntimeException(
            "You simulation contains the mote type: " + Cooja.getDescriptionOf(t.getClass()) + "\n" +
            "Only the Sky Mote Type is currently supported.\n"
        );
View Full Code Here

      return "Show LEDs on " + mote;
    }

    @Override
    public void doAction(Visualizer visualizer, Mote mote) {
      Simulation simulation = mote.getSimulation();
      LED led = mote.getInterfaces().getLED();
      if (led == null) {
        return;
      }

      /* Extract description (input to plugin) */
      String desc = Cooja.getDescriptionOf(mote.getInterfaces().getLED());

      MoteInterfaceViewer viewer
              = (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
                      MoteInterfaceViewer.class,
                      simulation.getCooja(),
                      simulation,
                      mote);
      if (viewer == null) {
        return;
      }
View Full Code Here

TOP

Related Classes of org.contikios.cooja.Simulation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.