SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSInductLoop.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // An unextended detector measuring at a fixed position on a fixed lane.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSInductLoop_h
24 #define MSInductLoop_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <deque>
38 #include <map>
39 #include <functional>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSLane;
48 class MSVehicle;
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
71  : public MSMoveReminder, public MSDetectorFileOutput {
72 public:
83  MSInductLoop(const std::string& id, MSLane* const lane,
84  SUMOReal positionInMeters, bool splitByType);
85 
86 
88  ~MSInductLoop();
89 
90 
93  virtual void reset();
94 
95 
100  return myPosition;
101  }
102 
103 
106 
123  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
124 
125 
140  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
141 
142 
158 
159 
160 
163 
171  SUMOReal getCurrentSpeed() const;
172 
173 
181  SUMOReal getCurrentLength() const;
182 
183 
194 
195 
205  unsigned int getCurrentPassedNumber() const;
206 
207 
213  std::vector<std::string> getCurrentVehicleIDs() const;
214 
215 
222 
223 
224 
227 
236  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
237 
238 
245  void writeXMLDetectorProlog(OutputDevice& dev) const;
247 
248 
249 
256  struct VehicleData {
265  VehicleData(const std::string& id, SUMOReal vehLength, SUMOReal entryTimestep, SUMOReal leaveTimestep,
266  const std::string& typeID)
267  : idM(id), lengthM(vehLength), entryTimeM(entryTimestep), leaveTimeM(leaveTimestep),
268  speedM(lengthM / ((leaveTimeM - entryTimeM))), typeIDM(typeID) {}
269 
271  std::string idM;
281  std::string typeIDM;
282  };
283 
284 
290  virtual std::vector<VehicleData> collectVehiclesOnDet(SUMOTime t) const;
291 
292 
293 protected:
296 
301  virtual void enterDetectorByMove(SUMOVehicle& veh, SUMOReal entryTimestep);
302 
303 
312  virtual void leaveDetectorByMove(SUMOVehicle& veh, SUMOReal leaveTimestep);
313 
314 
318  virtual void leaveDetectorByLaneChange(SUMOVehicle& veh);
320 
321 
322 protected:
325 
327  static inline SUMOReal speedSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData& data) {
328  return sumSoFar + data.speedM;
329  }
330 
332  static inline SUMOReal lengthSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData& data) {
333  return sumSoFar + data.lengthM;
334  }
336 
337 
338 protected:
341 
344 
347 
350 
353 
354 
356  typedef std::deque< VehicleData > VehicleDataCont;
357 
360 
363 
364 
366  typedef std::map< SUMOVehicle*, SUMOReal > VehicleMap;
367 
370 
371  void writeTypedXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime,
372  const std::string& type, const VehicleDataCont& vdc, const VehicleMap& vm);
373 
374 private:
376  MSInductLoop(const MSInductLoop&);
377 
380 
381 
382 };
383 
384 
385 #endif
386 
387 /****************************************************************************/
388