Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libtraci/Calibrator.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2017-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/****************************************************************************/
18// C++ TraCI client API implementation
19/****************************************************************************/
20#include <config.h>
21
22#define LIBTRACI 1
24#include <libsumo/Calibrator.h>
25#include "Connection.h"
26#include "Domain.h"
27
28
29namespace libtraci {
30
31typedef Domain<libsumo::CMD_GET_CALIBRATOR_VARIABLE, libsumo::CMD_SET_CALIBRATOR_VARIABLE> Dom;
32
33// ===========================================================================
34// static member definitions
35// ===========================================================================
36std::vector<std::string>
37Calibrator::getIDList() {
39}
40
41int
42Calibrator::getIDCount() {
44}
45
46std::string
47Calibrator::getEdgeID(const std::string& calibratorID) {
48 return Dom::getString(libsumo::VAR_ROAD_ID, calibratorID);
49}
50
51std::string
52Calibrator::getLaneID(const std::string& calibratorID) {
53 return Dom::getString(libsumo::VAR_LANE_ID, calibratorID);
54}
55
56double
57Calibrator::getVehsPerHour(const std::string& calibratorID) {
58 return Dom::getDouble(libsumo::VAR_VEHSPERHOUR, calibratorID);
59}
60
61double
62Calibrator::getSpeed(const std::string& calibratorID) {
63 return Dom::getDouble(libsumo::VAR_SPEED, calibratorID);
64}
65
66std::string
67Calibrator::getTypeID(const std::string& calibratorID) {
68 return Dom::getString(libsumo::VAR_TYPE, calibratorID);
69}
70
71double
72Calibrator::getBegin(const std::string& calibratorID) {
73 return Dom::getDouble(libsumo::VAR_BEGIN, calibratorID);
74}
75
76double
77Calibrator::getEnd(const std::string& calibratorID) {
78 return Dom::getDouble(libsumo::VAR_END, calibratorID);
79}
80
81std::string
82Calibrator::getRouteID(const std::string& calibratorID) {
83 return Dom::getString(libsumo::VAR_ROUTE_ID, calibratorID);
84}
85
86std::string
87Calibrator::getRouteProbeID(const std::string& calibratorID) {
88 return Dom::getString(libsumo::VAR_ROUTE_PROBE, calibratorID);
89}
90
91std::vector<std::string>
92Calibrator::getVTypes(const std::string& calibratorID) {
93 return Dom::getStringVector(libsumo::VAR_VTYPES, calibratorID);
94}
95
96
97int
98Calibrator::getPassed(const std::string& calibratorID) {
99 return Dom::getInt(libsumo::VAR_PASSED, calibratorID);
100}
101
102int
103Calibrator::getInserted(const std::string& calibratorID) {
104 return Dom::getInt(libsumo::VAR_INSERTED, calibratorID);
105}
106
107int
108Calibrator::getRemoved(const std::string& calibratorID) {
109 return Dom::getInt(libsumo::VAR_REMOVED, calibratorID);
110}
111
113
114void
115Calibrator::setFlow(const std::string& calibratorID, double begin, double end, double vehsPerHour, double speed,
116 const std::string& typeID, const std::string& routeID, const std::string& departLane, const std::string& departSpeed) {
117 tcpip::Storage content;
119 content.writeInt(8);
121 content.writeDouble(begin);
123 content.writeDouble(end);
125 content.writeDouble(vehsPerHour);
127 content.writeDouble(speed);
129 content.writeString(typeID);
131 content.writeString(routeID);
133 content.writeString(departLane);
135 content.writeString(departSpeed);
136 Dom::set(libsumo::CMD_SET_FLOW, calibratorID, &content);
137}
138
140
141
142}
143
144
145/****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:77
C++ TraCI client API implementation.
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:177
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:172
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:125
static void set(int var, const std::string &id, tcpip::Storage *add)
Definition Domain.h:219
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:130
virtual void writeString(const std::string &s)
Definition storage.cpp:197
virtual void writeInt(int)
Definition storage.cpp:321
virtual void writeDouble(double)
Definition storage.cpp:354
virtual void writeUnsignedByte(int)
Definition storage.cpp:165
virtual void writeByte(int)
Definition storage.cpp:140
TRACI_CONST int VAR_VEHSPERHOUR
TRACI_CONST int VAR_BEGIN
TRACI_CONST int CMD_SET_FLOW
TRACI_CONST int VAR_ROUTE_PROBE
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_REMOVED
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int VAR_VTYPES
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_END
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_INSERTED
TRACI_CONST int VAR_PASSED
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TYPE_STRING
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom