MSInductLoop.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSInductLoop_h
00020 #define MSInductLoop_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <deque>
00034 #include <map>
00035 #include <functional>
00036 #include <microsim/MSMoveReminder.h>
00037 #include <microsim/MSVehicle.h>
00038 #include <microsim/MSNet.h>
00039 #include <microsim/output/MSDetectorFileOutput.h>
00040 #include <utils/iodevices/OutputDevice.h>
00041 #include <utils/common/Named.h>
00042
00043
00044
00045
00046
00047 class MSLane;
00048 class GUIDetectorWrapper;
00049 class GUIGlObjectStorage;
00050 class GUILaneWrapper;
00051
00052
00053
00054
00055
00075 class MSInductLoop
00076 : public MSMoveReminder, public MSDetectorFileOutput,
00077 public MSVehicleQuitReminded, public Named {
00078 public:
00088 MSInductLoop(const std::string& id,
00089 MSLane * const lane,
00090 SUMOReal positionInMeters) throw();
00091
00092
00094 ~MSInductLoop() throw();
00095
00096
00099 void reset() throw();
00100
00101
00104
00121 bool isStillActive(MSVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw();
00122
00123
00137 void notifyLeave(MSVehicle& veh, bool isArrival, bool isLaneChange) throw();
00138
00139
00153 bool notifyEnter(MSVehicle& veh, bool isEmit, bool isLaneChange) throw();
00155
00156
00157
00160
00168 SUMOReal getCurrentSpeed() const throw();
00169
00170
00178 SUMOReal getCurrentLength() const throw();
00179
00180
00190 SUMOReal getCurrentOccupancy() const throw();
00191
00192
00202 SUMOReal getCurrentPassedNumber() const throw();
00203
00204
00210 std::vector<std::string> getCurrentVehicleIDs() const throw();
00211
00212
00217 SUMOReal getTimestepsSinceLastDetection() const throw();
00219
00220
00221
00224
00225 unsigned getNVehContributed() const throw();
00227
00228
00229
00232
00241 void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw(IOError);
00242
00243
00250 void writeXMLDetectorProlog(OutputDevice &dev) const throw(IOError);
00252
00253
00254
00257
00262 void removeOnTripEnd(MSVehicle *veh) throw();
00264
00265
00266 protected:
00269
00274 void enterDetectorByMove(MSVehicle& veh, SUMOReal entryTimestep) throw();
00275
00276
00285 void leaveDetectorByMove(MSVehicle& veh, SUMOReal leaveTimestep) throw();
00286
00287
00291 void leaveDetectorByLaneChange(MSVehicle& veh) throw();
00293
00294
00295 protected:
00302 struct VehicleData {
00311 VehicleData(const std::string &id, SUMOReal vehLength, SUMOReal entryTimestep, SUMOReal leaveTimestep) throw()
00312 : idM(id), lengthM(vehLength), entryTimeM(entryTimestep), leaveTimeM(leaveTimestep),
00313 speedM(lengthM / ((leaveTimeM - entryTimeM))) {}
00314
00316 std::string idM;
00318 SUMOReal lengthM;
00320 SUMOReal entryTimeM;
00322 SUMOReal leaveTimeM;
00324 SUMOReal speedM;
00325 };
00326
00327
00328 protected:
00331
00333 static inline SUMOReal speedSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData& data) throw() {
00334 return sumSoFar + data.speedM;
00335 }
00336
00338 static inline SUMOReal lengthSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData& data) throw() {
00339 return sumSoFar + data.lengthM;
00340 }
00342
00343
00352 std::vector<VehicleData> collectVehiclesOnDet(SUMOTime t) const throw();
00353
00354
00355 protected:
00357 MSVehicle *myCurrentVehicle;
00358
00360 const SUMOReal myPosition;
00361
00363 SUMOReal myLastLeaveTime;
00364
00366 SUMOReal myLastOccupancy;
00367
00369 unsigned myDismissedVehicleNumber;
00370
00371
00373 typedef std::deque< VehicleData > VehicleDataCont;
00374
00376 VehicleDataCont myVehicleDataCont;
00377
00379 VehicleDataCont myLastVehicleDataCont;
00380
00381
00383 typedef std::map< MSVehicle*, SUMOReal > VehicleMap;
00384
00386 VehicleMap myVehiclesOnDet;
00387
00388
00389 private:
00391 MSInductLoop(const MSInductLoop&);
00392
00394 MSInductLoop& operator=(const MSInductLoop&);
00395
00396
00397 };
00398
00399
00400 #endif
00401
00402
00403