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-2015 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 void
79 GUITriggerBuilder::buildBusStop(MSNet& net, const std::string& id,
80  const std::vector<std::string>& lines,
81  MSLane* lane,
82  SUMOReal frompos, SUMOReal topos) {
83 
84  GUIBusStop* stop = new GUIBusStop(id, lines, *lane, frompos, topos);
85  if (!net.addBusStop(stop)) {
86  delete stop;
87  throw InvalidArgument("Could not build bus stop '" + id + "'; probably declared twice.");
88  }
89  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
90 }
91 
92 void
93 GUITriggerBuilder::buildContainerStop(MSNet& net, const std::string& id,
94  const std::vector<std::string>& lines,
95  MSLane* lane,
96  SUMOReal frompos, SUMOReal topos) {
97  GUIContainerStop* stop = new GUIContainerStop(id, lines, *lane, frompos, topos);
98  if (!net.addContainerStop(stop)) {
99  delete stop;
100  throw InvalidArgument("Could not build container stop '" + id + "'; probably declared twice.");
101  }
102  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
103 }
104 
105 
106 void
107 GUITriggerBuilder::buildChargingStation(MSNet& net, const std::string& id,
108  const std::vector<std::string>& lines,
109  MSLane* lane,
110  SUMOReal frompos, SUMOReal topos, SUMOReal chrgpower, SUMOReal efficiency, SUMOReal chargeInTransit, SUMOReal chargeDelay) {
111  GUIChargingStation* chrg = new GUIChargingStation(id, lines, *lane, frompos, topos, chrgpower, efficiency, chargeInTransit, chargeDelay);
112 
113  if (!net.addChargingStation(chrg)) {
114  delete chrg;
115  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
116  }
117 
118  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(chrg);
119 }
120 
122 GUITriggerBuilder::buildCalibrator(MSNet& net, const std::string& id,
123  MSEdge* edge, SUMOReal pos,
124  const std::string& file,
125  const std::string& outfile,
126  const SUMOTime freq,
127  const MSRouteProbe* probe) {
128  GUICalibrator* cali = new GUICalibrator(id, edge, pos, file, outfile, freq, probe);
129  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(cali);
130  return cali;
131 }
132 
133 
134 /****************************************************************************/
135 
A lane area vehicles can halt at (gui-version)
Definition: GUIBusStop.h:71
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 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:780
~GUITriggerBuilder()
Destructor.
virtual void buildBusStop(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos)
Builds a bus stop.
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
virtual void buildContainerStop(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos)
Builds a container stop.
A road/street connecting two junctions.
Definition: MSEdge.h:81
GUITriggerBuilder()
Constructor.
virtual void buildChargingStation(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos, SUMOReal chrgpower, SUMOReal efficiency, SUMOReal chargeInTransit, SUMOReal chargeDelay)
Builds a charging station.
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:805
bool addChargingStation(MSChargingStation *chargingStation)
Adds a chargingg station.
Definition: MSNet.cpp:828
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:91
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:214
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:78
Changes the speed allowed on a set of lanes (gui version)
Representation of a lane in the micro simulation.
Definition: MSLane.h:77