LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSPerson.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 83.3 % 12 10
Test Date: 2024-11-21 15:56:26 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          250 :         void routeOutput(const bool, OutputDevice&, const bool, const MSStage* const) const {};
     108              : 
     109              :     private:
     110              :         class ProceedCmd : public Command {
     111              :         public:
     112         4120 :             ProceedCmd(MSTransportable* person, MSEdge* edge) : myPerson(person), myStopEdge(edge) {}
     113         4120 :             ~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   7197270340 :     virtual bool isSelected() const {
     151   7197270340 :         return false;
     152              :     }
     153              : 
     154    147231245 :     inline double getChosenSpeedFactor() const {
     155    147231245 :         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              : 
     171              :     /** @class Influencer
     172              :      * @brief Changes the wished person speed and position
     173              :      *
     174              :      * The class is used for passing velocities or positions obtained via TraCI to the person.
     175              :      */
     176              :     class Influencer {
     177              :     public:
     178              :         /// @brief Constructor
     179              :         Influencer();
     180              : 
     181              : 
     182              :         /// @brief Destructor
     183              :         ~Influencer();
     184              : 
     185              : 
     186              :         void setRemoteControlled(Position xyPos, MSLane* l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector& route, SUMOTime t);
     187              : 
     188              :         SUMOTime getLastAccessTimeStep() const {
     189              :             return myLastRemoteAccess;
     190              :         }
     191              : 
     192              :         void postProcessRemoteControl(MSPerson* p);
     193              : 
     194              :         bool isRemoteControlled() const;
     195              : 
     196              :         bool isRemoteAffected(SUMOTime t) const;
     197              : 
     198              :     private:
     199              :         Position myRemoteXYPos;
     200              :         MSLane* myRemoteLane;
     201              :         double myRemotePos;
     202              :         double myRemotePosLat;
     203              :         double myRemoteAngle;
     204              :         int myRemoteEdgeOffset;
     205              :         ConstMSEdgeVector myRemoteRoute;
     206              :         SUMOTime myLastRemoteAccess;
     207              :     };
     208              : 
     209              : 
     210              :     /** @brief Returns the velocity/lane influencer
     211              :      *
     212              :      * If no influencer was existing before, one is built, first
     213              :      * @return Reference to this vehicle's speed influencer
     214              :      */
     215              :     Influencer& getInfluencer();
     216              : 
     217              :     const Influencer* getInfluencer() const;
     218              : 
     219     95499739 :     bool hasInfluencer() const {
     220     95499739 :         return myInfluencer != 0;
     221              :     }
     222              : 
     223              :     /// @brief sets position outside the road network
     224              :     void setRemoteState(Position xyPos);
     225              : 
     226              : private:
     227              :     /// @brief An instance of a speed/position influencing instance; built in "getInfluencer"
     228              :     Influencer* myInfluencer;
     229              : 
     230              :     double myChosenSpeedFactor;
     231              : 
     232              : private:
     233              :     /// @brief Invalidated copy constructor.
     234              :     MSPerson(const MSPerson&);
     235              : 
     236              :     /// @brief Invalidated assignment operator.
     237              :     MSPerson& operator=(const MSPerson&);
     238              : 
     239              : };
        

Generated by: LCOV version 2.0-1