Examples of SimulationEngine


Examples of org.destecs.core.simulationengine.SimulationEngine

    final ListenerToLog log = getLog();

    try
    {
      SimulationEngine.eclipseEnvironment = true;
      final SimulationEngine engine = getEngine();

      UIJob listeners = new UIJob("Set Listeners")
      {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor)
        {
          final String engineViewId = IDebugConstants.ENGINE_VIEW_ID;
          final InfoTableView engineView = getInfoTableView(engineViewId);

          views.add(engineView);
          engine.engineListeners.add(new EngineListener(engineView));

          if (showDebugInfo)
          {
            final String messageViewId = IDebugConstants.MESSAGE_VIEW_ID;
            final String simulationViewId = IDebugConstants.SIMULATION_VIEW_ID;

            final InfoTableView messageView = getInfoTableView(messageViewId);
            final InfoTableView simulationView = getInfoTableView(simulationViewId);

            views.add(messageView);
            views.add(simulationView);

            engine.messageListeners.add(new MessageListener(messageView));
            engine.simulationListeners.add(new SimulationListener(simulationView));

            for (InfoTableView view : views)
            {
              view.refreshPackTable();
            }
          }
          return new Status(IStatus.OK, IDebugConstants.PLUGIN_ID, "Listeners OK");
        }
      };

      listeners.schedule();
      if (enableLogging)
      {
        engine.engineListeners.add(log);
        engine.messageListeners.add(log);
        engine.simulationListeners.add(log);
        engine.variablesSyncListeners.add(log);
      }
      if (!remoteDebug)
      {
        File libSearchRoot = new File(project.getLocation().toFile(), "lib");
        engine.setDeSimulationLauncher(new VdmRtBundleLauncher(deFile, deUrl.getPort(), libSearchRoot));// new
      } else
      {
        deUrl = new URL(IDebugConstants.DEFAULT_DE_ENDPOINT.replaceAll("PORT", Integer.valueOf(8080).toString()));
        engine.setDeSimulationLauncher(new VdmRtLauncher(5000));
      }

      final int deDebugPort = findFreePort();
      ModelConfig deModel = getDeModelConfig(project, deDebugPort);
      engine.setDeModel(deModel);
      engine.setDeEndpoint(deUrl);

      if (!useRemoteCtSimulator)
      {
        // engine.setCtSimulationLauncher(new
        // Clp20SimStatelessProgramLauncher(ctFile));
        // engine.setCtSimulationLauncher(new
        // Clp20SimProgramLauncher(ctFile));
        engine.setCtSimulationLauncher(selectClp20SimLauncher(engine, ctFile));
        engine.setCtEndpoint(new URL(IDebugConstants.DEFAULT_CT_ENDPOINT));
      } else
      {
        engine.setCtSimulationLauncher(new DummyLauncher("CT simulator"));
        engine.setCtEndpoint(ctUrl);
      }
      ModelConfig ctModel = getCtModelConfig(ctFile);
      engine.setCtModel(ctModel);

      setCtSettings(engine);
      setCtImplementations(engine);

      engine.setOutputFolder(outputFolder);
      engine.debug(debug);

      engine.addProcessCreationListener(new IProcessCreationListener()
      {
        public void processCreated(String name, Process p)
        {
          launch.addProcess(DebugPlugin.newProcess(launch, p, name));
        }
View Full Code Here

Examples of org.destecs.core.simulationengine.SimulationEngine

      }
      return new ScenarioSimulationEngine(contractFile, scenario);

    } else
    {
      return new SimulationEngine(contractFile);
    }
  }
View Full Code Here

Examples of simulationEngine.SimulationEngine

                                zone.setCurrentTimeStep(1);

                                //Handle part from Sonal-- create food web for each zone.
                                String networkName = String.valueOf(env.getID()) + "_" + String.valueOf(zone.getOrder());

                                SimulationEngine se = new SimulationEngine();
                                String manipulationId = se.createDefaultSubFoodweb(networkName).getManipulationId();//the primary key of the zone is unique.

                                zone.setManipulationID(manipulationId);

                                int zone_id = ZoneDAO.createZone(zone);
                                zone.setID(zone_id);
View Full Code Here

