SUMO - Simulation of Urban MObility
MEVehicleControl.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The class responsible for building and deletion of vehicles (meso-version)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
36 #include <microsim/MSNet.h>
38 #include <microsim/MSVehicleType.h>
39 #include "MESegment.h"
40 #include "MEVehicle.h"
41 #include "MEVehicleControl.h"
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // member method definitions
50 // ===========================================================================
52  : MSVehicleControl() {}
53 
54 
56 
57 
60  const MSRoute* route, const MSVehicleType* type,
61  const bool ignoreStopErrors, const bool fromRouteFile) {
62  myLoadedVehNo++;
63  if (fromRouteFile) {
65  }
66  MEVehicle* built = new MEVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : 0));
67  built->addStops(ignoreStopErrors);
69  return built;
70 }
71 
72 
73 /****************************************************************************/
74 
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:52
static MTRand * getParsingRNG()
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
SUMOReal computeChosenSpeedDeviation(MTRand *rng, const SUMOReal minDevFactor=0.2) const
Computes and returns the speed deviation.
The car-following model and parameter.
Definition: MSVehicleType.h:74
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
Representation of a vehicle.
Definition: SUMOVehicle.h:65
SUMOTime depart
The vehicle&#39;s departure time.
~MEVehicleControl()
Destructor.
The vehicle was built, but has not yet departed.
Definition: MSNet.h:528
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Structure representing possible vehicle parameter.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle&#39;s state change.
Definition: MSNet.cpp:764
MEVehicleControl()
Constructor.
The class responsible for building and deletion of vehicles.
unsigned int myLoadedVehNo
The number of build vehicles.