Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/libsumo/InductionLoop.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2017-2025 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 InductionLoop.h
15
/// @author Michael Behrisch
16
/// @date 15.03.2017
17
///
18
// C++ TraCI client API implementation
19
/****************************************************************************/
20
#pragma once
21
#include <string>
22
#include <vector>
23
#include <libsumo/TraCIDefs.h>
24
25
26
// ===========================================================================
27
// class declarations
28
// ===========================================================================
29
#ifndef LIBTRACI
30
class NamedRTree;
31
class MSInductLoop;
32
class MEInductLoop;
33
class PositionVector;
34
#endif
35
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
/**
41
* @class InductionLoop
42
* @brief C++ TraCI client API implementation
43
*/
44
namespace LIBSUMO_NAMESPACE {
45
class InductionLoop {
46
public:
47
static double getPosition(const std::string& loopID);
48
static std::string getLaneID(const std::string& loopID);
49
static int getLastStepVehicleNumber(const std::string& loopID);
50
static double getLastStepMeanSpeed(const std::string& loopID);
51
static std::vector<std::string> getLastStepVehicleIDs(const std::string& loopID);
52
static double getLastStepOccupancy(const std::string& loopID);
53
static double getLastStepMeanLength(const std::string& loopID);
54
static double getTimeSinceDetection(const std::string& loopID);
55
static std::vector<libsumo::TraCIVehicleData> getVehicleData(const std::string& loopID);
56
57
static double getIntervalOccupancy(const std::string& loopID);
58
static double getIntervalMeanSpeed(const std::string& loopID);
59
static int getIntervalVehicleNumber(const std::string& loopID);
60
static std::vector<std::string> getIntervalVehicleIDs(const std::string& loopID);
61
62
static double getLastIntervalOccupancy(const std::string& loopID);
63
static double getLastIntervalMeanSpeed(const std::string& loopID);
64
static int getLastIntervalVehicleNumber(const std::string& loopID);
65
static std::vector<std::string> getLastIntervalVehicleIDs(const std::string& loopID);
66
67
static void overrideTimeSinceDetection(const std::string& loopID, double time);
68
69
LIBSUMO_ID_PARAMETER_API
70
LIBSUMO_SUBSCRIPTION_API
71
72
#ifndef LIBTRACI
73
#ifndef SWIG
74
/** @brief Returns a tree filled with inductive loop instances
75
* @return The rtree of inductive loops
76
*/
77
static NamedRTree* getTree();
78
static void cleanup();
79
80
/** @brief Saves the shape of the requested object in the given container
81
* @param id The id of the loop to retrieve
82
* @param shape The container to fill
83
*/
84
static void storeShape(const std::string& id, PositionVector& shape);
85
86
static std::shared_ptr<VariableWrapper> makeWrapper();
87
88
static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
89
90
private:
91
static MSInductLoop* getDetector(const std::string& loopID);
92
static MEInductLoop* getMEDetector(const std::string& loopID);
93
94
private:
95
static SubscriptionResults mySubscriptionResults;
96
static ContextSubscriptionResults myContextSubscriptionResults;
97
static NamedRTree* myTree;
98
#endif
99
#endif
100
101
private:
102
/// @brief invalidated standard constructor
103
InductionLoop() = delete;
104
105
};
106
}
107
108