SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimSingleTypeParser_Signalgruppendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 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 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
53 
54 
56 
57 
58 bool
60  //
61  int id;
62  from >> id; // type-checking is missing!
63  //
64  std::string tag;
65  tag = myRead(from);
66  std::string name;
67  if (tag == "name") {
68  name = readName(from);
69  tag = myRead(from);
70  }
71  //
72  int lsaid;
73  from >> lsaid;
75  if (tl == 0) {
76  WRITE_ERROR("A traffic light group with an unknown traffic light occured.\n Group-ID: " + toString<int>(id)
77  + "\n TrafficLight-ID: " + toString<int>(lsaid));
78  return false;
79  }
80  std::string type = tl->getType();
81  if (type == "festzeit") {
82  return parseFixedTime(id, name, lsaid, from);
83  }
84  if (type == "festzeit_fake") {
85  return parseFixedTime(id, name, lsaid, from);
86 // return parseExternFixedTime(id, name, lsaid, from);
87  }
88  if (type == "vas") {
89  return parseVAS(id, name, lsaid, from);
90  }
91  if (type == "vsplus") {
92  return parseVSPLUS(id, name, lsaid, from);
93  }
94  if (type == "trends") {
95  return parseTRENDS(id, name, lsaid, from);
96  }
97  if (type == "vap") {
98  return parseVAP(id, name, lsaid, from);
99  }
100  if (type == "tl") {
101  return parseTL(id, name, lsaid, from);
102  }
103  if (type == "pos") {
104  return parsePOS(id, name, lsaid, from);
105  }
106  WRITE_WARNING("Unsupported LSA-Type '" + type + "' occured.");
107  return true;
108 }
109 
110 
111 bool
113  int id, const std::string& name, int lsaid, std::istream& from) {
114  //
115  bool isGreenBegin;
116  std::vector<SUMOReal> times;
117  std::string tag = myRead(from);
118  if (tag == "dauergruen") {
119  isGreenBegin = true;
120  from >> tag;
121  } else if (tag == "dauerrot") {
122  isGreenBegin = false;
123  from >> tag;
124  } else {
125  // the first phase will be green
126  isGreenBegin = true;
127  while (tag == "rotende" || tag == "gruenanfang") {
128  SUMOReal point;
129  from >> point; // type-checking is missing!
130  times.push_back(point);
131  from >> tag;
132  from >> point; // type-checking is missing!
133  times.push_back(point);
134  tag = myRead(from);
135  }
136  }
137  //
138  SUMOReal tredyellow, tyellow;
139  from >> tredyellow;
140  from >> tag;
141  from >> tyellow;
144  lsaid, id, name, isGreenBegin, times, (SUMOTime) tredyellow, (SUMOTime) tyellow);
145  if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) {
146  throw 1; // !!!
147  }
148  return true;
149 }
150 
151 
152 bool
154  int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) {
155  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
156  std::string tag;
157  while (tag != "detektoren") {
158  tag = myRead(from);
159  }
160  return true;
161 }
162 
163 
164 bool
166  int /*id*/, const std::string&, int lsaid, std::istream&) {
167  WRITE_WARNING("VSPLUS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
168  return true;
169 }
170 
171 
172 bool
174  int /*id*/, const std::string&, int lsaid, std::istream&) {
175  WRITE_WARNING("TRENDS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
176  return true;
177 }
178 
179 
180 bool
182  int /*id*/, const std::string&, int lsaid, std::istream&) {
183  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
184  return true;
185 }
186 
187 
188 bool
190  int /*id*/, const std::string&, int lsaid, std::istream&) {
191  WRITE_WARNING("TL traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
192  return true;
193 }
194 
195 
196 bool
198  int /*id*/, const std::string&, int lsaid, std::istream&) {
199  WRITE_WARNING("POS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
200  return true;
201 }
202 
203 
204 bool
206  int /*id*/, const std::string&, int lsaid, std::istream&) {
207  WRITE_WARNING("externally defined traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
208  return true;
209 }
210 
211 
212 
213 /****************************************************************************/
214 
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 getType() const
Definition: NIVissimTL.cpp:435
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 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:196
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:332
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
Definition: NIVissimTL.cpp:226
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 &quot;&lt;&lt;&quot; operator, as names may contain more than one wor...
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
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.
#define SUMOReal
Definition: config.h:215