Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSOffTrafficLightLogic.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 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/****************************************************************************/
20// A traffic lights logic which represents a tls in an off-mode
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <utility>
26#include <vector>
27#include <bitset>
29#include "MSTLLogicControl.h"
30#include "MSTrafficLightLogic.h"
31
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
41public:
48 const std::string& id);
49
50
55 virtual void init(NLDetectorBuilder& nb) override;
56
57
60
61
64
69 void adaptLinkInformationFrom(const MSTrafficLightLogic& logic) override;
71
72
73
76
81 SUMOTime trySwitch() override {
82 return 120 * DELTA_T;
83 }
84
86
87
90
95 int getPhaseNumber() const override;
96
97
102 const Phases& getPhases() const override;
103
104
110 const MSPhaseDefinition& getPhase(int givenstep) const override;
111
115 const std::string getLogicType() const {
116 return "offTrafficLightLogic";
117 }
119
120
121
124
129 int getCurrentPhaseIndex() const override;
130
131
136 const MSPhaseDefinition& getCurrentPhaseDef() const override;
138
139
140 void resetLastSwitch(SUMOTime t) override;
141
144
149 SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const override;
150
151
157 SUMOTime getOffsetFromIndex(int index) const override;
158
159
165 int getIndexFromOffset(SUMOTime offset) const override;
167
168
169
172
180 void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) override {
181 UNUSED_PARAMETER(tlcontrol);
182 UNUSED_PARAMETER(simStep);
183 UNUSED_PARAMETER(step);
184 UNUSED_PARAMETER(stepDuration);
185 }
187
188
189private:
192 void rebuildPhase();
193
194
195private:
198
199
200};
long long int SUMOTime
Definition GUI.h:36
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
A traffic lights logic which represents a tls in an off-mode.
void resetLastSwitch(SUMOTime t) override
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const override
Returns the index of the logic at the given simulation step.
SUMOTime getOffsetFromIndex(int index) const override
Returns the position (start of a phase during a cycle) from of a given step.
const MSPhaseDefinition & getCurrentPhaseDef() const override
Returns the definition of the current phase.
const MSPhaseDefinition & getPhase(int givenstep) const override
Returns the definition of the phase from the given position within the plan.
int getIndexFromOffset(SUMOTime offset) const override
Returns the step (the phasenumber) of a given position of the cycle.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic) override
Applies information about controlled links and lanes from the given logic.
const std::string getLogicType() const
Returns the type of the logic as a string.
const Phases & getPhases() const override
Returns the phases of this tls program.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) override
Changes the current phase and her duration.
int getPhaseNumber() const override
Returns the number of phases.
MSTrafficLightLogic::Phases myPhaseDefinition
The phase definition (only one)
SUMOTime trySwitch() override
Switches to the next phase.
int getCurrentPhaseIndex() const override
Returns the current index within the program.
void rebuildPhase()
(Re)builds the internal phase definition
virtual void init(NLDetectorBuilder &nb) override
Initialises the tls with information about incoming lanes.
The definition of a single phase of a tls logic.
A class that stores and controls tls and switching of their programs.
The parent class for traffic light logics.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Builds detectors for microsim.
#define UNUSED_PARAMETER(x)