SUMO - Simulation of Urban MObility
TraCIDefs.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // C++ TraCI client API implementation
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2012-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef TraCIDefs_h
24 #define TraCIDefs_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <map>
38 #include <string>
39 #include <stdexcept>
40 
41 
42 // ===========================================================================
43 // global definitions
44 // ===========================================================================
45 #define DEFAULT_VIEW "View #0"
46 #define PRECISION 2
47 
48 
49 // ===========================================================================
50 // class and type definitions
51 // ===========================================================================
52 typedef long long int SUMOTime; // <utils/common/SUMOTime.h>
53 #define SUMOTime_MAX std::numeric_limits<SUMOTime>::max()
54 
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 struct TraCIValue {
96  union {
97  double scalar;
100  };
101  std::string string;
102  std::vector<std::string> stringList;
103 };
104 
105 class TraCIPhase {
106 public:
107  TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string& _phase)
108  : duration(_duration), duration1(_duration1), duration2(_duration2), phase(_phase) {}
110 
111  SUMOTime duration, duration1, duration2;
112  std::string phase;
113 };
114 
115 
116 class TraCILogic {
117 public:
118  TraCILogic(const std::string& _subID, int _type, const std::map<std::string, double>& _subParameter, int _currentPhaseIndex, const std::vector<TraCIPhase>& _phases)
119  : subID(_subID), type(_type), subParameter(_subParameter), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
121 
122  std::string subID;
123  int type;
124  std::map<std::string, double> subParameter;
126  std::vector<TraCIPhase> phases;
127 };
128 
129 
130 class TraCILink {
131 public:
132  TraCILink(const std::string& _from, const std::string& _via, const std::string& _to)
133  : from(_from), via(_via), to(_to) {}
135 
136  std::string from;
137  std::string via;
138  std::string to;
139 };
140 
141 
143 public:
144  TraCIConnection(const std::string& _approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe,
145  const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
146  : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
147  approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
149 
150  std::string approachedLane;
151  bool hasPrio;
152  bool isOpen;
153  bool hasFoe;
154  std::string approachedInternal;
155  std::string state;
156  std::string direction;
157  double length;
158 };
159 
160 
162 public:
163  /* @brief Constructor
164  (mirrors MSInductLoop::VehicleData) */
167  std::string id;
169  double length;
171  double entryTime;
173  double leaveTime;
175  std::string typeID;
176 };
177 
179 
180 
181 #endif
182 
183 /****************************************************************************/
double length
Length of the vehicle.
Definition: TraCIDefs.h:169
std::string subID
Definition: TraCIDefs.h:122
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:173
std::map< std::string, double > subParameter
Definition: TraCIDefs.h:124
unsigned char r
Definition: TraCIDefs.h:79
double zMin
Definition: TraCIDefs.h:91
double zMax
Definition: TraCIDefs.h:92
double z
Definition: TraCIDefs.h:72
SUMOTime duration2
Definition: TraCIDefs.h:111
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:167
std::string direction
Definition: TraCIDefs.h:156
A 3D-position.
Definition: TraCIDefs.h:71
double scalar
Definition: TraCIDefs.h:97
TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string &_phase)
Definition: TraCIDefs.h:107
std::string approachedLane
Definition: TraCIDefs.h:150
TraCIPosition position
Definition: TraCIDefs.h:98
std::vector< TraCIPhase > phases
Definition: TraCIDefs.h:126
TraCIException(std::string what)
Definition: TraCIDefs.h:61
std::vector< std::string > stringList
Definition: TraCIDefs.h:102
TraCILogic(const std::string &_subID, int _type, const std::map< std::string, double > &_subParameter, int _currentPhaseIndex, const std::vector< TraCIPhase > &_phases)
Definition: TraCIDefs.h:118
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:175
A 3D-bounding box.
Definition: TraCIDefs.h:90
int currentPhaseIndex
Definition: TraCIDefs.h:125
long long int SUMOTime
Definition: TraCIDefs.h:52
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:85
std::string approachedInternal
Definition: TraCIDefs.h:154
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:171
std::string state
Definition: TraCIDefs.h:155
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:144
TraCIColor color
Definition: TraCIDefs.h:99
std::string string
Definition: TraCIDefs.h:101
std::string phase
Definition: TraCIDefs.h:112