LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSStageWalking.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 13 13
Test Date: 2024-12-21 15:45:41 Functions: 100.0 % 6 6

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-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    MSStageWalking.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Sascha Krieg
      18              : /// @author  Michael Behrisch
      19              : /// @date    Mon, 9 Jul 2001
      20              : ///
      21              : // A stage performing walking on a sequence of edges.
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : 
      26              : #include <string>
      27              : #include <vector>
      28              : #include <set>
      29              : #include <utils/common/SUMOTime.h>
      30              : #include <utils/common/Command.h>
      31              : #include <utils/geom/Position.h>
      32              : #include <utils/geom/PositionVector.h>
      33              : #include <microsim/transportables/MSTransportable.h>
      34              : #include <microsim/transportables/MSStageMoving.h>
      35              : 
      36              : 
      37              : // ===========================================================================
      38              : // class declarations
      39              : // ===========================================================================
      40              : class MSNet;
      41              : class MSEdge;
      42              : class MSLane;
      43              : class OutputDevice;
      44              : class SUMOVehicleParameter;
      45              : class MSStoppingPlace;
      46              : class SUMOVehicle;
      47              : class MSVehicleType;
      48              : class MSPModel;
      49              : class MSMoveReminder;
      50              : 
      51              : typedef std::vector<const MSEdge*> ConstMSEdgeVector;
      52              : 
      53              : // ===========================================================================
      54              : // class definitions
      55              : // ===========================================================================
      56              : /**
      57              :  * A stage performing walking on a sequence of edges. The real movements are part of the pedestrian model.
      58              :  */
      59              : class MSStageWalking : public MSStageMoving {
      60              : public:
      61              :     /// constructor
      62              :     MSStageWalking(const std::string& personID, const ConstMSEdgeVector& route, MSStoppingPlace* toStop, SUMOTime walkingTime,
      63              :                    double speed, double departPos, double arrivalPos, double departPosLat, int departLane = -1, const std::string& routeID = "");
      64              : 
      65              :     /// destructor
      66              :     ~MSStageWalking();
      67              : 
      68              :     MSStage* clone() const;
      69              : 
      70              :     /// proceeds to the next step
      71              :     virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
      72              : 
      73              :     /// abort this stage (TraCI)
      74              :     void abort(MSTransportable*);
      75              : 
      76              :     /// sets the walking speed (ignored in other stages)
      77              :     void setSpeed(double speed);
      78              : 
      79              :     /// @brief get travel distance in this stage
      80           75 :     double getDistance() const {
      81           75 :         return walkDistance();
      82              :     }
      83              : 
      84              :     /// @brief return index of current edge within route
      85              :     int getRoutePosition() const;
      86              : 
      87        18312 :     std::string getStageDescription(const bool isPerson) const {
      88              :         UNUSED_PARAMETER(isPerson);
      89        18312 :         return "walking";
      90              :     }
      91              : 
      92              :     std::string getStageSummary(const bool isPerson) const;
      93              : 
      94              :     /** @brief Saves the current state into the given stream
      95              :      */
      96              :     void saveState(std::ostringstream& out);
      97              : 
      98              :     /** @brief Reconstructs the current state
      99              :      */
     100              :     void loadState(MSTransportable* transportable, std::istringstream& state);
     101              : 
     102              :     /** @brief Called on writing tripinfo output
     103              :      * @param[in] os The stream to write the information into
     104              :      * @exception IOError not yet implemented
     105              :      */
     106              :     virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
     107              : 
     108              :     /** @brief Called on writing vehroute output
     109              :      * @param[in] os The stream to write the information into
     110              :      * @param[in] withRouteLength whether route length shall be written
     111              :      * @exception IOError not yet implemented
     112              :      */
     113              :     virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
     114              : 
     115              :     /// @brief move forward and return whether the person arrived
     116              :     bool moveToNextEdge(MSTransportable* person, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr, const bool isReplay = false);
     117              : 
     118              :     void activateEntryReminders(MSTransportable* person, const bool isDepart = false);
     119              : 
     120              :     void activateLeaveReminders(MSTransportable* person, const MSLane* lane, double lastPos, SUMOTime t, bool arrived);
     121              : 
     122              :     /// @brief accessors to be used by MSPModel
     123              :     //@{
     124              :     double getMaxSpeed(const MSTransportable* const person) const;
     125              : 
     126     26785708 :     inline double getArrivalPos() const {
     127     26785708 :         return myArrivalPos;
     128              :     }
     129              : 
     130    140445934 :     inline const MSEdge* getNextRouteEdge() const {
     131    140445934 :         return myRouteStep == myRoute.end() - 1 ? nullptr : *(myRouteStep + 1);
     132              :     }
     133              :     //@}
     134              : 
     135              :     /// @brief Whether the transportable is walking
     136           96 :     bool isWalk() const {
     137           96 :         return true;
     138              :     }
     139              : 
     140              :     SUMOTime getTimeLoss(const MSTransportable* transportable) const;
     141              : 
     142           80 :     bool equals(const MSStage& s) const {
     143           80 :         if (!MSStageMoving::equals(s)) {
     144              :             return false;
     145              :         }
     146              :         // this is safe because MSStage already checked that the type fits
     147              :         const MSStageWalking& sw = static_cast<const MSStageWalking&>(s);
     148           38 :         return myWalkingTime == sw.myWalkingTime;
     149              :     }
     150              : 
     151              : private:
     152              :     /// @brief compute total walking distance
     153              :     double walkDistance(bool partial = false) const;
     154              : 
     155              :     /* @brief compute average speed if the total walking duration is given
     156              :         * @note Must be called when the previous stage changes myDepartPos from the default*/
     157              :     double computeAverageSpeed() const;
     158              : 
     159              : private:
     160              :     /// the time the person is walking
     161              :     SUMOTime myWalkingTime;
     162              : 
     163              :     /// the time the person entered the edge
     164              :     SUMOTime myLastEdgeEntryTime;
     165              : 
     166              :     /// @brief the MoveReminders encountered while walking
     167              :     std::vector<MSMoveReminder*> myMoveReminders;
     168              : 
     169              :     /// @brief optional exit time tracking for vehroute output
     170              :     std::vector<SUMOTime>* myExitTimes;
     171              : 
     172              :     /// @brief distance walked on non-normal edges (i.e. walkingareas)
     173              :     double myInternalDistance;
     174              : 
     175              :     static bool myWarnedInvalidTripinfo;
     176              : 
     177              : private:
     178              :     /// @brief Invalidated copy constructor.
     179              :     MSStageWalking(const MSStageWalking&);
     180              : 
     181              :     /// @brief Invalidated assignment operator.
     182              :     MSStageWalking& operator=(const MSStageWalking&);
     183              : 
     184              : };
        

Generated by: LCOV version 2.0-1