SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Signalgruppendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <cassert>
34 #include <iostream>
36 #include <utils/common/ToString.h>
39 #include "../NIImporter_Vissim.h"
40 #include "../tempstructs/NIVissimTL.h"
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
48  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
49 
50 
52 
53 
54 bool
56  //
57  int id;
58  from >> id; // type-checking is missing!
59  //
60  std::string tag;
61  tag = myRead(from);
62  std::string name;
63  if (tag == "name") {
64  name = readName(from);
65  tag = myRead(from);
66  }
67  //
68  int lsaid;
69  from >> lsaid;
71  if (tl == 0) {
72  WRITE_ERROR("A traffic light group with an unknown traffic light occured.\n Group-ID: " + toString<int>(id)
73  + "\n TrafficLight-ID: " + toString<int>(lsaid));
74  return false;
75  }
76  std::string type = tl->getType();
77  if (type == "festzeit") {
78  return parseFixedTime(id, name, lsaid, from);
79  }
80  if (type == "festzeit_fake") {
81  return parseFixedTime(id, name, lsaid, from);
82 // return parseExternFixedTime(id, name, lsaid, from);
83  }
84  if (type == "vas") {
85  return parseVAS(id, name, lsaid, from);
86  }
87  if (type == "vsplus") {
88  return parseVSPLUS(id, name, lsaid, from);
89  }
90  if (type == "trends") {
91  return parseTRENDS(id, name, lsaid, from);
92  }
93  if (type == "vap") {
94  return parseVAP(id, name, lsaid, from);
95  }
96  if (type == "tl") {
97  return parseTL(id, name, lsaid, from);
98  }
99  if (type == "pos") {
100  return parsePOS(id, name, lsaid, from);
101  }
102  WRITE_WARNING("Unsupported LSA-Type '" + type + "' occured.");
103  return true;
104 }
105 
106 
107 bool
109  int id, const std::string& name, int lsaid, std::istream& from) {
110  //
111  bool isGreenBegin;
112  std::vector<double> times;
113  std::string tag = myRead(from);
114  if (tag == "dauergruen") {
115  isGreenBegin = true;
116  from >> tag;
117  } else if (tag == "dauerrot") {
118  isGreenBegin = false;
119  from >> tag;
120  } else {
121  // the first phase will be green
122  isGreenBegin = true;
123  while (tag == "rotende" || tag == "gruenanfang") {
124  double point;
125  from >> point; // type-checking is missing!
126  times.push_back(point);
127  from >> tag;
128  from >> point; // type-checking is missing!
129  times.push_back(point);
130  tag = myRead(from);
131  }
132  }
133  //
134  double tredyellow, tyellow;
135  from >> tredyellow;
136  from >> tag;
137  from >> tyellow;
140  id, name, isGreenBegin, times, (SUMOTime) tredyellow, (SUMOTime) tyellow);
141  if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) {
142  throw 1; // !!!
143  }
144  return true;
145 }
146 
147 
148 bool
150  int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) {
151  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
152  std::string tag;
153  while (tag != "detektoren") {
154  tag = myRead(from);
155  }
156  return true;
157 }
158 
159 
160 bool
162  int /*id*/, const std::string&, int lsaid, std::istream&) {
163  WRITE_WARNING("VSPLUS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
164  return true;
165 }
166 
167 
168 bool
170  int /*id*/, const std::string&, int lsaid, std::istream&) {
171  WRITE_WARNING("TRENDS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
172  return true;
173 }
174 
175 
176 bool
178  int /*id*/, const std::string&, int lsaid, std::istream&) {
179  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
180  return true;
181 }
182 
183 
184 bool
186  int /*id*/, const std::string&, int lsaid, std::istream&) {
187  WRITE_WARNING("TL traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
188  return true;
189 }
190 
191 
192 bool
194  int /*id*/, const std::string&, int lsaid, std::istream&) {
195  WRITE_WARNING("POS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
196  return true;
197 }
198 
199 
200 bool
202  int /*id*/, const std::string&, int lsaid, std::istream&) {
203  WRITE_WARNING("externally defined traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
204  return true;
205 }
206 
207 
208 
209 /****************************************************************************/
210 
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:431
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:200
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:328
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
Definition: NIVissimTL.cpp:222
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:206
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:52