Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2010-2024 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 : /****************************************************************************/
14 : /// @file MSSOTLPolicyBasedTrafficLightLogic.cpp
15 : /// @author Alessio Bonfietti
16 : /// @author Riccardo Belletti
17 : /// @date 2014-03-20
18 : ///
19 : // The class for SOTL Congestion logics
20 : /****************************************************************************/
21 :
22 : #include "MSSOTLPolicyBasedTrafficLightLogic.h"
23 : //#define SWARM_DEBUG
24 :
25 :
26 : // ===========================================================================
27 : // method definitions
28 : // ===========================================================================
29 64 : MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(
30 : MSTLLogicControl& tlcontrol, const std::string& id,
31 : const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
32 : SUMOTime delay, const Parameterised::Map& parameters,
33 64 : MSSOTLPolicy* policy) :
34 : MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
35 64 : parameters), myPolicy(policy) {
36 :
37 128 : MsgHandler::getMessageInstance()->inform(
38 128 : "*** Intersection " + id + " will run using MSSOTL"
39 64 : + policy->getName() + "TrafficLightLogic ***");
40 :
41 64 : }
42 :
43 0 : MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(
44 : MSTLLogicControl& tlcontrol, const std::string& id,
45 : const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
46 : SUMOTime delay, const Parameterised::Map& parameters,
47 0 : MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
48 : MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
49 0 : parameters, sensors), myPolicy(policy) {
50 0 : }
51 :
52 128 : MSSOTLPolicyBasedTrafficLightLogic::~MSSOTLPolicyBasedTrafficLightLogic(void) {
53 :
54 128 : }
55 :
56 67768 : int MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase() {
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
62 203304 : return myPolicy->decideNextPhase(getCurrentPhaseElapsed(),
63 67768 : &getCurrentPhaseDef(), getCurrentPhaseIndex(),
64 67768 : getPhaseIndexWithMaxCTS(), isThresholdPassed(), isPushButtonPressed(),
65 135536 : countVehicles(getCurrentPhaseDef()));
66 : }
67 :
68 0 : bool MSSOTLPolicyBasedTrafficLightLogic::canRelease() {
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
74 0 : return myPolicy->canRelease(getCurrentPhaseElapsed(), isThresholdPassed(), isPushButtonPressed(),
75 0 : &getCurrentPhaseDef(), countVehicles(getCurrentPhaseDef()));
76 : }
|