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 <microsim/MSParkingArea.h>
37 #include "MSStopOut.h"
38 
39 
40 // ---------------------------------------------------------------------------
41 // static initialisation methods
42 // ---------------------------------------------------------------------------
44 
45 void
47  if (OptionsCont::getOptions().isSet("stop-output")) {
49  }
50 }
51 
52 
53 // ===========================================================================
54 // method definitions
55 // ===========================================================================
57  myDevice(dev) {
58 }
59 
61 
62 
63 void
64 MSStopOut::stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers) {
65  assert(veh != 0);
66  if (myStopped.count(veh) != 0) {
67  WRITE_WARNING("Vehicle '" + veh->getID() + "' is already stopped.");
68  }
69  StopInfo stopInfo(MSNet::getInstance()->getCurrentTimeStep(), numPersons, numContainers);
70  myStopped[veh] = stopInfo;
71 }
72 
73 void
75  myStopped[veh].loadedPersons += n;
76 }
77 
78 void
80  myStopped[veh].unloadedPersons += n;
81 }
82 
83 void
85  myStopped[veh].loadedContainers += n;
86 }
87 
88 void
90  myStopped[veh].unloadedContainers += n;
91 }
92 
93 void
95  assert(veh != 0);
96  if (myStopped.count(veh) == 0) {
97  WRITE_WARNING("Vehicle '" + veh->getID() + "' is not stopped.");
98  return;
99  }
100  StopInfo& si = myStopped[veh];
101  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:261
static void init()
Static intialization.
Definition: MSStopOut.cpp:46
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:169
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:820
Stopped myStopped
Definition: MSStopOut.h:123
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
void loadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:84
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
MSChargingStation * chargingStation
(Optional) charging station if one is assigned to the stop
Definition: MSVehicle.h:832
void unloadedPersons(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:79
const std::string & getID() const
Returns the id.
Definition: Named.h:66
Representation of a vehicle.
Definition: SUMOVehicle.h:67
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
Definition: MSVehicle.h:828
const MSLane * lane
The lane to stop at.
Definition: MSVehicle.h:824
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers)
Definition: MSStopOut.cpp:64
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition: MSVehicle.h:830
static MSStopOut * myInstance
Definition: MSStopOut.h:127
void stopEnded(const SUMOVehicle *veh, const MSVehicle::Stop &stop)
Definition: MSStopOut.cpp:94
void unloadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:89
virtual ~MSStopOut()
Destructor.
Definition: MSStopOut.cpp:60
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
const std::string & getID() const
Returns the name of the vehicle type.
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:74
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Definition: MSVehicle.h:826
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:846
MSStopOut(OutputDevice &dev)
constructor.
Definition: MSStopOut.cpp:56