Line data Source code
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 : /****************************************************************************/
12 : /// @file TraCI.h
13 : /// @author Daniel Krajzewicz
14 : /// @author Mario Krumnow
15 : /// @author Michael Behrisch
16 : /// @date 30.05.2012
17 : /// @version $Id$
18 : ///
19 : // C++ TraCI client API implementation
20 : /****************************************************************************/
21 : #ifndef TraCI_h
22 : #define TraCI_h
23 :
24 :
25 : // ===========================================================================
26 : // included modules
27 : // ===========================================================================
28 : #ifdef _MSC_VER
29 : #include <windows_config.h>
30 : #else
31 : #include <config.h>
32 : #endif
33 :
34 : #include <vector>
35 : #include <map>
36 : #include <traci-server/TraCIDefs.h>
37 :
38 : class Position;
39 : class PositionVector;
40 : class RGBColor;
41 : class MSEdge;
42 : class MSLane;
43 :
44 :
45 : // ===========================================================================
46 : // class definitions
47 : // ===========================================================================
48 : /**
49 : * @class TraCI
50 : * @brief C++ TraCI client API implementation
51 : */
52 : class TraCI {
53 : public:
54 : /// @name Connection handling
55 : /// @{
56 :
57 : /** @brief Connects to the specified SUMO server
58 : * @param[in] host The name of the host to connect to
59 : * @param[in] port The port to connect to
60 : * @exception tcpip::SocketException if the connection fails
61 : */
62 : //void connect(const std::string& host, int port);
63 :
64 :
65 : /// @brief ends the simulation and closes the connection
66 : void close();
67 : /// @}
68 :
69 : /// @brief load a simulation with the given arguments
70 : static void load(const std::vector<std::string>& args);
71 :
72 : /// @brief Advances by one step (or up to the given time)
73 : //static void simulationStep(const SUMOTime time = 0);
74 :
75 : /// @brief {object->{variable->value}}
76 : typedef std::map<int, TraCIValue> TraCIValues;
77 : typedef std::map<std::string, TraCIValues> SubscribedValues;
78 : typedef std::map<std::string, SubscribedValues> SubscribedContextValues;
79 :
80 : //void subscribe(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, const std::vector<int>& vars) const;
81 : //void subscribeContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector<int>& vars) const;
82 :
83 : const SubscribedValues& getSubscriptionResults() const;
84 : const TraCIValues& getSubscriptionResults(const std::string& objID) const;
85 :
86 : const SubscribedContextValues& getContextSubscriptionResults() const;
87 : const SubscribedValues& getContextSubscriptionResults(const std::string& objID) const;
88 :
89 : /// @brief helper functions
90 : static TraCIPositionVector makeTraCIPositionVector(const PositionVector& positionVector);
91 : static TraCIPosition makeTraCIPosition(const Position& position);
92 : static Position makePosition(const TraCIPosition& position);
93 :
94 : static PositionVector makePositionVector(const TraCIPositionVector& vector);
95 : static TraCIColor makeTraCIColor(const RGBColor& color);
96 : static RGBColor makeRGBColor(const TraCIColor& color);
97 :
98 : static MSEdge* getEdge(const std::string& edgeID);
99 : static const MSLane* getLaneChecking(const std::string& edgeID, int laneIndex, double pos);
100 : static std::pair<MSLane*, double> convertCartesianToRoadMap(Position pos);
101 :
102 9863683 : static std::vector<std::string>& getLoadArgs() {
103 9863683 : return myLoadArgs;
104 : }
105 :
106 : private:
107 : /// @brief invalidated copy constructor
108 : TraCI(const TraCI& src);
109 :
110 : /// @brief invalidated assignment operator
111 : TraCI& operator=(const TraCI& src);
112 :
113 : SubscribedValues mySubscribedValues;
114 : SubscribedContextValues mySubscribedContextValues;
115 :
116 : static std::vector<std::string> myLoadArgs;
117 : };
118 :
119 :
120 : #endif
121 :
122 : /****************************************************************************/
123 :
|