MSMsgInductLoop.h

Go to the documentation of this file.
00001 /****************************************************************************/
00006 // An unextended detector measuring at a fixed position on a fixed lane.
00007 /****************************************************************************/
00008 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00009 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00010 /****************************************************************************/
00011 //
00012 //   This program is free software; you can redistribute it and/or modify
00013 //   it under the terms of the GNU General Public License as published by
00014 //   the Free Software Foundation; either version 2 of the License, or
00015 //   (at your option) any later version.
00016 //
00017 /****************************************************************************/
00018 #ifndef MSMsgInductLoop_h
00019 #define MSMsgInductLoop_h
00020 
00021 
00022 // ===========================================================================
00023 // included modules
00024 // ===========================================================================
00025 #ifdef _MSC_VER
00026 #include <windows_config.h>
00027 #else
00028 #include <config.h>
00029 #endif
00030 
00031 #ifdef _MESSAGES
00032 
00033 #include <string>
00034 #include <deque>
00035 #include <map>
00036 #include <functional>
00037 #include <microsim/MSMoveReminder.h>
00038 #include <microsim/MSVehicle.h>
00039 #include <microsim/MSNet.h>
00040 #include <microsim/output/MSDetectorFileOutput.h>
00041 #include <utils/iodevices/OutputDevice.h>
00042 #include <utils/common/Named.h>
00043 
00044 
00045 // ===========================================================================
00046 // class declarations
00047 // ===========================================================================
00048 class MSLane;
00049 class GUIDetectorWrapper;
00050 class GUIGlObjectStorage;
00051 class GUILaneWrapper;
00052 
00053 
00054 // ===========================================================================
00055 // class definitions
00056 // ===========================================================================
00076 class MSMsgInductLoop
00077         : public MSMoveReminder, public MSDetectorFileOutput,
00078             public MSVehicleQuitReminded, public Named {
00079 public:
00091     MSMsgInductLoop(const std::string& id, const std::string& msg,
00092                     MSLane* lane,
00093                     SUMOReal positionInMeters) throw();
00094 
00095 
00097     ~MSMsgInductLoop() throw();
00098 
00099 
00102     void reset() throw();
00103 
00104 
00107 
00124     bool isStillActive(MSVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw();
00125 
00126 
00140     void notifyLeave(MSVehicle& veh, bool isArrival, bool isLaneChange) throw();
00141 
00142 
00156     bool notifyEnter(MSVehicle& veh, bool isEmit, bool isLaneChange) throw();
00158 
00159 
00160 
00163 
00171     SUMOReal getCurrentSpeed() const throw();
00172 
00173 
00181     SUMOReal getCurrentLength() const throw();
00182 
00183 
00193     SUMOReal getCurrentOccupancy() const throw();
00194 
00195 
00205     SUMOReal getCurrentPassedNumber() const throw();
00206 
00207 
00212     SUMOReal getTimestepsSinceLastDetection() const throw();
00214 
00215 
00216 
00219 
00220     unsigned getNVehContributed() const throw();
00222 
00223 
00224 
00227 
00236     void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw(IOError);
00237 
00238 
00245     void writeXMLDetectorProlog(OutputDevice &dev) const throw(IOError);
00247 
00248 
00249 
00252 
00257     void removeOnTripEnd(MSVehicle *veh) throw();
00259 
00260 
00261 protected:
00264 
00269     void enterDetectorByMove(MSVehicle& veh, SUMOReal entryTimestep) throw();
00270 
00271 
00280     void leaveDetectorByMove(MSVehicle& veh, SUMOReal leaveTimestep) throw();
00281 
00282 
00286     void leaveDetectorByLaneChange(MSVehicle& veh) throw();
00288 
00289 
00290 protected:
00297     struct VehicleData {
00306         VehicleData(SUMOReal vehLength, SUMOReal entryTimestep, SUMOReal leaveTimestep) throw()
00307                 : lengthM(vehLength), entryTimeM(entryTimestep), leaveTimeM(leaveTimestep),
00308                 speedM(lengthM / (leaveTimeM - entryTimeM)),
00309                 occupancyM(leaveTimeM - entryTimeM) {}
00310 
00312         SUMOReal lengthM;
00314         SUMOReal entryTimeM;
00316         SUMOReal leaveTimeM;
00318         SUMOReal speedM;
00320         SUMOReal occupancyM;
00321     };
00322 
00323 
00324 protected:
00327 
00329     static inline SUMOReal speedSum(SUMOReal sumSoFar, const MSMsgInductLoop::VehicleData& data) throw() {
00330         return sumSoFar + data.speedM;
00331     }
00332 
00334     static inline SUMOReal occupancySum(SUMOReal sumSoFar, const MSMsgInductLoop::VehicleData& data) throw() {
00335         return sumSoFar + data.occupancyM;
00336     }
00337 
00339     static inline SUMOReal lengthSum(SUMOReal sumSoFar, const MSMsgInductLoop::VehicleData& data) throw() {
00340         return sumSoFar + data.lengthM;
00341     }
00343 
00344 
00345 protected:
00347     MSVehicle *myCurrentVehicle;
00348 
00350     const SUMOReal myPosition;
00351 
00353     SUMOReal myLastLeaveTime;
00354 
00356     SUMOReal myLastOccupancy;
00357 
00359     unsigned myDismissedVehicleNumber;
00360 
00361 
00363     typedef std::deque< VehicleData > VehicleDataCont;
00364 
00366     VehicleDataCont myVehicleDataCont;
00367 
00368 
00370     typedef std::map< MSVehicle*, SUMOReal > VehicleMap;
00371 
00373     VehicleMap myVehiclesOnDet;
00374 
00376     std::string myMsg;
00377 
00378     std::string myCurrentID;
00379 
00380 
00381 private:
00383     MSMsgInductLoop(const MSMsgInductLoop&);
00384 
00386     MSMsgInductLoop& operator=(const MSMsgInductLoop&);
00387 
00388 
00389 };
00390 #endif //_MESSAGES
00391 
00392 #endif
00393 
00394 /****************************************************************************/
00395 

Generated on Wed May 5 00:06:32 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6