LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSPModel_NonInteracting.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 13 13
Test Date: 2024-11-21 15:56:26 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2014-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    MSPModel_NonInteracting.h
      15              : /// @author  Jakob Erdmann
      16              : /// @date    Mon, 13 Jan 2014
      17              : ///
      18              : // The pedestrian following model (prototype)
      19              : /****************************************************************************/
      20              : #pragma once
      21              : #include <config.h>
      22              : 
      23              : #include <string>
      24              : #include <limits>
      25              : #include <utils/common/SUMOTime.h>
      26              : #include <utils/common/Command.h>
      27              : #include "MSPerson.h"
      28              : #include "MSPModel.h"
      29              : 
      30              : // ===========================================================================
      31              : // class declarations
      32              : // ===========================================================================
      33              : class MSNet;
      34              : class MSLink;
      35              : class MSLane;
      36              : class MSJunction;
      37              : 
      38              : 
      39              : // ===========================================================================
      40              : // class definitions
      41              : // ===========================================================================
      42              : /**
      43              :  * @class MSPModel_NonInteracting
      44              :  * @brief The pedestrian following model
      45              :  *
      46              :  */
      47              : class MSPModel_NonInteracting : public MSPModel {
      48              : public:
      49              : 
      50              :     /// @brief Constructor (it should not be necessary to construct more than one instance)
      51              :     MSPModel_NonInteracting(const OptionsCont& oc, MSNet* net);
      52              : 
      53              :     ~MSPModel_NonInteracting();
      54              : 
      55              :     /// @brief register the given transportable
      56              :     MSTransportableStateAdapter* add(MSTransportable* transportable, MSStageMoving* stage, SUMOTime now);
      57              : 
      58              :     /// @brief load the state of the given transportable
      59              :     MSTransportableStateAdapter* loadState(MSTransportable* transportable, MSStageMoving* stage, std::istringstream& in);
      60              : 
      61              :     /// @brief Resets pedestrians when quick-loading state
      62              :     void clearState();
      63              : 
      64              :     /// @brief remove the specified person from the pedestrian simulation
      65              :     void remove(MSTransportableStateAdapter* state);
      66              : 
      67              :     /// @brief whether movements on intersections are modelled
      68        16729 :     bool usingInternalLanes() {
      69        16729 :         return false;
      70              :     }
      71              : 
      72              :     /// @brief return the number of active objects
      73       362844 :     int getActiveNumber() {
      74       362844 :         return myNumActivePedestrians;
      75              :     }
      76              : 
      77              :     void registerArrived() {
      78       151135 :         myNumActivePedestrians--;
      79              :     }
      80              : 
      81              : private:
      82              :     class MoveToNextEdge : public Command {
      83              :     public:
      84       153520 :         MoveToNextEdge(MSTransportable* transportable, MSStageMoving& walk, MSPModel_NonInteracting* model) :
      85       153520 :             myParent(walk), myTransportable(transportable), myModel(model) {}
      86              :         SUMOTime execute(SUMOTime currentTime);
      87              :         void abortWalk() {
      88          430 :             myTransportable = nullptr;
      89              :         }
      90              :         const MSTransportable* getTransportable() const {
      91       219703 :             return myTransportable;
      92              :         }
      93              : 
      94              :     private:
      95              :         MSStageMoving& myParent;
      96              :         MSTransportable* myTransportable;
      97              :         MSPModel_NonInteracting* myModel;
      98              : 
      99              :     private:
     100              :         /// @brief Invalidated assignment operator.
     101              :         MoveToNextEdge& operator=(const MoveToNextEdge&);
     102              :     };
     103              : 
     104              : 
     105              :     /// @brief implementation of callbacks to retrieve various state information from the model
     106              :     class PState : public MSTransportableStateAdapter {
     107              :     public:
     108              :         PState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
     109              : 
     110              :         /// @brief abstract methods inherited from PedestrianState
     111              :         /// @{
     112              :         /// @brief return the offset from the start of the current edge measured in its natural direction
     113              :         double getEdgePos(SUMOTime now) const;
     114              :         int getDirection() const;
     115              :         virtual Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
     116              :         virtual double getAngle(const MSStageMoving& stage, SUMOTime now) const;
     117            2 :         SUMOTime getWaitingTime() const {
     118            2 :             return 0;
     119              :         }
     120              :         double getSpeed(const MSStageMoving& stage) const;
     121              :         const MSEdge* getNextEdge(const MSStageMoving& stage) const;
     122              :         /// @}
     123              : 
     124              :         /// @brief compute walking time on edge and update state members
     125              :         virtual SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
     126              :         MoveToNextEdge* getCommand() const {
     127          430 :             return myCommand;
     128              :         }
     129              : 
     130              :         SUMOTime getEventTime() const {
     131           10 :             return myLastEntryTime + myCurrentDuration;
     132              :         }
     133              : 
     134              :         /** @brief Saves the current state into the given stream
     135              :          */
     136              :         void saveState(std::ostringstream& out);
     137              : 
     138              :     protected:
     139              :         SUMOTime myLastEntryTime;
     140              :         SUMOTime myCurrentDuration;
     141              :         double myCurrentBeginPos;
     142              :         double myCurrentEndPos;
     143              :         MoveToNextEdge* myCommand;
     144              :     };
     145              : 
     146              : 
     147              :     class CState : public PState {
     148              :     public:
     149              :         CState(MoveToNextEdge* cmd, std::istringstream* in = nullptr);
     150              : 
     151              :         /// @brief the offset for computing container positions when being transhiped
     152              :         static const double LATERAL_OFFSET;
     153              : 
     154              :         /// @brief return the network coordinate of the container
     155              :         Position getPosition(const MSStageMoving& stage, SUMOTime now) const;
     156              :         /// @brief return the direction in which the container heading to
     157              :         double getAngle(const MSStageMoving& stage, SUMOTime now) const;
     158              :         /// @brief compute tranship time on edge and update state members
     159              :         SUMOTime computeDuration(const MSEdge* prev, const MSStageMoving& stage, SUMOTime currentTime);
     160              : 
     161              :     private:
     162              :         Position myCurrentBeginPosition;  //the position the container is moving from during its tranship stage
     163              :         Position myCurrentEndPosition;  //the position the container is moving to during its tranship stage
     164              :     };
     165              : 
     166              : private:
     167              :     /// @brief the net to which to issue moveToNextEdge commands
     168              :     MSNet* myNet;
     169              : 
     170              :     /// @brief the total number of active pedestrians
     171              :     int myNumActivePedestrians;
     172              : 
     173              : };
        

Generated by: LCOV version 2.0-1