SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00011 // Detectors container; responsible for string and output generation 00012 /****************************************************************************/ 00013 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00014 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00015 /****************************************************************************/ 00016 // 00017 // This file is part of SUMO. 00018 // SUMO is free software: you can redistribute it and/or modify 00019 // it under the terms of the GNU General Public License as published by 00020 // the Free Software Foundation, either version 3 of the License, or 00021 // (at your option) any later version. 00022 // 00023 /****************************************************************************/ 00024 #ifndef MSDetectorControl_h 00025 #define MSDetectorControl_h 00026 00027 00028 // =========================================================================== 00029 // included modules 00030 // =========================================================================== 00031 #ifdef _MSC_VER 00032 #include <windows_config.h> 00033 #else 00034 #include <config.h> 00035 #endif 00036 00037 #include <string> 00038 #include <vector> 00039 #include <utils/common/NamedObjectCont.h> 00040 #include <utils/xml/SUMOXMLDefinitions.h> 00041 #include <microsim/output/MSE2Collector.h> 00042 #include <microsim/output/MS_E2_ZS_CollectorOverLanes.h> 00043 #include <microsim/output/MSE3Collector.h> 00044 #include <microsim/output/MSInductLoop.h> 00045 #include <microsim/output/MSRouteProbe.h> 00046 00047 #ifdef HAVE_MESOSIM 00048 #include <mesosim/MEInductLoop.h> 00049 #endif 00050 00051 00052 // =========================================================================== 00053 // class declarations 00054 // =========================================================================== 00055 class MSMeanData; 00056 00057 00058 // =========================================================================== 00059 // class definitions 00060 // =========================================================================== 00065 class MSDetectorControl { 00066 public: 00067 // well, well, friends are evil; one could think about overriding MSDetectorControl and introducing GUIDetectorControl... 00068 friend class GUINet; 00069 00070 00073 MSDetectorControl() ; 00074 00075 00080 ~MSDetectorControl() ; 00081 00082 00090 void close(SUMOTime step); 00091 00092 00109 void add(SumoXMLTag type, MSDetectorFileOutput* d, OutputDevice& device, int splInterval, SUMOTime begin = -1) ; 00110 00111 00112 00125 void add(SumoXMLTag type, MSDetectorFileOutput* d) ; 00126 00127 00139 void add(MSMeanData* mn, OutputDevice& device, 00140 SUMOTime frequency, SUMOTime begin) ; 00141 00142 00143 00151 void addDetectorAndInterval(MSDetectorFileOutput* det, 00152 OutputDevice* device, 00153 SUMOTime interval, SUMOTime begin = -1) ; 00154 00155 00156 00162 const NamedObjectCont<MSDetectorFileOutput*> &getTypedDetectors(SumoXMLTag type) const ; 00163 00164 00165 00174 void updateDetectors(const SUMOTime step) ; 00175 00176 00188 void writeOutput(SUMOTime step, bool closing); 00189 00190 00191 protected: 00194 00196 typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair; 00197 00199 typedef std::vector< DetectorFilePair > DetectorFileVec; 00200 00202 typedef std::pair<SUMOTime, SUMOTime> IntervalsKey; 00203 00205 typedef std::map< IntervalsKey, DetectorFileVec > Intervals; 00207 00219 struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > { 00221 bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const { 00222 return pair.first == det; 00223 } 00224 }; 00225 00226 protected: 00228 std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors; 00229 00230 00232 Intervals myIntervals; 00233 00235 std::map<IntervalsKey, SUMOTime> myLastCalls; 00236 00238 std::vector<MSMeanData*> myMeanData; 00239 00241 NamedObjectCont< MSDetectorFileOutput*> myEmptyContainer; 00242 00243 00244 private: 00246 MSDetectorControl(const MSDetectorControl&); 00247 00249 MSDetectorControl& operator=(const MSDetectorControl&); 00250 00251 00252 }; 00253 00254 00255 #endif 00256 00257 /****************************************************************************/ 00258