Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/libtraci/Calibrator.cpp
169665 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 Calibrator.cpp
15
/// @author Jakob Erdmann
16
/// @date 16.03.2020
17
///
18
// C++ TraCI client API implementation
19
/****************************************************************************/
20
#include <config.h>
21
22
#define LIBTRACI 1
23
#include <libsumo/TraCIConstants.h>
24
#include <libsumo/Calibrator.h>
25
#include "Connection.h"
26
#include "Domain.h"
27
28
29
namespace libtraci {
30
31
typedef Domain<libsumo::CMD_GET_CALIBRATOR_VARIABLE, libsumo::CMD_SET_CALIBRATOR_VARIABLE> Dom;
32
33
// ===========================================================================
34
// static member definitions
35
// ===========================================================================
36
std::vector<std::string>
37
Calibrator::getIDList() {
38
return Dom::getStringVector(libsumo::TRACI_ID_LIST, "");
39
}
40
41
int
42
Calibrator::getIDCount() {
43
return Dom::getInt(libsumo::ID_COUNT, "");
44
}
45
46
std::string
47
Calibrator::getEdgeID(const std::string& calibratorID) {
48
return Dom::getString(libsumo::VAR_ROAD_ID, calibratorID);
49
}
50
51
std::string
52
Calibrator::getLaneID(const std::string& calibratorID) {
53
return Dom::getString(libsumo::VAR_LANE_ID, calibratorID);
54
}
55
56
double
57
Calibrator::getVehsPerHour(const std::string& calibratorID) {
58
return Dom::getDouble(libsumo::VAR_VEHSPERHOUR, calibratorID);
59
}
60
61
double
62
Calibrator::getSpeed(const std::string& calibratorID) {
63
return Dom::getDouble(libsumo::VAR_SPEED, calibratorID);
64
}
65
66
std::string
67
Calibrator::getTypeID(const std::string& calibratorID) {
68
return Dom::getString(libsumo::VAR_TYPE, calibratorID);
69
}
70
71
double
72
Calibrator::getBegin(const std::string& calibratorID) {
73
return Dom::getDouble(libsumo::VAR_BEGIN, calibratorID);
74
}
75
76
double
77
Calibrator::getEnd(const std::string& calibratorID) {
78
return Dom::getDouble(libsumo::VAR_END, calibratorID);
79
}
80
81
std::string
82
Calibrator::getRouteID(const std::string& calibratorID) {
83
return Dom::getString(libsumo::VAR_ROUTE_ID, calibratorID);
84
}
85
86
std::string
87
Calibrator::getRouteProbeID(const std::string& calibratorID) {
88
return Dom::getString(libsumo::VAR_ROUTE_PROBE, calibratorID);
89
}
90
91
std::vector<std::string>
92
Calibrator::getVTypes(const std::string& calibratorID) {
93
return Dom::getStringVector(libsumo::VAR_VTYPES, calibratorID);
94
}
95
96
97
int
98
Calibrator::getPassed(const std::string& calibratorID) {
99
return Dom::getInt(libsumo::VAR_PASSED, calibratorID);
100
}
101
102
int
103
Calibrator::getInserted(const std::string& calibratorID) {
104
return Dom::getInt(libsumo::VAR_INSERTED, calibratorID);
105
}
106
107
int
108
Calibrator::getRemoved(const std::string& calibratorID) {
109
return Dom::getInt(libsumo::VAR_REMOVED, calibratorID);
110
}
111
112
LIBTRACI_PARAMETER_IMPLEMENTATION(Calibrator, CALIBRATOR)
113
114
void
115
Calibrator::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;
118
content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
119
content.writeInt(8);
120
content.writeByte(libsumo::TYPE_DOUBLE);
121
content.writeDouble(begin);
122
content.writeByte(libsumo::TYPE_DOUBLE);
123
content.writeDouble(end);
124
content.writeByte(libsumo::TYPE_DOUBLE);
125
content.writeDouble(vehsPerHour);
126
content.writeByte(libsumo::TYPE_DOUBLE);
127
content.writeDouble(speed);
128
content.writeByte(libsumo::TYPE_STRING);
129
content.writeString(typeID);
130
content.writeByte(libsumo::TYPE_STRING);
131
content.writeString(routeID);
132
content.writeByte(libsumo::TYPE_STRING);
133
content.writeString(departLane);
134
content.writeByte(libsumo::TYPE_STRING);
135
content.writeString(departSpeed);
136
Dom::set(libsumo::CMD_SET_FLOW, calibratorID, &content);
137
}
138
139
LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(Calibrator, CALIBRATOR)
140
141
142
}
143
144
145
/****************************************************************************/
146
147