Package de.hpi.eworld.core

Examples of de.hpi.eworld.core.ModelManager


      endEdit.setText(Integer.toString(oldEndTime)); //reset to the previous
      // value since the new is invalid
      return;
    }
     
    ModelManager mm = ModelManager.getInstance();
    int startTime = mm.getSimulationStartTime();
  // //check if the new value is valid (must be greater than the starttime!)
    if(time <= startTime)
      endEdit.setText(Integer.toString(oldEndTime)); //reset to the previous
    //value since the new is invalid
    else {
  // //save new end value
      oldEndTime = 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.setSimulationEndTime(time);
      timeline.updateSimulationTime();
     
    }
    mainPanel.repaint();
  }
 
View Full Code Here


  /**
   * Loads the data for the start and end time widgets from the InternalDB
   */
  public void loadTimes() {
    ModelManager mm = ModelManager.getInstance();
      if( oldStartTime == mm.getSimulationStartTime() &&
        oldEndTime == mm.getSimulationEndTime())
    return; //nothing has changed. prevent endless notification loops
 
    oldStartTime = mm.getSimulationStartTime();
    startEdit.setText(Integer.toString(oldStartTime));
    oldEndTime = mm.getSimulationEndTime();
    endEdit.setText(Integer.toString(oldEndTime));
   
    this.updateStartTime();
    this.updateEndTime();
    mainPanel.repaint();
View Full Code Here

  private static final String DIR_VANET_TESTRES = "./resources/vanet_test/vanet.xml";
 
  @Test
  public void testExportModel() throws ParserConfigurationException, SAXException, FileNotFoundException, IOException {
    //load test data
    ModelManager mm = ModelManager.getInstance();
    //use mm mockup to count the element occurences for export verification
    ModelManagerMockUp mmMockUp = ModelManagerMockUp.getInstance();
    mmMockUp.convertWaysToEdges();
    mm.addObserver(mmMockUp);
    //ok, now actually load the .ewd file
   
    PersistenceManager.getInstance().loadFromFile("./resources/export/berlin_test.ewd");

    //start export
View Full Code Here

   
   
    ///////////////////////////////////
    // run restore test
   
    ModelManager mm = ModelManager.getInstance();
   
    //make sure the model is empty before we add anything
    mm.clearModel();
   
    mm.addModelElement(el1);
    mm.addModelElement(el2);
    mm.addModelElement(pl);
    mm.addModelElement(cl);
   
    //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();
    Assert.assertEquals(4, modelElements.size());

    //cleanup
    Assert.assertTrue(FileSysUtils.deleteFile(EWD_FILE));
  }
View Full Code Here

    areas.add(startArea2);
    vehicleCountPerArea.put(startArea1, new int[] { 50, 0 });
    vehicleCountPerArea.put(startArea2, new int[] { 10, 0 });

    // add all created areas to model manager
    ModelManager modelManager = ModelManager.getInstance();
    //modelManager.clearModel();
    for (AreaModel area : areas) {
      modelManager.addModelElement(area);
    }

    // export to sumo
    EWorld2sumo eWorld2sumo = new EWorld2sumo();
    eWorld2sumo.setData(DIRECTORY_SCENARIOS_TEST, FILE_SCENARIOS_TEST_PREFIX, true, EWorldConstants.getNetConvertFile(), "",
View Full Code Here

    areas.add(destinationArea2);
    vehicleCountPerArea.put(destinationArea1, new int[] { 50, 0 });
    vehicleCountPerArea.put(destinationArea2, new int[] { 10, 0 });

    // add all created areas to model manager
    ModelManager modelManager = ModelManager.getInstance();
    for (AreaModel area : areas) {
      modelManager.addModelElement(area);
    }

    // export to sumo
    EWorld2sumo eWorld2sumo = new EWorld2sumo();
    eWorld2sumo.setData(DIRECTORY_SCENARIOS_TEST, FILE_SCENARIOS_TEST_PREFIX, true, EWorldConstants.getNetConvertFile(), "",
View Full Code Here

    areas.add(startArea2);
    vehicleCountPerArea.put(startArea1, new int[] { 50, 0 });
    vehicleCountPerArea.put(startArea2, new int[] { 10, 0 });

    // add all created areas to model manager
    ModelManager modelManager = ModelManager.getInstance();
    for (AreaModel area : areas) {
      modelManager.addModelElement(area);
    }

    // export to sumo
    EWorld2sumo eWorld2sumo = new EWorld2sumo();
    eWorld2sumo.setData(DIRECTORY_SCENARIOS_TEST, FILE_SCENARIOS_TEST_PREFIX, true, EWorldConstants.getNetConvertFile(), "",
View Full Code Here

   * Initializes all needed variables for a single test.
   */
  private void init() {
    List<ModelElement> modelElements = TestCaseUtil.createSampleTestcase();

    ModelManager modelManager = ModelManager.getInstance();
    modelManager.clearModel();

    for (ModelElement modelElement : modelElements) {
      modelManager.addModelElement(modelElement);
    }

    edges = new ArrayList<EdgeModel>();
    for (ModelElement modelElement : modelElements) {
      if (modelElement instanceof WayModel) {
View Full Code Here

      }
    }

    logger.debug("now try to import");
    try {
      final ModelManager modelManager = ModelManager.getInstance();
      modelManager.setChanged();
      modelManager.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
      osm = new Osm2Model(pedestrian, filterCyclic);
      osm.addObserver(this);

      boolean missingData = false;
      if (length >= 0) {
        logger.debug("parse file");
        osm.parseFile(inputStream, length);
      } else {
        missingData = osm.parseFile(inputStream);
      }

      setChanged();
      if (osm.somethingImported()) {
        logger.debug("osm.somethingImported() true");
        notifyObservers(new ObserverNotification(NotificationType.done, null));
        logger.debug("notified");
      } else {
        logger.debug("osm.somethingImported() false");
        notifyObservers(new ObserverNotification(NotificationType.nothing, null));
        logger.debug("notified");
      }

      if (!osm.wasInterrupted()) {
        logger.debug("!osm.wasInterrupted()");
        modelManager.setChanged();
        modelManager.notifyObservers(
          new ObserverNotification(
            NotificationType.endBatchProcess,
            new Boolean(filterDuplicateEdges),
            new Boolean(missingData)
          )
View Full Code Here

   */
  @Ignore
  @Test
  public void testTLSaveAndRestore() {
   
    ModelManager modelManager = ModelManager.getInstance();
    modelManager.clearModel();
   
    // save
    modelManager.addModelElement(tl1);
    modelManager.addModelElement(e1);
    modelManager.addModelElement(e2);
    modelManager.addModelElement(e3);
    modelManager.addModelElement(e4);
    PersistenceManager.getInstance().saveToFile(EWD_FILE);
   
    // restore
    modelManager.clearModel();
    PersistenceManager.getInstance().loadFromFile(EWD_FILE);
    for( ModelElement modelElement : modelManager.getAllModelElements()){
      if (modelElement.getClass().equals(TrafficLightModel.class)) {
        TrafficLightModel restoredTl1 = (TrafficLightModel) modelElement;
        Assert.assertEquals(tl1.getDurations().length, restoredTl1.getDurations().length);
        Assert.assertEquals(tl1.getNoOfIncomingEdges(), restoredTl1.getNoOfIncomingEdges());
        Assert.assertEquals(tl1.getNoOfPhases(), restoredTl1.getNoOfPhases());
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.