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