1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2017-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file InductionLoop.h 11 /// @author Michael Behrisch 12 /// @date 15.03.2017 13 /// @version $Id$ 14 /// 15 // C++ TraCI client API implementation 16 /****************************************************************************/ 17 #ifndef InductionLoop_h 18 #define InductionLoop_h 19 20 21 // =========================================================================== 22 // included modules 23 // =========================================================================== 24 #include <config.h> 25 26 #include <vector> 27 #include <libsumo/TraCIConstants.h> 28 29 30 // =========================================================================== 31 // class declarations 32 // =========================================================================== 33 class NamedRTree; 34 class MSInductLoop; 35 class PositionVector; 36 namespace libsumo { 37 struct TraCIVehicleData; 38 class VariableWrapper; 39 } 40 41 42 // =========================================================================== 43 // class definitions 44 // =========================================================================== 45 /** 46 * @class InductionLoop 47 * @brief C++ TraCI client API implementation 48 */ 49 namespace libsumo { 50 class InductionLoop { 51 public: 52 static std::vector<std::string> getIDList(); 53 static int getIDCount(); 54 static double getPosition(const std::string& detID); 55 static std::string getLaneID(const std::string& detID); 56 static int getLastStepVehicleNumber(const std::string& detID); 57 static double getLastStepMeanSpeed(const std::string& detID); 58 static std::vector<std::string> getLastStepVehicleIDs(const std::string& detID); 59 static double getLastStepOccupancy(const std::string& detID); 60 static double getLastStepMeanLength(const std::string& detID); 61 static double getTimeSinceDetection(const std::string& detID); 62 static std::vector<libsumo::TraCIVehicleData> getVehicleData(const std::string& detID); 63 64 LIBSUMO_SUBSCRIPTION_API 65 66 /** @brief Returns a tree filled with inductive loop instances 67 * @return The rtree of inductive loops 68 */ 69 static NamedRTree* getTree(); 70 71 /** @brief Saves the shape of the requested object in the given container 72 * @param id The id of the loop to retrieve 73 * @param shape The container to fill 74 */ 75 static void storeShape(const std::string& id, PositionVector& shape); 76 77 static std::shared_ptr<VariableWrapper> makeWrapper(); 78 79 static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper); 80 81 private: 82 static MSInductLoop* getDetector(const std::string& detID); 83 84 private: 85 static SubscriptionResults mySubscriptionResults; 86 static ContextSubscriptionResults myContextSubscriptionResults; 87 88 private: 89 /// @brief invalidated standard constructor 90 InductionLoop() = delete; 91 92 }; 93 } 94 95 96 #endif 97 98 /****************************************************************************/ 99