SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp
Go to the documentation of this file.
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 <iostream>
00034 #include <utils/common/TplConvert.h>
00035 #include <utils/common/MsgHandler.h>
00036 #include "../NIImporter_Vissim.h"
00037 #include "../tempstructs/NIVissimTL.h"
00038 #include "NIVissimSingleTypeParser_Lichtsignalanlagendefinition.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_Lichtsignalanlagendefinition::NIVissimSingleTypeParser_Lichtsignalanlagendefinition(NIImporter_Vissim& parent)
00049     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00050 
00051 
00052 NIVissimSingleTypeParser_Lichtsignalanlagendefinition::~NIVissimSingleTypeParser_Lichtsignalanlagendefinition() {}
00053 
00054 
00055 bool
00056 NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parse(std::istream& from) {
00057     //
00058     int id;
00059     from >> id;
00060     //
00061     std::string tag, name;
00062     tag = myRead(from);
00063     if (tag == "name") {
00064         name = readName(from);
00065         tag = myRead(from);
00066     }
00067     // type
00068     std::string type;
00069     type = myRead(from);
00070     if (type == "festzeit") {
00071         return parseFixedTime(id, name, from);
00072     }
00073     if (type == "vas") {
00074         return parseVAS(id, name, from);
00075     }
00076     if (type == "vsplus") {
00077         return parseRestActuated(id, name, from, type);
00078     }
00079     if (type == "trends") {
00080         return parseRestActuated(id, name, from, type);
00081     }
00082     if (type == "vap") {
00083         return parseRestActuated(id, name, from, type);
00084     }
00085     if (type == "tl") {
00086         return parseRestActuated(id, name, from, type);
00087     }
00088     if (type == "pos") {
00089         return parseRestActuated(id, name, from, type);
00090     }
00091     if (type == "nema") {
00092         return parseRestActuated(id, name, from, type);
00093     }
00094     if (type == "extern") {
00095         return parseRestActuated(id, name, from, type);
00096     }
00097     WRITE_ERROR("Unsupported LSA-Type '" + type + "' occured.");
00098     return false;
00099 }
00100 
00101 
00102 bool
00103 NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseFixedTime(
00104     int id, std::string name, std::istream& from) {
00105     std::string type = "festzeit";
00106     std::string tag;
00107     from >> tag;
00108     //
00109     SUMOReal absdur;
00110     from >> absdur; // type-checking is missing!
00111     //
00112     tag = readEndSecure(from);
00113     SUMOReal offset = 0;
00114     if (tag == "versatz") {
00115         from >> offset; // type-checking is missing!
00116     }
00117     if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
00118         tag = readEndSecure(from);
00119         if (tag == "szpkonfdatei" || tag == "progdatei") {
00120             type = "festzeit_fake";
00121         }
00122     }
00123     return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
00124 }
00125 
00126 
00127 bool
00128 NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseVAS(
00129     int id, std::string name, std::istream& from) {
00130     std::string tag;
00131     from >> tag;
00132     //
00133     SUMOReal absdur;
00134     from >> absdur; // type-checking is missing!
00135     //
00136     tag = readEndSecure(from);
00137     SUMOReal offset = 0;
00138     if (tag == "versatz") {
00139         from >> offset; // type-checking is missing!
00140     }
00141     return NIVissimTL::dictionary(id, "vas", name, (SUMOTime) absdur, (SUMOTime) offset);
00142 }
00143 
00144 
00145 bool
00146 NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseRestActuated(
00147     int id, std::string name, std::istream& from, const std::string& type) {
00148     std::string tag;
00149     from >> tag;
00150     //
00151     SUMOReal absdur;
00152     from >> absdur; // type-checking is missing!
00153     //
00154     tag = readEndSecure(from);
00155     SUMOReal offset = 0;
00156     if (tag == "versatz") {
00157         from >> offset; // type-checking is missing!
00158     }
00159     while (tag != "datei") {
00160         tag = myRead(from);
00161     }
00162     return NIVissimTL::dictionary(id, type, name, (SUMOTime) absdur, (SUMOTime) offset);
00163 }
00164 
00165 
00166 
00167 /****************************************************************************/
00168 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines