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/GUICalibrator.h>
42 #include "GUITriggerBuilder.h"
43 
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
54 
55 
57 
58 
61  const std::string& id, const std::vector<MSLane*>& destLanes,
62  const std::string& file) {
63  GUILaneSpeedTrigger* lst = new GUILaneSpeedTrigger(id, destLanes, file);
64  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(lst);
65  return lst;
66 }
67 
68 
70 GUITriggerBuilder::buildRerouter(MSNet& net, const std::string& id,
71  MSEdgeVector& edges,
72  SUMOReal prob, const std::string& file, bool off) {
73  GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, file, off,
74  dynamic_cast<GUINet&>(net).getVisualisationSpeedUp());
75  return rr;
76 }
77 
78 
79 void
80 GUITriggerBuilder::buildStoppingPlace(MSNet& net, const std::string& id, const std::vector<std::string>& lines,
81  MSLane* lane, SUMOReal frompos, SUMOReal topos, const SumoXMLTag element) {
82  bool success = false;
83  GUIGlObject* o = 0;
84  if (element == SUMO_TAG_CONTAINER_STOP) {
85  GUIContainerStop* stop = new GUIContainerStop(id, lines, *lane, frompos, topos);
86  success = net.addContainerStop(stop);
87  o = stop;
88  myCurrentStop = stop;
89  } else {
90  GUIBusStop* stop = new GUIBusStop(id, lines, *lane, frompos, topos);
91  success = net.addBusStop(stop);
92  o = stop;
93  myCurrentStop = stop;
94  }
95  if (!success) {
96  delete o;
97  throw InvalidArgument("Could not build " + toString(element) + " stop '" + id + "'; probably declared twice.");
98  }
99  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(o);
100 }
101 
102 
103 void
104 GUITriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, SUMOReal frompos, SUMOReal topos,
105  SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, int chargeDelay) {
106  GUIChargingStation* chargingStation = new GUIChargingStation(id, *lane, frompos, topos, chargingPower, efficiency, chargeInTransit, chargeDelay);
107 
108  if (!net.addChargingStation(chargingStation)) {
109  delete chargingStation;
110  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
111  }
112 
113  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(chargingStation);
114 }
115 
117 GUITriggerBuilder::buildCalibrator(MSNet& net, const std::string& id,
118  MSEdge* edge, SUMOReal pos,
119  const std::string& file,
120  const std::string& outfile,
121  const SUMOTime freq,
122  const MSRouteProbe* probe) {
123  GUICalibrator* cali = new GUICalibrator(id, edge, pos, file, outfile, freq, probe);
124  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(cali);
125  return cali;
126 }
127 
128 
129 /****************************************************************************/
130 
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:783
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:93
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.
MSStoppingPlace * myCurrentStop
The currently parsed stop to add access points to.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
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:808
bool addChargingStation(MSChargingStation *chargingStation)
Adds a chargingg station.
Definition: MSNet.cpp:831
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
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:213
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