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