SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <cassert> 00034 #include <iostream> 00035 #include <utils/common/TplConvert.h> 00036 #include <utils/common/ToString.h> 00037 #include <utils/common/MsgHandler.h> 00038 #include <utils/common/VectorHelper.h> 00039 #include "../NIImporter_Vissim.h" 00040 #include "../tempstructs/NIVissimTL.h" 00041 #include "NIVissimSingleTypeParser_Signalgruppendefinition.h" 00042 00043 #ifdef CHECK_MEMORY_LEAKS 00044 #include <foreign/nvwa/debug_new.h> 00045 #endif // CHECK_MEMORY_LEAKS 00046 00047 00048 // =========================================================================== 00049 // method definitions 00050 // =========================================================================== 00051 NIVissimSingleTypeParser_Signalgruppendefinition::NIVissimSingleTypeParser_Signalgruppendefinition(NIImporter_Vissim& parent) 00052 : NIImporter_Vissim::VissimSingleTypeParser(parent) {} 00053 00054 00055 NIVissimSingleTypeParser_Signalgruppendefinition::~NIVissimSingleTypeParser_Signalgruppendefinition() {} 00056 00057 00058 bool 00059 NIVissimSingleTypeParser_Signalgruppendefinition::parse(std::istream& from) { 00060 // 00061 int id; 00062 from >> id; // type-checking is missing! 00063 // 00064 std::string tag; 00065 tag = myRead(from); 00066 std::string name; 00067 if (tag == "name") { 00068 name = readName(from); 00069 tag = myRead(from); 00070 } 00071 // 00072 int lsaid; 00073 from >> lsaid; 00074 NIVissimTL* tl = NIVissimTL::dictionary(lsaid); 00075 if (tl == 0) { 00076 WRITE_ERROR("A traffic light group with an unknown traffic light occured.\n Group-ID: " + toString<int>(id) 00077 + "\n TrafficLight-ID: " + toString<int>(lsaid)); 00078 return false; 00079 } 00080 std::string type = tl->getType(); 00081 if (type == "festzeit") { 00082 return parseFixedTime(id, name, lsaid, from); 00083 } 00084 if (type == "festzeit_fake") { 00085 return parseFixedTime(id, name, lsaid, from); 00086 // return parseExternFixedTime(id, name, lsaid, from); 00087 } 00088 if (type == "vas") { 00089 return parseVAS(id, name, lsaid, from); 00090 } 00091 if (type == "vsplus") { 00092 return parseVSPLUS(id, name, lsaid, from); 00093 } 00094 if (type == "trends") { 00095 return parseTRENDS(id, name, lsaid, from); 00096 } 00097 if (type == "vap") { 00098 return parseVAP(id, name, lsaid, from); 00099 } 00100 if (type == "tl") { 00101 return parseTL(id, name, lsaid, from); 00102 } 00103 if (type == "pos") { 00104 return parsePOS(id, name, lsaid, from); 00105 } 00106 WRITE_WARNING("Unsupported LSA-Type '" + type + "' occured."); 00107 return true; 00108 } 00109 00110 00111 bool 00112 NIVissimSingleTypeParser_Signalgruppendefinition::parseFixedTime( 00113 int id, const std::string& name, int lsaid, std::istream& from) { 00114 // 00115 bool isGreenBegin; 00116 std::vector<SUMOReal> times; 00117 std::string tag = myRead(from); 00118 if (tag == "dauergruen") { 00119 isGreenBegin = true; 00120 from >> tag; 00121 } else if (tag == "dauerrot") { 00122 isGreenBegin = false; 00123 from >> tag; 00124 } else { 00125 // the first phase will be green 00126 isGreenBegin = true; 00127 while (tag == "rotende" || tag == "gruenanfang") { 00128 SUMOReal point; 00129 from >> point; // type-checking is missing! 00130 times.push_back(point); 00131 from >> tag; 00132 from >> point; // type-checking is missing! 00133 times.push_back(point); 00134 tag = myRead(from); 00135 } 00136 } 00137 // 00138 SUMOReal tredyellow, tyellow; 00139 from >> tredyellow; 00140 from >> tag; 00141 from >> tyellow; 00142 NIVissimTL::NIVissimTLSignalGroup* group = 00143 new NIVissimTL::NIVissimTLSignalGroup( 00144 lsaid, id, name, isGreenBegin, times, (SUMOTime) tredyellow, (SUMOTime) tyellow); 00145 if (!NIVissimTL::NIVissimTLSignalGroup::dictionary(lsaid, id, group)) { 00146 throw 1; // !!! 00147 } 00148 return true; 00149 } 00150 00151 00152 bool 00153 NIVissimSingleTypeParser_Signalgruppendefinition::parseVAS( 00154 int /*id*/, const std::string& /*name*/, int lsaid, std::istream& from) { 00155 WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00156 std::string tag; 00157 while (tag != "detektoren") { 00158 tag = myRead(from); 00159 } 00160 return true; 00161 } 00162 00163 00164 bool 00165 NIVissimSingleTypeParser_Signalgruppendefinition::parseVSPLUS( 00166 int /*id*/, const std::string&, int lsaid, std::istream&) { 00167 WRITE_WARNING("VSPLUS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00168 return true; 00169 } 00170 00171 00172 bool 00173 NIVissimSingleTypeParser_Signalgruppendefinition::parseTRENDS( 00174 int /*id*/, const std::string&, int lsaid, std::istream&) { 00175 WRITE_WARNING("TRENDS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00176 return true; 00177 } 00178 00179 00180 bool 00181 NIVissimSingleTypeParser_Signalgruppendefinition::parseVAP( 00182 int /*id*/, const std::string&, int lsaid, std::istream&) { 00183 WRITE_WARNING("VAS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00184 return true; 00185 } 00186 00187 00188 bool 00189 NIVissimSingleTypeParser_Signalgruppendefinition::parseTL( 00190 int /*id*/, const std::string&, int lsaid, std::istream&) { 00191 WRITE_WARNING("TL traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00192 return true; 00193 } 00194 00195 00196 bool 00197 NIVissimSingleTypeParser_Signalgruppendefinition::parsePOS( 00198 int /*id*/, const std::string&, int lsaid, std::istream&) { 00199 WRITE_WARNING("POS traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00200 return true; 00201 } 00202 00203 00204 bool 00205 NIVissimSingleTypeParser_Signalgruppendefinition::parseExternFixedTime( 00206 int /*id*/, const std::string&, int lsaid, std::istream&) { 00207 WRITE_WARNING("externally defined traffic lights are not supported (lsa=" + toString<int>(lsaid) + ")"); 00208 return true; 00209 } 00210 00211 00212 00213 /****************************************************************************/ 00214