SUMO - Simulation of Urban MObility
GUITriggerBuilder.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Builds trigger objects for guisim
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <fstream>
36 #include <guisim/GUINet.h>
38 #include <guisim/GUIBusStop.h>
40 #include <guisim/GUIParkingArea.h>
41 #include <guisim/GUICalibrator.h>
43 #include "GUITriggerBuilder.h"
44 
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
51 
52 
54 
55 
58  const std::string& id, const std::vector<MSLane*>& destLanes,
59  const std::string& file) {
60  GUILaneSpeedTrigger* lst = new GUILaneSpeedTrigger(id, destLanes, file);
61  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(lst);
62  return lst;
63 }
64 
65 
67 GUITriggerBuilder::buildRerouter(MSNet& net, const std::string& id,
68  MSEdgeVector& edges,
69  double prob, const std::string& file, bool off) {
70  GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, file, off,
71  dynamic_cast<GUINet&>(net).getVisualisationSpeedUp());
72  return rr;
73 }
74 
75 
76 void
77 GUITriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
78  double frompos, double topos, const SumoXMLTag element, std::string name) {
79  bool success = false;
80  GUIGlObject* o = 0;
81  if (element == SUMO_TAG_CONTAINER_STOP) {
82  //TODO: shall we also allow names for container stops? might make sense [GL March '17]
83  GUIContainerStop* stop = new GUIContainerStop(id, lines, *lane, frompos, topos);
84  success = net.addContainerStop(stop);
85  o = stop;
86  myCurrentStop = stop;
87  } else {
88  GUIBusStop* stop = new GUIBusStop(id, lines, *lane, frompos, topos, name);
89  success = net.addBusStop(stop);
90  o = stop;
91  myCurrentStop = stop;
92  }
93  if (!success) {
94  delete o;
95  throw InvalidArgument("Could not build " + toString(element) + " stop '" + id + "'; probably declared twice.");
96  }
97  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(o);
98 }
99 
100 
101 void
102 GUITriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
103  const std::vector<std::string>& lines,
104  MSLane* lane,
105  double frompos, double topos,
106  unsigned int capacity,
107  double width, double length, double angle) {
108  assert(myParkingArea == 0);
109 
110  GUIParkingArea* stop = new GUIParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle);
111  if (!net.addParkingArea(stop)) {
112  delete stop;
113  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
114  } else {
115  myParkingArea = stop;
116  }
117  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
118 }
119 
120 void
121 GUITriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos,
122  double chargingPower, double efficiency, bool chargeInTransit, int chargeDelay) {
123  GUIChargingStation* chargingStation = new GUIChargingStation(id, *lane, frompos, topos, chargingPower, efficiency, chargeInTransit, chargeDelay);
124 
125  if (!net.addChargingStation(chargingStation)) {
126  delete chargingStation;
127  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
128  }
129 
130  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(chargingStation);
131 }
132 
134 GUITriggerBuilder::buildCalibrator(MSNet& net, const std::string& id,
135  MSEdge* edge, double pos,
136  const std::string& file,
137  const std::string& outfile,
138  const SUMOTime freq,
139  const MSRouteProbe* probe) {
140  GUICalibrator* cali = new GUICalibrator(id, edge, pos, file, outfile, freq, probe);
141  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(cali);
142  return cali;
143 }
144 
145 
146 /****************************************************************************/
147 
A lane area vehicles can halt at (gui-version)
Definition: GUIBusStop.h:71
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, MSEdgeVector &edges, double prob, const std::string &file, bool off)
builds an rerouter
Changes the speed allowed on a set of lanes (gui version)
Definition: GUICalibrator.h:53
Reroutes vehicles passing an edge One rerouter can be active on multiple edges. To reduce drawing loa...
virtual void buildStoppingPlace(MSNet &net, std::string id, std::vector< std::string > lines, MSLane *lane, double frompos, double topos, const SumoXMLTag element, std::string string)
Builds a bus stop.
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:68
virtual void beginParkingArea(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, double frompos, double topos, unsigned int capacity, double width, double length, double angle)
Builds a parking area.
bool addBusStop(MSStoppingPlace *busStop)
Adds a bus stop.
Definition: MSNet.cpp:821
bool addParkingArea(MSParkingArea *parkingArea)
Adds a parking area.
Definition: MSNet.cpp:869
virtual void buildChargingStation(MSNet &net, const std::string &id, MSLane *lane, double frompos, double topos, double chargingPower, double efficiency, bool chargeInTransit, int chargeDelay)
Builds a charging station.
MSParkingArea * myParkingArea
definition of the currently parsed parking area
~GUITriggerBuilder()
Destructor.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
Changes the speed allowed on a set of lanes.
A road/street connecting two junctions.
Definition: MSEdge.h:80
GUITriggerBuilder()
Constructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
MSStoppingPlace * myCurrentStop
The currently parsed stop to add access points to.
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane *> &destLanes, const std::string &file)
Builds a lane speed trigger.
Reroutes vehicles passing an edge.
A lane area vehicles can halt at (gui-version)
bool addContainerStop(MSStoppingPlace *containerStop)
Adds a container stop.
Definition: MSNet.cpp:846
bool addChargingStation(MSChargingStation *chargingStation)
Adds a chargingg station.
Definition: MSNet.cpp:891
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
A lane area vehicles can halt at (gui-version)
A lane area vehicles can halt at (gui-version)
Calibrates the flow on a segment to a specified one.
Definition: MSCalibrator.h:57
long long int SUMOTime
Definition: TraCIDefs.h:52
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
Changes the speed allowed on a set of lanes (gui version)
virtual MSCalibrator * buildCalibrator(MSNet &net, const std::string &id, MSEdge *edge, double pos, const std::string &file, const std::string &outfile, const SUMOTime freq, const MSRouteProbe *probe)
builds a microscopic calibrator
Representation of a lane in the micro simulation.
Definition: MSLane.h:79