LCOV - code coverage report
Current view: top level - src/microsim/transportables - MSStage.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 90.3 % 72 65
Test Date: 2026-05-24 16:29:35 Functions: 85.2 % 27 23

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2026 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    MSStage.cpp
      15              : /// @author  Melanie Weber
      16              : /// @author  Andreas Kendziorra
      17              : /// @author  Michael Behrisch
      18              : /// @date    Thu, 12 Jun 2014
      19              : ///
      20              : // The common superclass for modelling transportable objects like persons and containers
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <utils/vehicle/SUMOVehicleParameter.h>
      25              : #include <microsim/MSEdge.h>
      26              : #include <microsim/MSLane.h>
      27              : #include <microsim/MSNet.h>
      28              : #include <microsim/MSStoppingPlace.h>
      29              : #include <microsim/devices/MSTransportableDevice.h>
      30              : #include <microsim/transportables/MSTransportableControl.h>
      31              : #include <microsim/transportables/MSTransportable.h>
      32              : #include <microsim/transportables/MSPModel.h>
      33              : 
      34              : 
      35              : /* -------------------------------------------------------------------------
      36              : * static member definitions
      37              : * ----------------------------------------------------------------------- */
      38              : const double MSStage::ARRIVALPOS_UNSPECIFIED(std::numeric_limits<double>::infinity());
      39              : const double MSStage::ROADSIDE_OFFSET(3);
      40              : 
      41              : // ===========================================================================
      42              : // method definitions
      43              : // ===========================================================================
      44              : /* -------------------------------------------------------------------------
      45              :  * MSStage - methods
      46              :  * ----------------------------------------------------------------------- */
      47      1172087 : MSStage::MSStage(MSStageType type, const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos,
      48      1172087 :                  const double arrivalPosLat, const std::string& group) :
      49      1172087 :     myDestination(destination),
      50      1172087 :     myDestinationStop(toStop),
      51      1172087 :     myArrivalPos(arrivalPos),
      52      1172087 :     myArrivalPosLat(arrivalPosLat),
      53      1172087 :     myDeparted(-1),
      54      1172087 :     myArrived(-1),
      55      1172087 :     myType(type),
      56      1172087 :     myGroup(group),
      57      1172087 :     myCosts(-1),
      58      1172087 :     myParametersSet(0)
      59      1172087 : {}
      60              : 
      61      1171974 : MSStage::~MSStage() {}
      62              : 
      63              : 
      64              : const MSEdge*
      65     51795027 : MSStage::getDestination() const {
      66     51795027 :     return myDestination;
      67              : }
      68              : 
      69              : 
      70              : const MSEdge*
      71       674263 : MSStage::getEdge() const {
      72       674263 :     return myDestination;
      73              : }
      74              : 
      75              : 
      76              : const MSEdge*
      77           97 : MSStage::getFromEdge() const {
      78           97 :     return myDestination;
      79              : }
      80              : 
      81              : 
      82              : double
      83       486192 : MSStage::getEdgePos(SUMOTime /* now */) const {
      84       486192 :     return myArrivalPos;
      85              : }
      86              : 
      87              : 
      88              : double
      89            0 : MSStage::getEdgePosLat(SUMOTime /* now */) const {
      90            0 :     return myArrivalPosLat;
      91              : }
      92              : 
      93              : 
      94              : int
      95            0 : MSStage::getDirection() const {
      96            0 :     return MSPModel::UNDEFINED_DIRECTION;
      97              : }
      98              : 
      99              : 
     100              : double
     101        12752 : MSStage::getSpeed() const {
     102        12752 :     return 0.;
     103              : }
     104              : 
     105              : 
     106              : ConstMSEdgeVector
     107          357 : MSStage::getEdges() const {
     108              :     ConstMSEdgeVector result;
     109          357 :     result.push_back(getDestination());
     110          357 :     return result;
     111            0 : }
     112              : 
     113              : 
     114              : void
     115       505031 : MSStage::setDeparted(SUMOTime now) {
     116       505031 :     if (myDeparted < 0) {
     117       501589 :         myDeparted = now;
     118              :     }
     119       505031 : }
     120              : 
     121              : 
     122              : void
     123        40477 : MSStage::setEnded(SUMOTime t) {
     124        40477 :     myArrived = t;
     125        40477 : }
     126              : 
     127              : 
     128              : SUMOTime
     129       528725 : MSStage::getDeparted() const {
     130       528725 :     return myDeparted;
     131              : }
     132              : 
     133              : SUMOTime
     134          886 : MSStage::getArrived() const {
     135          886 :     return myArrived;
     136              : }
     137              : 
     138              : 
     139              : SUMOTime
     140       234604 : MSStage::getDuration() const {
     141       234604 :     return myArrived >= 0 ? myArrived - myDeparted : SUMOTime_MAX;
     142              : }
     143              : 
     144              : 
     145              : SUMOTime
     146        58910 : MSStage::getTravelTime() const {
     147        58910 :     return getDuration();
     148              : }
     149              : 
     150              : SUMOTime
     151        71673 : MSStage::getWaitingTime() const {
     152        71673 :     return 0;
     153              : }
     154              : 
     155              : SUMOTime
     156        79251 : MSStage::getTotalWaitingTime() const {
     157        79251 :     return getWaitingTime();
     158              : }
     159              : 
     160              : SUMOTime
     161        72137 : MSStage::getTimeLoss(const MSTransportable* /*transportable*/) const {
     162        72137 :     return 0;
     163              : }
     164              : 
     165              : 
     166              : const std::string
     167      1054390 : MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
     168      1054390 :     myArrived = now;
     169      1054390 :     return "";
     170              : }
     171              : 
     172              : bool
     173            0 : MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
     174            0 :     return false;
     175              : }
     176              : 
     177              : Position
     178       320707 : MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
     179       320707 :     return getLanePosition(e->getLanes()[0], at, offset);
     180              : }
     181              : 
     182              : Position
     183      8821024 : MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
     184      8821024 :     return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
     185              : }
     186              : 
     187              : 
     188              : double
     189      3916740 : MSStage::getEdgeAngle(const MSEdge* e, double at) const {
     190      3916740 :     return e->getLanes()[0]->getShape().rotationAtOffset(at);
     191              : }
     192              : 
     193              : 
     194              : void
     195           56 : MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
     196           56 :     myDestination = newDestination;
     197           56 :     myDestinationStop = newDestStop;
     198           56 :     if (newDestStop != nullptr) {
     199           49 :         myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
     200              :     }
     201           56 : }
     202              : 
     203              : bool
     204       308479 : MSStage::unspecifiedArrivalPos() const {
     205       308479 :     return myArrivalPos == ARRIVALPOS_UNSPECIFIED;
     206              : }
     207              : 
     208              : 
     209              : 
     210              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1