LCOV - code coverage report
Current view: top level - src/libsumo - TrafficLight.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 3 3
Test Date: 2024-12-21 15:45:41 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2024 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    TrafficLight.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Mario Krumnow
      17              : /// @author  Michael Behrisch
      18              : /// @date    30.05.2012
      19              : ///
      20              : // C++ TraCI client API implementation
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <vector>
      24              : #include <libsumo/TraCIDefs.h>
      25              : #include <libsumo/TraCIConstants.h>
      26              : 
      27              : // ===========================================================================
      28              : // class declarations
      29              : // ===========================================================================
      30              : #ifndef LIBTRACI
      31              : class MSRailSignalConstraint;
      32              : class SUMOVehicle;
      33              : #endif
      34              : 
      35              : // ===========================================================================
      36              : // class definitions
      37              : // ===========================================================================
      38              : /**
      39              : * @class TrafficLight
      40              : * @brief C++ TraCI client API implementation
      41              : */
      42              : namespace LIBSUMO_NAMESPACE {
      43              : class TrafficLight {
      44              : public:
      45              : 
      46              :     static std::string getRedYellowGreenState(const std::string& tlsID);
      47              :     static std::vector<libsumo::TraCILogic> getAllProgramLogics(const std::string& tlsID);
      48              :     static std::vector<std::string> getControlledJunctions(const std::string& tlsID);
      49              :     static std::vector<std::string> getControlledLanes(const std::string& tlsID);
      50              :     static std::vector<std::vector<libsumo::TraCILink> > getControlledLinks(const std::string& tlsID);
      51              :     static std::string getProgram(const std::string& tlsID);
      52              :     static int getPhase(const std::string& tlsID);
      53              :     static std::string getPhaseName(const std::string& tlsID);
      54              :     static double getPhaseDuration(const std::string& tlsID);
      55              :     static double getNextSwitch(const std::string& tlsID);
      56              :     static double getSpentDuration(const std::string& tlsID);
      57              :     static int getServedPersonCount(const std::string& tlsID, int index);
      58              :     static std::vector<std::string> getBlockingVehicles(const std::string& tlsID, int linkIndex);
      59              :     static std::vector<std::string> getRivalVehicles(const std::string& tlsID, int linkIndex);
      60              :     static std::vector<std::string> getPriorityVehicles(const std::string& tlsID, int linkIndex);
      61              :     static std::vector<libsumo::TraCISignalConstraint> getConstraints(const std::string& tlsID, const std::string& tripId = "");
      62              :     static std::vector<libsumo::TraCISignalConstraint> getConstraintsByFoe(const std::string& foeSignal, const std::string& foeId = "");
      63              : 
      64              :     LIBSUMO_ID_PARAMETER_API
      65              :     LIBSUMO_SUBSCRIPTION_API
      66              : 
      67              : 
      68              :     static void setRedYellowGreenState(const std::string& tlsID, const std::string& state);
      69              :     static void setPhase(const std::string& tlsID, const int index);
      70              :     static void setPhaseName(const std::string& tlsID, const std::string& name);
      71              :     static void setProgram(const std::string& tlsID, const std::string& programID);
      72              :     static void setPhaseDuration(const std::string& tlsID, const double phaseDuration);
      73              :     static void setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic);
      74              : 
      75              :     static void addConstraint(const std::string& tlsID, const std::string& tripId, const std::string& foeSignal, const std::string& foeId, const int type = 0, const int limit = 0);
      76              :     static std::vector<libsumo::TraCISignalConstraint> swapConstraints(const std::string& tlsID, const std::string& tripId, const std::string& foeSignal, const std::string& foeId);
      77              :     static void removeConstraints(const std::string& tlsID, const std::string& tripId, const std::string& foeSignal, const std::string& foeId);
      78              :     static void updateConstraints(const std::string& vehID, std::string tripId = "");
      79              : 
      80              :     // aliases for backward compatibility
      81              :     inline static std::vector<libsumo::TraCILogic> getCompleteRedYellowGreenDefinition(const std::string& tlsID) {
      82            3 :         return getAllProgramLogics(tlsID);
      83              :     }
      84              :     inline static void setCompleteRedYellowGreenDefinition(const std::string& tlsID, const libsumo::TraCILogic& logic) {
      85           46 :         setProgramLogic(tlsID, logic);
      86           45 :     }
      87              : 
      88              :     static void setNemaSplits(const std::string& tlsID, const std::vector<double>& splits);
      89              :     static void setNemaMaxGreens(const std::string& tlsID, const std::vector<double>& maxGreens);
      90              :     static void setNemaCycleLength(const std::string& tlsID,  double cycleLength);
      91              :     static void setNemaOffset(const std::string& tlsID, double offset);
      92              : 
      93              : #ifndef LIBTRACI
      94              : #ifndef SWIG
      95              :     static std::shared_ptr<VariableWrapper> makeWrapper();
      96              : 
      97              :     static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
      98              : 
      99              : private:
     100              :     static libsumo::TraCISignalConstraint buildConstraint(const std::string& tlsID, const std::string& tripId, MSRailSignalConstraint* constraint);
     101              :     /// @brief perform swapConstraints to resolve deadlocks and return the new constraints
     102              :     static std::vector<libsumo::TraCISignalConstraint> findConstraintsDeadLocks(const std::string& foeId, const std::string& tripId, const std::string& foeSignal, const std::string& tlsID);
     103              :     static SUMOVehicle* getVehicleByTripId(const std::string tripOrVehID);
     104              :     static std::vector<std::string> getFutureTripIds(const std::string vehID);
     105              :     static void swapParameters(MSRailSignalConstraint* c);
     106              :     static void swapParameters(MSRailSignalConstraint* c, const std::string& key1, const std::string& key2);
     107              :     static void swapParameters(TraCISignalConstraint& c);
     108              :     static void swapParameters(TraCISignalConstraint& c, const std::string& key1, const std::string& key2);
     109              :     static std::vector<std::pair<std::string, std::string> > getSwapParams(int constraintType);
     110              : 
     111              : private:
     112              :     static SubscriptionResults mySubscriptionResults;
     113              :     static ContextSubscriptionResults myContextSubscriptionResults;
     114              : #endif
     115              : #endif
     116              :     /// @brief invalidated standard constructor
     117              :     TrafficLight() = delete;
     118              : };
     119              : 
     120              : 
     121              : }
        

Generated by: LCOV version 2.0-1