Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Signalgruppendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
20 //
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <cassert>
25 #include <iostream>
27 #include <utils/common/ToString.h>
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
39  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
40 
41 
43 
44 
45 bool
47  //
48  int id;
49  from >> id; // type-checking is missing!
50  //
51  std::string tag;
52  tag = myRead(from);
53  std::string name;
54  if (tag == "name") {
55  name = readName(from);
56  tag = myRead(from);
57  }
58  //
59  int lsaid;
60  from >> lsaid;
62  if (tl == nullptr) {
63  WRITE_ERROR("A traffic light group with an unknown traffic light occurred.\n Group-ID: " + toString<int>(id)
64  + "\n TrafficLight-ID: " + toString<int>(lsaid));
65  return false;
66  }
67  std::string type = tl->getType();
68  if (type == "festzeit") {
69  return parseFixedTime(id, name, lsaid, from);
70  }
71  if (type == "festzeit_fake") {
72  return parseFixedTime(id, name, lsaid, from);
73 // return parseExternFixedTime(id, name, lsaid, from);
74  }
75  if (type == "vas") {
76  return parseVAS(id, name, lsaid, from);
77  }
78  if (type == "vsplus") {
79  return parseVSPLUS(id, name, lsaid, from);
80  }
81  if (type == "trends") {
82  return parseTRENDS(id, name, lsaid, from);
83  }
84  if (type == "vap") {
85  return parseVAP(id, name, lsaid, from);
86  }
87  if (type == "tl") {
88  return parseTL(id, name, lsaid, from);
89  }
90  if (type == "pos") {
91  return parsePOS(id, name, lsaid, from);
92  }
93  WRITE_WARNINGF(TL("Unsupported LSA-Type '%' occurred."), type);
94  return true;
95 }
96 
97 
98 bool
100  int id, const std::string& name, int lsaid, std::istream& from) {
101  //
102  bool isGreenBegin;
103  std::vector<SUMOTime> times;
104  std::string tag = myRead(from);
105  if (tag == "dauergruen") {
106  isGreenBegin = true;
107  from >> tag;
108  } else if (tag == "dauerrot") {
109  isGreenBegin = false;
110  from >> tag;
111  } else {
112  // the first phase will be green
113  isGreenBegin = true;
114  while (tag == "rotende" || tag == "gruenanfang") {
115  double point;
116  from >> point; // type-checking is missing!
117  times.push_back(TIME2STEPS(point));
118  from >> tag;
119  from >> point; // type-checking is missing!
120  times.push_back(TIME2STEPS(point));
121  tag = myRead(from);
122  }
123  }
124  //
125  double tredyellow, tyellow;
126  from >> tredyellow;
127  from >> tag;
128  from >> tyellow;
131  id, name, isGreenBegin, times, TIME2STEPS(tredyellow), TIME2STEPS(tyellow));
132  if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) {
133  throw 1; // !!!
134  }
135  return true;
136 }
137 
138 
139 bool
141  int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) {
142  WRITE_WARNINGF(TL("VAS traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
143  std::string tag;
144  while (tag != "detektoren") {
145  tag = myRead(from);
146  }
147  return true;
148 }
149 
150 
151 bool
153  int /*id*/, const std::string&, int lsaid, std::istream&) {
154  WRITE_WARNINGF(TL("VSPLUS traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
155  return true;
156 }
157 
158 
159 bool
161  int /*id*/, const std::string&, int lsaid, std::istream&) {
162  WRITE_WARNINGF(TL("TRENDS traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
163  return true;
164 }
165 
166 
167 bool
169  int /*id*/, const std::string&, int lsaid, std::istream&) {
170  WRITE_WARNINGF(TL("VAS traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
171  return true;
172 }
173 
174 
175 bool
177  int /*id*/, const std::string&, int lsaid, std::istream&) {
178  WRITE_WARNINGF(TL("TL traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
179  return true;
180 }
181 
182 
183 bool
185  int /*id*/, const std::string&, int lsaid, std::istream&) {
186  WRITE_WARNINGF(TL("POS traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
187  return true;
188 }
189 
190 
191 bool
193  int /*id*/, const std::string&, int lsaid, std::istream&) {
194  WRITE_WARNINGF(TL("externally defined traffic lights are not supported (lsa=%)"), toString<int>(lsaid));
195  return true;
196 }
197 
198 
199 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define TL(string)
Definition: MsgHandler.h:315
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Importer for networks stored in Vissim format.
bool parse(std::istream &from)
Parses the data type from the given stream.
bool parseVAS(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a VAS traffic light.
bool parseVAP(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a VAStraffic light.
bool parseTL(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a TL traffic light.
bool parsePOS(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a POS traffic light.
bool parseTRENDS(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a TRENDS traffic light.
bool parseExternFixedTime(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs fixed time traffic light with an extern definition.
bool parseVSPLUS(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a VSPLUS traffic light.
bool parseFixedTime(int id, const std::string &name, int lsaid, std::istream &from)
Parses a traffic light group which belongs to a fixed time traffic light.
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
Definition: NIVissimTL.cpp:213
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:310
std::string getType() const
Definition: NIVissimTL.cpp:413