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 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
55 
56 
58 
59 
62  const std::string& id, const std::vector<MSLane*>& destLanes,
63  const std::string& file) {
64  GUILaneSpeedTrigger* lst = new GUILaneSpeedTrigger(id, destLanes, file);
65  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(lst);
66  return lst;
67 }
68 
69 
71 GUITriggerBuilder::buildRerouter(MSNet& net, const std::string& id,
72  MSEdgeVector& edges,
73  SUMOReal prob, const std::string& file, bool off) {
74  GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, file, off,
75  dynamic_cast<GUINet&>(net).getVisualisationSpeedUp());
76  return rr;
77 }
78 
79 
80 void
81 GUITriggerBuilder::buildStoppingPlace(MSNet& net, const std::string& id, const std::vector<std::string>& lines,
82  MSLane* lane, SUMOReal frompos, SUMOReal topos, const SumoXMLTag element) {
83  bool success = false;
84  GUIGlObject* o = 0;
85  if (element == SUMO_TAG_CONTAINER_STOP) {
86  GUIContainerStop* stop = new GUIContainerStop(id, lines, *lane, frompos, topos);
87  success = net.addContainerStop(stop);
88  o = stop;
89  myCurrentStop = stop;
90  } else {
91  GUIBusStop* stop = new GUIBusStop(id, lines, *lane, frompos, topos);
92  success = net.addBusStop(stop);
93  o = stop;
94  myCurrentStop = stop;
95  }
96  if (!success) {
97  delete o;
98  throw InvalidArgument("Could not build " + toString(element) + " stop '" + id + "'; probably declared twice.");
99  }
100  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(o);
101 }
102 
103 
104 void
105 GUITriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
106  const std::vector<std::string>& lines,
107  MSLane* lane,
108  SUMOReal frompos, SUMOReal topos,
109  unsigned int capacity,
110  SUMOReal width, SUMOReal length, SUMOReal angle) {
111  assert(myParkingArea == 0);
112 
113  GUIParkingArea* stop = new GUIParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle);
114  if (!net.addParkingArea(stop)) {
115  delete stop;
116  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
117  } else {
118  myParkingArea = stop;
119  }
120  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
121 }
122 
123 void
124 GUITriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, SUMOReal frompos, SUMOReal topos,
125  SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, int chargeDelay) {
126  GUIChargingStation* chargingStation = new GUIChargingStation(id, *lane, frompos, topos, chargingPower, efficiency, chargeInTransit, chargeDelay);
127 
128  if (!net.addChargingStation(chargingStation)) {
129  delete chargingStation;
130  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
131  }
132 
133  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(chargingStation);
134 }
135 
137 GUITriggerBuilder::buildCalibrator(MSNet& net, const std::string& id,
138  MSEdge* edge, SUMOReal pos,
139  const std::string& file,
140  const std::string& outfile,
141  const SUMOTime freq,
142  const MSRouteProbe* probe) {
143  GUICalibrator* cali = new GUICalibrator(id, edge, pos, file, outfile, freq, probe);
144  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(cali);
145  return cali;
146 }
147 
148 
149 /****************************************************************************/
150 
A lane area vehicles can halt at (gui-version)
Definition: GUIBusStop.h:71
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
Builds a lane speed trigger.
long long int SUMOTime
Definition: SUMOTime.h:43
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 buildChargingStation(MSNet &net, const std::string &id, MSLane *lane, SUMOReal frompos, SUMOReal topos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, int chargeDelay)
Builds a charging station.
virtual MSCalibrator * buildCalibrator(MSNet &net, const std::string &id, MSEdge *edge, SUMOReal pos, const std::string &file, const std::string &outfile, const SUMOTime freq, const MSRouteProbe *probe)
builds a microscopic calibrator
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:68
bool addBusStop(MSStoppingPlace *busStop)
Adds a bus stop.
Definition: MSNet.cpp:801
bool addParkingArea(MSParkingArea *parkingArea)
Adds a parking area.
Definition: MSNet.cpp:849
MSParkingArea * myParkingArea
definition of the currently parsed parking area
virtual void beginParkingArea(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos, unsigned int capacity, SUMOReal width, SUMOReal length, SUMOReal angle)
Builds a parking area.
virtual void buildStoppingPlace(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos, const SumoXMLTag element)
Builds a bus stop.
~GUITriggerBuilder()
Destructor.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
Changes the speed allowed on a set of lanes.
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, MSEdgeVector &edges, SUMOReal prob, const std::string &file, bool off)
builds an rerouter
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:55
MSStoppingPlace * myCurrentStop
The currently parsed stop to add access points to.
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:826
bool addChargingStation(MSChargingStation *chargingStation)
Adds a chargingg station.
Definition: MSNet.cpp:871
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
#define SUMOReal
Definition: config.h:208
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
Changes the speed allowed on a set of lanes (gui version)
Representation of a lane in the micro simulation.
Definition: MSLane.h:79