Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 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 : /****************************************************************************/
14 : /// @file MSStopOut.h
15 : /// @author Jakob Erdmann
16 : /// @date Wed, 21.12.2016
17 : ///
18 : // Ouput information about planned vehicle stop
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 :
23 : #include <map>
24 : #include <utils/common/SUMOTime.h>
25 : #include <utils/vehicle/SUMOVehicleParameter.h>
26 :
27 :
28 : // ===========================================================================
29 : // class declarations
30 : // ===========================================================================
31 : class OutputDevice;
32 : class SUMOVehicle;
33 :
34 :
35 : // ===========================================================================
36 : // class definitions
37 : // ===========================================================================
38 : /**
39 : * @class MSStopOut
40 : * @brief Realises dumping the complete network state
41 : *
42 : * The class offers a static method, which writes the complete dump of
43 : * the given network into the given OutputDevice.
44 : *
45 : * @todo consider error-handling on write (using IOError)
46 : */
47 : class MSStopOut {
48 : public:
49 :
50 : /** @brief Static intialization
51 : */
52 : static void init();
53 :
54 : static bool active() {
55 395252 : return myInstance != 0;
56 : }
57 :
58 : static void cleanup();
59 :
60 : static MSStopOut* getInstance() {
61 175 : return myInstance;
62 : }
63 :
64 : /// @brief constructor.
65 : MSStopOut(OutputDevice& dev);
66 :
67 : /// @brief Destructor.
68 : virtual ~MSStopOut();
69 :
70 : void stopBlocked(const SUMOVehicle* veh, SUMOTime time);
71 : void stopNotStarted(const SUMOVehicle* veh);
72 : void stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers, SUMOTime time);
73 :
74 : void loadedPersons(const SUMOVehicle* veh, int n);
75 : void unloadedPersons(const SUMOVehicle* veh, int n);
76 :
77 : void loadedContainers(const SUMOVehicle* veh, int n);
78 : void unloadedContainers(const SUMOVehicle* veh, int n);
79 :
80 : void stopEnded(const SUMOVehicle* veh, const SUMOVehicleParameter::Stop& stop, const std::string& laneOrEdgeID, bool simEnd = false);
81 :
82 : /// @brief generate output for vehicles which are still stopped at simulation end
83 : void generateOutputForUnfinished();
84 :
85 : private:
86 : struct StopInfo {
87 :
88 5897 : StopInfo(SUMOTime now, int numPersons, int numContainers) :
89 5897 : blockTime(now),
90 5897 : initialNumPersons(numPersons),
91 5897 : loadedPersons(0),
92 5897 : unloadedPersons(0),
93 5897 : initialNumContainers(numContainers),
94 5897 : loadedContainers(0),
95 5897 : unloadedContainers(0) {
96 : }
97 :
98 : SUMOTime blockTime;
99 : int initialNumPersons;
100 : int loadedPersons;
101 : int unloadedPersons;
102 : int initialNumContainers;
103 : int loadedContainers;
104 : int unloadedContainers;
105 : };
106 :
107 : std::map<const SUMOVehicle*, StopInfo, ComparatorNumericalIdLess> myStopped;
108 :
109 : OutputDevice& myDevice;
110 :
111 : static MSStopOut* myInstance;
112 :
113 : /// @brief Invalidated copy constructor.
114 : MSStopOut(const MSStopOut&);
115 :
116 : /// @brief Invalidated assignment operator.
117 : MSStopOut& operator=(const MSStopOut&);
118 :
119 :
120 : };
|