SUMO - Simulation of Urban MObility
TraCIDefs.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // C++ TraCI client API implementation
21 /****************************************************************************/
22 #ifndef TraCIDefs_h
23 #define TraCIDefs_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <map>
37 #include <string>
38 #include <stdexcept>
39 
40 
41 // ===========================================================================
42 // global definitions
43 // ===========================================================================
44 #define DEFAULT_VIEW "View #0"
45 #define PRECISION 2
46 
47 
48 // ===========================================================================
49 // class and type definitions
50 // ===========================================================================
51 typedef long long int SUMOTime; // <utils/common/SUMOTime.h>
52 #define SUMOTime_MAX std::numeric_limits<SUMOTime>::max()
53 
54 namespace libsumo {
58 class TraCIException : public std::runtime_error {
59 public:
61  TraCIException(std::string what)
62  : std::runtime_error(what) {}
63 };
64 
67 
71 struct TraCIPosition {
72  double x, y, z;
73 };
74 
78 struct TraCIColor {
79  unsigned char r, g, b, a;
80 };
81 
85 typedef std::vector<TraCIPosition> TraCIPositionVector;
86 
90 struct TraCIBoundary {
91  double xMin, yMin, zMin;
92  double xMax, yMax, zMax;
93 };
94 
95 
96 struct TraCIValue {
97  union {
98  double scalar;
101  };
102  std::string string;
103  std::vector<std::string> stringList;
104 };
105 
106 
107 class TraCIPhase {
108 public:
109  TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string& _phase)
110  : duration(_duration), duration1(_duration1), duration2(_duration2), phase(_phase) {}
112 
113  SUMOTime duration, duration1, duration2;
114  std::string phase;
115 };
116 
117 
118 class TraCILogic {
119 public:
121  TraCILogic(const std::string& _subID, int _type, int _currentPhaseIndex)
122  : subID(_subID), type(_type), currentPhaseIndex(_currentPhaseIndex) {}
124 
125  std::string subID;
126  int type;
128  std::vector<TraCIPhase> phases;
129  std::map<std::string, std::string> subParameter;
130 };
131 
132 
133 class TraCILink {
134 public:
135  TraCILink(const std::string& _from, const std::string& _via, const std::string& _to)
136  : from(_from), via(_via), to(_to) {}
138 
139  std::string from;
140  std::string via;
141  std::string to;
142 };
143 
144 
146 public:
147  TraCIConnection(const std::string& _approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe,
148  const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
149  : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
150  approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
152 
153  std::string approachedLane;
154  bool hasPrio;
155  bool isOpen;
156  bool hasFoe;
157  std::string approachedInternal;
158  std::string state;
159  std::string direction;
160  double length;
161 };
162 
163 
167  std::string id;
169  double length;
171  double entryTime;
173  double leaveTime;
175  std::string typeID;
176 };
177 
178 
181  std::string id;
183  int tlIndex;
185  double dist;
187  char state;
188 };
189 
190 
193  std::string laneID;
195  double length;
197  double occupation;
203  std::vector<std::string> continuationLanes;
204 };
205 
206 
207 class TraCIStage {
208 public:
209  TraCIStage() {} // only to make swig happy
210  TraCIStage(int _type) : type(_type) {}
212  int type;
214  std::string line;
216  std::string destStop;
218  std::vector<std::string> edges;
220  double travelTime;
222  double cost;
223 };
224 }
225 
226 
227 #endif
228 
229 /****************************************************************************/
TraCIColor color
Definition: TraCIDefs.h:100
std::string id
The id of the next tls.
Definition: TraCIDefs.h:181
std::string phase
Definition: TraCIDefs.h:114
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:212
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:173
double dist
The distance to the tls.
Definition: TraCIDefs.h:185
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:201
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:214
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:175
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:165
TraCIStage(int _type)
Definition: TraCIDefs.h:210
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:216
A 3D-bounding box.
Definition: TraCIDefs.h:90
double occupation
The traffic density along length.
Definition: TraCIDefs.h:197
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:193
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:129
TraCIConnection(const std::string &_approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe, const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
Definition: TraCIDefs.h:147
std::vector< TraCIPhase > phases
Definition: TraCIDefs.h:128
TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string &_phase)
Definition: TraCIDefs.h:109
double cost
effort needed
Definition: TraCIDefs.h:222
std::string string
Definition: TraCIDefs.h:102
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:199
std::string approachedInternal
Definition: TraCIDefs.h:157
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:218
double length
Length of the vehicle.
Definition: TraCIDefs.h:169
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:167
TraCIPosition position
Definition: TraCIDefs.h:99
unsigned char r
Definition: TraCIDefs.h:79
TraCILogic(const std::string &_subID, int _type, int _currentPhaseIndex)
Definition: TraCIDefs.h:121
std::string approachedLane
Definition: TraCIDefs.h:153
Definition: Edge.cpp:31
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:85
char state
The current state of the tls.
Definition: TraCIDefs.h:187
SUMOTime duration2
Definition: TraCIDefs.h:113
double travelTime
duration of the stage
Definition: TraCIDefs.h:220
std::string subID
Definition: TraCIDefs.h:125
TraCIException(std::string what)
Definition: TraCIDefs.h:61
long long int SUMOTime
Definition: TraCIDefs.h:51
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:195
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:171
std::vector< std::string > stringList
Definition: TraCIDefs.h:103
A 3D-position.
Definition: TraCIDefs.h:71
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:183
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:203