Package de.hpi.eworld.exporter.sumo.data

Examples of de.hpi.eworld.exporter.sumo.data.SumoManager


   * generates the sumo trips file from user defined trips.
   *
   * @return true if successful. false otherwise.
   */
  private boolean generateTripFileFromEwd() {
    SumoManager sm = SumoManager.getInstance();
    return writeToXML("trips", getXmlFileContent("tripdefs", sm.getVehicleTypes(), sm.getTrips()));
  }
View Full Code Here


   * generates sumo routes file from user defined routes.
   *
   * @return true if successful. false otherwise.
   */
  private boolean generateRouFileFromEwd() {
    SumoManager sm = SumoManager.getInstance();
    return writeToXML("rou", getXmlFileContent("routes", sm.getVehicleTypes(), sm.getRoutes(), sm.getVehicles()));
  }
View Full Code Here

          return 0;
        }
      }
    });

    SumoManager sumoManager = SumoManager.getInstance();
    allVehicleTypes = sumoManager.getVehicleTypes();
    defaultVehicleType = sumoManager.getDefaultVehicleType().getId();

    // append all vehicle types
    for (SumoVehicleType vehicleType : allVehicleTypes) {
      buffer.append("\t").append(vehicleType.toXMLString());
    }
View Full Code Here

          usedVehicleTypes.add(vehicleType);
        }
      }
    }

    SumoManager sumoManager = SumoManager.getInstance();
    allVehicleTypes = sumoManager.getVehicleTypes();
    defaultVehicleType = sumoManager.getDefaultVehicleType().getId();

    // append all vehicle types
    for (SumoVehicleType vehicleType : allVehicleTypes) {
      buffer.append("\t").append(vehicleType.toXMLString());
    }
View Full Code Here

   * @param toggled
   *            tells if the trips export button was toggled.
   */
  @SuppressWarnings("unused")
  private void onTripCheck(final boolean toggled) {
    final SumoManager sm = SumoManager.getInstance();
    if (sm.getTrips().size() == 0) {
      JOptionPane.showMessageDialog(this, "Error in rou-config", "No trips configured!", JOptionPane.WARNING_MESSAGE);
      return;
    }
  }
View Full Code Here

   * @param toggled
   *            tells if the user defined routes export button was toggled.
   */
  @SuppressWarnings("unused")
  private void onEdwRouButtonToggled(final boolean toggled) {
    final SumoManager sm = SumoManager.getInstance();
    if (sm.getVehicles().size() == 0) {
      JOptionPane.showMessageDialog(this, "Error in rou-config", "There are no vehicles configured!", JOptionPane.WARNING_MESSAGE);
      genRouButton.setSelected(true);
      return;
    }
    if (sm.getRoutes().size() == 0) {
      JOptionPane.showMessageDialog(this, "Error in rou-config", "There are no routes configured!", JOptionPane.WARNING_MESSAGE);
      genRouButton.setSelected(true);
      return;
    }
  }
View Full Code Here

    toEdgeEdit = new QLineEdit();
    toEdgeEdit.setEnabled(false);
    toEdgeSelectButton = new QPushButton("Select");
    toEdgeSelectButton.pressed.connect(this, "onToNodeSelect()");
    typeCombo = new QComboBox();
    SumoManager sm = SumoManager.getInstance();
    List<SumoVehicleType> vTypes = sm.getVehicleTypes();
    for (SumoVehicleType v : vTypes) {
      typeCombo.addItem(v.getId());
    }
   
