/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NIVisumTL.h14/// @author Daniel Krajzewicz15/// @date Wed, 07 May 200316///17// Intermediate class for storing visum traffic lights during their import18/****************************************************************************/19#pragma once20#include <config.h>2122#include <vector>23#include <map>24#include <string>25#include <netbuild/NBConnectionDefs.h>26#include <netbuild/NBNodeCont.h>27#include <utils/common/SUMOTime.h>2829class NBTrafficLightLogicCont;30class NBEdgeCont;313233// ===========================================================================34// class declaration35// ===========================================================================36/**37* @class NIVisumTL38* @brief Intermediate class for storing visum traffic lights during their import39*/40class NIVisumTL {41public:42/** @class TimePeriod43* @brief A time period with a start and an end time44*/45class TimePeriod {46public:47/// @brief Constructor48TimePeriod(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)49: myStartTime(startTime), myEndTime(endTime), myYellowTime(yellowTime) {}5051/// @brief Destructor52~TimePeriod() {}5354/// @brief Returns the stored start time55SUMOTime getStartTime() {56return myStartTime;57}5859/// @brief Returns the stored end time60SUMOTime getEndTime() {61return myEndTime;62}6364/// @brief Returns the stored yellow time65SUMOTime getYellowTime() {66return myYellowTime;67}6869private:70/// @brief Start time71const SUMOTime myStartTime;72/// @brief End time73const SUMOTime myEndTime;74/// @brief Yellow time75const SUMOTime myYellowTime;7677private:78/// @brief Invalidated assignment operator79TimePeriod& operator=(const TimePeriod& s) = delete;80};81828384/** @class Phase85* @brief A phase86*/87class Phase : public TimePeriod {88public:89/// @brief Constructor90Phase(SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime) : NIVisumTL::TimePeriod(startTime, endTime, yellowTime) {}9192/// @brief Destructor93~Phase() {}9495};96979899/** @class SignalGroup100* @brief A signal group can be defined either by a time period or by phases101*/102class SignalGroup : public TimePeriod {103public:104/// @brief constructor105SignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime)106: NIVisumTL::TimePeriod(startTime, endTime, yellowTime), myName(name) {}107108/// @brief destructor109~SignalGroup() {}110111/// @brief Returns the connections vector112NBConnectionVector& connections() {113return myConnections;114}115116/// @brief Returns the phases map117std::map<std::string, Phase*>& phases() {118return myPhases;119}120121private:122/// @brief Connections123NBConnectionVector myConnections;124/// @brief phases125std::map<std::string, Phase*> myPhases;126/// @brief name127std::string myName;128};129130131132public:133/** @brief Constructor134* @param[in] name The name of the TLS135* @param[in] cycleTime The cycle time of the TLS136* @param[in] offset Seconds to skip137* @param[in] intermediateTime The name of the TLS138* @param[in] phaseDefined Whether phases are defined139*/140NIVisumTL(const std::string& name, SUMOTime cycleTime, SUMOTime offset, SUMOTime intermediateTime,141bool phaseDefined);142143/// @brief Destructor144~NIVisumTL();145146/// @brief Adds a node to control147void addNode(NBNode* n) {148myNodes.push_back(n);149}150151/// @brief Adds a signal group152void addSignalGroup(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);153154/// @brief Adds a phase155void addPhase(const std::string& name, SUMOTime startTime, SUMOTime endTime, SUMOTime yellowTime);156157/// @brief Returns the map of named phases158std::map<std::string, Phase*>& getPhases() {159return myPhases;160}161162/// @brief Returns the named signal group163SignalGroup& getSignalGroup(const std::string& name);164165/// @brief build the traffic light and add it to the given container166void build(NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);167168private:169/// @brief The name of traffic light170std::string myName;171172/// @brief The cycle time of traffic light in seconds173SUMOTime myCycleTime;174175/// @brief The offset in the plan176SUMOTime myOffset;177178/// @brief The all-red time (unused here)179SUMOTime myIntermediateTime;180181/// @brief Toggles the usage either of phases or of time periods in signal groups182bool myPhaseDefined;183184/// @brief Vector of nodes belonging to this traffic light185std::vector<NBNode*> myNodes;186187/// @brief Map of used phases if phases defined188std::map<std::string, Phase*> myPhases;189190/// @brief Map of used signal groups191std::map<std::string, SignalGroup*> mySignalGroups;192193194};195196197