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-2020 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 
25  MSTLLogicControl& tlcontrol, const std::string& id,
26  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
27  SUMOTime delay, const std::map<std::string, std::string>& parameters,
28  MSSOTLPolicy* policy) :
29  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
30  parameters), myPolicy(policy) {
31 
33  "*** Intersection " + id + " will run using MSSOTL"
34  + policy->getName() + "TrafficLightLogic ***");
35 
36 }
37 
39  MSTLLogicControl& tlcontrol, const std::string& id,
40  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
41  SUMOTime delay, const std::map<std::string, std::string>& parameters,
42  MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
43  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
44  parameters, sensors), myPolicy(policy) {
45 }
46 
48 
49 }
50 
52 
53  DBG(
54  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase()"; WRITE_MESSAGE(str.str());)
55 
60 }
61 
63 
64  DBG(
65  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::canRelease()"; WRITE_MESSAGE(str.str());)
66 
69 }
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:31
TrafficLightType
#define DBG(X)
Definition: SwarmDebug.h:30
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
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:63
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:116
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:73