SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimSingleTypeParser_Lichtsignalanlagendefinition.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-2014 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 <iostream>
36 #include "../NIImporter_Vissim.h"
37 #include "../tempstructs/NIVissimTL.h"
39 
40 #ifdef CHECK_MEMORY_LEAKS
41 #include <foreign/nvwa/debug_new.h>
42 #endif // CHECK_MEMORY_LEAKS
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
49  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
50 
51 
53 
54 
55 bool
57  //
58  int id;
59  from >> id;
60  //
61  std::string tag, name;
62  tag = myRead(from);
63  if (tag == "name") {
64  name = readName(from);
65  tag = myRead(from);
66  }
67  // type
68  std::string type;
69  type = myRead(from);
70  if (type == "festzeit") {
71  return parseFixedTime(id, name, from);
72  }
73  if (type == "vas") {
74  return parseVAS(id, name, from);
75  }
76  if (type == "vsplus") {
77  return parseRestActuated(id, name, from, type);
78  }
79  if (type == "trends") {
80  return parseRestActuated(id, name, from, type);
81  }
82  if (type == "vap") {
83  return parseRestActuated(id, name, from, type);
84  }
85  if (type == "tl") {
86  return parseRestActuated(id, name, from, type);
87  }
88  if (type == "pos") {
89  return parseRestActuated(id, name, from, type);
90  }
91  if (type == "nema") {
92  return parseRestActuated(id, name, from, type);
93  }
94  if (type == "extern") {
95  return parseRestActuated(id, name, from, type);
96  }
97  WRITE_ERROR("Unsupported LSA-Type '" + type + "' occured.");
98  return false;
99 }
100 
101 
102 bool
104  int id, std::string name, std::istream& from) {
105  std::string type = "festzeit";
106  std::string tag;
107  from >> tag;
108  //
109  SUMOReal absdur;
110  from >> absdur; // type-checking is missing!
111  //
112  tag = readEndSecure(from);
113  SUMOReal offset = 0;
114  if (tag == "versatz") {
115  from >> offset; // type-checking is missing!
116  }
117  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
118  tag = readEndSecure(from);
119  if (tag == "szpkonfdatei" || tag == "progdatei") {
120  type = "festzeit_fake";
121  }
122  }
123  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
124 }
125 
126 
127 bool
129  int id, std::string name, std::istream& from) {
130  std::string tag;
131  from >> tag;
132  //
133  SUMOReal absdur;
134  from >> absdur; // type-checking is missing!
135  //
136  tag = readEndSecure(from);
137  SUMOReal offset = 0;
138  if (tag == "versatz") {
139  from >> offset; // type-checking is missing!
140  }
141  return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
142 }
143 
144 
145 bool
147  int id, std::string name, std::istream& from, const std::string& type) {
148  std::string tag;
149  from >> tag;
150  //
151  SUMOReal absdur;
152  from >> absdur; // type-checking is missing!
153  //
154  tag = readEndSecure(from);
155  SUMOReal offset = 0;
156  if (tag == "versatz") {
157  from >> offset; // type-checking is missing!
158  }
159  while (tag != "datei") {
160  tag = myRead(from);
161  }
162  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
163 }
164 
165 
166 
167 /****************************************************************************/
168 
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:332
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 wor...
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
#define SUMOReal
Definition: config.h:215