43 #ifdef CHECK_MEMORY_LEAKS
45 #endif // CHECK_MEMORY_LEAKS
54 : myVehicleControl(vc), myMaxDepartDelay(maxDepartDelay),
55 myCheckEdgesOnce(checkEdgesOnce) {}
59 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
81 const std::vector<const MSRoute*>& routes = dist->
getVals();
83 for (std::vector<const MSRoute*>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
85 e = (*i)->getEdges()[0];
87 if (e != (*i)->getEdges()[0]) {
107 unsigned int noEmitted = 0;
119 MSVehicleContainer::VehicleVector::const_iterator veh;
120 for (veh = previousRefused.begin(); veh != previousRefused.end(); veh++) {
121 noEmitted +=
tryInsert(time, *veh, refusedEmits);
124 previousRefused.clear();
134 for (veh = next.begin(); veh != next.end(); veh++) {
135 noEmitted +=
tryInsert(time, *veh, refusedEmits);
150 if ((!
myCheckEdgesOnce || edge.getLastFailedInsertionTime() != time) && edge.insertVehicle(*veh, time)) {
160 }
else if (edge.isVaporizing()) {
171 refusedEmits.push_back(veh);
173 edge.setLastFailedInsertionTime(time);
180 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
181 if (i->vehicle == veh) {
196 copy(top.begin(), top.end(), back_inserter(previousRefused));
206 unsigned int noEmitted = 0;
207 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end();) {
209 if (!i->isVolatile && i->vehicle != 0) {
223 i->vehicle = vehControl.
buildVehicle(newPars, route, vtype);
226 noEmitted +=
tryInsert(time, i->vehicle, refusedEmits);
227 if (!i->isVolatile && i->vehicle != 0) {
239 throw ProcessError(
"Another vehicle with the id '" + newPars->
id +
"' exists.");
int getPendingFlowCount() const
Returns the number of flows that are still active.
void checkFlowWait(SUMOVehicle *veh)
Checks whether any flow is blocked due to this vehicle and clears the block.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle
SUMOTime topTime() const
Returns the time the uppermost vehicle vector is assigned to.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::set< SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
std::string vtypeid
The vehicle's type id.
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID)
Returns the named vehicle type or a sample from the named distribution.
static bool gStateLoaded
Information whether a state has been loaded.
bool isEmpty() const
Returns the information whether the container is empty.
int repetitionsDone
The number of times the vehicle was already inserted.
SUMOVehicle * vehicle
The last created vehicle.
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
The lane is chosen randomly.
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
The position is chosen randomly.
~MSInsertionControl()
Destructor.
The car-following model and parameter.
const std::vector< T > & getVals() const
Returns the members of the distribution.
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type)
Builds a vehicle, increases the number of built vehicles.
A road/street connecting two junctions.
unsigned int checkFlows(SUMOTime time, MSVehicleContainer::VehicleVector &refusedEmits)
Checks for all vehicles coming from flows whether they can be emitted.
void pop()
Removes the uppermost vehicle vector.
unsigned int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
std::string routeid
The vehicle's route id.
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool myCheckEdgesOnce
Whether an edge on which a vehicle could not depart should be ignored in the same step...
unsigned int tryInsert(SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits)
Tries to emit the vehicle.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime depart
The vehicle's departure time.
SUMOTime myMaxDepartDelay
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
void add(SUMOVehicle *veh)
Adds a single vehicle.
MSVehicleContainer::VehicleVector myRefusedEmits1
Buffers for vehicles that could not be inserted.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
const VehicleVector & top()
Returns the uppermost vehicle vector.
bool isVolatile
whether it has route or vehicle type distribution
bool anyWaitingFor(SUMOTime time) const
Returns the information whether any vehicles want to depart at the given time.
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
MSVehicleContainer::VehicleVector myRefusedEmits2
Structure representing possible vehicle parameter.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
MSInsertionControl(MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce)
Constructor.
unsigned int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool isInQuota(SUMOReal frac=-1) const
Returns the information whether the currently vehicle number shall be emitted considering that only f...
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
The class responsible for building and deletion of vehicles.
SUMOVehicleParameter * pars
The paramters.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
std::string id
The vehicle's id.
void checkPrevious(SUMOTime time)
Adds all vehicles that should have been emitted earlier to the refuse container.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.