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

            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    MSPerson.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              : // The class for modelling person-movements
      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              :   * @class MSPerson
      58              :   *
      59              :   * The class holds a simulated person together with her movement stages
      60              :   */
      61              : class MSPerson : public MSTransportable {
      62              : public:
      63              :     /**
      64              :      * An intermediate stage performing the access from or to public transport as given
      65              :      * by the access elements of the public transport stop. The travel time is computed by the simulation
      66              :      */
      67              :     class MSPersonStage_Access : public MSStage {
      68              :     public:
      69              :         /// constructor
      70              :         MSPersonStage_Access(const MSEdge* destination, MSStoppingPlace* toStop,
      71              :                              const double arrivalPos, const double arrivalPosLat, const double dist, const bool isExit,
      72              :                              const Position& startPos, const Position& endPos);
      73              : 
      74              :         /// destructor
      75              :         ~MSPersonStage_Access();
      76              : 
      77              :         MSStage* clone() const;
      78              : 
      79              :         /// proceeds to the next step
      80              :         virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSStage* previous);
      81              : 
      82              :         /// @brief returns the stage description as a string
      83              :         std::string getStageDescription(const bool isPerson) const;
      84              :         std::string getStageSummary(const bool isPerson) const;
      85              : 
      86              :         Position getPosition(SUMOTime now) const;
      87              : 
      88              :         double getAngle(SUMOTime now) const;
      89              : 
      90              :         /// @brief get travel distance in this stage
      91            0 :         double getDistance() const {
      92            0 :             return myDist;
      93              :         }
      94              : 
      95              :         /// @brief the speed of the person in this stage
      96              :         double getSpeed() const;
      97              : 
      98              :         /** @brief Called on writing tripinfo output
      99              :         *
     100              :         * @param[in] os The stream to write the information into
     101              :         * @param[in] transportable The person to write information about
     102              :         * @exception IOError not yet implemented
     103              :         */
     104              :         void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
     105              : 
     106              :         /// @brief Called on writing vehroute output. Currently does nothing.
     107          266 :         void routeOutput(const bool, OutputDevice&, const bool, const MSStage* const) const {};
     108              : 
     109              :     private:
     110              :         class ProceedCmd : public Command {
     111              :         public:
     112         4135 :             ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
     113         4135 :             ~ProceedCmd() {}
     114              :             SUMOTime execute(SUMOTime currentTime);
     115              :         private:
     116              :             MSTransportable* const myPerson;
     117              :             MSEdge* myStopEdge;
     118              :         private:
     119              :             /// @brief Invalidated assignment operator.
     120              :             ProceedCmd& operator=(const ProceedCmd&);
     121              :         };
     122              : 
     123              :     private:
     124              :         /// the origin edge
     125              :         const MSEdge* myOrigin;
     126              :         const double myDist;
     127              :         const bool myAmExit;
     128              :         SUMOTime myEstimatedArrival;
     129              :         PositionVector myPath;
     130              :     };
     131              : 
     132              : public:
     133              :     /// constructor
     134              :     MSPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
     135              : 
     136              :     /// destructor
     137              :     virtual ~MSPerson();
     138              : 
     139              :     /* @brief check whether an access stage must be added and return whether a
     140              :      * stage was added */
     141              :     bool checkAccess(const MSStage* const prior, const bool waitAtStop = true);
     142              : 
     143              :     /// @brief return the list of internal edges if this person is walking and the pedestrian model allows it
     144              :     const std::string& getNextEdge() const;
     145              : 
     146              :     /// @brief returns the next edge ptr if this person is walking and the pedestrian model allows it
     147              :     const MSEdge* getNextEdgePtr() const;
     148              : 
     149              :     /// @brief whether this person is selected in the GUI
     150  10939417891 :     virtual bool isSelected() const {
     151  10939417891 :         return false;
     152              :     }
     153              : 
     154    261999305 :     inline double getChosenSpeedFactor() const {
     155    261999305 :         return myChosenSpeedFactor;
     156              :     }
     157              : 
     158              :     inline void setChosenSpeedFactor(const double factor) {
     159           30 :         myChosenSpeedFactor = factor;
     160              :     }
     161              : 
     162              :     double getImpatience() const;
     163              : 
     164              :     /// @brief whether the person is jammed as defined by the current pedestrian model
     165              :     bool isJammed() const;
     166              : 
     167              :     /// @brief set new walk and replace the stages with relative indices in the interval [firstIndex, nextIndex[
     168              :     void replaceWalk(const ConstMSEdgeVector& newEdges, double departPos, int firstIndex, int nextIndex);
     169              : 
     170              :     inline double getTimegapCrossing() const {
     171     68125297 :         return myTimegapCrossing;
     172              :     }
     173              : 
     174              :     /** @class Influencer
     175              :      * @brief Changes the wished person speed and position
     176              :      *
     177              :      * The class is used for passing velocities or positions obtained via TraCI to the person.
     178              :      */
     179              :     class Influencer {
     180              :     public:
     181              :         /// @brief Constructor
     182              :         Influencer();
     183              : 
     184              : 
     185              :         /// @brief Destructor
     186              :         ~Influencer();
     187              : 
     188              : 
     189              :         void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
     190              : 
     191              :         SUMOTime getLastAccessTimeStep() const {
     192              :             return myLastRemoteAccess;
     193              :         }
     194              : 
     195              :         void postProcessRemoteControl(MSPerson* p);
     196              : 
     197              :         bool isRemoteControlled() const;
     198              : 
     199              :         bool isRemoteAffected(SUMOTime t) const;
     200              : 
     201              :     private:
     202              :         Position myRemoteXYPos;
     203              :         MSLane* myRemoteLane;
     204              :         double myRemotePos;
     205              :         double myRemotePosLat;
     206              :         double myRemoteAngle;
     207              :         int myRemoteEdgeOffset;
     208              :         ConstMSEdgeVector myRemoteRoute;
     209              :         SUMOTime myLastRemoteAccess;
     210              :     };
     211              : 
     212              : 
     213              :     /** @brief Returns the velocity/lane influencer
     214              :      *
     215              :      * If no influencer was existing before, one is built, first
     216              :      * @return Reference to this vehicle's speed influencer
     217              :      */
     218              :     Influencer& getInfluencer();
     219              : 
     220              :     const Influencer* getInfluencer() const;
     221              : 
     222    129749259 :     bool hasInfluencer() const {
     223    129749259 :         return myInfluencer != 0;
     224              :     }
     225              : 
     226              :     /// @brief sets position outside the road network
     227              :     void setRemoteState(Position xyPos);
     228              : 
     229              : private:
     230              :     /// @brief An instance of a speed/position influencing instance; built in "getInfluencer"
     231              :     Influencer* myInfluencer;
     232              : 
     233              :     double myChosenSpeedFactor;
     234              : 
     235              :     /// @brief value may be sampled from distribution and therefore must be cached
     236              :     double myTimegapCrossing;
     237              : 
     238              : private:
     239              :     /// @brief Invalidated copy constructor.
     240              :     MSPerson(const MSPerson&);
     241              : 
     242              :     /// @brief Invalidated assignment operator.
     243              :     MSPerson& operator=(const MSPerson&);
     244              : 
     245              : };
        

Generated by: LCOV version 2.0-1