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.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 <iostream>
29 #include "../NIImporter_Vissim.h"
30 #include "../tempstructs/NIVissimTL.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
38  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
39 
40 
42 
43 
44 bool
46  //
47  int id;
48  from >> id;
49  //
50  std::string tag, name;
51  tag = myRead(from);
52  if (tag == "name") {
53  name = readName(from);
54  tag = myRead(from);
55  }
56  // type
57  std::string type;
58  type = myRead(from);
59  if (type == "festzeit") {
60  return parseFixedTime(id, name, from);
61  }
62  if (type == "vas") {
63  return parseVAS(id, name, from);
64  }
65  if (type == "vsplus") {
66  return parseRestActuated(id, name, from, type);
67  }
68  if (type == "trends") {
69  return parseRestActuated(id, name, from, type);
70  }
71  if (type == "vap") {
72  return parseRestActuated(id, name, from, type);
73  }
74  if (type == "tl") {
75  return parseRestActuated(id, name, from, type);
76  }
77  if (type == "pos") {
78  return parseRestActuated(id, name, from, type);
79  }
80  if (type == "nema") {
81  return parseRestActuated(id, name, from, type);
82  }
83  if (type == "extern") {
84  return parseRestActuated(id, name, from, type);
85  }
86  WRITE_ERROR("Unsupported LSA-Type '" + type + "' occurred.");
87  return false;
88 }
89 
90 
91 bool
93  int id, std::string name, std::istream& from) {
94  std::string type = "festzeit";
95  std::string tag;
96  from >> tag;
97  //
98  double absdur;
99  from >> absdur; // type-checking is missing!
100  //
101  tag = readEndSecure(from);
102  double offset = 0;
103  if (tag == "versatz") {
104  from >> offset; // type-checking is missing!
105  }
106  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
107  tag = readEndSecure(from);
108  if (tag == "szpkonfdatei" || tag == "progdatei") {
109  type = "festzeit_fake";
110  }
111  }
112  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
113 }
114 
115 
116 bool
118  int id, std::string name, std::istream& from) {
119  std::string tag;
120  from >> tag;
121  //
122  double absdur;
123  from >> absdur; // type-checking is missing!
124  //
125  tag = readEndSecure(from);
126  double offset = 0;
127  if (tag == "versatz") {
128  from >> offset; // type-checking is missing!
129  }
130  return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
131 }
132 
133 
134 bool
136  int id, std::string name, std::istream& from, const std::string& type) {
137  std::string tag;
138  from >> tag;
139  //
140  double absdur;
141  from >> absdur; // type-checking is missing!
142  //
143  tag = readEndSecure(from);
144  double offset = 0;
145  if (tag == "versatz") {
146  from >> offset; // type-checking is missing!
147  }
148  while (tag != "datei") {
149  tag = myRead(from);
150  }
151  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
152 }
153 
154 
155 
156 /****************************************************************************/
157 
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::NIVissimSingleTypeParser_Lichtsignalanlagendefinition
NIVissimSingleTypeParser_Lichtsignalanlagendefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:37
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::~NIVissimSingleTypeParser_Lichtsignalanlagendefinition
~NIVissimSingleTypeParser_Lichtsignalanlagendefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:41
MsgHandler.h
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
NIVissimTL::dictionary
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:321
NIImporter_Vissim::VissimSingleTypeParser::readEndSecure
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Definition: NIImporter_Vissim.cpp:680
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:45
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseFixedTime
bool parseFixedTime(int id, std::string name, std::istream &from)
parses a traffic light with fixed times (no other types are supported by now)
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:92
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseVAS
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...
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:117
NIVissimSingleTypeParser_Lichtsignalanlagendefinition.h
StringUtils.h
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseRestActuated
bool parseRestActuated(int id, std::string name, std::istream &from, const std::string &type)
Parses actuated traffic lights (beside VAS)
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:135
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