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) {
157TrafficLight::getServedPersonCount(
const std::string& tlsID,
int index) {
164std::vector<std::string>
165TrafficLight::getBlockingVehicles(
const std::string& tlsID,
int linkIndex) {
172std::vector<std::string>
173TrafficLight::getRivalVehicles(
const std::string& tlsID,
int linkIndex) {
180std::vector<std::string>
181TrafficLight::getPriorityVehicles(
const std::string& tlsID,
int linkIndex) {
188std::vector<libsumo::TraCISignalConstraint>
189TrafficLight::getConstraints(
const std::string& tlsID,
const std::string& tripId) {
190 std::vector<libsumo::TraCISignalConstraint> result;
199 for (
int i = 0; i < n; ++i) {
210 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
211 c.
param[paramItems[j]] = paramItems[j + 1];
218std::vector<libsumo::TraCISignalConstraint>
219TrafficLight::getConstraintsByFoe(
const std::string& foeSignal,
const std::string& foeId) {
220 std::vector<libsumo::TraCISignalConstraint> result;
229 for (
int i = 0; i < n; ++i) {
240 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
241 c.
param[paramItems[j]] = paramItems[j + 1];
251TrafficLight::setRedYellowGreenState(
const std::string& tlsID,
const std::string& state) {
257TrafficLight::setPhase(
const std::string& tlsID,
const int index) {
263TrafficLight::setPhaseName(
const std::string& tlsID,
const std::string& name) {
269TrafficLight::setProgram(
const std::string& tlsID,
const std::string& programID) {
275TrafficLight::setPhaseDuration(
const std::string& tlsID,
const double phaseDuration) {
288 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.
phases) {
295 for (
int n : phase->next) {
308std::vector<libsumo::TraCISignalConstraint>
309TrafficLight::swapConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
310 std::vector<libsumo::TraCISignalConstraint> result;
323 for (
int i = 0; i < n; ++i) {
334 for (
int j = 0; j < (int)paramItems.size(); j += 2) {
335 c.
param[paramItems[j]] = paramItems[j + 1];
344TrafficLight::removeConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
355TrafficLight::updateConstraints(
const std::string& vehID, std::string tripId) {
361 std::ostringstream tmp;
362 for (
double d : value) {
365 std::string tmp2 = tmp.str();
372TrafficLight::setNemaSplits(
const std::string& tlsID,
const std::vector<double>& splits) {
373 setParameter(tlsID,
"NEMA.splits",
to_string(splits));
377TrafficLight::setNemaMaxGreens(
const std::string& tlsID,
const std::vector<double>& maxGreens) {
378 setParameter(tlsID,
"NEMA.maxGreens",
to_string(maxGreens));
382TrafficLight::setNemaCycleLength(
const std::string& tlsID,
double cycleLength) {
383 setParameter(tlsID,
"NEMA.cycleLength",
std::to_string(cycleLength));
387TrafficLight::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 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
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