SUMO - Simulation of Urban MObility
MSStopOut.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Ouput information about planned vehicle stop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
33 #include <microsim/MSNet.h>
34 #include "MSStopOut.h"
35 
36 
37 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif // CHECK_MEMORY_LEAKS
40 
41 // ---------------------------------------------------------------------------
42 // static initialisation methods
43 // ---------------------------------------------------------------------------
45 
46 void
48  if (OptionsCont::getOptions().isSet("stop-output")) {
50  }
51 }
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
58  myDevice(dev) {
59 }
60 
62 
63 
64 void
65 MSStopOut::stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers) {
66  assert(veh != 0);
67  if (myStopped.count(veh) != 0) {
68  WRITE_WARNING("Vehicle '" + veh->getID() + "' is already stopped.");
69  }
70  StopInfo stopInfo(MSNet::getInstance()->getCurrentTimeStep(), numPersons, numContainers);
71  myStopped[veh] = stopInfo;
72 }
73 
74 void
76  myStopped[veh].loadedPersons += n;
77 }
78 
79 void
81  myStopped[veh].unloadedPersons += n;
82 }
83 
84 void
86  myStopped[veh].loadedContainers += n;
87 }
88 
89 void
91  myStopped[veh].unloadedContainers += n;
92 }
93 
94 void
96  assert(veh != 0);
97  if (myStopped.count(veh) == 0) {
98  WRITE_WARNING("Vehicle '" + veh->getID() + "' is not stopped.");
99  return;
100  }
101  StopInfo& si = myStopped[veh];
102  myDevice.openTag("stopinfo");
107  myDevice.writeAttr("started", time2string(si.started));
108  myDevice.writeAttr("ended", time2string(MSNet::getInstance()->getCurrentTimeStep()));
109  myDevice.writeAttr("initialPersons", si.initialNumPersons);
110  myDevice.writeAttr("loadedPersons", si.loadedPersons);
111  myDevice.writeAttr("unloadedPersons", si.unloadedPersons);
112  myDevice.writeAttr("initialContainers", si.initialNumContainers);
113  myDevice.writeAttr("loadedContainers", si.loadedContainers);
114  myDevice.writeAttr("unloadedContainers", si.unloadedContainers);
115  if (stop.busstop != 0) {
117  }
118  if (stop.containerstop != 0) {
120  }
121  if (stop.parkingarea != 0) {
123  }
124  if (stop.chargingStation != 0) {
126  }
127  myDevice.closeTag();
128  myStopped.erase(veh);
129 }
130 
131 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
static void init()
Static intialization.
Definition: MSStopOut.cpp:47
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:803
Stopped myStopped
Definition: MSStopOut.h:123
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
void loadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:85
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
MSChargingStation * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:815
void unloadedPersons(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:80
const std::string & getID() const
Returns the id.
Definition: Named.h:66
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:67
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:811
const MSLane * lane
The lane to stop at.
Definition: MSVehicle.h:807
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers)
Definition: MSStopOut.cpp:65
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:813
static MSStopOut * myInstance
Definition: MSStopOut.h:127
void stopEnded(const SUMOVehicle *veh, const MSVehicle::Stop &stop)
Definition: MSStopOut.cpp:95
void unloadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:90
virtual ~MSStopOut()
Destructor.
Definition: MSStopOut.cpp:61
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
OutputDevice & myDevice
Definition: MSStopOut.h:125
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
void loadedPersons(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:75
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:809
Realises dumping the complete network state.
Definition: MSStopOut.h:57
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool parking
whether the vehicle is removed from the net while stopping
Definition: MSVehicle.h:829
MSStopOut(OutputDevice &dev)
constructor.
Definition: MSStopOut.cpp:57