Package de.hpi.eworld.core

Examples of de.hpi.eworld.core.ModelManager


  private boolean generateCfgFile(boolean tlsFile, boolean netFile, boolean rouFile, boolean addFile) {
    if (!path_name.equals("") && !(filename.equals(""))) {
      EWorld2sumoTemplate_Config configXml = new EWorld2sumoTemplate_Config();

      List<String> arguments = new ArrayList<String>();
      ModelManager mManager = ModelManager.getInstance();

      arguments.add(filename);
      arguments.add(String.valueOf(mManager.getSimulationStartTime()));
      arguments.add(String.valueOf(mManager.getSimulationEndTime()));
      arguments.add(String.valueOf(tlsFile));
      arguments.add(String.valueOf(netFile));
      arguments.add(String.valueOf(rouFile));
      arguments.add(String.valueOf(doStatistics));
      // arguments.add(String.valueOf(statisticsIntervals));
View Full Code Here


    generateTripFileFromEwd();

    List<String> command = new ArrayList<String>();

    ModelManager mManager = ModelManager.getInstance();

    command.add(duarouter_dest);
    command.add("--trips");
    command.add(path_name + File.separator + filename + ".trips.xml");
    command.add("--net");
    command.add(path_name + File.separator + filename + ".net.xml");
    command.add("-o");
    command.add(path_name + File.separator + filename + ".rou.xml");
    command.add("-b");
    command.add(String.valueOf(mManager.getSimulationStartTime()));
    command.add("-e");
    command.add(String.valueOf(mManager.getSimulationEndTime()));
    command.add("--continue-on-unbuild");
    /*
     * are we using sumo 0.9.8? if yes, then append another parameter. as of version 0.9.9 this one is obsolete and we will omit it then.
     */
    int[] tmp = { 0, 9, 9 };
View Full Code Here

   * @return a list of commands
   */
  private List<String> createRandRouteCommand(String duarouter_dest, String arguments) {
    List<String> command = new ArrayList<String>();

    ModelManager mManager = ModelManager.getInstance();

    command.add(duarouter_dest);
    command.add("--net");
    command.add(path_name + File.separator + filename + ".net.xml");
    command.add("-o");
    command.add(path_name + File.separator + filename + ".rou.xml");
    command.add("-b");
    command.add(String.valueOf(mManager.getSimulationStartTime()));
    command.add("-e");
    command.add(String.valueOf(mManager.getSimulationEndTime()));
    command.add("--continue-on-unbuild");
    /*
     * are we using sumo 0.9.8? if yes, then append another parameter. as of version 0.9.9 this one is obsolete and we will omit it then.
     */
    int[] minVersion = { 0, 9, 9 };
View Full Code Here

   * @return The command in the form of a list.
   */
  private List<String> createScenariosCommand(String duarouterDestination) {
    List<String> command = new ArrayList<String>();

    ModelManager mManager = ModelManager.getInstance();

    command.add(duarouterDestination);
    command.add("--net");
    command.add(path_name + File.separator + filename + ".net.xml");
    command.add("--flows");
    command.add(path_name + File.separator + filename + ".flows.xml");
    command.add("-o");
    command.add(path_name + File.separator + filename + ".rou.xml");
    command.add("-b");
    command.add(String.valueOf(mManager.getSimulationStartTime()));
    command.add("-e");
    command.add(String.valueOf(mManager.getSimulationEndTime()));

    return command;
  }
View Full Code Here

   * @param inputFilename
   */
  private void testParseFileInputStream(String inputFilename) {
    Osm2Model converter = new Osm2Model();
    this.mmmu = ModelManagerMockUp.getInstance();
    ModelManager mm = ModelManager.getInstance();
    mm.clearModel();
    mm.addObserver(this.mmmu);
    try {
      converter.parseFile(new FileInputStream(inputFilename));
    }
    catch (Exception xcp) {
      xcp.printStackTrace();
View Full Code Here

  private static final String DIR_SUMO_TESTRES = "./resources/sumo_test/gen/";
  private static final String RES_FILE_PREFIX = "gen_result";

  @Test
  public void testSumoImport() {
    ModelManager model = ModelManager.getInstance();
    model.clearModel();
    model.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
    Sumo2ModelDOM s2m = new Sumo2ModelDOM("./resources/sumo_test/original/berlin_test.net.xml", model, false,
        false, "");
    s2m.run();
   
    model.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));

    Assert.assertEquals(1597, ModelManager.getInstance().getAllModelElements().size());
  }
View Full Code Here

    int ways = 0;
    int tls = 0;

    PersistenceManager.getInstance().loadFromFile("./resources/export/berlin_test.ewd");

    ModelManager model = ModelManager.getInstance();

    for (ModelElement el : model.getAllModelElements()) {
      if (el.getClass().equals(NodeModel.class))
        nodes++;
      else if (el.getClass().equals(WayModel.class)) {
        ways++;
        WayModel curWay = (WayModel) el;
        edges += (curWay.getBackwardEdges().size() + curWay.getForwardEdges().size());
      } else if (el.getClass().equals(TrafficLightModel.class))
        tls++;
    }

    System.out.println("ModelElements: " + model.getAllModelElements().size());
    System.out.println("Edges: " + edges);
    System.out.println("Nodes: " + nodes);
    System.out.println("Ways: " + ways);
    System.out.println("TrafficLights: " + tls);

    EWorld2sumo ew2s = new EWorld2sumo();
    ew2s.setData(DIR_SUMO_TESTRES, RES_FILE_PREFIX, true /* doNetconvert */,
        EWorldConstants.getNetConvertFile(), "", true /* doDuarouter */,
        EWorldConstants.getDuaRouterFile(), "", true /* doTlsFile */, false, false,
        false, true, new Integer[]{10000}, false);
    ew2s.run();

    model.clearModel();
    model.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
    Sumo2ModelDOM s2m = new Sumo2ModelDOM("./resources/sumo_test/original/berlin_test.net.xml", model, true,
        false, "");
    s2m.run();
    model.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));

    int edges2 = 0;
    int nodes2 = 0;
    int ways2 = 0;
    int tls2 = 0;

    for (ModelElement el : model.getAllModelElements()) {
      if (el.getClass().equals(NodeModel.class))
        nodes2++;
      else if (el.getClass().equals(WayModel.class)) {
        ways2++;
        WayModel curWay = (WayModel) el;
        edges2 += (curWay.getBackwardEdges().size() + curWay.getForwardEdges().size());
      } else if (el.getClass().equals(TrafficLightModel.class))
        tls2++;
    }
    System.out.println("ModelElements: " + model.getAllModelElements().size());
    System.out.println("Edges: " + edges2);
    System.out.println("Nodes: " + nodes2);
    System.out.println("Ways: " + ways2);
    System.out.println("TrafficLights: " + tls2);

View Full Code Here

   * Saves the model element to an ewd file via ModelManager.saveToFile and Loads it afterwards to
   * check if all attributes are restored correctly
   */
  @Test
  public void testSaveAndRestore() {
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.clearModel();

    // save
    modelManager.addModelElement(myWay1);

    PersistenceManager.getInstance().saveToFile(EWD_FILE);

    // restore
    modelManager.clearModel();
    PersistenceManager.getInstance().loadFromFile(EWD_FILE);
    for (ModelElement modelElement : modelManager.getAllModelElements()) {
      WayModel restoredWay1 = (WayModel)modelElement;
      Assert.assertEquals(myWay1.getBackwardEdges().size(), restoredWay1.getBackwardEdges().size());
      Assert.assertEquals(myWay1.getForwardEdges().size(), restoredWay1.getForwardEdges().size());
    }

View Full Code Here

  public void testSaveAndRestore() {
    NodeModel node = new NodeModel(1., 2.);
    NodeModel helperNode = new NodeModel(2., 3.);
    EdgeModel usedByEdge = TestCaseUtil.createTestEdge(node, helperNode);
   
    ModelManager mm = ModelManager.getInstance();
    //make sure the model is empty before we add anything
    mm.clearModel();
   
    mm.addModelElement(node);
    mm.addModelElement(usedByEdge);
    //save it to an ewd file
    PersistenceManager.getInstance().saveToFile(EWD_FILE);
    //fine, now lets restore the saved objects
    mm.clearModel();
    PersistenceManager.getInstance().loadFromFile(EWD_FILE);
   
    Collection<ModelElement> modelElements = mm.getAllModelElements();
    Iterator<ModelElement> iterator = modelElements.iterator();
    Assert.assertEquals(2, modelElements.size());
    Object obj = iterator.next();
    if(obj instanceof NodeModel) {
      NodeModel restoredNode = (NodeModel) obj;
View Full Code Here

   * prevent endless notification loops between the timeline and the
   * modelmanager. do nothing if the time has not changed.
   */
     if(oldStartTime == time)
       return;
     ModelManager mm = ModelManager.getInstance();
     int endTime = mm.getSimulationEndTime();
     if(time >= endTime)
       startEdit.setText(Integer.toString(oldStartTime));
     else {
       //save new start value
       oldStartTime = time;
  // /* notify modelmanager
  // * DO NOT NOTIFY THE MODELMANAGER BEFORE SAVING THE NEW TIME
  // * INTERNALLY IN oldEndTime. Otherwise this will result in
  // * an endless notification loop (timeline notifying the modelmanager
  // * which in turn notifies all listeners such as the timeline and so on).
  // * the timeline checks if the time change propagated by the modelmanager
  // * actually is a time change at loadTimes().
  // */
       mm.setSimulationStartTime(time);
       timeline.updateSimulationTime();
      
    }
    mainPanel.repaint();
  }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.core.ModelManager

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.