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 1290793 : MSStage::MSStage(MSStageType type, const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos,
48 1290793 : const double arrivalPosLat, const std::string& group) :
49 1290793 : myDestination(destination),
50 1290793 : myDestinationStop(toStop),
51 1290793 : myArrivalPos(arrivalPos),
52 1290793 : myArrivalPosLat(arrivalPosLat),
53 1290793 : myDeparted(-1),
54 1290793 : myArrived(-1),
55 1290793 : myType(type),
56 1290793 : myGroup(group),
57 1290793 : myCosts(-1),
58 1290793 : myParametersSet(0)
59 1290793 : {}
60 :
61 1290606 : MSStage::~MSStage() {}
62 :
63 :
64 : const MSEdge*
65 71508644 : MSStage::getDestination() const {
66 71508644 : return myDestination;
67 : }
68 :
69 :
70 : const MSEdge*
71 713209 : MSStage::getEdge() const {
72 713209 : return myDestination;
73 : }
74 :
75 :
76 : const MSEdge*
77 101 : MSStage::getFromEdge() const {
78 101 : return myDestination;
79 : }
80 :
81 :
82 : double
83 483844 : MSStage::getEdgePos(SUMOTime /* now */) const {
84 483844 : 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 8388 : MSStage::getSpeed() const {
102 8388 : return 0.;
103 : }
104 :
105 :
106 : ConstMSEdgeVector
107 308 : MSStage::getEdges() const {
108 : ConstMSEdgeVector result;
109 308 : result.push_back(getDestination());
110 308 : return result;
111 0 : }
112 :
113 :
114 : void
115 503343 : MSStage::setDeparted(SUMOTime now) {
116 503343 : if (myDeparted < 0) {
117 499896 : myDeparted = now;
118 : }
119 503343 : }
120 :
121 : SUMOTime
122 566119 : MSStage::getDeparted() const {
123 566119 : return myDeparted;
124 : }
125 :
126 : SUMOTime
127 742 : MSStage::getArrived() const {
128 742 : return myArrived;
129 : }
130 :
131 :
132 : SUMOTime
133 234217 : MSStage::getDuration() const {
134 234217 : return myArrived >= 0 ? myArrived - myDeparted : SUMOTime_MAX;
135 : }
136 :
137 :
138 : SUMOTime
139 58828 : MSStage::getTravelTime() const {
140 58828 : return getDuration();
141 : }
142 :
143 : SUMOTime
144 71165 : MSStage::getWaitingTime() const {
145 71165 : return 0;
146 : }
147 :
148 : SUMOTime
149 78355 : MSStage::getTotalWaitingTime() const {
150 78355 : return getWaitingTime();
151 : }
152 :
153 : SUMOTime
154 71629 : MSStage::getTimeLoss(const MSTransportable* /*transportable*/) const {
155 71629 : return 0;
156 : }
157 :
158 :
159 : const std::string
160 1168935 : MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
161 1168935 : myArrived = now;
162 1168935 : return "";
163 : }
164 :
165 : bool
166 0 : MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
167 0 : return false;
168 : }
169 :
170 : Position
171 301039 : MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
172 301039 : return getLanePosition(e->getLanes()[0], at, offset);
173 : }
174 :
175 : Position
176 1884169 : MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
177 1884169 : return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
178 : }
179 :
180 :
181 : double
182 486119 : MSStage::getEdgeAngle(const MSEdge* e, double at) const {
183 486119 : return e->getLanes()[0]->getShape().rotationAtOffset(at);
184 : }
185 :
186 :
187 : void
188 57 : MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
189 57 : myDestination = newDestination;
190 57 : myDestinationStop = newDestStop;
191 57 : if (newDestStop != nullptr) {
192 50 : myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
193 : }
194 57 : }
195 :
196 : bool
197 283106 : MSStage::unspecifiedArrivalPos() const {
198 283106 : return myArrivalPos == ARRIVALPOS_UNSPECIFIED;
199 : }
200 :
201 :
202 :
203 : /****************************************************************************/
|