Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 //
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <iostream>
30 
31 
32 // ===========================================================================
33 // method definitions
34 // ===========================================================================
36  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
37 
38 
40 
41 
42 bool
44  //
45  int id;
46  from >> id;
47  //
48  std::string tag, name;
49  tag = myRead(from);
50  if (tag == "name") {
51  name = readName(from);
52  tag = myRead(from);
53  }
54  // type
55  std::string type;
56  type = myRead(from);
57  if (type == "festzeit") {
58  return parseFixedTime(id, name, from);
59  }
60  if (type == "vas") {
61  return parseVAS(id, name, from);
62  }
63  if (type == "vsplus") {
64  return parseRestActuated(id, name, from, type);
65  }
66  if (type == "trends") {
67  return parseRestActuated(id, name, from, type);
68  }
69  if (type == "vap") {
70  return parseRestActuated(id, name, from, type);
71  }
72  if (type == "tl") {
73  return parseRestActuated(id, name, from, type);
74  }
75  if (type == "pos") {
76  return parseRestActuated(id, name, from, type);
77  }
78  if (type == "nema") {
79  return parseRestActuated(id, name, from, type);
80  }
81  if (type == "extern") {
82  return parseRestActuated(id, name, from, type);
83  }
84  WRITE_ERRORF(TL("Unsupported LSA-Type '%' occurred."), type);
85  return false;
86 }
87 
88 
89 bool
91  int id, std::string name, std::istream& from) {
92  std::string type = "festzeit";
93  std::string tag;
94  from >> tag;
95  //
96  double absdur;
97  from >> absdur; // type-checking is missing!
98  //
99  tag = readEndSecure(from);
100  double offset = 0;
101  if (tag == "versatz") {
102  from >> offset; // type-checking is missing!
103  }
104  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
105  tag = readEndSecure(from);
106  if (tag == "szpkonfdatei" || tag == "progdatei") {
107  type = "festzeit_fake";
108  }
109  }
110  return NIVissimTL::dictionary(id, type, name, TIME2STEPS(absdur), TIME2STEPS(offset));
111 }
112 
113 
114 bool
116  int id, std::string name, std::istream& from) {
117  std::string tag;
118  from >> tag;
119  //
120  double absdur;
121  from >> absdur; // type-checking is missing!
122  //
123  tag = readEndSecure(from);
124  double offset = 0;
125  if (tag == "versatz") {
126  from >> offset; // type-checking is missing!
127  }
128  return NIVissimTL::dictionary(id, "vas", name, TIME2STEPS(absdur), TIME2STEPS(offset));
129 }
130 
131 
132 bool
134  int id, std::string name, std::istream& from, const std::string& type) {
135  std::string tag;
136  from >> tag;
137  //
138  double absdur;
139  from >> absdur; // type-checking is missing!
140  //
141  tag = readEndSecure(from);
142  double offset = 0;
143  if (tag == "versatz") {
144  from >> offset; // type-checking is missing!
145  }
146  while (tag != "datei") {
147  tag = myRead(from);
148  }
149  return NIVissimTL::dictionary(id, type, name, TIME2STEPS(absdur), TIME2STEPS(offset));
150 }
151 
152 
153 /****************************************************************************/
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:305
#define TL(string)
Definition: MsgHandler.h:315
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
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 parseFixedTime(int id, std::string name, std::istream &from)
parses a traffic light with fixed times (no other types are supported by now)
bool parseRestActuated(int id, std::string name, std::istream &from, const std::string &type)
Parses actuated traffic lights (beside VAS)
bool parseVAS(int id, std::string name, std::istream &from)
Parses a vas-traffic light; All other actuated traffic lights are parsed using "parseRestActuated" as...
bool parse(std::istream &from)
Parses the data type from the given stream.
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:310