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 /****************************************************************************/
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
28 #include "../NIImporter_Vissim.h"
29 #include "../tempstructs/NIVissimTL.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
37  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
38 
39 
41 
42 
43 bool
45  //
46  int id;
47  from >> id;
48  //
49  std::string tag, name;
50  tag = myRead(from);
51  if (tag == "name") {
52  name = readName(from);
53  tag = myRead(from);
54  }
55  // type
56  std::string type;
57  type = myRead(from);
58  if (type == "festzeit") {
59  return parseFixedTime(id, name, from);
60  }
61  if (type == "vas") {
62  return parseVAS(id, name, from);
63  }
64  if (type == "vsplus") {
65  return parseRestActuated(id, name, from, type);
66  }
67  if (type == "trends") {
68  return parseRestActuated(id, name, from, type);
69  }
70  if (type == "vap") {
71  return parseRestActuated(id, name, from, type);
72  }
73  if (type == "tl") {
74  return parseRestActuated(id, name, from, type);
75  }
76  if (type == "pos") {
77  return parseRestActuated(id, name, from, type);
78  }
79  if (type == "nema") {
80  return parseRestActuated(id, name, from, type);
81  }
82  if (type == "extern") {
83  return parseRestActuated(id, name, from, type);
84  }
85  WRITE_ERROR("Unsupported LSA-Type '" + type + "' occurred.");
86  return false;
87 }
88 
89 
90 bool
92  int id, std::string name, std::istream& from) {
93  std::string type = "festzeit";
94  std::string tag;
95  from >> tag;
96  //
97  double absdur;
98  from >> absdur; // type-checking is missing!
99  //
100  tag = readEndSecure(from);
101  double offset = 0;
102  if (tag == "versatz") {
103  from >> offset; // type-checking is missing!
104  }
105  if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
106  tag = readEndSecure(from);
107  if (tag == "szpkonfdatei" || tag == "progdatei") {
108  type = "festzeit_fake";
109  }
110  }
111  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
112 }
113 
114 
115 bool
117  int id, std::string name, std::istream& from) {
118  std::string tag;
119  from >> tag;
120  //
121  double absdur;
122  from >> absdur; // type-checking is missing!
123  //
124  tag = readEndSecure(from);
125  double offset = 0;
126  if (tag == "versatz") {
127  from >> offset; // type-checking is missing!
128  }
129  return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
130 }
131 
132 
133 bool
135  int id, std::string name, std::istream& from, const std::string& type) {
136  std::string tag;
137  from >> tag;
138  //
139  double absdur;
140  from >> absdur; // type-checking is missing!
141  //
142  tag = readEndSecure(from);
143  double offset = 0;
144  if (tag == "versatz") {
145  from >> offset; // type-checking is missing!
146  }
147  while (tag != "datei") {
148  tag = myRead(from);
149  }
150  return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
151 }
152 
153 
154 
155 /****************************************************************************/
156 
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::NIVissimSingleTypeParser_Lichtsignalanlagendefinition
NIVissimSingleTypeParser_Lichtsignalanlagendefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:36
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::~NIVissimSingleTypeParser_Lichtsignalanlagendefinition
~NIVissimSingleTypeParser_Lichtsignalanlagendefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:40
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:797
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimTL::dictionary
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:320
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:679
NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp:44
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:91
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:116
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:134
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:670
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283