SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSVehicleControl.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // The class responsible for building and deletion of vehicles
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSVehicleControl_h
23 #define MSVehicleControl_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <math.h>
36 #include <string>
37 #include <map>
38 #include <set>
39 #include "MSGlobals.h"
41 #include <utils/common/SUMOTime.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class SUMOVehicle;
50 class MSVehicle;
51 class MSRoute;
52 class MSVehicleType;
53 class BinaryInputDevice;
54 class MSEdge;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
76 public:
78  typedef std::map<std::string, SUMOVehicle*>::const_iterator constVehIt;
79 
80 public:
83 
84 
86  virtual ~MSVehicleControl();
87 
88 
91 
102  virtual SUMOVehicle* buildVehicle(SUMOVehicleParameter* defs, const MSRoute* route,
103  const MSVehicleType* type);
105 
106 
107 
110 
123  virtual bool addVehicle(const std::string& id, SUMOVehicle* v);
124 
125 
134  SUMOVehicle* getVehicle(const std::string& id) const;
135 
136 
143  virtual void deleteVehicle(SUMOVehicle* v, bool discard = false);
144 
145 
158 
159 
164  constVehIt loadedVehBegin() const;
165 
166 
171  constVehIt loadedVehEnd() const;
173 
174 
175 
178 
186  void vehicleDeparted(const SUMOVehicle& v);
188 
189 
190 
193 
197  unsigned int getLoadedVehicleNo() const {
198  return myLoadedVehNo;
199  }
200 
201 
205  unsigned int getEndedVehicleNo() const {
206  return myEndedVehNo;
207  }
208 
209 
213  unsigned int getRunningVehicleNo() const {
214  return myRunningVehNo;
215  }
216 
217 
221  unsigned int getDepartedVehicleNo() const {
223  }
224 
225 
232  bool isInQuota(SUMOReal frac = -1) const;
233 
234 
239  int getActiveVehicleCount() const {
241  }
242 
244  unsigned int getCollisionCount() const {
245  return myCollisions;
246  }
247 
248 
250  unsigned int getTeleportCount() const {
251  return myTeleports;
252  }
254 
255 
258 
263  void printMeanWaitingTime(OutputDevice& od) const;
264 
265 
270  void printMeanTravelTime(OutputDevice& od) const;
272 
273 
274 
275 
278 
291  bool addVType(MSVehicleType* vehType);
292 
293 
307  bool addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*>* vehTypeDistribution);
308 
309 
317  bool hasVTypeDistribution(const std::string& id) const;
318 
319 
324  MSVehicleType* getVType(const std::string& id = DEFAULT_VTYPE_ID);
325 
326 
330  void insertVTypeIDs(std::vector<std::string>& into) const;
332 
333  void addWaiting(const MSEdge* const edge, SUMOVehicle* vehicle);
334 
335  void removeWaiting(const MSEdge* const edge, SUMOVehicle* vehicle);
336 
337  SUMOVehicle* getWaitingVehicle(const MSEdge* const edge, const std::set<std::string>& lines);
338 
343  }
344 
349  }
350 
353  myTeleports++;
354  myCollisions++;
355  }
356 
359  myTeleports++;
360  }
361 
364 
368  virtual void saveState(std::ostream& os);
369 
373  virtual void loadState(BinaryInputDevice& bis, const SUMOTime offset);
375 
376 
379  void abortWaiting();
380 
381 
382 public:
385 
386 
387 private:
394  bool checkVType(const std::string& id);
395 
396 
397 protected:
400 
402  unsigned int myLoadedVehNo;
403 
405  unsigned int myRunningVehNo;
406 
408  unsigned int myEndedVehNo;
409 
411  unsigned int myDiscarded;
412 
414  unsigned int myCollisions;
415 
417  unsigned int myTeleports;
419 
420 
423 
426 
430 
431 
434 
436  typedef std::map< std::string, SUMOVehicle* > VehicleDictType;
440 
441 
444 
446  typedef std::map< std::string, MSVehicleType* > VTypeDictType;
449 
451  typedef std::map< std::string, RandomDistributor<MSVehicleType*>* > VTypeDistDictType;
454 
457 
459  std::map<const MSEdge* const, std::vector<SUMOVehicle*> > myWaiting;
460 
462  unsigned int myWaitingForPerson;
463 
466 
467 private:
470 
473 
474 
475 };
476 
477 
478 #endif
479 
480 /****************************************************************************/
481