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) {
61 std::vector<libsumo::TraCILogic> result;
63 while (numLogics-- > 0) {
70 while (numPhases-- > 0) {
78 while (numNext-- > 0) {
82 logic.
phases.emplace_back(phase);
85 while (numParams-- > 0) {
89 result.emplace_back(logic);
95std::vector<std::string>
96TrafficLight::getControlledJunctions(
const std::string& tlsID) {
101std::vector<std::string>
102TrafficLight::getControlledLanes(
const std::string& tlsID) {
107std::vector<std::vector<libsumo::TraCILink> >
108TrafficLight::getControlledLinks(
const std::string& tlsID) {
111 std::vector< std::vector<libsumo::TraCILink> > result;
114 while (numSignals-- > 0) {
115 std::vector<libsumo::TraCILink> controlledLinks;
117 while (numLinks-- > 0) {
119 controlledLinks.emplace_back(link[0], link[2], link[1]);
121 result.emplace_back(controlledLinks);
128TrafficLight::getProgram(
const std::string& tlsID) {
134TrafficLight::getPhase(
const std::string& tlsID) {
140TrafficLight::getPhaseName(
const std::string& tlsID) {
146TrafficLight::getPhaseDuration(
const std::string& tlsID) {
152TrafficLight::getNextSwitch(
const std::string& tlsID) {
158TrafficLight::getSpentDuration(
const std::string& tlsID) {
164TrafficLight::getServedPersonCount(
const std::string& tlsID,
int index) {
171std::vector<std::string>
172TrafficLight::getBlockingVehicles(
const std::string& tlsID,
int linkIndex) {
179std::vector<std::string>
180TrafficLight::getRivalVehicles(
const std::string& tlsID,
int linkIndex) {
187std::vector<std::string>
188TrafficLight::getPriorityVehicles(
const std::string& tlsID,
int linkIndex) {
195std::vector<libsumo::TraCISignalConstraint>
196TrafficLight::getConstraints(
const std::string& tlsID,
const std::string& tripId) {
197 std::vector<libsumo::TraCISignalConstraint> result;
206 for (
int i = 0; i < n; ++i) {
217 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
218 c.
param[paramItems[j]] = paramItems[j + 1];
225std::vector<libsumo::TraCISignalConstraint>
226TrafficLight::getConstraintsByFoe(
const std::string& foeSignal,
const std::string& foeId) {
227 std::vector<libsumo::TraCISignalConstraint> result;
236 for (
int i = 0; i < n; ++i) {
247 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
248 c.
param[paramItems[j]] = paramItems[j + 1];
258TrafficLight::setRedYellowGreenState(
const std::string& tlsID,
const std::string& state) {
264TrafficLight::setPhase(
const std::string& tlsID,
const int index) {
270TrafficLight::setPhaseName(
const std::string& tlsID,
const std::string& name) {
276TrafficLight::setProgram(
const std::string& tlsID,
const std::string& programID) {
282TrafficLight::setPhaseDuration(
const std::string& tlsID,
const double phaseDuration) {
295 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.
phases) {
302 for (
int n : phase->next) {
316TrafficLight::addConstraint(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId,
const int type,
const int limit) {
328std::vector<libsumo::TraCISignalConstraint>
329TrafficLight::swapConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
330 std::vector<libsumo::TraCISignalConstraint> result;
342 for (
int i = 0; i < n; ++i) {
353 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
354 c.
param[paramItems[j]] = paramItems[j + 1];
363TrafficLight::removeConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
373TrafficLight::updateConstraints(
const std::string& vehID, std::string tripId) {
379 std::ostringstream tmp;
380 for (
double d : value) {
383 std::string tmp2 = tmp.str();
390TrafficLight::setNemaSplits(
const std::string& tlsID,
const std::vector<double>& splits) {
391 setParameter(tlsID,
"NEMA.splits",
to_string(splits));
395TrafficLight::setNemaMaxGreens(
const std::string& tlsID,
const std::vector<double>& maxGreens) {
396 setParameter(tlsID,
"NEMA.maxGreens",
to_string(maxGreens));
400TrafficLight::setNemaCycleLength(
const std::string& tlsID,
double cycleLength) {
401 setParameter(tlsID,
"NEMA.cycleLength", std::to_string(cycleLength));
405TrafficLight::setNemaOffset(
const std::string& tlsID,
double offset) {
406 setParameter(tlsID,
"NEMA.offset", std::to_string(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 Connection & getActive()
std::mutex & getMutex() const
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
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 TL_SPENT_DURATION
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_CONSTRAINT_ADD
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