LCOV - code coverage report
Current view: top level - src/netimport/vissim/typeloader - NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 66.7 % 54 36
Test Date: 2025-03-19 16:11:11 Functions: 85.7 % 7 6

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    NIVissimSingleTypeParser_Lichtsignalanlagendefinition.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Wed, 18 Dec 2002
      19              : ///
      20              : //
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <iostream>
      25              : #include <utils/common/StringUtils.h>
      26              : #include <utils/common/MsgHandler.h>
      27              : #include <netimport/vissim/NIImporter_Vissim.h>
      28              : #include <netimport/vissim/tempstructs/NIVissimTL.h>
      29              : #include "NIVissimSingleTypeParser_Lichtsignalanlagendefinition.h"
      30              : 
      31              : 
      32              : // ===========================================================================
      33              : // method definitions
      34              : // ===========================================================================
      35            9 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::NIVissimSingleTypeParser_Lichtsignalanlagendefinition(NIImporter_Vissim& parent)
      36            9 :     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
      37              : 
      38              : 
      39           18 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::~NIVissimSingleTypeParser_Lichtsignalanlagendefinition() {}
      40              : 
      41              : 
      42              : bool
      43           33 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parse(std::istream& from) {
      44              :     //
      45              :     int id;
      46           33 :     from >> id;
      47              :     //
      48              :     std::string tag, name;
      49           33 :     tag = myRead(from);
      50           33 :     if (tag == "name") {
      51           33 :         name = readName(from);
      52           66 :         tag = myRead(from);
      53              :     }
      54              :     // type
      55              :     std::string type;
      56           33 :     type = myRead(from);
      57           33 :     if (type == "festzeit") {
      58           24 :         return parseFixedTime(id, name, from);
      59              :     }
      60           21 :     if (type == "vas") {
      61            0 :         return parseVAS(id, name, from);
      62              :     }
      63           21 :     if (type == "vsplus") {
      64            0 :         return parseRestActuated(id, name, from, type);
      65              :     }
      66           21 :     if (type == "trends") {
      67            0 :         return parseRestActuated(id, name, from, type);
      68              :     }
      69           21 :     if (type == "vap") {
      70            0 :         return parseRestActuated(id, name, from, type);
      71              :     }
      72           21 :     if (type == "tl") {
      73           42 :         return parseRestActuated(id, name, from, type);
      74              :     }
      75            0 :     if (type == "pos") {
      76            0 :         return parseRestActuated(id, name, from, type);
      77              :     }
      78            0 :     if (type == "nema") {
      79            0 :         return parseRestActuated(id, name, from, type);
      80              :     }
      81            0 :     if (type == "extern") {
      82            0 :         return parseRestActuated(id, name, from, type);
      83              :     }
      84            0 :     WRITE_ERRORF(TL("Unsupported LSA-Type '%' occurred."), type);
      85            0 :     return false;
      86              : }
      87              : 
      88              : 
      89              : bool
      90           12 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseFixedTime(
      91              :     int id, std::string name, std::istream& from) {
      92           12 :     std::string type = "festzeit";
      93              :     std::string tag;
      94           12 :     from >> tag;
      95              :     //
      96              :     double absdur;
      97              :     from >> absdur; // type-checking is missing!
      98              :     //
      99           12 :     tag = readEndSecure(from);
     100           12 :     double offset = 0;
     101           12 :     if (tag == "versatz") {
     102              :         from >> offset; // type-checking is missing!
     103              :     }
     104           12 :     if (tag != "szpkonfdatei" && tag != "DATAEND" && tag != "progdatei") {
     105           12 :         tag = readEndSecure(from);
     106           12 :         if (tag == "szpkonfdatei" || tag == "progdatei") {
     107              :             type = "festzeit_fake";
     108              :         }
     109              :     }
     110           24 :     return NIVissimTL::dictionary(id, type, name, TIME2STEPS(absdur), TIME2STEPS(offset));
     111              : }
     112              : 
     113              : 
     114              : bool
     115            0 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseVAS(
     116              :     int id, std::string name, std::istream& from) {
     117              :     std::string tag;
     118            0 :     from >> tag;
     119              :     //
     120              :     double absdur;
     121              :     from >> absdur; // type-checking is missing!
     122              :     //
     123            0 :     tag = readEndSecure(from);
     124            0 :     double offset = 0;
     125            0 :     if (tag == "versatz") {
     126              :         from >> offset; // type-checking is missing!
     127              :     }
     128            0 :     return NIVissimTL::dictionary(id, "vas", name, TIME2STEPS(absdur), TIME2STEPS(offset));
     129              : }
     130              : 
     131              : 
     132              : bool
     133           21 : NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseRestActuated(
     134              :     int id, std::string name, std::istream& from, const std::string& type) {
     135              :     std::string tag;
     136           21 :     from >> tag;
     137              :     //
     138              :     double absdur;
     139              :     from >> absdur; // type-checking is missing!
     140              :     //
     141           21 :     tag = readEndSecure(from);
     142           21 :     double offset = 0;
     143           21 :     if (tag == "versatz") {
     144              :         from >> offset; // type-checking is missing!
     145              :     }
     146          186 :     while (tag != "datei") {
     147          330 :         tag = myRead(from);
     148              :     }
     149           42 :     return NIVissimTL::dictionary(id, type, name, TIME2STEPS(absdur), TIME2STEPS(offset));
     150              : }
     151              : 
     152              : 
     153              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1