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 // ---------------------------------------------------------------------------
38 // static initialisation methods
39 // ---------------------------------------------------------------------------
41 
42 void
44  if (OptionsCont::getOptions().isSet("stop-output")) {
46  }
47 }
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
54  myDevice(dev) {
55 }
56 
58 
59 
60 void
61 MSStopOut::stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers) {
62  assert(veh != 0);
63  if (myStopped.count(veh) != 0) {
64  WRITE_WARNING("Vehicle '" + veh->getID() + "' is already stopped.");
65  }
66  StopInfo stopInfo(MSNet::getInstance()->getCurrentTimeStep(), numPersons, numContainers);
67  myStopped[veh] = stopInfo;
68 }
69 
70 void
72  myStopped[veh].loadedPersons += n;
73 }
74 
75 void
77  myStopped[veh].unloadedPersons += n;
78 }
79 
80 void
82  myStopped[veh].loadedContainers += n;
83 }
84 
85 void
87  myStopped[veh].unloadedContainers += n;
88 }
89 
90 void
92  assert(veh != 0);
93  if (myStopped.count(veh) == 0) {
94  WRITE_WARNING("Vehicle '" + veh->getID() + "' is not stopped.");
95  return;
96  }
97  StopInfo& si = myStopped[veh];
98  myDevice.openTag("stopinfo");
104  myDevice.writeAttr("started", time2string(si.started));
105  myDevice.writeAttr("ended", time2string(MSNet::getInstance()->getCurrentTimeStep()));
106  myDevice.writeAttr("initialPersons", si.initialNumPersons);
107  myDevice.writeAttr("loadedPersons", si.loadedPersons);
108  myDevice.writeAttr("unloadedPersons", si.unloadedPersons);
109  myDevice.writeAttr("initialContainers", si.initialNumContainers);
110  myDevice.writeAttr("loadedContainers", si.loadedContainers);
111  myDevice.writeAttr("unloadedContainers", si.unloadedContainers);
112  if (stop.busstop != 0) {
114  }
115  if (stop.containerstop != 0) {
117  }
118  if (stop.parkingarea != 0) {
120  }
121  if (stop.chargingStation != 0) {
123  }
124  myDevice.closeTag();
125  myStopped.erase(veh);
126 }
127 
128 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
static void init()
Static intialization.
Definition: MSStopOut.cpp:43
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:158
Definition of vehicle stop (position and duration)
Definition: MSVehicle.h:820
Stopped myStopped
Definition: MSStopOut.h:123
const std::string & getID() const
Returns the id.
Definition: Named.h:66
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
void loadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:81
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:76
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:61
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:91
void unloadedContainers(const SUMOVehicle *veh, int n)
Definition: MSStopOut.cpp:86
virtual ~MSStopOut()
Destructor.
Definition: MSStopOut.cpp:57
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.
const std::string & getID() const
Returns the name of the vehicle type.
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:71
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
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
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
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
MSStopOut(OutputDevice &dev)
constructor.
Definition: MSStopOut.cpp:53