Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2013-2024 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 : 55 : /** @brief Build devices for the given vehicle, if needed 56 : * 57 : * The options are read and evaluated whether a FCD-device shall be built 58 : * for the given vehicle. 59 : * 60 : * The built device is stored in the given vector. 61 : * 62 : * @param[in] v The vehicle for which a device may be built 63 : * @param[filled] into The vector to store the built device in 64 : */ 65 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into); 66 : 67 : public: 68 : /// @brief Destructor. 69 : ~MSDevice_FCD(); 70 : 71 8147 : bool notifyEnter(SUMOTrafficObject& /*veh*/, MSMoveReminder::Notification /*reason*/, const MSLane* /*enteredLane*/) { 72 8147 : return false; 73 : } 74 : 75 15 : void saveState(OutputDevice& /* out */) const { 76 15 : } 77 : 78 : /// @brief return the name for this type of device 79 1294 : const std::string deviceName() const { 80 1294 : return "fcd"; 81 : } 82 : 83 : static const std::set<const MSEdge*>& getEdgeFilter() { 84 : return myEdgeFilter; 85 : } 86 : 87 : static SumoXMLAttrMask getWrittenAttributes() { 88 724133 : return myWrittenAttributes; 89 : } 90 : 91 : /// @brief initialize edge filter and attribute mask (once) 92 : static void initOnce(); 93 : 94 : 95 : /// @brief resets the edge filter 96 : static void cleanup(); 97 : 98 : /// @brief checks if in polygon 99 : static bool shapeFilter(const SUMOTrafficObject* veh); 100 : 101 : /// @brief is there a filter based on shapes? 102 : inline static bool hasShapeFilter() { 103 724133 : return myShapeFilterDesired; 104 : } 105 : 106 : private: 107 : /** @brief Constructor 108 : * 109 : * @param[in] holder The vehicle that holds this device 110 : * @param[in] id The ID of the device 111 : */ 112 : MSDevice_FCD(SUMOVehicle& holder, const std::string& id); 113 : 114 : 115 : /// @brief edge filter for FCD output 116 : static std::set<const MSEdge*> myEdgeFilter; 117 : static bool myEdgeFilterInitialized; 118 : 119 : /// @brief polygon spatial filter for FCD output 120 : static std::vector<PositionVector> myShape4Filters; 121 : static bool myShapeFilterInitialized; 122 : static bool myShapeFilterDesired; 123 : 124 : /// @brief bit mask for checking attributes to be written 125 : static SumoXMLAttrMask myWrittenAttributes; 126 : static SumoXMLAttrMask getDefaultMask(); 127 : 128 : private: 129 : /// @brief Invalidated copy constructor. 130 : MSDevice_FCD(const MSDevice_FCD&); 131 : 132 : /// @brief Invalidated assignment operator. 133 : MSDevice_FCD& operator=(const MSDevice_FCD&); 134 : 135 : static void buildShapeFilter(); 136 : 137 : 138 : };