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.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
35 #include "../NIImporter_Vissim.h"
36 #include "../tempstructs/NIVissimTL.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
44  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
45 
46 
48 
49 
50 bool
52  //
53  int id;
54  from >> id;
55  //
56  std::string tag, name;
57  tag = myRead(from);
58  if (tag == "name") {
59  name = readName(from);
60  tag = myRead(from);
61  }
62  // type
63  std::string type;
64  type = myRead(from);
65  if (type == "festzeit") {
66  return parseFixedTime(id, name, from);
67  }
68  if (type == "vas") {
69  return parseVAS(id, name, from);
70  }
71  if (type == "vsplus") {
72  return parseRestActuated(id, name, from, type);
73  }
74  if (type == "trends") {
75  return parseRestActuated(id, name, from, type);
76  }
77  if (type == "vap") {
78  return parseRestActuated(id, name, from, type);
79  }
80  if (type == "tl") {
81  return parseRestActuated(id, name, from, type);
82  }
83  if (type == "pos") {
84  return parseRestActuated(id, name, from, type);
85  }
86  if (type == "nema") {
87  return parseRestActuated(id, name, from, type);
88  }
89  if (type == "extern") {
90  return parseRestActuated(id, name, from, type);
91  }
92  WRITE_ERROR("Unsupported LSA-Type '" + type + "' occured.");
93  return false;
94 }
95 
96 
97 bool
99  int id, std::string name, std::istream& from) {
100  std::string type = "festzeit";
101  std::string tag;
102  from >> tag;
103  //
104  double absdur;
105  from >> absdur; // type-checking is missing!
106  //
107  tag = readEndSecure(from);
108  double offset = 0;
109  if (tag == "versatz") {
110  from >> offset; // type-checking is missing!
111  }
112  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
113  tag = readEndSecure(from);
114  if (tag == "szpkonfdatei" || tag == "progdatei") {
115  type = "festzeit_fake";
116  }
117  }
118  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
119 }
120 
121 
122 bool
124  int id, std::string name, std::istream& from) {
125  std::string tag;
126  from >> tag;
127  //
128  double absdur;
129  from >> absdur; // type-checking is missing!
130  //
131  tag = readEndSecure(from);
132  double offset = 0;
133  if (tag == "versatz") {
134  from >> offset; // type-checking is missing!
135  }
136  return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
137 }
138 
139 
140 bool
142  int id, std::string name, std::istream& from, const std::string& type) {
143  std::string tag;
144  from >> tag;
145  //
146  double absdur;
147  from >> absdur; // type-checking is missing!
148  //
149  tag = readEndSecure(from);
150  double offset = 0;
151  if (tag == "versatz") {
152  from >> offset; // type-checking is missing!
153  }
154  while (tag != "datei") {
155  tag = myRead(from);
156  }
157  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
158 }
159 
160 
161 
162 /****************************************************************************/
163 
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Importer for networks stored in Vissim format.
bool parseRestActuated(int id, std::string name, std::istream &from, const std::string &type)
Parses actuated traffic lights (beside VAS)
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:327
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.
bool parseFixedTime(int id, std::string name, std::istream &from)
parses a traffic light with fixed times (no other types are supported by now)
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:205
long long int SUMOTime
Definition: TraCIDefs.h:51