50 std::vector<std::string>
51 TrafficLight::getIDList() {
57 TrafficLight::getIDCount() {
58 return (
int)getIDList().size();
68 std::vector<TraCILogic>
70 std::vector<TraCILogic> result;
73 TraCILogic l(logic->getProgramID(), (int)logic->getLogicType(), logic->getCurrentPhaseIndex());
78 phase->getNextPhases(), phase->getName()));
80 result.emplace_back(l);
86 std::vector<std::string>
88 std::set<std::string> junctionIDs;
91 for (
const MSLink* l : llinks) {
92 junctionIDs.insert(l->getJunction()->getID());
95 return std::vector<std::string>(junctionIDs.begin(), junctionIDs.end());
99 std::vector<std::string>
101 std::vector<std::string> laneIDs;
104 for (
const MSLane* l : llanes) {
105 laneIDs.push_back(l->getID());
112 std::vector<std::vector<TraCILink> >
114 std::vector<std::vector<TraCILink> > result;
117 for (
int i = 0; i < (int)lanes.size(); ++i) {
118 std::vector<TraCILink> subList;
122 for (
int j = 0; j < (int)llanes.size(); ++j) {
128 subList.emplace_back(
TraCILink(llanes[j]->getID(), via, to));
130 result.emplace_back(subList);
156 return STEPS2TIME(
getTLS(tlsID).getActive()->getCurrentPhaseDef().duration);
168 if (index < 0 || active->getPhaseNumber() <= index) {
175 const std::string& state = active->
getPhases()[index]->getState();
176 for (
int i = 0; i < (int)state.size(); i++) {
178 if (link->getLane()->getEdge().isCrossing()) {
181 if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLane()->getEdge().getID()) {
188 if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLane()->getEdge().getID()) {
192 }
else if (link->getLaneBefore()->getEdge().isCrossing()) {
195 if (static_cast<MSPerson*>(person)->getNextEdge() == link->getLaneBefore()->getEdge().getID()) {
205 std::vector<std::string>
207 std::vector<std::string> result;
210 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
215 result.push_back(veh->getID());
220 std::vector<std::string>
222 std::vector<std::string> result;
224 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
229 result.push_back(veh->getID());
234 std::vector<std::string>
236 std::vector<std::string> result;
238 if (linkIndex < 0 || linkIndex >= active->
getNumLinks()) {
243 result.push_back(veh->getID());
249 TrafficLight::getParameter(
const std::string& tlsID,
const std::string& paramName) {
266 if (index < 0 || active->getPhaseNumber() <= index) {
306 throw TraCIException(
"set program: parameter index must be less than parameter phase number.");
308 std::vector<MSPhaseDefinition*> phases;
315 const std::string basePath =
"";
322 phases, step, nextSwitch,
328 phases, step, nextSwitch,
334 phases, step, nextSwitch,
351 TrafficLight::setParameter(
const std::string& tlsID,
const std::string& paramName,
const std::string& value) {
368 std::shared_ptr<VariableWrapper>
380 return wrapper->
wrapInt(objID, variable, getIDCount());
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int TL_CURRENT_PHASE
MSTrafficLightLogic * getDefault() const
return the default program (that last used program except TRACI_PROGRAM)
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
const std::string & getState() const
Returns the state within this phase.
Builds detectors for microsim.
MSEdge & getEdge() const
Returns the lane's edge.
static double getPhaseDuration(const std::string &tlsID)
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
static std::string getPhaseName(const std::string &tlsID)
An actuated traffic light logic based on time delay of approaching vehicles.
Storage for all programs of a single tls.
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
const MSEdge * getEdge() const
Returns the current edge.
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
static std::string getRedYellowGreenState(const std::string &tlsID)
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
static std::vector< std::string > getControlledJunctions(const std::string &tlsID)
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual VehicleVector getRivalVehicles(int linkIndex)
return vehicles that approach the intersection/rail signal and are in conflict with vehicles that wis...
virtual VehicleVector getPriorityVehicles(int linkIndex)
return vehicles that approach the intersection/rail signal and have priority over vehicles that wish ...
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
TRACI_CONST int TL_NEXT_SWITCH
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
TRACI_CONST int TL_PHASE_DURATION
std::map< std::string, std::string > subParameter
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
const std::string & getID() const
Returns the id.
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static std::vector< std::string > getControlledLanes(const std::string &tlsID)
static std::vector< std::string > getBlockingVehicles(const std::string &tlsID, int linkIndex)
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
static void setProgramLogic(const std::string &tlsID, const TraCILogic &logic)
A fixed traffic light logic.
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
An actuated (adaptive) traffic light logic.
A class that stores and controls tls and switching of their programs.
TRACI_CONST int TRACI_ID_LIST
SUMOTime duration
The duration of the phase.
std::vector< MSTrafficLightLogic * > getAllLogics() const
static MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program)
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual int getPhaseNumber() const =0
Returns the number of phases.
Representation of a vehicle.
const std::string & getProgramID() const
Returns this tl-logic's id.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
static double getNextSwitch(const std::string &tlsID)
static std::vector< std::string > getRivalVehicles(const std::string &tlsID, int linkIndex)
TRACI_CONST int TL_CONTROLLED_LANES
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
const MSLane * getLane() const
Returns the current lane (may be nullptr)
TRACI_CONST int TL_CONTROLLED_JUNCTIONS
static SubscriptionResults mySubscriptionResults
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
MSLane * getViaLane() const
Returns the following inner lane.
static std::vector< TraCILogic > getAllProgramLogics(const std::string &tlsID)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
static std::shared_ptr< VariableWrapper > makeWrapper()
void setStateInstantiatingOnline(MSTLLogicControl &tlc, const std::string &state)
std::vector< TraCIPhase * > phases
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
virtual VehicleVector getBlockingVehicles(int linkIndex)
return vehicles that block the intersection/rail signal for vehicles that wish to pass the given link...
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
TRACI_CONST int TL_CURRENT_PROGRAM
static std::vector< std::string > getPriorityVehicles(const std::string &tlsID, int linkIndex)
static void setPhase(const std::string &tlsID, const int index)
static void setPhaseName(const std::string &tlsID, const std::string &name)
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
static int getServedPersonCount(const std::string &tlsID, int index)
The parent class for traffic light logics.
static void setProgram(const std::string &tlsID, const std::string &programID)
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
const std::string & getName() const
static std::string getProgram(const std::string &tlsID)
MSTrafficLightLogic * getActive() const
static int getPhase(const std::string &tlsID)
std::vector< std::string > getAllTLIds() const
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
MSTrafficLightLogic * getLogic(const std::string &programID) const
static ContextSubscriptionResults myContextSubscriptionResults
Representation of a lane in the micro simulation.
The definition of a single phase of a tls logic.
int getNumLinks()
return the number of controlled link indices
static std::vector< std::vector< TraCILink > > getControlledLinks(const std::string &tlsID)
MSLane * getLane() const
Returns the connected lane.