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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The class for SOTL Congestion logics
17 /****************************************************************************/
18 
20 
22  MSTLLogicControl& tlcontrol, const std::string& id,
23  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
24  SUMOTime delay, const std::map<std::string, std::string>& parameters,
25  MSSOTLPolicy* policy) :
26  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
27  parameters), myPolicy(policy) {
28 
30  "*** Intersection " + id + " will run using MSSOTL"
31  + policy->getName() + "TrafficLightLogic ***");
32 
33 }
34 
36  MSTLLogicControl& tlcontrol, const std::string& id,
37  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
38  SUMOTime delay, const std::map<std::string, std::string>& parameters,
39  MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
40  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
41  parameters, sensors), myPolicy(policy) {
42 }
43 
45 
46 }
47 
49 
50  DBG(
51  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase()"; WRITE_MESSAGE(str.str());)
52 
57 }
58 
60 
61  DBG(
62  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::canRelease()"; WRITE_MESSAGE(str.str());)
63 
66 }
MSSOTLPolicy::decideNextPhase
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
Definition: MSSOTLPolicy.cpp:121
MSSOTLPolicyBasedTrafficLightLogic::canRelease
bool canRelease()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:59
MSSOTLTrafficLightLogic
A self-organizing traffic light logic.
Definition: MSSOTLTrafficLightLogic.h:59
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:65
MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic
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.
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:21
MSSOTLTrafficLightLogic::isThresholdPassed
bool isThresholdPassed()
Definition: MSSOTLTrafficLightLogic.cpp:306
MSSOTLPolicyBasedTrafficLightLogic::myPolicy
MSSOTLPolicy * myPolicy
Definition: MSSOTLPolicyBasedTrafficLightLogic.h:107
DBG
#define DBG(X)
Definition: SwarmDebug.h:27
MSPhasedTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSPhasedTrafficLightLogic.cpp:132
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:62
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1192
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSSOTLPolicyBasedTrafficLightLogic::~MSSOTLPolicyBasedTrafficLightLogic
~MSSOTLPolicyBasedTrafficLightLogic()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:44
MSSOTLTrafficLightLogic::isPushButtonPressed
bool isPushButtonPressed()
Definition: MSSOTLTrafficLightLogic.cpp:507
MSSOTLPolicy::getName
std::string getName()
Definition: MSSOTLPolicy.h:118
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase
int decideNextPhase()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:48
MSSOTLTrafficLightLogic::getPhaseIndexWithMaxCTS
int getPhaseIndexWithMaxCTS()
Definition: MSSOTLTrafficLightLogic.cpp:370
MSPhasedTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSPhasedTrafficLightLogic.cpp:126
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
MSSOTLTrafficLightLogic::countVehicles
int countVehicles(MSPhaseDefinition phase)
Definition: MSSOTLTrafficLightLogic.cpp:265
MSSOTLSensors
Definition: MSSOTLSensors.h:33
MSSOTLPolicy::canRelease
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:60
MSSOTLPolicyBasedTrafficLightLogic.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:240
MSSOTLTrafficLightLogic::getCurrentPhaseElapsed
SUMOTime getCurrentPhaseElapsed()
Definition: MSSOTLTrafficLightLogic.cpp:359
MsgHandler::getMessageInstance
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Definition: MsgHandler.cpp:59