Eclipse SUMO - Simulation of Urban MObility
libtraci/InductionLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2020 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 /****************************************************************************/
21 // C++ TraCI client API implementation
22 /****************************************************************************/
23 #include <config.h>
24 
25 #define LIBTRACI 1
26 #include <libsumo/InductionLoop.h>
27 #include "Connection.h"
28 #include "Domain.h"
29 
30 
31 namespace libtraci {
32 
33 typedef Domain<libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE, libsumo::CMD_SET_INDUCTIONLOOP_VARIABLE> Dom;
34 
35 
36 // ===========================================================================
37 // member definitions
38 // ===========================================================================
39 std::vector<std::string>
40 InductionLoop::getIDList() {
42 }
43 
44 
45 int
46 InductionLoop::getIDCount() {
47  return Dom::getInt(libsumo::ID_COUNT, "");
48 }
49 
50 
51 double
52 InductionLoop::getPosition(const std::string& detID) {
54 }
55 
56 
57 std::string
58 InductionLoop::getLaneID(const std::string& detID) {
59  return Dom::getString(libsumo::VAR_LANE_ID, detID);
60 }
61 
62 
63 int
64 InductionLoop::getLastStepVehicleNumber(const std::string& detID) {
66 }
67 
68 
69 double
70 InductionLoop::getLastStepMeanSpeed(const std::string& detID) {
72 }
73 
74 
75 std::vector<std::string>
76 InductionLoop::getLastStepVehicleIDs(const std::string& detID) {
78 }
79 
80 
81 double
82 InductionLoop::getLastStepOccupancy(const std::string& detID) {
84 }
85 
86 
87 double
88 InductionLoop::getLastStepMeanLength(const std::string& detID) {
90 }
91 
92 
93 double
94 InductionLoop::getTimeSinceDetection(const std::string& detID) {
96 }
97 
98 
99 std::vector<libsumo::TraCIVehicleData>
100 InductionLoop::getVehicleData(const std::string& detID) {
101  std::vector<libsumo::TraCIVehicleData> result;
104  ret.readInt(); // components
105  // number of items
106  ret.readUnsignedByte();
107  const int n = ret.readInt();
108  for (int i = 0; i < n; ++i) {
110 
111  ret.readUnsignedByte();
112  vd.id = ret.readString();
113 
114  ret.readUnsignedByte();
115  vd.length = ret.readDouble();
116 
117  ret.readUnsignedByte();
118  vd.entryTime = ret.readDouble();
119 
120  ret.readUnsignedByte();
121  vd.leaveTime = ret.readDouble();
122 
123  ret.readUnsignedByte();
124  vd.typeID = ret.readString();
125 
126  result.push_back(vd);
127  }
128  }
129  return result;
130 }
131 
132 
135 
136 
137 } // namespace libtraci
138 
139 /****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:36
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:74
C++ TraCI client API implementation.
static Connection & getActive()
Definition: Connection.h:53
tcpip::Storage & doCommand(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Connection.cpp:366
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:140
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:136
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:116
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:120
virtual std::string readString()
Definition: storage.cpp:175
virtual int readUnsignedByte()
Definition: storage.cpp:150
virtual double readDouble()
Definition: storage.cpp:357
virtual int readInt()
Definition: storage.cpp:306
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_DATA
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_POSITION
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int LAST_STEP_TIME_SINCE_DETECTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:328
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:330
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:334
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:338
double length
Length of the vehicle.
Definition: TraCIDefs.h:332
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:336