Examples of simulationEngine.SimulationEngine

                for (Zone zone : env.getZones()) {
                    if (zone.isEnable()) {
                        zone.restart();

                        SimulationEngine se = new SimulationEngine();
                        zone.setSimulationEngine(se);

                        String networkName = "WoB-" + env.getID() + "." + zone.getOrder() + "-" + System.currentTimeMillis() % 100000;

                        int nodeList[] = {1, 8, 9};
                        zone.setManipulationID(se.createAndRunSeregenttiSubFoodweb(nodeList, networkName, 0, 0, false));

                        ZoneDAO.updateManipulationID(zone.getID(), zone.getManipulationID());

//                        se.setCarryingCapacity(0, 5, zone.getManipulationID(), 3000);

                        List<NodeBiomass> lNodeBiomass = new ArrayList<NodeBiomass>();

                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(1).getAvgBiomass() * 10, 1));
                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(8).getAvgBiomass() * 5, 8));
                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(9).getAvgBiomass() * 5, 9));

                        if (!lNodeBiomass.isEmpty()) {
                            se.updateBiomass(zone.getManipulationID(), lNodeBiomass, 0);
                        }

                        se.getBiomass(zone.getManipulationID(), 0, 0);

                        for (SpeciesZoneType szt : se.getSpecies().values()) {
                            int species_id = GameServer.getInstance().getSpeciesTypeByNodeID(szt.getNodeIndex()).getID();

//                            if (szt.getType() == SpeciesTypeEnum.ANIMAL) {
//                                world.getGameEngine().createOrganismByResponse(Constants.ORGANISM_TYPE_ANIMAL, species_id, client.getPlayer().getID(), zone.getID(), szt.getSpeciesCount(), 1, Constants.CREATE_STATUS_DEFAULT);
//                            } else if (szt.getType() == SpeciesTypeEnum.PLANT) {
View Full Code Here

Examples of simulationEngine.SimulationEngine

    public Zone(int zone_id) {
        this.zone_id = zone_id;
        manipulationID = "";

        simulationEngine = new SimulationEngine();

        animals = new HashMap<Integer, Animal>();
        plants = new HashMap<Integer, Plant>();

        totalSpeciesList = new HashMap<Integer, Integer>();
View Full Code Here

Examples of simulationEngine.SimulationEngine

                        responseCreateEnv.setEnvironment(env);
                        client.getServer().addResponseToOtherPeopleInTheSameWorld(client.getId(), world.getID(), responseCreateEnv);

                        Zone startZone = env.getZones().get(0);

                        SimulationEngine se = startZone.getSimulationEngine();
                        String networkName = "WoB-" + env.getID() + "." + startZone.getOrder() + "-" + System.currentTimeMillis() % 100000;

                        int nodeList[] = {13, 20, 31};
                        startZone.setManipulationID(se.createAndRunSeregenttiSubFoodweb(nodeList, networkName, 0, 0, false));

                        ZoneDAO.updateManipulationID(startZone.getID(), startZone.getManipulationID());

                        List<NodeBiomass> lNodeBiomass = new ArrayList<NodeBiomass>();

                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(13).getAvgBiomass() * 10 / Constants.BIOMASS_SCALE, 13));
                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(20).getAvgBiomass() * 10 / Constants.BIOMASS_SCALE, 20));
                        lNodeBiomass.add(new NodeBiomass(GameServer.getInstance().getSpeciesTypeByNodeID(31).getAvgBiomass() * 10 / Constants.BIOMASS_SCALE, 31));

                        if (!lNodeBiomass.isEmpty()) {
                            System.out.println("Updating Initial Biomass...");
                            se.updateBiomass(startZone.getManipulationID(), lNodeBiomass, 0);
                        }

                        se.getBiomass(startZone.getManipulationID(), 0, 0);

                        world.setEnvironment(env);
                        world.setPlayer(client.getPlayer());
                        responseGetEnv.setWorld(world);
                        client.setWorld(world);

                        WorldDAO.updateLastPlayed(world.getID());
                        WorldDAO.updateWorldProperties(world);

                        int initialAmount = 3;

                        for (SpeciesZoneType szt : se.getSpecies().values()) {
                            int species_id = GameServer.getInstance().getSpeciesTypeByNodeID(szt.getNodeIndex()).getID();

                            se.setParameter(0, szt, startZone.getManipulationID(), Constants.PARAMETER_X, szt.getParamX());

                            world.getGameEngine().createOrganisms(species_id, startZone.getID(), initialAmount, Constants.CREATE_STATUS_DEFAULT);
                            world.getGameEngine().createOrganismsByBirth(species_id, startZone.getID(), szt.getSpeciesCount() - initialAmount);
                        }

                        try {
                            String csv = null;

                            while (true) {
                                csv = se.getBiomassCSVString(startZone.getManipulationID());

                                if (!csv.isEmpty()) {
                                    break;
                                } else {
                                    System.out.println("Error: CSV [" + startZone.getManipulationID() + "] Retrieval Failed!");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.