LCOV - code coverage report
Current view: top level - src/libsumo - TraCIDefs.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 99 161 61.5 %
Date: 2024-04-27 15:34:54 Functions: 19 29 65.5 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2012-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    TraCIDefs.h
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Mario Krumnow
      17             : /// @author  Michael Behrisch
      18             : /// @author  Robert Hilbrich
      19             : /// @date    30.05.2012
      20             : ///
      21             : // C++ TraCI client API implementation
      22             : /****************************************************************************/
      23             : #pragma once
      24             : // we do not include config.h here, since we should be independent of a special sumo build
      25             : // but we want to avoid certain warnings in MSVC see config.h.cmake for details
      26             : #ifdef _MSC_VER
      27             : #pragma warning(push)
      28             : #pragma warning(disable: 4514 4820)
      29             : #endif
      30             : 
      31             : #include <libsumo/TraCIConstants.h>
      32             : #include <vector>
      33             : #include <limits>
      34             : #include <map>
      35             : #include <string>
      36             : #include <stdexcept>
      37             : #include <sstream>
      38             : #include <memory>
      39             : #include <cstring>
      40             : 
      41             : 
      42             : // ===========================================================================
      43             : // common declarations
      44             : // ===========================================================================
      45             : namespace libsumo {
      46             : class VariableWrapper;
      47             : }
      48             : namespace tcpip {
      49             : class Storage;
      50             : }
      51             : 
      52             : 
      53             : // ===========================================================================
      54             : // global definitions
      55             : // ===========================================================================
      56             : #ifdef LIBTRACI
      57             : #define LIBSUMO_NAMESPACE libtraci
      58             : #else
      59             : #define LIBSUMO_NAMESPACE libsumo
      60             : #endif
      61             : 
      62             : #define LIBSUMO_SUBSCRIPTION_API \
      63             : static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
      64             :                       double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
      65             : static void unsubscribe(const std::string& objectID); \
      66             : static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
      67             :                              double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
      68             : static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
      69             : static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
      70             : static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
      71             : static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
      72             : static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
      73             : static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE); \
      74             : static const int DOMAIN_ID;
      75             : 
      76             : #define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM) \
      77             : const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOM##_VARIABLE); \
      78             : void \
      79             : CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
      80             :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, varIDs, begin, end, params); \
      81             : } \
      82             : void \
      83             : CLASS::unsubscribe(const std::string& objectID) { \
      84             :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
      85             : } \
      86             : void \
      87             : CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& params) { \
      88             :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, varIDs, begin, end, params, domain, dist); \
      89             : } \
      90             : void \
      91             : CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
      92             :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
      93             : } \
      94             : const libsumo::SubscriptionResults \
      95             : CLASS::getAllSubscriptionResults() { \
      96             :     return mySubscriptionResults; \
      97             : } \
      98             : const libsumo::TraCIResults \
      99             : CLASS::getSubscriptionResults(const std::string& objectID) { \
     100             :     return mySubscriptionResults[objectID]; \
     101             : } \
     102             : const libsumo::ContextSubscriptionResults \
     103             : CLASS::getAllContextSubscriptionResults() { \
     104             :     return myContextSubscriptionResults; \
     105             : } \
     106             : const libsumo::SubscriptionResults \
     107             : CLASS::getContextSubscriptionResults(const std::string& objectID) { \
     108             :     return myContextSubscriptionResults[objectID]; \
     109             : } \
     110             : void \
     111             : CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
     112             :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>({libsumo::VAR_PARAMETER_WITH_KEY}), beginTime, endTime, libsumo::TraCIResults {{libsumo::VAR_PARAMETER_WITH_KEY, std::make_shared<libsumo::TraCIString>(key)}}); \
     113             : }
     114             : 
     115             : 
     116             : #define LIBSUMO_ID_PARAMETER_API \
     117             : static std::vector<std::string> getIDList(); \
     118             : static int getIDCount(); \
     119             : static std::string getParameter(const std::string& objectID, const std::string& key); \
     120             : static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
     121             : static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);
     122             : 
     123             : #define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
     124             : const std::pair<std::string, std::string> \
     125             : CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
     126             :     return std::make_pair(key, getParameter(objectID, key)); \
     127             : }
     128             : 
     129             : 
     130             : #define SWIGJAVA_CAST(CLASS) \
     131             : static std::shared_ptr<CLASS> cast(std::shared_ptr<TraCIResult> res) { \
     132             :     return std::dynamic_pointer_cast<CLASS>(res); \
     133             : }
     134             : 
     135             : 
     136             : // ===========================================================================
     137             : // class and type definitions
     138             : // ===========================================================================
     139             : namespace libsumo {
     140             : /**
     141             :  * @class TraCIException
     142             :  * @brief An error which allows to continue
     143             :  */
     144             : class TraCIException : public std::runtime_error {
     145             : public:
     146             :     /** constructor */
     147             :     TraCIException(std::string what)
     148        4929 :         : std::runtime_error(what) {}
     149             : };
     150             : 
     151             : /**
     152             :  * @class FatalTraCIError
     153             :  * @brief An error which is not recoverable
     154             :  */
     155             : class FatalTraCIError : public std::runtime_error {
     156             : public:
     157             :     /** constructor */
     158             :     FatalTraCIError(std::string what)
     159          99 :         : std::runtime_error(what) {}
     160             : };
     161             : 
     162             : /// @name Structures definitions
     163             : /// @{
     164             : 
     165      318798 : struct TraCIResult {
     166           0 :     virtual ~TraCIResult() {}
     167           0 :     virtual std::string getString() const {
     168           0 :         return "";
     169             :     }
     170           0 :     virtual int getType() const {
     171           0 :         return -1;
     172             :     }
     173             : };
     174             : 
     175             : /** @struct TraCIPosition
     176             :  * @brief A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE
     177             :  */
     178     3006892 : struct TraCIPosition : TraCIResult {
     179         181 :     std::string getString() const {
     180         181 :         std::ostringstream os;
     181         362 :         os << "TraCIPosition(" << x << "," << y;
     182         181 :         if (z != INVALID_DOUBLE_VALUE) {
     183           5 :             os << "," << z;
     184             :         }
     185         181 :         os << ")";
     186         181 :         return os.str();
     187         181 :     }
     188             :     double x = INVALID_DOUBLE_VALUE, y = INVALID_DOUBLE_VALUE, z = INVALID_DOUBLE_VALUE;
     189             : #ifdef SWIGJAVA
     190           0 :     SWIGJAVA_CAST(TraCIPosition)
     191             : #endif
     192             : };
     193             : 
     194             : /** @struct TraCIRoadPosition
     195             :  * @brief An edgeId, position and laneIndex
     196             :  */
     197         158 : struct TraCIRoadPosition : TraCIResult {
     198        4692 :     TraCIRoadPosition() {}
     199        9076 :     TraCIRoadPosition(const std::string e, const double p) : edgeID(e), pos(p) {}
     200           2 :     std::string getString() const {
     201           2 :         std::ostringstream os;
     202           4 :         os << "TraCIRoadPosition(" << edgeID << "_" << laneIndex << "," << pos << ")";
     203           2 :         return os.str();
     204           2 :     }
     205             :     std::string edgeID = "";
     206             :     double pos = INVALID_DOUBLE_VALUE;
     207             :     int laneIndex = INVALID_INT_VALUE;
     208             : #ifdef SWIGJAVA
     209           0 :     SWIGJAVA_CAST(TraCIRoadPosition)
     210             : #endif
     211             : };
     212             : 
     213             : /** @struct TraCIColor
     214             :  * @brief A color
     215             :  */
     216        2412 : struct TraCIColor : TraCIResult {
     217        2173 :     TraCIColor() : r(0), g(0), b(0), a(255) {}
     218         103 :     TraCIColor(int r, int g, int b, int a = 255) : r(r), g(g), b(b), a(a) {}
     219           3 :     std::string getString() const {
     220           3 :         std::ostringstream os;
     221          12 :         os << "TraCIColor(" << r << "," << g << "," << b << "," << a << ")";
     222           3 :         return os.str();
     223           3 :     }
     224             :     int r, g, b, a;
     225             : #ifdef SWIGJAVA
     226           0 :     SWIGJAVA_CAST(TraCIColor)
     227             : #endif
     228             : };
     229             : 
     230             : 
     231             : /** @struct TraCIPositionVector
     232             :  * @brief A list of positions
     233             :  */
     234      109262 : struct TraCIPositionVector : TraCIResult {
     235           3 :     std::string getString() const {
     236           3 :         std::ostringstream os;
     237           3 :         os << "[";
     238          20 :         for (const TraCIPosition& v : value) {
     239          51 :             os << "(" << v.x << "," << v.y << "," << v.z << ")";
     240             :         }
     241           3 :         os << "]";
     242           3 :         return os.str();
     243           3 :     }
     244             :     std::vector<TraCIPosition> value;
     245             : #ifdef SWIGJAVA
     246           0 :     SWIGJAVA_CAST(TraCIPositionVector)
     247             : #endif
     248             : };
     249             : 
     250             : 
     251             : struct TraCIInt : TraCIResult {
     252           0 :     TraCIInt() : value(0) {}
     253       22102 :     TraCIInt(int v) : value(v) {}
     254           0 :     std::string getString() const {
     255           0 :         std::ostringstream os;
     256           0 :         os << value;
     257           0 :         return os.str();
     258           0 :     }
     259             :     int value;
     260             : #ifdef SWIGJAVA
     261           0 :     SWIGJAVA_CAST(TraCIInt)
     262             : #endif
     263             : };
     264             : 
     265             : 
     266             : struct TraCIDouble : TraCIResult {
     267           0 :     TraCIDouble() : value(0.) {}
     268       50722 :     TraCIDouble(double v) : value(v) {}
     269         175 :     std::string getString() const {
     270         175 :         std::ostringstream os;
     271         175 :         os << value;
     272         175 :         return os.str();
     273         175 :     }
     274         102 :     int getType() const {
     275         102 :         return libsumo::TYPE_DOUBLE;
     276             :     }
     277             :     double value;
     278             : #ifdef SWIGJAVA
     279           0 :     SWIGJAVA_CAST(TraCIDouble)
     280             : #endif
     281             : };
     282             : 
     283             : 
     284             : struct TraCIString : TraCIResult {
     285           0 :     TraCIString() : value("") {}
     286       43682 :     TraCIString(std::string v) : value(v) {}
     287          22 :     std::string getString() const {
     288          22 :         return value;
     289             :     }
     290          42 :     int getType() const {
     291          42 :         return libsumo::TYPE_STRING;
     292             :     }
     293             :     std::string value;
     294             : #ifdef SWIGJAVA
     295           0 :     SWIGJAVA_CAST(TraCIString)
     296             : #endif
     297             : };
     298             : 
     299             : 
     300        1350 : struct TraCIStringList : TraCIResult {
     301           0 :     std::string getString() const {
     302           0 :         std::ostringstream os;
     303           0 :         os << "[";
     304           0 :         for (std::string v : value) {
     305           0 :             os << v << ",";
     306             :         }
     307           0 :         os << "]";
     308           0 :         return os.str();
     309           0 :     }
     310             :     std::vector<std::string> value;
     311             : #ifdef SWIGJAVA
     312          40 :     SWIGJAVA_CAST(TraCIStringList)
     313             : #endif
     314             : };
     315             : 
     316             : 
     317           0 : struct TraCIDoubleList : TraCIResult {
     318           0 :     std::string getString() const {
     319           0 :         std::ostringstream os;
     320           0 :         os << "[";
     321           0 :         for (double v : value) {
     322           0 :             os << v << ",";
     323             :         }
     324           0 :         os << "]";
     325           0 :         return os.str();
     326           0 :     }
     327             :     std::vector<double> value;
     328             : #ifdef SWIGJAVA
     329           0 :     SWIGJAVA_CAST(TraCIDoubleList)
     330             : #endif
     331             : };
     332             : 
     333             : 
     334             : /// @brief {variable->value}
     335             : typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> > TraCIResults;
     336             : /// @brief {object->{variable->value}}
     337             : typedef std::map<std::string, libsumo::TraCIResults> SubscriptionResults;
     338             : typedef std::map<std::string, libsumo::SubscriptionResults> ContextSubscriptionResults;
     339             : 
     340             : 
     341             : class TraCIPhase {
     342             : public:
     343         220 :     TraCIPhase() {}
     344        1454 :     TraCIPhase(const double _duration, const std::string& _state, const double _minDur = libsumo::INVALID_DOUBLE_VALUE,
     345             :                const double _maxDur = libsumo::INVALID_DOUBLE_VALUE,
     346             :                const std::vector<int>& _next = std::vector<int>(),
     347        1454 :                const std::string& _name = "") :
     348        2908 :         duration(_duration), state(_state), minDur(_minDur), maxDur(_maxDur), next(_next), name(_name) {}
     349        1626 :     ~TraCIPhase() {}
     350             : 
     351             :     double duration;
     352             :     std::string state;
     353             :     double minDur, maxDur;
     354             :     std::vector<int> next;
     355             :     std::string name;
     356             : };
     357             : }
     358             : 
     359             : 
     360             : #ifdef SWIG
     361             : %template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >; // *NOPAD*
     362             : #endif
     363             : 
     364             : 
     365             : namespace libsumo {
     366             : class TraCILogic {
     367             : public:
     368          80 :     TraCILogic() {}
     369         197 :     TraCILogic(const std::string& _programID, const int _type, const int _currentPhaseIndex,
     370             :                const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
     371         197 :         : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
     372         791 :     ~TraCILogic() {}
     373             : 
     374             :     std::string programID;
     375             :     int type;
     376             :     int currentPhaseIndex;
     377             :     std::vector<std::shared_ptr<libsumo::TraCIPhase> > phases;
     378             :     std::map<std::string, std::string> subParameter;
     379             : };
     380             : 
     381             : 
     382             : class TraCILink {
     383             : public:
     384           0 :     TraCILink() {}
     385        1038 :     TraCILink(const std::string& _from, const std::string& _via, const std::string& _to)
     386        3114 :         : fromLane(_from), viaLane(_via), toLane(_to) {}
     387        3418 :     ~TraCILink() {}
     388             : 
     389             :     std::string fromLane;
     390             :     std::string viaLane;
     391             :     std::string toLane;
     392             : };
     393             : 
     394             : 
     395             : class TraCIConnection {
     396             : public:
     397           0 :     TraCIConnection() {} // this is needed by SWIG when building a vector of this type, please don't use it
     398         112 :     TraCIConnection(const std::string& _approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe,
     399             :                     const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
     400         112 :         : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
     401         448 :           approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
     402         356 :     ~TraCIConnection() {}
     403             : 
     404             :     std::string approachedLane;
     405             :     bool hasPrio;
     406             :     bool isOpen;
     407             :     bool hasFoe;
     408             :     std::string approachedInternal;
     409             :     std::string state;
     410             :     std::string direction;
     411             :     double length;
     412             : };
     413             : 
     414             : 
     415             : /// @brief mirrors MSInductLoop::VehicleData
     416             : struct TraCIVehicleData {
     417             :     /// @brief The id of the vehicle
     418             :     std::string id;
     419             :     /// @brief Length of the vehicle
     420             :     double length;
     421             :     /// @brief Entry-time of the vehicle in [s]
     422             :     double entryTime;
     423             :     /// @brief Leave-time of the vehicle in [s]
     424             :     double leaveTime;
     425             :     /// @brief Type of the vehicle in
     426             :     std::string typeID;
     427             : };
     428             : 
     429             : 
     430        4513 : struct TraCINextTLSData {
     431             :     /// @brief The id of the next tls
     432             :     std::string id;
     433             :     /// @brief The tls index of the controlled link
     434             :     int tlIndex;
     435             :     /// @brief The distance to the tls
     436             :     double dist;
     437             :     /// @brief The current state of the tls
     438             :     char state;
     439             : };
     440             : 
     441             : 
     442             : struct TraCINextStopData : TraCIResult {
     443             : 
     444       12278 :     TraCINextStopData(const std::string& lane = "",
     445             :                       double startPos = INVALID_DOUBLE_VALUE,
     446             :                       double endPos = INVALID_DOUBLE_VALUE,
     447             :                       const std::string& stoppingPlaceID = "",
     448             :                       int stopFlags = 0,
     449             :                       double duration = INVALID_DOUBLE_VALUE,
     450             :                       double until = INVALID_DOUBLE_VALUE,
     451             :                       double intendedArrival = INVALID_DOUBLE_VALUE,
     452             :                       double arrival = INVALID_DOUBLE_VALUE,
     453             :                       double depart = INVALID_DOUBLE_VALUE,
     454             :                       const std::string& split = "",
     455             :                       const std::string& join = "",
     456             :                       const std::string& actType = "",
     457             :                       const std::string& tripId = "",
     458             :                       const std::string& line = "",
     459       12278 :                       double speed = 0):
     460       12278 :         lane(lane),
     461       12278 :         startPos(startPos),
     462       12278 :         endPos(endPos),
     463       12278 :         stoppingPlaceID(stoppingPlaceID),
     464       12278 :         stopFlags(stopFlags),
     465       12278 :         duration(duration),
     466       12278 :         until(until),
     467       12278 :         intendedArrival(intendedArrival),
     468       12278 :         arrival(arrival),
     469       12278 :         depart(depart),
     470       12278 :         split(split),
     471       12278 :         join(join),
     472       12278 :         actType(actType),
     473       12278 :         tripId(tripId),
     474       12278 :         line(line),
     475       12278 :         speed(speed)
     476       12278 :     {}
     477             : 
     478           0 :     std::string getString() const {
     479           0 :         std::ostringstream os;
     480           0 :         os << "TraCINextStopData(" << lane << "," << endPos << "," << stoppingPlaceID
     481           0 :            << "," << stopFlags << "," << duration << "," << until
     482           0 :            << "," << arrival << ")";
     483           0 :         return os.str();
     484           0 :     }
     485             : 
     486             :     /// @brief The lane to stop at
     487             :     std::string lane;
     488             :     /// @brief The stopping position start
     489             :     double startPos;
     490             :     /// @brief The stopping position end
     491             :     double endPos;
     492             :     /// @brief Id assigned to the stop
     493             :     std::string stoppingPlaceID;
     494             :     /// @brief Stop flags
     495             :     int stopFlags;
     496             :     /// @brief The intended (minimum) stopping duration
     497             :     double duration;
     498             :     /// @brief The time at which the vehicle may continue its journey
     499             :     double until;
     500             :     /// @brief The intended arrival time
     501             :     double intendedArrival;
     502             :     /// @brief The actual arrival time (only for past stops)
     503             :     double arrival;
     504             :     /// @brief The time at which this stop was ended
     505             :     double depart;
     506             :     /// @brief the id of the vehicle (train portion) that splits of upon reaching this stop
     507             :     std::string split;
     508             :     /// @brief the id of the vehicle (train portion) to which this vehicle shall be joined
     509             :     std::string join;
     510             :     /// @brief additional information for this stop
     511             :     std::string actType;
     512             :     /// @brief id of the trip within a cyclical public transport route
     513             :     std::string tripId;
     514             :     /// @brief the new line id of the trip within a cyclical public transport route
     515             :     std::string line;
     516             :     /// @brief the speed at which this stop counts as reached (waypoint mode)
     517             :     double speed;
     518             : };
     519             : 
     520             : 
     521             : /** @struct TraCINextStopDataVector
     522             :  * @brief A list of vehicle stops
     523             :  * @see TraCINextStopData
     524             :  */
     525           0 : struct TraCINextStopDataVector : TraCIResult {
     526           0 :     std::string getString() const {
     527           0 :         std::ostringstream os;
     528           0 :         os << "TraCINextStopDataVector[";
     529           0 :         for (TraCINextStopData v : value) {
     530           0 :             os << v.getString() << ",";
     531           0 :         }
     532           0 :         os << "]";
     533           0 :         return os.str();
     534           0 :     }
     535             : 
     536             :     std::vector<TraCINextStopData> value;
     537             : };
     538             : 
     539             : 
     540         120 : struct TraCIBestLanesData {
     541             :     /// @brief The id of the lane
     542             :     std::string laneID;
     543             :     /// @brief The length than can be driven from that lane without lane change
     544             :     double length;
     545             :     /// @brief The traffic density along length
     546             :     double occupation;
     547             :     /// @brief The offset of this lane from the best lane
     548             :     int bestLaneOffset;
     549             :     /// @brief Whether this lane allows continuing the route
     550             :     bool allowsContinuation;
     551             :     /// @brief The sequence of lanes that best allows continuing the route without lane change
     552             :     std::vector<std::string> continuationLanes;
     553             : };
     554             : 
     555             : 
     556             : class TraCIStage {
     557             : public:
     558       15397 :     TraCIStage(int type = INVALID_INT_VALUE, const std::string& vType = "", const std::string& line = "", const std::string& destStop = "",
     559             :                const std::vector<std::string>& edges = std::vector<std::string>(),
     560             :                double travelTime = INVALID_DOUBLE_VALUE, double cost = INVALID_DOUBLE_VALUE, double length = INVALID_DOUBLE_VALUE,
     561             :                const std::string& intended = "", double depart = INVALID_DOUBLE_VALUE, double departPos = INVALID_DOUBLE_VALUE,
     562       15397 :                double arrivalPos = INVALID_DOUBLE_VALUE, const std::string& description = "") :
     563       46191 :         type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
     564       46191 :         length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
     565             :     /// @brief The type of stage (walking, driving, ...)
     566             :     int type;
     567             :     /// @brief The vehicle type when using a private car or bike
     568             :     std::string vType;
     569             :     /// @brief The line or the id of the vehicle type
     570             :     std::string line;
     571             :     /// @brief The id of the destination stop
     572             :     std::string destStop;
     573             :     /// @brief The sequence of edges to travel
     574             :     std::vector<std::string> edges;
     575             :     /// @brief duration of the stage in seconds
     576             :     double travelTime;
     577             :     /// @brief effort needed
     578             :     double cost;
     579             :     /// @brief length in m
     580             :     double length;
     581             :     /// @brief id of the intended vehicle for public transport ride
     582             :     std::string intended;
     583             :     /// @brief intended depart time for public transport ride or INVALID_DOUBLE_VALUE
     584             :     double depart;
     585             :     /// @brief position on the lane when starting the stage
     586             :     double departPos;
     587             :     /// @brief position on the lane when ending the stage
     588             :     double arrivalPos;
     589             :     /// @brief arbitrary description string
     590             :     std::string description;
     591             : };
     592             : 
     593             : 
     594             : 
     595             : class TraCIReservation {
     596             : public:
     597         586 :     TraCIReservation() {}
     598        7008 :     TraCIReservation(const std::string& id,
     599             :                      const std::vector<std::string>& persons,
     600             :                      const std::string& group,
     601             :                      const std::string& fromEdge,
     602             :                      const std::string& toEdge,
     603             :                      double departPos,
     604             :                      double arrivalPos,
     605             :                      double depart,
     606             :                      double reservationTime,
     607        7008 :                      int state) :
     608       21024 :         id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
     609        7008 :         depart(depart), reservationTime(reservationTime), state(state) {}
     610             :     /// @brief The id of the taxi reservation (usable for traci.vehicle.dispatchTaxi)
     611             :     std::string id;
     612             :     /// @brief The persons ids that are part of this reservation
     613             :     std::vector<std::string> persons;
     614             :     /// @brief The group id of this reservation
     615             :     std::string group;
     616             :     /// @brief The origin edge id
     617             :     std::string fromEdge;
     618             :     /// @brief The destination edge id
     619             :     std::string toEdge;
     620             :     /// @brief pickup position on the origin edge
     621             :     double departPos;
     622             :     /// @brief drop-off position on the destination edge
     623             :     double arrivalPos;
     624             :     /// @brief pickup-time
     625             :     double depart;
     626             :     /// @brief time when the reservation was made
     627             :     double reservationTime;
     628             :     /// @brief the state of this reservation
     629             :     int state;
     630             : };
     631             : 
     632             : struct TraCICollision {
     633             :     /// @brief The ids of the participating vehicles and persons
     634             :     std::string collider;
     635             :     std::string victim;
     636             :     std::string colliderType;
     637             :     std::string victimType;
     638             :     double colliderSpeed;
     639             :     double victimSpeed;
     640             :     /// @brief The type of collision
     641             :     std::string type;
     642             :     /// @brief The lane where the collision happended
     643             :     std::string lane;
     644             :     /// @brief The position of the collision along the lane
     645             :     double pos;
     646             : };
     647             : 
     648             : 
     649             : struct TraCISignalConstraint {
     650             :     /// @brief the idea of the rail signal where this constraint is active
     651             :     std::string signalId;
     652             :     /// @brief the tripId or vehicle id of the train that is constrained
     653             :     std::string tripId;
     654             :     /// @brief the tripId or vehicle id of the train that must pass first
     655             :     std::string foeId;
     656             :     /// @brief the tlsID of the rail signla that the foe must pass first
     657             :     std::string foeSignal;
     658             :     /// @brief the number of trains that must be recorded at the foeSignal
     659             :     int limit;
     660             :     /// @brief the type of constraint (predecessor:0, insertionPredecessor:1)
     661             :     int type;
     662             :     /// @brief whether tripId must still wait for foeId to pass foeSignal
     663             :     bool mustWait;
     664             :     /// @brief whether this constraint is active
     665             :     bool active;
     666             :     /// @brief additional parameters
     667             :     std::map<std::string, std::string> param;
     668             : 
     669           0 :     std::string getString() const {
     670           0 :         std::ostringstream os;
     671           0 :         os << "TraCISignalConstraint(signalId=" << signalId << ", tripid=" << tripId << ", foeSignal=" << foeSignal << ", foeId=" << foeId << ")";
     672           0 :         return os.str();
     673           0 :     }
     674             : };
     675             : 
     676             : 
     677             : struct TraCIJunctionFoe {
     678             :     /// @brief the id of the vehicle with intersecting trajectory
     679             :     std::string foeId;
     680             :     double egoDist;
     681             :     double foeDist;
     682             :     double egoExitDist;
     683             :     double foeExitDist;
     684             :     std::string egoLane;
     685             :     std::string foeLane;
     686             :     bool egoResponse;
     687             :     bool foeResponse;
     688             : };
     689             : 
     690             : }
     691             : 
     692             : // pop MSVC warnings
     693             : #ifdef _MSC_VER
     694             : #pragma warning(pop)
     695             : #endif

Generated by: LCOV version 1.14