Eclipse SUMO - Simulation of Urban MObility
MSPhasedTrafficLightLogic.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2010-2022 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// The base class for traffic light logic with phases
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <utility>
24#include <vector>
25#include <bitset>
27#include <microsim/MSNet.h>
28#include "MSTrafficLightLogic.h"
29#include "MSPhaseDefinition.h"
30
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
46public:
56 const std::string& id, const std::string& programID,
57 const SUMOTime offset,
58 const TrafficLightType logicType,
59 const Phases& phases, int step, SUMOTime delay,
60 const Parameterised::Map& parameters);
61
62
65
66
67
71
76 /* SUMOTime trySwitch(bool isActive);*/
77
78
79
82
87 int getPhaseNumber() const;
88
89
94 const Phases& getPhases() const;
95
101 const MSPhaseDefinition& getPhase(int givenstep) const;
103
104
105
108
113 int getCurrentPhaseIndex() const;
114
115
122
123
124
127
133
134
140 SUMOTime getOffsetFromIndex(int index) const;
141
142
148 int getIndexFromOffset(SUMOTime offset) const;
150
151
152
155
163 void changeStepAndDuration(MSTLLogicControl& tlcontrol, SUMOTime simStep,
164 int step, SUMOTime stepDuration);
166
169 void setPhases(const Phases& phases, int index);
171
172protected:
175
177 void proceedToNextStep();
178
180 void setStep(int step);
181
182private:
183
185 void deletePhases();
186
187protected:
188
191
192
193
194};
long long int SUMOTime
Definition: GUI.h:36
TrafficLightType
The definition of a single phase of a tls logic.
A fixed traffic light logic.
Phases myPhases
The list of phases this logic uses.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
void proceedToNextStep()
Proceed to the next step.
void deletePhases()
frees memory responsibilities
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
const Phases & getPhases() const
Returns the phases of this tls program.
int getCurrentPhaseIndex() const
Returns the current index within the program.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
int getPhaseNumber() const
Returns the number of phases.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
void setStep(int step)
Forces a specific step.
MSPhasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const SUMOTime offset, const TrafficLightType logicType, const Phases &phases, int step, SUMOTime delay, const Parameterised::Map &parameters)
Constructor.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
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.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45