Eclipse SUMO - Simulation of Urban MObility
MSDelayBasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2002-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 /****************************************************************************/
18 // An actuated traffic light logic based on time delay of approaching vehicles
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <map>
25 
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class NLDetectorBuilder;
31 class MSE2Collector;
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
46 public:
57  const std::string& id, const std::string& programID,
58  const SUMOTime offset,
60  int step, SUMOTime delay,
61  const Parameterised::Map& parameter,
62  const std::string& basePath);
63 
64 
69  void init(NLDetectorBuilder& nb) override;
70 
71 
74 
75 
76 
79 
84  SUMOTime trySwitch() override;
86 
87  bool showDetectors() const {
88  return myShowDetectors;
89  }
90 
91  void setShowDetectors(bool show);
92 
94  std::map<std::string, double> getDetectorStates() const override;
95 
97  double getDetectorState(const std::string laneID) const override;
98 
100  double getTLQueueLength(const std::string laneID) const override;
101 
102 
103 protected:
106 
115 
124  SUMOTime proposeProlongation(const SUMOTime actDuration, const SUMOTime maxDuration, bool& othersEmpty);
125 
126 protected:
128  std::map<const MSLane*, MSE2Collector*> myLaneDetectors;
129 
132 
135  // (Idea: this might be adapted to the detector-length and the vehicle's maximal speed)
137 
140 
142  std::string myFile;
143 
146 
148  std::string myVehicleTypes;
149 
152 };
long long int SUMOTime
Definition: GUI.h:35
An actuated traffic light logic based on time delay of approaching vehicles.
double myDetectionRange
Range of the connected detector, which provides the information on approaching vehicles.
double getDetectorState(const std::string laneID) const override
retrieve a specific detector used by this program
bool myExtendMaxDur
Whether phases may be extended beyond maxDur in the absence of traffic.
std::string myVehicleTypes
Whether detector output separates by vType.
SUMOTime myFreq
The frequency for aggregating detector output.
std::map< std::string, double > getDetectorStates() const override
retrieve all detectors used by this program
std::map< const MSLane *, MSE2Collector * > myLaneDetectors
A map from lanes to the corresponding lane detectors.
void init(NLDetectorBuilder &nb) override
Initializes the tls with information about incoming lanes.
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
std::string myFile
The output file for generated detectors.
MSDelayBasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const SUMOTime offset, const MSSimpleTrafficLightLogic::Phases &phases, int step, SUMOTime delay, const Parameterised::Map &parameter, const std::string &basePath)
Constructor.
SUMOTime proposeProlongation(const SUMOTime actDuration, const SUMOTime maxDuration, bool &othersEmpty)
The returned, proposed prolongation for the green phase is oriented on the largest estimated passing ...
SUMOTime trySwitch() override
Switches to the next phase, if possible.
double getTLQueueLength(const std::string laneID) const override
return the estimated queue length at the upcoming traffic light
SUMOTime checkForWaitingTime()
Checks for approaching vehicles on the lanes associated with green signals and returns the minimal ti...
An areal detector corresponding to a sequence of consecutive lanes.
Definition: MSE2Collector.h:79
A fixed traffic light logic.
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.
Builds detectors for microsim.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45