Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDetectorFileOutput.h
Go to the documentation of this file.
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/****************************************************************************/
22// Base of value-generating classes (detectors)
23/****************************************************************************/
24#pragma once
25#include <config.h>
26
27#include <string>
28#include <set>
29
30#include <utils/common/Named.h>
33#include <microsim/MSNet.h>
34
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
39class OutputDevice;
43class MSTransportable;
44class MSEdge;
45
46
47// ===========================================================================
48// class definitions
49// ===========================================================================
55
64public:
66 MSDetectorFileOutput(const std::string& id, const std::string& vTypes, const std::string& nextEdges = "", const int detectPersons = 0);
67
70
71
74
81 virtual void writeXMLOutput(OutputDevice& dev,
82 SUMOTime startTime, SUMOTime stopTime) = 0;
83
84
93 virtual void writeXMLDetectorProlog(OutputDevice& dev) const = 0;
94
95
103 virtual void reset() { }
104
105
110 virtual void detectorUpdate(const SUMOTime step) {
111 UNUSED_PARAMETER(step);
112 }
113
114
121 return 0;
122 }
123
124
130 bool vehicleApplies(const SUMOTrafficObject& veh) const;
131
132 bool personApplies(const MSTransportable& p, int dir) const;
133
134
139 bool isTyped() const {
140 return !myVehicleTypes.empty();
141 }
142
143 const std::set<std::string>& getVehicleTypes() const {
144 return myVehicleTypes;
145 }
146
147 inline bool detectsPersons() const {
148 return myDetectPersons != 0;
149 }
150
152 virtual void clearState(SUMOTime /*step*/) {};
153
155 virtual void saveState(OutputDevice& /*out*/) const {}
156
158 virtual void loadState(const SUMOSAXAttributes& /*attrs*/, const SUMOTime /*offset*/) {}
159
160protected:
162 std::set<std::string> myVehicleTypes;
163
165 std::vector<const MSEdge*> myNextEdges;
166
169
170private:
173
176
177
178};
long long int SUMOTime
Definition GUI.h:36
@ DU_USER_DEFINED
@ DU_SUMO_INTERNAL
@ DU_TL_CONTROL
Base of value-generating classes (detectors)
virtual void clearState(SUMOTime)
Remove all vehicles before quick-loading state.
bool isTyped() const
Checks whether the detector is type specific.
MSDetectorFileOutput(const MSDetectorFileOutput &)
Invalidated copy constructor.
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
virtual void loadState(const SUMOSAXAttributes &, const SUMOTime)
Loads the state, shifting all times by the given offset.
std::vector< const MSEdge * > myNextEdges
The upcoming edges to filter by (empty means no filtering)
const int myDetectPersons
Whether pedestrians shall be detected instead of vehicles.
MSDetectorFileOutput & operator=(const MSDetectorFileOutput &)
Invalidated assignment operator.
virtual void reset()
Resets collected values.
virtual void saveState(OutputDevice &) const
Saves the state which is needed to continue after loading state.
virtual void detectorUpdate(const SUMOTime step)
Updates the detector (computes values)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const =0
Open the XML-output.
const std::set< std::string > & getVehicleTypes() const
virtual ~MSDetectorFileOutput()
(virtual) destructor
bool personApplies(const MSTransportable &p, int dir) const
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation()
Builds the graphical representation.
A road/street connecting two junctions.
Definition MSEdge.h:78
Base class for objects which have an id.
Definition Named.h:53
Static storage of an output device and its base (abstract) implementation.
An upper class for objects with additional parameters.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
#define UNUSED_PARAMETER(x)