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.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <cassert>
33 #include <iostream>
35 #include <utils/common/ToString.h>
38 #include "../NIImporter_Vissim.h"
39 #include "../tempstructs/NIVissimTL.h"
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
48 
49 
51 
52 
53 bool
55  //
56  int id;
57  from >> id; // type-checking is missing!
58  //
59  std::string tag;
60  tag = myRead(from);
61  std::string name;
62  if (tag == "name") {
63  name = readName(from);
64  tag = myRead(from);
65  }
66  //
67  int lsaid;
68  from >> lsaid;
70  if (tl == 0) {
71  WRITE_ERROR("A traffic light group with an unknown traffic light occured.\n Group-ID: " + toString<int>(id)
72  + "\n TrafficLight-ID: " + toString<int>(lsaid));
73  return false;
74  }
75  std::string type = tl->getType();
76  if (type == "festzeit") {
77  return parseFixedTime(id, name, lsaid, from);
78  }
79  if (type == "festzeit_fake") {
80  return parseFixedTime(id, name, lsaid, from);
81 // return parseExternFixedTime(id, name, lsaid, from);
82  }
83  if (type == "vas") {
84  return parseVAS(id, name, lsaid, from);
85  }
86  if (type == "vsplus") {
87  return parseVSPLUS(id, name, lsaid, from);
88  }
89  if (type == "trends") {
90  return parseTRENDS(id, name, lsaid, from);
91  }
92  if (type == "vap") {
93  return parseVAP(id, name, lsaid, from);
94  }
95  if (type == "tl") {
96  return parseTL(id, name, lsaid, from);
97  }
98  if (type == "pos") {
99  return parsePOS(id, name, lsaid, from);
100  }
101  WRITE_WARNING("Unsupported LSA-Type '" + type + "' occured.");
102  return true;
103 }
104 
105 
106 bool
108  int id, const std::string& name, int lsaid, std::istream& from) {
109  //
110  bool isGreenBegin;
111  std::vector<double> times;
112  std::string tag = myRead(from);
113  if (tag == "dauergruen") {
114  isGreenBegin = true;
115  from >> tag;
116  } else if (tag == "dauerrot") {
117  isGreenBegin = false;
118  from >> tag;
119  } else {
120  // the first phase will be green
121  isGreenBegin = true;
122  while (tag == "rotende" || tag == "gruenanfang") {
123  double point;
124  from >> point; // type-checking is missing!
125  times.push_back(point);
126  from >> tag;
127  from >> point; // type-checking is missing!
128  times.push_back(point);
129  tag = myRead(from);
130  }
131  }
132  //
133  double tredyellow, tyellow;
134  from >> tredyellow;
135  from >> tag;
136  from >> tyellow;
139  id, name, isGreenBegin, times, (SUMOTime) tredyellow, (SUMOTime) tyellow);
140  if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) {
141  throw 1; // !!!
142  }
143  return true;
144 }
145 
146 
147 bool
149  int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) {
150  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
151  std::string tag;
152  while (tag != "detektoren") {
153  tag = myRead(from);
154  }
155  return true;
156 }
157 
158 
159 bool
161  int /*id*/, const std::string&, int lsaid, std::istream&) {
162  WRITE_WARNING("VSPLUS 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_WARNING("TRENDS 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_WARNING("VAS 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_WARNING("TL 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_WARNING("POS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
195  return true;
196 }
197 
198 
199 bool
201  int /*id*/, const std::string&, int lsaid, std::istream&) {
202  WRITE_WARNING("externally defined traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
203  return true;
204 }
205 
206 
207 
208 /****************************************************************************/
209 
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.
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string getType() const
Definition: NIVissimTL.cpp:430
Importer for networks stored in Vissim format.
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 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.
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.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
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.
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:327
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
Definition: NIVissimTL.cpp:221
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.
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
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 parse(std::istream &from)
Parses the data type from the given stream.
long long int SUMOTime
Definition: TraCIDefs.h:51