Eclipse SUMO - Simulation of Urban MObility
MSSOTLPolicyBasedTrafficLightLogic.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2010-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // The class for SOTL Congestion logics
20 /****************************************************************************/
21 
23 //#define SWARM_DEBUG
24 
25 
26 // ===========================================================================
27 // method definitions
28 // ===========================================================================
30  MSTLLogicControl& tlcontrol, const std::string& id,
31  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
32  SUMOTime delay, const std::map<std::string, std::string>& parameters,
33  MSSOTLPolicy* policy) :
34  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
35  parameters), myPolicy(policy) {
36 
38  "*** Intersection " + id + " will run using MSSOTL"
39  + policy->getName() + "TrafficLightLogic ***");
40 
41 }
42 
44  MSTLLogicControl& tlcontrol, const std::string& id,
45  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
46  SUMOTime delay, const std::map<std::string, std::string>& parameters,
47  MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
48  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
49  parameters, sensors), myPolicy(policy) {
50 }
51 
53 
54 }
55 
57 #ifdef SWARM_DEBUG
58  std::ostringstream str;
59  str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase()";
60  WRITE_MESSAGE(str.str());
61 #endif
66 }
67 
69 #ifdef SWARM_DEBUG
70  std::ostringstream str;
71  str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::canRelease()";
72  WRITE_MESSAGE(str.str());
73 #endif
76 }
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:282
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:32
TrafficLightType
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
int getCurrentPhaseIndex() const
Returns the current index within the program.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
MSSOTLPolicyBasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const TrafficLightType logicType, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > &parameters, MSSOTLPolicy *policy)
Constructor without sensors passed.
Class for a low-level policy.
Definition: MSSOTLPolicy.h:61
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
std::string getName()
Definition: MSSOTLPolicy.h:114
A self-organizing traffic light logic.
int countVehicles(MSPhaseDefinition phase)
A class that stores and controls tls and switching of their programs.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:117
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Definition: MsgHandler.cpp:54
const std::string & getID() const
Returns the id.
Definition: Named.h:74