Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2013-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 MSDevice_FCD.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @date 11.06.2013
18 : ///
19 : // A device which records floating car data
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include "MSVehicleDevice.h"
25 : #include <microsim/MSVehicle.h>
26 : #include <utils/common/SUMOTime.h>
27 : #include <utils/shapes/SUMOPolygon.h>
28 :
29 : // ===========================================================================
30 : // class declarations
31 : // ===========================================================================
32 : class SUMOVehicle;
33 : class SUMOTrafficObject;
34 :
35 :
36 : // ===========================================================================
37 : // class definitions
38 : // ===========================================================================
39 : /**
40 : * @class MSDevice_FCD
41 : * @brief A device which collects info on the vehicle trip (mainly on departure and arrival)
42 : *
43 : * Each device collects departure time, lane and speed and the same for arrival.
44 : *
45 : * @see MSDevice
46 : */
47 : class MSDevice_FCD : public MSVehicleDevice {
48 : public:
49 : /** @brief Inserts MSDevice_FCD-options
50 : * @param[filled] oc The options container to add the options to
51 : */
52 : static void insertOptions(OptionsCont& oc);
53 :
54 : /** @brief Build devices for the given vehicle, if needed
55 : *
56 : * The options are read and evaluated whether a FCD-device shall be built
57 : * for the given vehicle.
58 : *
59 : * The built device is stored in the given vector.
60 : *
61 : * @param[in] v The vehicle for which a device may be built
62 : * @param[filled] into The vector to store the built device in
63 : */
64 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
65 :
66 : public:
67 : /// @brief Destructor.
68 : ~MSDevice_FCD();
69 :
70 8548 : bool notifyEnter(SUMOTrafficObject& /*veh*/, MSMoveReminder::Notification /*reason*/, const MSLane* /*enteredLane*/) {
71 8548 : return false;
72 : }
73 :
74 10 : void saveState(OutputDevice& /* out */) const {
75 10 : }
76 :
77 : /// @brief return the name for this type of device
78 1295 : const std::string deviceName() const {
79 1295 : return "fcd";
80 : }
81 :
82 : static inline SUMOTime getBegin() {
83 5061332 : return myBegin;
84 : }
85 :
86 : static inline SUMOTime getPeriod() {
87 5061332 : return myPeriod;
88 : }
89 :
90 : static inline bool useGeo() {
91 5003632 : return myUseGeo;
92 : }
93 :
94 : static inline double getMaxLeaderDistance() {
95 5003632 : return myMaxLeaderDistance;
96 : }
97 :
98 : static inline const std::vector<std::string>& getParamsToWrite() {
99 : return myParamsToWrite;
100 : }
101 :
102 : static inline double getRadius() {
103 5003632 : return myRadius;
104 : }
105 :
106 : static inline const std::set<const MSEdge*>& getEdgeFilter() {
107 : return myEdgeFilter;
108 : }
109 :
110 : static inline const SumoXMLAttrMask& getWrittenAttributes() {
111 : return myWrittenAttributes;
112 : }
113 :
114 : /// @brief initialize edge filter and attribute mask (once)
115 : static void initOnce();
116 :
117 : /// @brief resets the edge filter
118 : static void cleanup();
119 :
120 : /// @brief checks if in polygon
121 : static bool shapeFilter(const SUMOTrafficObject* veh);
122 :
123 : /// @brief is there a filter based on shapes?
124 : inline static bool hasShapeFilter() {
125 5003632 : return myShapeFilterDesired;
126 : }
127 :
128 : private:
129 : /** @brief Constructor
130 : *
131 : * @param[in] holder The vehicle that holds this device
132 : * @param[in] id The ID of the device
133 : */
134 : MSDevice_FCD(SUMOVehicle& holder, const std::string& id);
135 :
136 : /// @brief begin time
137 : static SUMOTime myBegin;
138 : static SUMOTime myPeriod;
139 : static bool myUseGeo;
140 : static double myMaxLeaderDistance;
141 : static std::vector<std::string> myParamsToWrite;
142 : static double myRadius;
143 :
144 : /// @brief edge filter for FCD output
145 : static std::set<const MSEdge*> myEdgeFilter;
146 : static bool myEdgeFilterInitialized;
147 :
148 : /// @brief polygon spatial filter for FCD output
149 : static std::vector<PositionVector> myShape4Filters;
150 : static bool myShapeFilterInitialized;
151 : static bool myShapeFilterDesired;
152 :
153 : /// @brief bit mask for checking attributes to be written
154 : static SumoXMLAttrMask myWrittenAttributes;
155 : static SumoXMLAttrMask getDefaultMask();
156 :
157 : private:
158 : /// @brief Invalidated copy constructor.
159 : MSDevice_FCD(const MSDevice_FCD&);
160 :
161 : /// @brief Invalidated assignment operator.
162 : MSDevice_FCD& operator=(const MSDevice_FCD&);
163 :
164 : static void buildShapeFilter();
165 :
166 :
167 : };
|