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 /****************************************************************************/
15 // The class for SOTL Congestion logics
16 /****************************************************************************/
17 
19 
21  MSTLLogicControl& tlcontrol, const std::string& id,
22  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
23  SUMOTime delay, const std::map<std::string, std::string>& parameters,
24  MSSOTLPolicy* policy) :
25  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
26  parameters), myPolicy(policy) {
27 
29  "*** Intersection " + id + " will run using MSSOTL"
30  + policy->getName() + "TrafficLightLogic ***");
31 
32 }
33 
35  MSTLLogicControl& tlcontrol, const std::string& id,
36  const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
37  SUMOTime delay, const std::map<std::string, std::string>& parameters,
38  MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
39  MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
40  parameters, sensors), myPolicy(policy) {
41 }
42 
44 
45 }
46 
48 
49  DBG(
50  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase()"; WRITE_MESSAGE(str.str());)
51 
56 }
57 
59 
60  DBG(
61  std::ostringstream str; str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::canRelease()"; WRITE_MESSAGE(str.str());)
62 
65 }
MSSOTLPolicy::decideNextPhase
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
Definition: MSSOTLPolicy.cpp:120
MSSOTLPolicyBasedTrafficLightLogic::canRelease
bool canRelease()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:58
MSSOTLTrafficLightLogic
A self-organizing traffic light logic.
Definition: MSSOTLTrafficLightLogic.h:58
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:64
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:20
MSSOTLTrafficLightLogic::isThresholdPassed
bool isThresholdPassed()
Definition: MSSOTLTrafficLightLogic.cpp:305
MSSOTLPolicyBasedTrafficLightLogic::myPolicy
MSSOTLPolicy * myPolicy
Definition: MSSOTLPolicyBasedTrafficLightLogic.h:106
DBG
#define DBG(X)
Definition: SwarmDebug.h:26
MSPhasedTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSPhasedTrafficLightLogic.cpp:131
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
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:1197
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSSOTLPolicyBasedTrafficLightLogic::~MSSOTLPolicyBasedTrafficLightLogic
~MSSOTLPolicyBasedTrafficLightLogic()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:43
MSSOTLTrafficLightLogic::isPushButtonPressed
bool isPushButtonPressed()
Definition: MSSOTLTrafficLightLogic.cpp:506
MSSOTLPolicy::getName
std::string getName()
Definition: MSSOTLPolicy.h:117
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase
int decideNextPhase()
Definition: MSSOTLPolicyBasedTrafficLightLogic.cpp:47
MSSOTLTrafficLightLogic::getPhaseIndexWithMaxCTS
int getPhaseIndexWithMaxCTS()
Definition: MSSOTLTrafficLightLogic.cpp:369
MSPhasedTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSPhasedTrafficLightLogic.cpp:125
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSSOTLTrafficLightLogic::countVehicles
int countVehicles(MSPhaseDefinition phase)
Definition: MSSOTLTrafficLightLogic.cpp:264
MSSOTLSensors
Definition: MSSOTLSensors.h:32
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:59
MSSOTLPolicyBasedTrafficLightLogic.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
MSSOTLTrafficLightLogic::getCurrentPhaseElapsed
SUMOTime getCurrentPhaseElapsed()
Definition: MSSOTLTrafficLightLogic.cpp:358
MsgHandler::getMessageInstance
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Definition: MsgHandler.cpp:55