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 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::ROADSIDE_OFFSET(3); 39 : 40 : 41 : // =========================================================================== 42 : // method definitions 43 : // =========================================================================== 44 : /* ------------------------------------------------------------------------- 45 : * MSStage - methods 46 : * ----------------------------------------------------------------------- */ 47 1170151 : MSStage::MSStage(MSStageType type, const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, 48 1170151 : const double arrivalPosLat, const std::string& group) : 49 1170151 : myDestination(destination), 50 1170151 : myDestinationStop(toStop), 51 1170151 : myArrivalPos(arrivalPos), 52 1170151 : myArrivalPosLat(arrivalPosLat), 53 1170151 : myDeparted(-1), 54 1170151 : myArrived(-1), 55 1170151 : myType(type), 56 1170151 : myGroup(group), 57 1170151 : myCosts(-1), 58 1170151 : myParametersSet(0) 59 1170151 : {} 60 : 61 1170053 : MSStage::~MSStage() {} 62 : 63 : 64 : const MSEdge* 65 50164472 : MSStage::getDestination() const { 66 50164472 : return myDestination; 67 : } 68 : 69 : 70 : const MSEdge* 71 598677 : MSStage::getEdge() const { 72 598677 : return myDestination; 73 : } 74 : 75 : 76 : const MSEdge* 77 0 : MSStage::getFromEdge() const { 78 0 : return myDestination; 79 : } 80 : 81 : 82 : double 83 425914 : MSStage::getEdgePos(SUMOTime /* now */) const { 84 425914 : 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 : SUMOTime 101 0 : MSStage::getWaitingTime(SUMOTime /* now */) const { 102 0 : return 0; 103 : } 104 : 105 : 106 : double 107 8434 : MSStage::getSpeed() const { 108 8434 : return 0.; 109 : } 110 : 111 : 112 : ConstMSEdgeVector 113 290 : MSStage::getEdges() const { 114 : ConstMSEdgeVector result; 115 290 : result.push_back(getDestination()); 116 290 : return result; 117 : } 118 : 119 : 120 : void 121 17801 : MSStage::setDeparted(SUMOTime now) { 122 17801 : if (myDeparted < 0) { 123 12143 : myDeparted = now; 124 : } 125 17801 : } 126 : 127 : SUMOTime 128 20362 : MSStage::getDeparted() const { 129 20362 : return myDeparted; 130 : } 131 : 132 : SUMOTime 133 967 : MSStage::getArrived() const { 134 967 : return myArrived; 135 : } 136 : 137 : 138 : SUMOTime 139 220882 : MSStage::getDuration() const { 140 220882 : return myArrived >= 0 ? myArrived - myDeparted : SUMOTime_MAX; 141 : } 142 : 143 : 144 : SUMOTime 145 59223 : MSStage::getTravelTime() const { 146 59223 : return getDuration(); 147 : } 148 : 149 : SUMOTime 150 100859 : MSStage::getWaitingTime() const { 151 100859 : return 0; 152 : } 153 : 154 : SUMOTime 155 63622 : MSStage::getTimeLoss(const MSTransportable* /*transportable*/) const { 156 63622 : return 0; 157 : } 158 : 159 : 160 : const std::string 161 1103642 : MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) { 162 1103642 : myArrived = now; 163 1103642 : return ""; 164 : } 165 : 166 : bool 167 0 : MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const { 168 0 : return false; 169 : } 170 : 171 : Position 172 324791 : MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const { 173 324791 : return getLanePosition(e->getLanes()[0], at, offset); 174 : } 175 : 176 : Position 177 1566622 : MSStage::getLanePosition(const MSLane* lane, double at, double offset) const { 178 1566622 : return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset); 179 : } 180 : 181 : 182 : double 183 475286 : MSStage::getEdgeAngle(const MSEdge* e, double at) const { 184 475286 : return e->getLanes()[0]->getShape().rotationAtOffset(at); 185 : } 186 : 187 : 188 : void 189 46 : MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) { 190 46 : myDestination = newDestination; 191 46 : myDestinationStop = newDestStop; 192 46 : if (newDestStop != nullptr) { 193 46 : myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2; 194 : } 195 46 : } 196 : 197 : 198 : /****************************************************************************/