SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 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 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
45  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
46 
47 
49 
50 
51 bool
53  //
54  int id;
55  from >> id;
56  //
57  std::string tag, name;
58  tag = myRead(from);
59  if (tag == "name") {
60  name = readName(from);
61  tag = myRead(from);
62  }
63  // type
64  std::string type;
65  type = myRead(from);
66  if (type == "festzeit") {
67  return parseFixedTime(id, name, from);
68  }
69  if (type == "vas") {
70  return parseVAS(id, name, from);
71  }
72  if (type == "vsplus") {
73  return parseRestActuated(id, name, from, type);
74  }
75  if (type == "trends") {
76  return parseRestActuated(id, name, from, type);
77  }
78  if (type == "vap") {
79  return parseRestActuated(id, name, from, type);
80  }
81  if (type == "tl") {
82  return parseRestActuated(id, name, from, type);
83  }
84  if (type == "pos") {
85  return parseRestActuated(id, name, from, type);
86  }
87  if (type == "nema") {
88  return parseRestActuated(id, name, from, type);
89  }
90  if (type == "extern") {
91  return parseRestActuated(id, name, from, type);
92  }
93  WRITE_ERROR("Unsupported LSA-Type '" + type + "' occured.");
94  return false;
95 }
96 
97 
98 bool
100  int id, std::string name, std::istream& from) {
101  std::string type = "festzeit";
102  std::string tag;
103  from >> tag;
104  //
105  double absdur;
106  from >> absdur; // type-checking is missing!
107  //
108  tag = readEndSecure(from);
109  double offset = 0;
110  if (tag == "versatz") {
111  from >> offset; // type-checking is missing!
112  }
113  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
114  tag = readEndSecure(from);
115  if (tag == "szpkonfdatei" || tag == "progdatei") {
116  type = "festzeit_fake";
117  }
118  }
119  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
120 }
121 
122 
123 bool
125  int id, std::string name, std::istream& from) {
126  std::string tag;
127  from >> tag;
128  //
129  double absdur;
130  from >> absdur; // type-checking is missing!
131  //
132  tag = readEndSecure(from);
133  double offset = 0;
134  if (tag == "versatz") {
135  from >> offset; // type-checking is missing!
136  }
137  return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
138 }
139 
140 
141 bool
143  int id, std::string name, std::istream& from, const std::string& type) {
144  std::string tag;
145  from >> tag;
146  //
147  double absdur;
148  from >> absdur; // type-checking is missing!
149  //
150  tag = readEndSecure(from);
151  double offset = 0;
152  if (tag == "versatz") {
153  from >> offset; // type-checking is missing!
154  }
155  while (tag != "datei") {
156  tag = myRead(from);
157  }
158  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
159 }
160 
161 
162 
163 /****************************************************************************/
164 
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:328
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:206
long long int SUMOTime
Definition: TraCIDefs.h:52