33 #pragma warning(disable: 4100)
35 #pragma GCC diagnostic ignored "-Wunused-parameter"
40 typedef Domain<libsumo::CMD_GET_TL_VARIABLE, libsumo::CMD_SET_TL_VARIABLE>
Dom;
45 std::vector<std::string>
46 TrafficLight::getIDList() {
52 TrafficLight::getIDCount() {
58 TrafficLight::getRedYellowGreenState(
const std::string& tlsID) {
63 std::vector<libsumo::TraCILogic>
64 TrafficLight::getAllProgramLogics(
const std::string& tlsID) {
66 std::vector<libsumo::TraCILogic> result;
68 while (numLogics-- > 0) {
75 while (numPhases-- > 0) {
83 while (numNext-- > 0) {
87 logic.
phases.emplace_back(phase);
90 while (numParams-- > 0) {
94 result.emplace_back(logic);
100 std::vector<std::string>
101 TrafficLight::getControlledJunctions(
const std::string& tlsID) {
106 std::vector<std::string>
107 TrafficLight::getControlledLanes(
const std::string& tlsID) {
112 std::vector<std::vector<libsumo::TraCILink> >
113 TrafficLight::getControlledLinks(
const std::string& tlsID) {
115 std::vector< std::vector<libsumo::TraCILink> > result;
118 while (numSignals-- > 0) {
119 std::vector<libsumo::TraCILink> controlledLinks;
121 while (numLinks-- > 0) {
123 controlledLinks.emplace_back(link[0], link[2], link[1]);
125 result.emplace_back(controlledLinks);
132 TrafficLight::getProgram(
const std::string& tlsID) {
138 TrafficLight::getPhase(
const std::string& tlsID) {
144 TrafficLight::getPhaseName(
const std::string& tlsID) {
150 TrafficLight::getPhaseDuration(
const std::string& tlsID) {
156 TrafficLight::getNextSwitch(
const std::string& tlsID) {
161 TrafficLight::getServedPersonCount(
const std::string& tlsID,
int index) {
168 std::vector<std::string>
169 TrafficLight::getBlockingVehicles(
const std::string& tlsID,
int linkIndex) {
176 std::vector<std::string>
177 TrafficLight::getRivalVehicles(
const std::string& tlsID,
int linkIndex) {
184 std::vector<std::string>
185 TrafficLight::getPriorityVehicles(
const std::string& tlsID,
int linkIndex) {
192 std::vector<libsumo::TraCISignalConstraint>
193 TrafficLight::getConstraints(
const std::string& tlsID,
const std::string& tripId) {
194 std::vector<libsumo::TraCISignalConstraint> result;
202 for (
int i = 0; i < n; ++i) {
216 std::vector<libsumo::TraCISignalConstraint>
217 TrafficLight::getConstraintsByFoe(
const std::string& foeSignal,
const std::string& foeId) {
218 std::vector<libsumo::TraCISignalConstraint> result;
226 for (
int i = 0; i < n; ++i) {
243 TrafficLight::setRedYellowGreenState(
const std::string& tlsID,
const std::string& state) {
249 TrafficLight::setPhase(
const std::string& tlsID,
const int index) {
255 TrafficLight::setPhaseName(
const std::string& tlsID,
const std::string& name) {
261 TrafficLight::setProgram(
const std::string& tlsID,
const std::string& programID) {
267 TrafficLight::setPhaseDuration(
const std::string& tlsID,
const double phaseDuration) {
273 TrafficLight::setProgramLogic(
const std::string& tlsID,
const libsumo::TraCILogic& logic) {
280 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.
phases) {
287 for (
int n : phase->next) {
300 std::vector<libsumo::TraCISignalConstraint>
301 TrafficLight::swapConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
302 std::vector<libsumo::TraCISignalConstraint> result;
314 for (
int i = 0; i < n; ++i) {
330 TrafficLight::removeConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
342 std::ostringstream tmp;
343 for (
double d : value) {
346 std::string tmp2 = tmp.str();
353 TrafficLight::setNemaSplits(
const std::string& tlsID,
const std::vector<double>& splits) {
354 setParameter(tlsID,
"NEMA.splits",
to_string(splits));
358 TrafficLight::setNemaMaxGreens(
const std::string& tlsID,
const std::vector<double>& maxGreens) {
359 setParameter(tlsID,
"NEMA.maxGreens",
to_string(maxGreens));
363 TrafficLight::setNemaCycleLength(
const std::string& tlsID,
double cycleLength) {
364 setParameter(tlsID,
"NEMA.cycleLength",
std::to_string(cycleLength));
368 TrafficLight::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 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 std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
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 tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
static void setInt(int var, const std::string &id, int value)
static void setString(int var, const std::string &id, const std::string &value)
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_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
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