LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSStageMoving.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 83.3 % 24 20
Test Date: 2024-12-21 15:45:41 Functions: 66.7 % 3 2

            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    MSStageMoving.h
      15              : /// @author  Michael Behrisch
      16              : /// @author  Jakob Erdmann
      17              : /// @date    Wed, 1 Jun 2022
      18              : ///
      19              : // The common superclass for modelling walking and tranship
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include <microsim/transportables/MSStage.h>
      25              : 
      26              : 
      27              : // ===========================================================================
      28              : // class declarations
      29              : // ===========================================================================
      30              : 
      31              : /**
      32              : * An abstract stage providing additional interface for the movement models
      33              : */
      34              : class MSStageMoving : public MSStage {
      35              : public:
      36              :     /// constructor
      37       402523 :     MSStageMoving(const MSStageType type, const std::vector<const MSEdge*>& route, const std::string& routeID, MSStoppingPlace* toStop, const double speed,
      38       402523 :                   const double departPos, const double arrivalPos, const double departPosLat, const int departLane) :
      39              :         MSStage(type, route.back(), toStop, arrivalPos),
      40       402523 :         myPState(nullptr), myRoute(route), myRouteID(routeID), myRouteStep(myRoute.begin()),
      41       402523 :         mySpeed(speed), myDepartPos(departPos),
      42      1207569 :         myDepartPosLat(departPosLat), myDepartLane(departLane) {}
      43              : 
      44              :     /// destructor
      45              :     virtual ~MSStageMoving();
      46              : 
      47              :     virtual const MSEdge* getNextRouteEdge() const = 0;
      48              : 
      49              :     inline MSTransportableStateAdapter* getPState() const {
      50      1447017 :         return myPState;
      51              :     }
      52              : 
      53              :     inline void setPState(MSTransportableStateAdapter* pstate) {
      54              :         myPState = pstate;
      55              :     }
      56              : 
      57              :     /// Returns the current edge
      58              :     const MSEdge* getEdge() const;
      59              : 
      60              :     /// Returns the current lane
      61              :     const MSLane* getLane() const;
      62              : 
      63              :     /// Returns first edge of the containers route
      64              :     const MSEdge* getFromEdge() const;
      65              : 
      66              :     /// @brief the edges of the current stage
      67              :     ConstMSEdgeVector getEdges() const;
      68              : 
      69              :     /// Returns the offset from the start of the current edge measured in its natural direction
      70              :     double getEdgePos(SUMOTime now) const;
      71              : 
      72              :     /// @brief Return the movement directon on the edge
      73              :     int getDirection() const;
      74              : 
      75              :     /// Returns the position of the container
      76              :     Position getPosition(SUMOTime now) const;
      77              : 
      78              :     /// Returns the angle of the container
      79              :     double getAngle(SUMOTime now) const;
      80              : 
      81              :     /// Returns the time the container spent waiting
      82              :     SUMOTime getWaitingTime(SUMOTime now) const;
      83              : 
      84              :     /// Returns the speed of the container
      85              :     double getSpeed() const;
      86              : 
      87              :     /// Returns the configured speed in this stage
      88              :     double getConfiguredSpeed() const {
      89    136250594 :         return mySpeed;
      90              :     }
      91              : 
      92              :     /// @brief the maximum speed of the transportable
      93              :     virtual double getMaxSpeed(const MSTransportable* const transportable = nullptr) const = 0;
      94              : 
      95              :     /// @brief move forward and return whether the transportable arrived
      96              :     virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr, const bool isReplay = false) = 0;
      97              : 
      98              :     /// @brief add the move reminders for the current lane on entry
      99            0 :     virtual void activateEntryReminders(MSTransportable* person, const bool isDepart = false) {
     100              :         UNUSED_PARAMETER(person);
     101              :         UNUSED_PARAMETER(isDepart);
     102            0 :     }
     103              : 
     104              :     /// @brief place transportable on a previously passed edge
     105              :     virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
     106              : 
     107              :     virtual void replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset);
     108              : 
     109              :     inline const std::vector<const MSEdge*>& getRoute() const {
     110       243815 :         return myRoute;
     111              :     }
     112              : 
     113              :     inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
     114       976007 :         return myRouteStep;
     115              :     }
     116              : 
     117              :     inline double getDepartPos() const {
     118       398159 :         return myDepartPos;
     119              :     }
     120              : 
     121              :     inline void setDepartPos(const double pos) {
     122            0 :         myDepartPos = pos;
     123            0 :     }
     124              : 
     125              :     inline double getDepartPosLat() const {
     126       243773 :         return myDepartPosLat;
     127              :     }
     128              : 
     129              :     inline int getDepartLane() const {
     130       243767 :         return myDepartLane;
     131              :     }
     132              : 
     133              :     /// @brief interpret custom depart lane
     134              :     static const MSLane* checkDepartLane(const MSEdge* edge, SUMOVehicleClass svc, int laneIndex, const std::string& id);
     135              : 
     136           80 :     bool equals(const MSStage& s) const {
     137           80 :         if (!MSStage::equals(s)) {
     138              :             return false;
     139              :         }
     140              :         // this is safe because MSStage already checked that the type fits
     141              :         const MSStageMoving& sm = static_cast<const MSStageMoving&>(s);
     142          160 :         return myRoute == sm.myRoute &&
     143           80 :                myRouteID == sm.myRouteID &&
     144           80 :                mySpeed == sm.mySpeed &&
     145           80 :                myDepartPos == sm.myDepartPos &&
     146          118 :                myDepartPosLat == sm.myDepartPosLat &&
     147           38 :                myDepartLane == sm.myDepartLane;
     148              :     }
     149              : 
     150              : protected:
     151              :     /// @brief state that is to be manipulated by MSPModel
     152              :     MSTransportableStateAdapter* myPState;
     153              : 
     154              :     /// @brief The route of the container
     155              :     std::vector<const MSEdge*> myRoute;
     156              : 
     157              :     /// @brief The original route id
     158              :     std::string myRouteID;
     159              : 
     160              :     /// @brief current step
     161              :     std::vector<const MSEdge*>::iterator myRouteStep;
     162              : 
     163              :     /// @brief The current internal edge this transportable is on or nullptr
     164              :     MSEdge* myCurrentInternalEdge = nullptr;
     165              : 
     166              :     /// @brief the speed of the transportable
     167              :     double mySpeed;
     168              : 
     169              :     /// @brief the depart position
     170              :     double myDepartPos;
     171              : 
     172              :     /// @brief the lateral depart position
     173              :     double myDepartPosLat;
     174              : 
     175              :     /// @brief the depart lane or -1
     176              :     int myDepartLane;
     177              : };
        

Generated by: LCOV version 2.0-1