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 /****************************************************************************/
17 //
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <cassert>
27 #include <iostream>
29 #include <utils/common/ToString.h>
32 #include "../NIImporter_Vissim.h"
33 #include "../tempstructs/NIVissimTL.h"
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
41  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
42 
43 
45 
46 
47 bool
49  //
50  int id;
51  from >> id; // type-checking is missing!
52  //
53  std::string tag;
54  tag = myRead(from);
55  std::string name;
56  if (tag == "name") {
57  name = readName(from);
58  tag = myRead(from);
59  }
60  //
61  int lsaid;
62  from >> lsaid;
64  if (tl == nullptr) {
65  WRITE_ERROR("A traffic light group with an unknown traffic light occurred.\n Group-ID: " + toString<int>(id)
66  + "\n TrafficLight-ID: " + toString<int>(lsaid));
67  return false;
68  }
69  std::string type = tl->getType();
70  if (type == "festzeit") {
71  return parseFixedTime(id, name, lsaid, from);
72  }
73  if (type == "festzeit_fake") {
74  return parseFixedTime(id, name, lsaid, from);
75 // return parseExternFixedTime(id, name, lsaid, from);
76  }
77  if (type == "vas") {
78  return parseVAS(id, name, lsaid, from);
79  }
80  if (type == "vsplus") {
81  return parseVSPLUS(id, name, lsaid, from);
82  }
83  if (type == "trends") {
84  return parseTRENDS(id, name, lsaid, from);
85  }
86  if (type == "vap") {
87  return parseVAP(id, name, lsaid, from);
88  }
89  if (type == "tl") {
90  return parseTL(id, name, lsaid, from);
91  }
92  if (type == "pos") {
93  return parsePOS(id, name, lsaid, from);
94  }
95  WRITE_WARNING("Unsupported LSA-Type '" + type + "' occurred.");
96  return true;
97 }
98 
99 
100 bool
102  int id, const std::string& name, int lsaid, std::istream& from) {
103  //
104  bool isGreenBegin;
105  std::vector<double> times;
106  std::string tag = myRead(from);
107  if (tag == "dauergruen") {
108  isGreenBegin = true;
109  from >> tag;
110  } else if (tag == "dauerrot") {
111  isGreenBegin = false;
112  from >> tag;
113  } else {
114  // the first phase will be green
115  isGreenBegin = true;
116  while (tag == "rotende" || tag == "gruenanfang") {
117  double point;
118  from >> point; // type-checking is missing!
119  times.push_back(point);
120  from >> tag;
121  from >> point; // type-checking is missing!
122  times.push_back(point);
123  tag = myRead(from);
124  }
125  }
126  //
127  double tredyellow, tyellow;
128  from >> tredyellow;
129  from >> tag;
130  from >> tyellow;
133  id, name, isGreenBegin, times, (SUMOTime) tredyellow, (SUMOTime) tyellow);
134  if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) {
135  throw 1; // !!!
136  }
137  return true;
138 }
139 
140 
141 bool
143  int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) {
144  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
145  std::string tag;
146  while (tag != "detektoren") {
147  tag = myRead(from);
148  }
149  return true;
150 }
151 
152 
153 bool
155  int /*id*/, const std::string&, int lsaid, std::istream&) {
156  WRITE_WARNING("VSPLUS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
157  return true;
158 }
159 
160 
161 bool
163  int /*id*/, const std::string&, int lsaid, std::istream&) {
164  WRITE_WARNING("TRENDS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
165  return true;
166 }
167 
168 
169 bool
171  int /*id*/, const std::string&, int lsaid, std::istream&) {
172  WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
173  return true;
174 }
175 
176 
177 bool
179  int /*id*/, const std::string&, int lsaid, std::istream&) {
180  WRITE_WARNING("TL traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
181  return true;
182 }
183 
184 
185 bool
187  int /*id*/, const std::string&, int lsaid, std::istream&) {
188  WRITE_WARNING("POS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
189  return true;
190 }
191 
192 
193 bool
195  int /*id*/, const std::string&, int lsaid, std::istream&) {
196  WRITE_WARNING("externally defined traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")");
197  return true;
198 }
199 
200 
201 
202 /****************************************************************************/
203 
NIVissimSingleTypeParser_Signalgruppendefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Signalgruppendefinition.cpp:48
ToString.h
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
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:178
MsgHandler.h
NIVissimTL::NIVissimTLSignalGroup
Definition: NIVissimTL.h:107
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:798
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:59
NIVissimSingleTypeParser_Signalgruppendefinition::~NIVissimSingleTypeParser_Signalgruppendefinition
~NIVissimSingleTypeParser_Signalgruppendefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Signalgruppendefinition.cpp:44
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:162
NIVissimTL::dictionary
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:321
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:170
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:154
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:142
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:186
NIVissimTL::NIVissimTLSignalGroup::dictionary
static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup *o)
Definition: NIVissimTL.cpp:215
NIVissimSingleTypeParser_Signalgruppendefinition.h
NIVissimTL
Definition: NIVissimTL.h:50
StringUtils.h
NIVissimTL::getType
std::string getType() const
Definition: NIVissimTL.cpp:424
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:101
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:671
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
NIVissimSingleTypeParser_Signalgruppendefinition::NIVissimSingleTypeParser_Signalgruppendefinition
NIVissimSingleTypeParser_Signalgruppendefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Signalgruppendefinition.cpp:40
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:194