// _lg: this Dialog makes absoluteley no sense here
View Full Code Here

   *
   */
  private void importRoutes() throws XPathExpressionException {
    XPath xpath = XPathFactory.newInstance().newXPath();
    NodeList vehicles = (NodeList) xpath.evaluate("//vehicle", inputSource, XPathConstants.NODESET);
    SumoManager sumoMan = SumoManager.getInstance();

    int all = vehicles.getLength();
    int current = 0;
    for (int i = 0; i < vehicles.getLength(); i++) {
      org.w3c.dom.Node curVehicle = vehicles.item(i);

      String id = curVehicle.getAttributes().getNamedItem("id").getTextContent();
     
      SumoVehicleType vType;
      org.w3c.dom.Node vTypeNode = curVehicle.getAttributes().getNamedItem("type");
      if (vTypeNode == null) {
        vType = sumoMan.getDefaultVehicleType();
      } else {
        vType = sumoMan.getVehicleTypeById(vTypeNode.getTextContent());
      }

      double depart = Double.parseDouble(curVehicle.getAttributes().getNamedItem("depart").getTextContent());

      NodeList routes = curVehicle.getChildNodes();
      for (int j = 0; j < routes.getLength(); j++) {
        if (routes.item(j).getNodeName().equals("route")) {
          String routeStr = routes.item(j).getAttributes().getNamedItem("edges").getTextContent();
          String[] edgeList = routeStr.split(" ");

          SumoRoute curRoute = new SumoRoute("route_for_vehicle_nr_" + id + "_"
              + UUID.randomUUID().toString());

          for (String curEdgeLabel : edgeList) {
            EdgeModel edgeToAdd = edges.get(curEdgeLabel);
            curRoute.addEdge(edgeToAdd.getInternalID());
          }

          sumoMan.addRoute(curRoute);
          SumoVehicle newVehicle = new SumoVehicle(depart, id, sumoMan.getSumoRouteById(curRoute
              .getId()), vType);
          sumoMan.addVehicle(newVehicle);

        }
        current++;
        this.setChanged();
        this.notifyObservers(new ObserverNotification(NotificationType.progress,
View Full Code Here

   * @author Lutz Gericke
   * @author Christian Wiggert, Martin Linkhorst
   *
   */
  private void importVehicleTypes() throws XPathExpressionException {
    SumoManager sumoManager = SumoManager.getInstance();
   
    XPath xpath = XPathFactory.newInstance().newXPath();
    NodeList vehicleTypes = (NodeList) xpath.evaluate("//vtype", inputSource, XPathConstants.NODESET);

    int currentVehicleCount = 0;
    int numVehicles = vehicleTypes.getLength();
   
    for (int i = 0; i < vehicleTypes.getLength(); i++) {
      org.w3c.dom.Node vehicleType = vehicleTypes.item(i);
      NamedNodeMap vehicleAttributes = vehicleType.getAttributes();
     
      // mandatory
      String id = vehicleAttributes.getNamedItem("id").getTextContent();
     
      if (sumoManager.getVehicleTypeById(id) != null) {
        log.info("INFO: vehicle type \"" + id + "\" is already registered, skipping");
        continue;
      }
     
      org.w3c.dom.Node lengthNode = vehicleAttributes.getNamedItem("length");
      org.w3c.dom.Node maxSpeedNode = vehicleAttributes.getNamedItem("maxspeed");
     
      org.w3c.dom.Node accelNode = vehicleAttributes.getNamedItem("accel");
      org.w3c.dom.Node decelNode = vehicleAttributes.getNamedItem("decel");
      org.w3c.dom.Node sigmaNode = vehicleAttributes.getNamedItem("sigma");

      // optional
      org.w3c.dom.Node colorNode = vehicleAttributes.getNamedItem("color");
     
      float r = 255, g = 0, b = 0;
     
      if (colorNode != null) {
        String[] colors = colorNode.getTextContent().split(",");
        r = Float.parseFloat(colors[0]);
        g = Float.parseFloat(colors[1]);
        b = Float.parseFloat(colors[2]);
      }
     
      NodeList typeChildren = vehicleType.getChildNodes();
     
      for (int j = 0; j < typeChildren.getLength(); j++) {
        org.w3c.dom.Node typeChild = typeChildren.item(j);
       
        if (typeChild.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
         
          NamedNodeMap childAttributes = typeChild.getAttributes();
         
          org.w3c.dom.Node childLengthNode = childAttributes.getNamedItem("length");
          org.w3c.dom.Node childMaxSpeedNode = childAttributes.getNamedItem("maxspeed");
         
          org.w3c.dom.Node childAccelNode = childAttributes.getNamedItem("accel");
          org.w3c.dom.Node childDecelNode = childAttributes.getNamedItem("decel");
          org.w3c.dom.Node childSigmaNode = childAttributes.getNamedItem("sigma");
 
          // optional
          org.w3c.dom.Node childColorNode = childAttributes.getNamedItem("color");
         
          try {
           
            double length = Double.parseDouble((childLengthNode != null ? childLengthNode : lengthNode).getTextContent());
            double maxSpeed = Double.parseDouble((childMaxSpeedNode != null ? childMaxSpeedNode : maxSpeedNode).getTextContent());
            double accel = Double.parseDouble((childAccelNode != null ? childAccelNode : accelNode).getTextContent());
            double decel = Double.parseDouble((childDecelNode != null ? childDecelNode : decelNode).getTextContent());
            double sigma = Double.parseDouble((childSigmaNode != null ? childSigmaNode : sigmaNode).getTextContent());
           
            if (childColorNode != null) {
              String[] colors = childColorNode.getTextContent().split(",");
              r = Float.parseFloat(colors[0]);
              g = Float.parseFloat(colors[1]);
              b = Float.parseFloat(colors[2]);
            }
         
            SumoVehicleType newVehicleType;
            newVehicleType = new SumoVehicleType(id, accel, decel, length, maxSpeed, sigma);
            newVehicleType.setColor(r, g, b);
           
            sumoManager.addVehicleType(newVehicleType);
           
          } catch (NullPointerException e) {
            System.err.println("missing vehicle type attribute");
            e.printStackTrace();
          }
View Full Code Here

  }

  public void loadTypesFromSumoManager() {
    typeListView.removeAll();

    SumoManager sm = SumoManager.getInstance();
    LinkedList<String> vtypes = new LinkedList<String>();
   
    for (SumoVehicleType i : sm.getVehicleTypes()) {
      vtypes.add(i.getId());
    }
    typeListView.setListData(vtypes.toArray());
  }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.exporter.sumo.data.SumoManager

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.