 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
51 std::vector<std::string>
69 std::vector<TraCILogic>
71 std::vector<TraCILogic> result;
74 TraCILogic l(logic->getProgramID(), (int)logic->getLogicType(), logic->getCurrentPhaseIndex());
79 phase->getNextPhases(), phase->getName()));
81 result.emplace_back(l);
87 std::vector<std::string>
89 std::set<std::string> junctionIDs;
92 for (
const MSLink* l : llinks) {
93 junctionIDs.insert(l->getJunction()->getID());
96 return std::vector<std::string>(junctionIDs.begin(), junctionIDs.end());
100 std::vector<std::string>
102 std::vector<std::string> laneIDs;
105 for (
const MSLane* l : llanes) {
106 laneIDs.push_back(l->getID());
113 std::vector<std::vector<TraCILink> >
115 std::vector<std::vector<TraCILink> > result;
118 for (
int i = 0; i < (int)lanes.size(); ++i) {
119 std::vector<TraCILink> subList;
123 for (
int j = 0; j < (int)llanes.size(); ++j) {
129 subList.emplace_back(
TraCILink(llanes[j]->getID(), via, to));
131 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()) {
220 if (index < 0 || active->getPhaseNumber() <= index) {
260 throw TraCIException(
"set program: parameter index must be less than parameter phase number.");
262 std::vector<MSPhaseDefinition*> phases;
269 const std::string basePath =
"";
272 switch (logic.
type) {
276 phases, step, nextSwitch,
282 phases, step, nextSwitch,
288 phases, step, nextSwitch,
322 std::shared_ptr<VariableWrapper>
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
static std::vector< std::vector< TraCILink > > getControlledLinks(const std::string &tlsID)
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program)
TRACI_CONST int TL_CURRENT_PHASE
static void setParameter(const std::string &tlsID, const std::string ¶mName, const std::string &value)
static void setProgram(const std::string &tlsID, const std::string &programID)
Representation of a lane in the micro simulation.
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
const std::string & getProgramID() const
Returns this tl-logic's id.
TRACI_CONST int TL_NEXT_SWITCH
std::vector< std::string > getAllTLIds() const
TRACI_CONST int TL_PHASE_DURATION
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
static std::vector< std::string > getControlledLanes(const std::string &tlsID)
static void setPhase(const std::string &tlsID, const int index)
MSTrafficLightLogic * getActive() const
static void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCILogic &logic)
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
MSTrafficLightLogic * getLogic(const std::string &programID) const
static double getPhaseDuration(const std::string &tlsID)
static SubscriptionResults mySubscriptionResults
static std::string getRedYellowGreenState(const std::string &tlsID)
static void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
const MSEdge * getEdge() const
Returns the current edge.
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
static std::vector< std::string > getIDList()
std::vector< MSTrafficLightLogic * > getAllLogics() const
SUMOTime duration
The duration of the phase.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
MSLane * getLane() const
Returns the connected lane.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
static std::string getProgram(const std::string &tlsID)
const std::string & getState() const
Returns the state within this phase.
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
TRACI_CONST int TL_CONTROLLED_LANES
A fixed traffic light logic.
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
static std::vector< std::string > getControlledJunctions(const std::string &tlsID)
TRACI_CONST int TRACI_ID_LIST
static MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
An actuated (adaptive) traffic light logic.
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
The parent class for traffic light logics.
static void setPhaseName(const std::string &tlsID, const std::string &name)
virtual int getPhaseNumber() const =0
Returns the number of phases.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
static ContextSubscriptionResults myContextSubscriptionResults
static std::string getParameter(const std::string &tlsID, const std::string ¶mName)
static LIBSUMO_SUBSCRIPTION_API std::shared_ptr< VariableWrapper > makeWrapper()
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_CURRENT_PROGRAM
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
TRACI_CONST int TL_CONTROLLED_JUNCTIONS
MSEdge & getEdge() const
Returns the lane's edge.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::vector< TraCIPhase > phases
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
void setStateInstantiatingOnline(MSTLLogicControl &tlc, const std::string &state)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static int getServedPersonCount(const std::string &tlsID, int index)
static int getPhase(const std::string &tlsID)
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
An actuated traffic light logic based on time delay of approaching vehicles.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Storage for all programs of a single tls.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
std::map< std::string, std::string > subParameter
A class that stores and controls tls and switching of their programs.
The definition of a single phase of a tls logic.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
const std::string & getID() const
Returns the id.
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
MSLane * getViaLane() const
Returns the following inner lane.
Builds detectors for microsim.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
static double getNextSwitch(const std::string &tlsID)
static std::vector< TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID)
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
static std::string getPhaseName(const std::string &tlsID)
const std::string & getName() const