Eclipse SUMO - Simulation of Urban MObility
MSStop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-2020 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 /****************************************************************************/
19 // A lane area vehicles can halt at
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include "MSLane.h"
24 #include "MSParkingArea.h"
25 #include "MSStoppingPlace.h"
26 #include "MSStop.h"
27 
28 
29 // ===========================================================================
30 // method definitions
31 // ===========================================================================
32 double
33 MSStop::getEndPos(const SUMOVehicle& veh) const {
34  if (busstop != nullptr) {
35  return busstop->getLastFreePos(veh);
36  } else if (containerstop != nullptr) {
37  return containerstop->getLastFreePos(veh);
38  } else if (parkingarea != nullptr) {
39  return parkingarea->getLastFreePos(veh);
40  } else if (chargingStation != nullptr) {
41  return chargingStation->getLastFreePos(veh);
42  } else if (overheadWireSegment != nullptr) {
44  }
45  return pars.endPos;
46 }
47 
48 
49 std::string
51  if (parkingarea != nullptr) {
52  return "parkingArea:" + parkingarea->getID();
53  } else if (containerstop != nullptr) {
54  return "containerStop:" + containerstop->getID();
55  } else if (busstop != nullptr) {
56  return "busStop:" + busstop->getID();
57  } else if (chargingStation != nullptr) {
58  return "chargingStation:" + chargingStation->getID();
59  } else if (overheadWireSegment != nullptr) {
60  return "overheadWireSegment:" + overheadWireSegment->getID();
61  } else {
62  return "lane:" + lane->getID() + " pos:" + toString(pars.endPos);
63  }
64 }
65 
66 
67 void
70  tmp.duration = duration;
71  if (busstop == nullptr
72  && containerstop == nullptr
73  && parkingarea == nullptr
74  && chargingStation == nullptr) {
76  }
77  tmp.write(dev, false);
78  if (pars.actualArrival >= 0) {
80  }
81  dev.closeTag();
82 }
83 
84 void
91  duration = stopPar.duration;
92  triggered = stopPar.triggered;
94  joinTriggered = stopPar.joinTriggered || stopPar.join != "";
95  numExpectedPerson = (int)stopPar.awaitedPersons.size();
96  numExpectedContainer = (int)stopPar.awaitedContainers.size();
97 }
98 
99 
100 
101 /****************************************************************************/
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
const int STOP_START_SET
const int STOP_END_SET
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_ATTR_ACTUALARRIVAL
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1098
A lane area vehicles can halt at.
Definition: MSParkingArea.h:57
double getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
void write(OutputDevice &dev) const
Write the current stop configuration (used for state saving)
Definition: MSStop.cpp:68
const MSLane * lane
The lane to stop at (microsim only)
Definition: MSStop.h:50
bool triggered
whether an arriving person lets the vehicle continue
Definition: MSStop.h:69
bool containerTriggered
whether an arriving container lets the vehicle continue
Definition: MSStop.h:71
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSStop.h:56
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
Definition: MSStop.h:73
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
Definition: MSStop.cpp:85
int numExpectedContainer
The number of still expected containers.
Definition: MSStop.h:79
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
Definition: MSStop.cpp:33
int numExpectedPerson
The number of still expected persons.
Definition: MSStop.h:77
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSStop.h:58
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSStop.h:60
std::string getDescription() const
get a short description for showing in the gui
Definition: MSStop.cpp:50
SUMOTime duration
The stopping duration.
Definition: MSStop.h:67
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSStop.h:65
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSStop.h:54
MSStoppingPlace * overheadWireSegment
(Optional) overhead wire segment if one is assigned to the stop
Definition: MSStop.h:63
double getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
const std::string & getID() const
Returns the id.
Definition: Named.h:73
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
Definition of vehicle stop (position and duration)
void write(OutputDevice &dev, bool close=true) const
Writes the stop as XML.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime actualArrival
the time at which this stop was reached
bool triggered
whether an arriving person lets the vehicle continue
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool joinTriggered
whether an joined vehicle lets this vehicle continue
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime duration
The stopping duration.