34typedef Domain<libsumo::CMD_GET_TL_VARIABLE, libsumo::CMD_SET_TL_VARIABLE>
Dom;
39std::vector<std::string>
40TrafficLight::getIDList() {
46TrafficLight::getIDCount() {
52TrafficLight::getRedYellowGreenState(
const std::string& tlsID) {
57std::vector<libsumo::TraCILogic>
58TrafficLight::getAllProgramLogics(
const std::string& tlsID) {
60 std::vector<libsumo::TraCILogic> result;
62 while (numLogics-- > 0) {
69 while (numPhases-- > 0) {
77 while (numNext-- > 0) {
81 logic.
phases.emplace_back(phase);
84 while (numParams-- > 0) {
88 result.emplace_back(logic);
94std::vector<std::string>
95TrafficLight::getControlledJunctions(
const std::string& tlsID) {
100std::vector<std::string>
101TrafficLight::getControlledLanes(
const std::string& tlsID) {
106std::vector<std::vector<libsumo::TraCILink> >
107TrafficLight::getControlledLinks(
const std::string& tlsID) {
109 std::vector< std::vector<libsumo::TraCILink> > result;
112 while (numSignals-- > 0) {
113 std::vector<libsumo::TraCILink> controlledLinks;
115 while (numLinks-- > 0) {
117 controlledLinks.emplace_back(link[0], link[2], link[1]);
119 result.emplace_back(controlledLinks);
126TrafficLight::getProgram(
const std::string& tlsID) {
132TrafficLight::getPhase(
const std::string& tlsID) {
138TrafficLight::getPhaseName(
const std::string& tlsID) {
144TrafficLight::getPhaseDuration(
const std::string& tlsID) {
150TrafficLight::getNextSwitch(
const std::string& tlsID) {
155TrafficLight::getServedPersonCount(
const std::string& tlsID,
int index) {
162std::vector<std::string>
163TrafficLight::getBlockingVehicles(
const std::string& tlsID,
int linkIndex) {
170std::vector<std::string>
171TrafficLight::getRivalVehicles(
const std::string& tlsID,
int linkIndex) {
178std::vector<std::string>
179TrafficLight::getPriorityVehicles(
const std::string& tlsID,
int linkIndex) {
186std::vector<libsumo::TraCISignalConstraint>
187TrafficLight::getConstraints(
const std::string& tlsID,
const std::string& tripId) {
188 std::vector<libsumo::TraCISignalConstraint> result;
196 for (
int i = 0; i < n; ++i) {
207 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
208 c.
param[paramItems[j]] = paramItems[j + 1];
215std::vector<libsumo::TraCISignalConstraint>
216TrafficLight::getConstraintsByFoe(
const std::string& foeSignal,
const std::string& foeId) {
217 std::vector<libsumo::TraCISignalConstraint> result;
225 for (
int i = 0; i < n; ++i) {
236 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
237 c.
param[paramItems[j]] = paramItems[j + 1];
247TrafficLight::setRedYellowGreenState(
const std::string& tlsID,
const std::string& state) {
253TrafficLight::setPhase(
const std::string& tlsID,
const int index) {
259TrafficLight::setPhaseName(
const std::string& tlsID,
const std::string& name) {
265TrafficLight::setProgram(
const std::string& tlsID,
const std::string& programID) {
271TrafficLight::setPhaseDuration(
const std::string& tlsID,
const double phaseDuration) {
284 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.
phases) {
291 for (
int n : phase->next) {
304std::vector<libsumo::TraCISignalConstraint>
305TrafficLight::swapConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
306 std::vector<libsumo::TraCISignalConstraint> result;
318 for (
int i = 0; i < n; ++i) {
329 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
330 c.
param[paramItems[j]] = paramItems[j + 1];
339TrafficLight::removeConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
350TrafficLight::updateConstraints(
const std::string& vehID, std::string tripId) {
356 std::ostringstream tmp;
357 for (
double d : value) {
360 std::string tmp2 = tmp.str();
367TrafficLight::setNemaSplits(
const std::string& tlsID,
const std::vector<double>& splits) {
368 setParameter(tlsID,
"NEMA.splits",
to_string(splits));
372TrafficLight::setNemaMaxGreens(
const std::string& tlsID,
const std::vector<double>& maxGreens) {
373 setParameter(tlsID,
"NEMA.maxGreens",
to_string(maxGreens));
377TrafficLight::setNemaCycleLength(
const std::string& tlsID,
double cycleLength) {
378 setParameter(tlsID,
"NEMA.cycleLength",
std::to_string(cycleLength));
382TrafficLight::setNemaOffset(
const std::string& tlsID,
double offset) {
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
C++ TraCI client API implementation.
static int readTypedByte(tcpip::Storage &ret, const std::string &error="")
static void writeTypedDouble(tcpip::Storage &content, double value)
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static void writeCompound(tcpip::Storage &content, int size)
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedStringList(tcpip::Storage &content, const std::vector< std::string > &value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
std::map< std::string, std::string > subParameter
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
static void setDouble(int var, const std::string &id, double value)
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void set(int var, const std::string &id, tcpip::Storage *add)
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void setInt(int var, const std::string &id, int value)
static void setString(int var, const std::string &id, const std::string &value)
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
virtual void writeInt(int)
virtual int readUnsignedByte()
virtual void writeUnsignedByte(int)
StorageType::size_type size() const
virtual void writeByte(int)
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int TL_CONSTRAINT_REMOVE
TRACI_CONST int TL_BLOCKING_VEHICLES
TRACI_CONST int TL_CONSTRAINT_SWAP
TRACI_CONST int TL_PRIORITY_VEHICLES
TRACI_CONST int TL_CONTROLLED_LANES
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int TL_CONSTRAINT_UPDATE
TRACI_CONST int TL_CONTROLLED_JUNCTIONS
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int TL_CONSTRAINT_BYFOE
TRACI_CONST int TL_CONSTRAINT
TRACI_CONST int TL_NEXT_SWITCH
TRACI_CONST int TL_PROGRAM
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TL_CURRENT_PHASE
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TL_CURRENT_PROGRAM
TRACI_CONST int TL_RIVAL_VEHICLES
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
std::string to_string(const std::vector< double > &value)
std::string foeId
the tripId or vehicle id of the train that must pass first
std::string tripId
the tripId or vehicle id of the train that is constrained
std::string foeSignal
the tlsID of the rail signla that the foe must pass first
std::string signalId
the idea of the rail signal where this constraint is active
std::map< std::string, std::string > param
additional parameters
bool active
whether this constraint is active
int type
the type of constraint (predecessor:0, insertionPredecessor:1)
bool mustWait
whether tripId must still wait for foeId to pass foeSignal
int limit
the number of trains that must be recorded at the foeSignal