LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSStageTrip.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 90.0 % 20 18
Test Date: 2026-09-20 15:45:03 Functions: 87.5 % 8 7

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2026 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    MSStageTrip.h
      15              : /// @author  Michael Behrisch
      16              : /// @author  Jakob Erdmann
      17              : /// @date    Wed, 1 Jun 2022
      18              : ///
      19              : // An intermodal routing request (to be transformed into a sequence of walks and rides)
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include <microsim/transportables/MSStage.h>
      25              : #ifndef THREAD_POOL
      26              : #ifdef HAVE_FOX
      27              : #include <utils/foxtools/MFXWorkerThread.h>
      28              : #endif
      29              : #endif
      30              : 
      31              : 
      32              : // ===========================================================================
      33              : // class declarations
      34              : // ===========================================================================
      35              : class MSTransportable;
      36              : class MSEdge;
      37              : class MSLane;
      38              : class MSNet;
      39              : class MSStoppingPlace;
      40              : class OutputDevice;
      41              : 
      42              : /**
      43              : * A "placeholder" stage storing routing info which will result in real stages when routed
      44              : */
      45              : class MSStageTrip : public MSStage {
      46              : public:
      47              :     /// constructor
      48              :     MSStageTrip(const MSEdge* origin, MSStoppingPlace* fromStop,
      49              :                 const MSEdge* destination, MSStoppingPlace* toStop,
      50              :                 const SUMOTime duration, const SVCPermissions modeSet,
      51              :                 const std::string& vTypes, const double speed, const double walkFactor,
      52              :                 const std::string& group,
      53              :                 const double departPosLat, const bool hasArrivalPos, const double arrivalPos);
      54              : 
      55              :     /// destructor
      56              :     virtual ~MSStageTrip();
      57              : 
      58              :     MSStage* clone() const;
      59              : 
      60              :     const MSEdge* getEdge() const;
      61              : 
      62       330872 :     MSStoppingPlace* getOriginStop() const {
      63       330872 :         return myOriginStop;
      64              :     }
      65              : 
      66              :     double getEdgePos(SUMOTime now) const;
      67              : 
      68              :     Position getPosition(SUMOTime now) const;
      69              : 
      70              :     double getAngle(SUMOTime now) const;
      71              : 
      72           54 :     double getDistance() const {
      73              :         // invalid
      74           54 :         return -1;
      75              :     }
      76              : 
      77           54 :     std::string getStageDescription(const bool isPerson) const {
      78              :         UNUSED_PARAMETER(isPerson);
      79           54 :         return "trip";
      80              :     }
      81              : 
      82              :     std::string getOriginDescription() const;
      83              :     std::string getDestinationDescription() const;
      84              : 
      85              :     std::string getStageSummary(const bool isPerson) const;
      86              : 
      87              :     std::vector<SUMOVehicle*> getVehicles(MSVehicleControl& vehControl, MSTransportable* transportable, const MSEdge* origin);
      88              : 
      89              :     const std::string reroute(const SUMOTime time, MSTransportableRouter& router, MSTransportable* const transportable,
      90              :                               MSStage* previous, const MSEdge* origin, const MSEdge* destination, std::vector<MSStage*>& stages);
      91              : 
      92              :     /// logs end of the step
      93              :     const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
      94              : 
      95              :     /// change origin for parking area rerouting
      96           39 :     void setOrigin(const MSEdge* origin, MSStoppingPlace* originStop, double departPos) {
      97           39 :         myOrigin = origin;
      98           39 :         myOriginStop = originStop;
      99           39 :         myDepartPos = departPos;
     100           39 :     }
     101              : 
     102              :     /// proceeds to the next step
     103              :     void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
     104              : 
     105              :     /** @brief Called on writing tripinfo output
     106              :     *
     107              :     * @param[in] os The stream to write the information into
     108              :     * @exception IOError not yet implemented
     109              :     */
     110        10078 :     void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const {
     111              :         UNUSED_PARAMETER(os);
     112              :         UNUSED_PARAMETER(transportable);
     113        10078 :     }
     114              : 
     115              :     /// @brief trip doesn't participate in plan summary
     116        10078 :     SUMOTime getDuration() const {
     117        10078 :         return 0;
     118              :     }
     119              : 
     120        10078 :     SUMOTime getTravelTime() const {
     121        10078 :         return 0;
     122              :     }
     123              : 
     124              :     /** @brief Called on writing vehroute output
     125              :     *
     126              :     * @param[in] os The stream to write the information into
     127              :     * @exception IOError not yet implemented
     128              :     */
     129              :     void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous, const bool withTiming, const bool saveState = false) const;
     130              : 
     131              :     /// @brief Whether the transportable is walking
     132            0 :     bool isWalk() const {
     133            0 :         return myModeSet == 0;
     134              :     }
     135              : 
     136              : private:
     137              :     /// the origin edge
     138              :     const MSEdge* myOrigin;
     139              : 
     140              :     /// the origin edge
     141              :     MSStoppingPlace* myOriginStop;
     142              : 
     143              :     /// the time the trip should take (applies to only walking)
     144              :     SUMOTime myDuration;
     145              : 
     146              :     /// @brief The allowed modes of transportation
     147              :     const SVCPermissions myModeSet;
     148              : 
     149              :     /// @brief The possible vehicles to use
     150              :     const std::string myVTypes;
     151              : 
     152              :     /// @brief The walking speed
     153              :     const double mySpeed;
     154              : 
     155              :     /// @brief The factor to apply to walking durations
     156              :     const double myWalkFactor;
     157              : 
     158              :     /// @brief The depart position
     159              :     double myDepartPos;
     160              : 
     161              :     /// @brief The lateral depart position
     162              :     const double myDepartPosLat;
     163              : 
     164              :     /// @brief whether an arrivalPos was in the input
     165              :     const bool myHaveArrivalPos;
     166              : 
     167              :     /// @brief stages pre-computed in proceed() (serial) or by TripRoutingTask (parallel)
     168              :     std::vector<MSStage*> myComputedStages;
     169              : 
     170              :     /// @brief routing error stored alongside myComputedStages
     171              :     std::string myRoutingError;
     172              : 
     173              :     /// @brief personal vehicle to add to simulation after parallel routing completes
     174              :     SUMOVehicle* myVehicleToAdd = nullptr;
     175              : 
     176              : private:
     177              :     /// @brief Invalidated copy constructor.
     178              :     MSStageTrip(const MSStageTrip&);
     179              : 
     180              :     /// @brief Invalidated assignment operator.
     181              :     MSStageTrip& operator=(const MSStageTrip&);
     182              : 
     183              : #ifndef THREAD_POOL
     184              : #ifdef HAVE_FOX
     185              :     static FXMutex myVehCtrlMutex;
     186              : 
     187              : public:
     188              :     /**
     189              :      * @class TripRoutingTask
     190              :      * @brief Computes the intermodal route for a transportable in a worker thread
     191              :      */
     192              :     class TripRoutingTask : public MFXWorkerThread::Task {
     193              :     public:
     194              :         TripRoutingTask(MSStageTrip& stage, MSTransportable* transportable, SUMOTime time, MSStage* previous)
     195         4512 :             : myStage(stage), myTransportable(transportable), myTime(time), myPrevious(previous) {}
     196              :         void run(MFXWorkerThread* context);
     197              :     private:
     198              :         MSStageTrip& myStage;
     199              :         MSTransportable* const myTransportable;
     200              :         const SUMOTime myTime;
     201              :         MSStage* const myPrevious;
     202              :         TripRoutingTask& operator=(const TripRoutingTask&) = delete;
     203              :     };
     204              : #endif
     205              : #endif
     206              : 
     207              : };
        

Generated by: LCOV version 2.0-1