SUMO - Simulation of Urban MObility
MSStopOut.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Ouput information about planned vehicle stop
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
32 #include <microsim/MSNet.h>
33 #include <microsim/MSParkingArea.h>
36 #include "MSStopOut.h"
37 
38 
39 // ---------------------------------------------------------------------------
40 // static initialisation methods
41 // ---------------------------------------------------------------------------
43 
44 void
46  if (OptionsCont::getOptions().isSet("stop-output")) {
48  }
49 }
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
56  myDevice(dev) {
57 }
58 
60 
61 
62 void
63 MSStopOut::stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers) {
64  assert(veh != 0);
65  if (myStopped.count(veh) != 0) {
66  WRITE_WARNING("Vehicle '" + veh->getID() + "' is already stopped.");
67  }
68  StopInfo stopInfo(MSNet::getInstance()->getCurrentTimeStep(), numPersons, numContainers);
69  myStopped[veh] = stopInfo;
70 }
71 
72 void
74  myStopped[veh].loadedPersons += n;
75 }
76 
77 void
79  myStopped[veh].unloadedPersons += n;
80 }
81 
82 void
84  myStopped[veh].loadedContainers += n;
85 }
86 
87 void
89  myStopped[veh].unloadedContainers += n;
90 }
91 
92 void
94  assert(veh != 0);
95  if (myStopped.count(veh) == 0) {
96  WRITE_WARNING("Vehicle '" + veh->getID() + "' is not stopped.");
97  return;
98  }
99  double delay = -1;
100  if (stop.pars.until >= 0) {
101  delay = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - stop.pars.until);
102  }
103  StopInfo& si = myStopped[veh];
104  myDevice.openTag("stopinfo");
110  myDevice.writeAttr("started", time2string(si.started));
111  myDevice.writeAttr("ended", time2string(MSNet::getInstance()->getCurrentTimeStep()));
112  myDevice.writeAttr("delay", delay);
113  myDevice.writeAttr("initialPersons", si.initialNumPersons);
114  myDevice.writeAttr("loadedPersons", si.loadedPersons);
115  myDevice.writeAttr("unloadedPersons", si.unloadedPersons);
116  myDevice.writeAttr("initialContainers", si.initialNumContainers);
117  myDevice.writeAttr("loadedContainers", si.loadedContainers);
118  myDevice.writeAttr("unloadedContainers", si.unloadedContainers);
119  if (stop.busstop != 0) {
121  }
122  if (stop.containerstop != 0) {
124  }
125  if (stop.parkingarea != 0) {
127  }
128  if (stop.chargingStation != 0) {
130  }
131  myDevice.closeTag();
132  myStopped.erase(veh);
133 }
134 
135 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
static void init()
Static intialization.
Definition: MSStopOut.cpp:45
bool parking
whether the vehicle is removed from the net while stopping
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSVehicle.h:917
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:913
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:909
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
SUMOTime until
The time at which the vehicle may continue its journey.
Stopped myStopped
Definition: MSStopOut.h:122
const std::string & getID() const
Returns the id.
Definition: Named.h:65
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
void loadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:83
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
void unloadedPersons(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:78
Representation of a vehicle.
Definition: SUMOVehicle.h:66
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers)
Definition: MSStopOut.cpp:63
static MSStopOut * myInstance
Definition: MSStopOut.h:126
const MSLane * lane
The lane to stop at.
Definition: MSVehicle.h:907
void stopEnded(const SUMOVehicle *veh, const MSVehicle::Stop &stop)
Definition: MSStopOut.cpp:93
void unloadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:88
virtual ~MSStopOut()
Destructor.
Definition: MSStopOut.cpp:59
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:915
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:911
const std::string & getID() const
Returns the name of the vehicle type.
OutputDevice & myDevice
Definition: MSStopOut.h:124
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
void loadedPersons(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:73
Realises dumping the complete network state.
Definition: MSStopOut.h:56
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:901
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
MSStopOut(OutputDevice &dev)
constructor.
Definition: MSStopOut.cpp:55