59std::vector<std::string>
60TrafficLight::getIDList() {
66TrafficLight::getIDCount() {
67 return (
int)getIDList().size();
72TrafficLight::getRedYellowGreenState(
const std::string& tlsID) {
77std::vector<TraCILogic>
78TrafficLight::getAllProgramLogics(
const std::string& tlsID) {
79 std::vector<TraCILogic> result;
82 TraCILogic l(logic->getProgramID(), (
int)logic->getLogicType(), logic->getCurrentPhaseIndex());
84 l.subParameter = logic->getParametersMap();
86 l.phases.emplace_back(
new TraCIPhase(
STEPS2TIME(phase->duration), phase->getState(),
88 phase->getNextPhases(), phase->getName()));
90 result.emplace_back(l);
96std::vector<std::string>
97TrafficLight::getControlledJunctions(
const std::string& tlsID) {
98 std::set<std::string> junctionIDs;
101 for (
const MSLink* l : llinks) {
102 junctionIDs.insert(l->getJunction()->getID());
105 return std::vector<std::string>(junctionIDs.begin(), junctionIDs.end());
109std::vector<std::string>
110TrafficLight::getControlledLanes(
const std::string& tlsID) {
111 std::vector<std::string> laneIDs;
114 for (
const MSLane* l : llanes) {
115 laneIDs.push_back(l->getID());
122std::vector<std::vector<TraCILink> >
123TrafficLight::getControlledLinks(
const std::string& tlsID) {
124 std::vector<std::vector<TraCILink> > result;
127 for (
int i = 0; i < (int)lanes.size(); ++i) {
128 std::vector<TraCILink> subList;
132 for (
int j = 0; j < (int)llanes.size(); ++j) {
138 subList.emplace_back(TraCILink(llanes[j]->getID(), via, to));
140 result.emplace_back(subList);
147TrafficLight::getProgram(
const std::string& tlsID) {
153TrafficLight::getPhase(
const std::string& tlsID) {
159TrafficLight::getPhaseName(
const std::string& tlsID) {
165TrafficLight::getPhaseDuration(
const std::string& tlsID) {
171TrafficLight::getNextSwitch(
const std::string& tlsID) {
177TrafficLight::getSpentDuration(
const std::string& tlsID) {
182TrafficLight::getServedPersonCount(
const std::string& tlsID,
int index) {
184 if (index < 0 || active->getPhaseNumber() <= index) {
185 throw TraCIException(
"The phase index " +
toString(index) +
" is not in the allowed range [0,"
191 const std::string& state = active->
getPhases()[index]->getState();
192 for (
int i = 0; i < (int)state.size(); i++) {
195 if (link->getLane()->isCrossing()) {
197 for (
MSTransportable* person : link->getLaneBefore()->getEdge().getPersons()) {
209 }
else if (link->getLaneBefore()->isCrossing()) {
211 for (
MSTransportable* person : link->getLane()->getEdge().getPersons()) {
212 if (
static_cast<MSPerson*
>(person)->
getNextEdge() == link->getLaneBefore()->getEdge().getID()) {
223std::vector<std::string>
224TrafficLight::getBlockingVehicles(
const std::string& tlsID,
int linkIndex) {
225 std::vector<std::string> result;
228 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
229 throw TraCIException(
"The link index " +
toString(linkIndex) +
" is not in the allowed range [0,"
233 result.push_back(veh->getID());
238std::vector<std::string>
239TrafficLight::getRivalVehicles(
const std::string& tlsID,
int linkIndex) {
240 std::vector<std::string> result;
242 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
243 throw TraCIException(
"The link index " +
toString(linkIndex) +
" is not in the allowed range [0,"
247 result.push_back(veh->getID());
252std::vector<std::string>
253TrafficLight::getPriorityVehicles(
const std::string& tlsID,
int linkIndex) {
254 std::vector<std::string> result;
256 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
257 throw TraCIException(
"The link index " +
toString(linkIndex) +
" is not in the allowed range [0,"
261 result.push_back(veh->getID());
266std::vector<TraCISignalConstraint>
267TrafficLight::getConstraints(
const std::string& tlsID,
const std::string& tripId) {
268 std::vector<TraCISignalConstraint> result;
272 throw TraCIException(
"'" + tlsID +
"' is not a rail signal");
275 if (tripId !=
"" && tripId != item.first) {
279 result.push_back(buildConstraint(tlsID, item.first, c));
285std::vector<TraCISignalConstraint>
286TrafficLight::getConstraintsByFoe(
const std::string& foeSignal,
const std::string& foeId) {
289 std::vector<TraCISignalConstraint> result;
290 for (
const std::string& tlsID : getIDList()) {
298 && (foeId ==
"" || pc->
myTripId == foeId)) {
299 result.push_back(buildConstraint(s->
getID(), item.first, pc));
310TrafficLight::addConstraint(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId,
const int type,
const int limit) {
316 throw TraCIException(
"'" + tlsID +
"' is not a rail signal");
319 throw TraCIException(
"'" + foeSignal +
"' is not a rail signal");
326std::vector<TraCISignalConstraint>
327TrafficLight::swapConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
328#ifdef DEBUG_CONSTRAINT_DEADLOCK
329 std::cout <<
"swapConstraints tlsId=" << tlsID <<
" tripId=" << tripId <<
" foeSignal=" << foeSignal <<
" foeId=" << foeId <<
"\n";
336 throw TraCIException(
"'" + tlsID +
"' is not a rail signal");
339 throw TraCIException(
"'" + foeSignal +
"' is not a rail signal");
343 if (tripId == item.first) {
360 swapParameters(swapped);
363 return findConstraintsDeadLocks(foeId, tripId, foeSignal, tlsID);
365 throw TraCIException(
"Rail signal '" + tlsID +
"' does not have a constraint for tripId '" + tripId +
"' with foeSignal '" + foeSignal +
"' and foeId '" + foeId +
"'");
370std::vector<std::pair<std::string, std::string> >
371TrafficLight::getSwapParams(
int constraintType) {
372 std::vector<std::pair<std::string, std::string> > result({
375 {
"arrival",
"foeArrival"}});
378 std::vector<std::pair<std::string, std::string> > special({
379 {
"busStop",
"busStop2"},
380 {
"priorStop",
"priorStop2"},
381 {
"stopArrival",
"foeStopArrival"}});
382 result.insert(result.end(), special.begin(), special.end());
391 for (
auto keys : getSwapParams(c->
getType())) {
392 swapParameters(c, keys.first, keys.second);
413TrafficLight::swapParameters(TraCISignalConstraint& c) {
415 for (
auto keys : getSwapParams(c.type)) {
416 swapParameters(c, keys.first, keys.second);
421TrafficLight::swapParameters(TraCISignalConstraint& c,
const std::string& key1,
const std::string& key2) {
422 auto it1 = c.param.find(key1);
423 auto it2 = c.param.find(key2);
424 const std::string value1 = it1 != c.param.end() ? it1->second :
"";
425 const std::string value2 = it2 != c.param.end() ? it2->second :
"";
427 c.param[key2] = value1;
432 c.param[key1] = value2;
440TrafficLight::removeConstraints(
const std::string& tlsID,
const std::string& tripId,
const std::string& foeSignal,
const std::string& foeId) {
443 for (
const std::string& tlsCand : getIDList()) {
444 if (tlsID ==
"" || tlsCand == tlsID) {
449 if (tripId ==
"" || item.first == tripId) {
453 && (foeId ==
"" || pc->
myTripId == foeId)
467TrafficLight::updateConstraints(
const std::string& vehID, std::string tripId) {
474 tripId = tripId ==
"" ? curTripId : tripId;
477 std::map<const MSRailSignal*, std::set<std::string> > onRoute;
481 for (
auto it = routeIt; it < stop.edge; it++) {
484 if (it + 1 != route.end()) {
485 const MSEdge* next = *(it + 1);
487 if (link !=
nullptr && link->
getTLLogic() !=
nullptr) {
489 onRoute[s].insert(curTripId);
494 if (stop.pars.tripId !=
"") {
495 curTripId = stop.pars.tripId;
499 for (
auto it = routeIt; it < route.end(); it++) {
502 if (it + 1 != route.end()) {
503 const MSEdge* next = *(it + 1);
505 if (link !=
nullptr && link->
getTLLogic() !=
nullptr) {
507 onRoute[s].insert(curTripId);
520 std::vector<MSRailSignalConstraint*> onVeh;
521 std::vector<std::pair<std::string, MSRailSignalConstraint*> > byVeh;
523 for (
auto item : s->getConstraints()) {
527 if (item.first == tripId) {
528 if (onRoute[s].count(tripId) == 0) {
530 onVeh.push_back(cand);
532 }
else if (pc->
myTripId == tripId) {
535 byVeh.push_back(std::make_pair(item.first, cand));
542 s->removeConstraint(tripId, c);
544 for (
auto item : byVeh) {
545 s->removeConstraint(item.first, item.second);
551std::vector<TraCISignalConstraint>
552TrafficLight::findConstraintsDeadLocks(
const std::string& foeId,
const std::string& tripId,
const std::string& foeSignal,
const std::string& tlsID) {
553 std::vector<TraCISignalConstraint> result;
559 std::map<std::string, TraCISignalConstraint> constraintsOnTripId;
560 std::map<std::string, TraCISignalConstraint> constrainedByFoeId;
561 std::set<std::string> foeId2Cands1;
562 std::set<std::string> foeId2Cands2;
564 for (
auto item : s->getConstraints()) {
568 if (item.first == tripId) {
572 constraintsOnTripId[pc->
myTripId] = tsc;
574 for (std::string& futureFoe2Id : getFutureTripIds(pc->
myTripId)) {
575 foeId2Cands1.insert(futureFoe2Id);
577 constraintsOnTripId[futureFoe2Id] = tsc;
582 constrainedByFoeId[item.first] = tsc;
583 foeId2Cands2.insert(item.first);
584 for (std::string& futureTripId : getFutureTripIds(item.first)) {
585 foeId2Cands2.insert(futureTripId);
587 constrainedByFoeId[futureTripId] = tsc;
594#ifdef DEBUG_CONSTRAINT_DEADLOCK
595 std::cout <<
"findConstraintsDeadLocks foeId=" << foeId <<
" tripId=" << tripId <<
" foeSignal=" << foeSignal <<
" tlsID=" << tlsID <<
"\n";
596 std::cout <<
" foeId2Cands1=" <<
toString(foeId2Cands1) <<
"\n";
597 std::cout <<
" foeId2Cands2=" <<
toString(foeId2Cands2) <<
"\n";
599 if (foeId2Cands1.size() > 0) {
607 if (foe !=
nullptr) {
610 for (
const std::string& foeId2 : foeId2Cands1) {
613 if (foe2 !=
nullptr) {
615 const TraCISignalConstraint& c = constraintsOnTripId[foeId2];
616 bool foeAhead =
false;
618 const MSEdge* e = foe2Route[i];
627#ifdef DEBUG_CONSTRAINT_DEADLOCK
628 std::cout <<
"findConstraintsDeadLocks foeId=" << foeId <<
" tripId=" << tripId <<
" foeSignal=" << foeSignal <<
"\n";
632 <<
" " << constraintsOnTripId[foeId2].getString() <<
"\n";
643 TraCISignalConstraint nc;
646 nc.signalId = c.foeSignal;
647 nc.foeSignal = c.signalId;
654 result.push_back(nc);
656 std::vector<TraCISignalConstraint> result2 = swapConstraints(c.signalId, c.tripId, c.foeSignal, c.foeId);
657 result.insert(result.end(), result2.begin(), result2.end());
660 const std::vector<TraCISignalConstraint>& result4 = findConstraintsDeadLocks(foeId, tripId, foeSignal, tlsID);
661 result.insert(result.end(), result4.begin(), result4.end());
669 if (foeId2Cands2.size() > 0) {
676 std::set<const MSEdge*> egoToSignal;
680 const MSEdge* e = egoRoute[i];
681 egoToSignal.insert(e);
687 for (
const std::string& foeId2 : foeId2Cands2) {
691 if (foe2 !=
nullptr) {
692 if (egoToSignal.count(foe2->
getEdge()) != 0
694 const TraCISignalConstraint& c = constrainedByFoeId[foeId2];
695#ifdef DEBUG_CONSTRAINT_DEADLOCK
696 std::cout <<
"findConstraintsDeadLocks foeId=" << foeId <<
" tripId=" << tripId <<
" foeSignal=" << foeSignal <<
"\n";
698 <<
" " << c.getString() <<
"\n";
701 TraCISignalConstraint nc;
704 nc.signalId = c.foeSignal;
705 nc.foeSignal = c.signalId;
712 result.push_back(nc);
714 std::vector<TraCISignalConstraint> result2 = swapConstraints(c.signalId, c.tripId, c.foeSignal, c.foeId);
715 result.insert(result.end(), result2.begin(), result2.end());
718 const std::vector<TraCISignalConstraint>& result4 = findConstraintsDeadLocks(foeId, tripId, foeSignal, tlsID);
719 result.insert(result.end(), result4.begin(), result4.end());
724 }
else if (ego !=
nullptr) {
725 WRITE_WARNINGF(
TL(
"Cannot check for all deadlocks on swapConstraints because the route for vehicle '%' is not computed yet"), ego->
getID());
730 std::vector<std::string> foeIds2;
731 std::set_intersection(
732 foeId2Cands1.begin(), foeId2Cands1.end(),
733 foeId2Cands2.begin(), foeId2Cands2.end(),
734 std::back_inserter(foeIds2));
735#ifdef DEBUG_CONSTRAINT_DEADLOCK
736 std::cout <<
"findConstraintsDeadLocks foeId=" << foeId <<
" tripId=" << tripId <<
" foeSignal=" << foeSignal <<
"\n";
737 for (
const std::string& foeId2 : foeIds2) {
738 std::cout <<
" deadlockId=" << foeId2 <<
" " << constraintsOnTripId[foeId2].getString() <<
" " << constrainedByFoeId[foeId2].getString() <<
"\n";
741 if (foeIds2.size() > 0) {
742 TraCISignalConstraint c = constrainedByFoeId[foeIds2.front()];
745 c = constraintsOnTripId[foeIds2.front()];
747 TraCISignalConstraint nc;
750 nc.signalId = c.foeSignal;
751 nc.foeSignal = c.signalId;
758 result.push_back(nc);
760 const std::vector<TraCISignalConstraint>& result2 = swapConstraints(c.signalId, c.tripId, c.foeSignal, c.foeId);
761 result.insert(result.end(), result2.begin(), result2.end());
762 if (foeIds2.size() > 1) {
764 const std::vector<TraCISignalConstraint>& result3 = findConstraintsDeadLocks(foeId, tripId, foeSignal, tlsID);
765 result.insert(result.end(), result3.begin(), result3.end());
773TrafficLight::getVehicleByTripId(
const std::string tripOrVehID) {
785std::vector<std::string>
786TrafficLight::getFutureTripIds(
const std::string vehID) {
787 std::vector<std::string> result;
792 result.push_back(tripId);
795 if (stop.pars.tripId !=
"") {
796 result.push_back(stop.pars.tripId);
805TrafficLight::getParameter(
const std::string& tlsID,
const std::string& paramName) {
808 throw TraCIException(
"'" + tlsID +
"' is not a NEMA controller");
818TrafficLight::setRedYellowGreenState(
const std::string& tlsID,
const std::string& state) {
824TrafficLight::setPhase(
const std::string& tlsID,
const int index) {
826 if (index < 0 || active->getPhaseNumber() <= index) {
827 throw TraCIException(
"The phase index " +
toString(index) +
" is not in the allowed range [0,"
836TrafficLight::setPhaseName(
const std::string& tlsID,
const std::string& name) {
843TrafficLight::setProgram(
const std::string& tlsID,
const std::string& programID) {
847 throw TraCIException(e.what());
853TrafficLight::setPhaseDuration(
const std::string& tlsID,
const double phaseDuration) {
861TrafficLight::setProgramLogic(
const std::string& tlsID,
const TraCILogic& logic) {
864 if (logic.currentPhaseIndex >= (
int)logic.phases.size()) {
865 throw TraCIException(
"set program: parameter index must be less than parameter phase number.");
867 std::vector<MSPhaseDefinition*> phases;
868 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.phases) {
873 phases.push_back(sumoPhase);
875 if (vars.
getLogic(logic.programID) ==
nullptr) {
878 int step = logic.currentPhaseIndex;
879 const std::string basePath =
"";
881 SUMOTime nextSwitch = now + phases[step]->duration;
890 cycleTime += phase->duration;
894 SUMOTime positionInCycle = (offsetSteps > 0
895 ? (cycleTime - (offsetSteps % cycleTime)) % cycleTime
896 : ((-offsetSteps) % cycleTime));
898 while (positionInCycle >= phases[step]->duration) {
899 positionInCycle -= phases[step]->duration;
902 nextSwitch = now + phases[step]->duration - positionInCycle;
908 tlsID, logic.programID,
TIME2STEPS(logic.offset),
909 phases, step, nextSwitch,
910 logic.subParameter, basePath);
914 tlsID, logic.programID,
TIME2STEPS(logic.offset),
915 phases, step, nextSwitch,
916 logic.subParameter, basePath);
920 tlsID, logic.programID,
TIME2STEPS(logic.offset),
921 phases, step, nextSwitch,
922 logic.subParameter, basePath);
927 phases, step, nextSwitch,
931 throw TraCIException(
"Unsupported traffic light type '" +
toString(logic.type) +
"'");
934 if (!vars.
addLogic(logic.programID, tlLogic,
true,
true)) {
935 throw TraCIException(
"Could not add traffic light logic '" + logic.programID +
"'");
938 throw TraCIException(e.what());
946 tlLogic->
setPhases(phases, logic.currentPhaseIndex);
954TrafficLight::setParameter(
const std::string& tlsID,
const std::string& paramName,
const std::string& value) {
957 throw TraCIException(
"'" + tlsID +
"' is not a NEMA controller");
965TrafficLight::setNemaSplits(
const std::string& tlsID,
const std::vector<double>& splits) {
966 setParameter(tlsID,
"NEMA.splits",
toString(splits));
970TrafficLight::setNemaMaxGreens(
const std::string& tlsID,
const std::vector<double>& maxGreens) {
971 setParameter(tlsID,
"NEMA.maxGreens",
toString(maxGreens));
975TrafficLight::setNemaCycleLength(
const std::string& tlsID,
double cycleLength) {
976 setParameter(tlsID,
"NEMA.cycleLength",
toString(cycleLength));
980TrafficLight::setNemaOffset(
const std::string& tlsID,
double offset) {
981 setParameter(tlsID,
"NEMA.offset",
toString(offset));
987 TraCISignalConstraint c;
1007std::shared_ptr<VariableWrapper>
1008TrafficLight::makeWrapper() {
1009 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
1014TrafficLight::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
1017 return wrapper->wrapStringList(objID, variable, getIDList());
1019 return wrapper->wrapInt(objID, variable, getIDCount());
1021 return wrapper->wrapString(objID, variable, getRedYellowGreenState(objID));
1023 return wrapper->wrapLogicVector(objID, variable, getAllProgramLogics(objID));
1025 return wrapper->wrapStringList(objID, variable, getControlledLanes(objID));
1027 return wrapper->wrapLinkVectorVector(objID, variable, getControlledLinks(objID));
1029 return wrapper->wrapInt(objID, variable, getPhase(objID));
1031 return wrapper->wrapString(objID, variable, getPhaseName(objID));
1033 return wrapper->wrapString(objID, variable, getProgram(objID));
1035 return wrapper->wrapDouble(objID, variable, getPhaseDuration(objID));
1037 return wrapper->wrapDouble(objID, variable, getNextSwitch(objID));
1039 return wrapper->wrapDouble(objID, variable, getSpentDuration(objID));
1041 return wrapper->wrapInt(objID, variable, getServedPersonCount(objID,
StoHelp::readTypedInt(*paramData)));
1043 return wrapper->wrapStringList(objID, variable, getBlockingVehicles(objID,
StoHelp::readTypedInt(*paramData)));
1045 return wrapper->wrapStringList(objID, variable, getRivalVehicles(objID,
StoHelp::readTypedInt(*paramData)));
1047 return wrapper->wrapStringList(objID, variable, getPriorityVehicles(objID,
StoHelp::readTypedInt(*paramData)));
1049 return wrapper->wrapSignalConstraintVector(objID, variable, getConstraints(objID,
StoHelp::readTypedString(*paramData)));
1051 return wrapper->wrapSignalConstraintVector(objID, variable, getConstraintsByFoe(objID,
StoHelp::readTypedString(*paramData)));
1053 return wrapper->wrapStringList(objID, variable, getControlledJunctions(objID));
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
constexpr SUMOTime TIME2STEPS(double x)
const long long int VEHPARS_FORCE_REROUTE
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
An actuated (adaptive) traffic light logic.
The base class for microscopic and mesoscopic vehicles.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
const std::list< MSStop > & getStops() const
const MSRoute & getRoute() const
Returns the current route.
An actuated traffic light logic based on time delay of approaching vehicles.
A road/street connecting two junctions.
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersons() const
Returns this edge's persons set.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSJunction * getToJunction() const
SumoXMLNodeType getType() const
return the type of this Junction
Representation of a lane in the micro simulation.
MSEdge & getEdge() const
Returns the lane's edge.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
MSLane * getLane() const
Returns the connected lane.
MSLane * getViaLane() const
Returns the following inner lane.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual void createTLWrapper(MSTrafficLightLogic *)
creates a wrapper for the given logic (see GUINet)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
The definition of a single phase of a tls logic.
SUMOTime maxDuration
The maximum duration of the phase.
SUMOTime minDuration
The minimum duration of the phase.
const std::string & getName() const
const std::string & getState() const
Returns the state within this phase.
SUMOTime duration
The duration of the phase.
std::vector< int > nextPhases
The index of the phase that suceeds this one (or -1)
const MSRailSignal * myFoeSignal
store the foe signal (for TraCI access)
bool cleared() const
whether the constraint has been met
const std::string myTripId
id of the predecessor that must already have passed
void setActive(bool active)
const int myLimit
the number of passed vehicles within which tripId must have occurred
A base class for constraints.
ConstraintType getType() const
ConstraintType getSwappedType() const
static MSRailSignalControl & getInstance()
const std::vector< MSRailSignal * > & getSignals() const
void addConstraint(const std::string &tripId, MSRailSignalConstraint *constraint)
register constraint for signal switching
const std::map< std::string, std::vector< MSRailSignalConstraint * > > & getConstraints() const
bool removeConstraint(const std::string &tripId, MSRailSignalConstraint *constraint)
remove constraint for signal switching
const ConstMSEdgeVector & getEdges() const
A fixed traffic light logic.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
Storage for all programs of a single tls.
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
void setStateInstantiatingOnline(MSTLLogicControl &tlc, const std::string &state)
std::vector< MSTrafficLightLogic * > getAllLogics() const
MSTrafficLightLogic * getLogic(const std::string &programID) const
void executeOnSwitchActions() const
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program). In case of an error the logic gets deleted.
MSTrafficLightLogic * getActive() const
MSTrafficLightLogic * getDefault() const
return the default program (that last used program except TRACI_PROGRAM)
A class that stores and controls tls and switching of their programs.
std::vector< std::string > getAllTLIds() const
The parent class for traffic light logics.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
virtual int getPhaseNumber() const =0
Returns the number of phases.
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
virtual VehicleVector getPriorityVehicles(int linkIndex)
return vehicles that approach the intersection/rail signal and have priority over vehicles that wish ...
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
virtual VehicleVector getBlockingVehicles(int linkIndex)
return vehicles that block the intersection/rail signal for vehicles that wish to pass the given link...
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
virtual VehicleVector getRivalVehicles(int linkIndex)
return vehicles that approach the intersection/rail signal and are in conflict with vehicles that wis...
const std::string & getProgramID() const
Returns this tl-logic's id.
TrafficLightType getLogicType() const
Returns the type of the logic.
int getNumLinks() const
return the number of controlled link indices
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
A NEMA (adaptive) traffic light logic based on E2Detector.
Builds detectors for microsim.
const std::string & getID() const
Returns the id.
void unsetParameter(const std::string &key)
Removes a parameter.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void updateParameters(const Parameterised::Map &mapArg)
Adds or updates all given parameters from the map.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual int getRoutePosition() const =0
return index of edge within route
virtual const MSRoute & getRoute() const =0
Returns the current route.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
C++ TraCI client API implementation.
static MSBaseVehicle * getVehicle(const std::string &id)
static MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int TL_BLOCKING_VEHICLES
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
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_CONTROLLED_JUNCTIONS
TRACI_CONST int TL_CONTROLLED_LINKS
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int TL_CONSTRAINT_BYFOE
TRACI_CONST int TL_CONSTRAINT
TRACI_CONST int TL_NEXT_SWITCH
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_CURRENT_PHASE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TL_CURRENT_PROGRAM
TRACI_CONST int TL_RIVAL_VEHICLES
std::string tripId
the tripId or vehicle id of the train that is constrained