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