Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIMEVehicleControl.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// The class responsible for building and deletion of meso vehicles (gui-version)
19/****************************************************************************/
20#include <config.h>
21
24#include <gui/GUIGlobals.h>
26#include "GUIMEVehicleControl.h"
27#include "GUIMEVehicle.h"
28
29
30// ===========================================================================
31// member method definitions
32// ===========================================================================
35
36
38 // just to quit cleanly on a failure
39 if (myLock.locked()) {
40 myLock.unlock();
41 }
42}
43
44
47 ConstMSRoutePtr route, MSVehicleType* type,
48 const bool ignoreStopErrors, const VehicleDefinitionSource source,
49 bool addRouteStops) {
51 initVehicle(built, ignoreStopErrors, addRouteStops, source);
52 return built;
53}
54
55
56
57bool
58GUIMEVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
59 FXMutexLock locker(myLock);
60 return MEVehicleControl::addVehicle(id, v);
61}
62
63
64void
65GUIMEVehicleControl::deleteVehicle(SUMOVehicle* veh, bool discard, bool wasKept) {
66 FXMutexLock locker(myLock);
67 MEVehicleControl::deleteVehicle(veh, discard, wasKept);
68}
69
70
71void
72GUIMEVehicleControl::insertVehicleIDs(std::vector<GUIGlID>& into) {
73 FXMutexLock locker(myLock);
74 into.reserve(myVehicleDict.size());
75 for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
76 SUMOVehicle* veh = (*i).second;
77 if (veh->isOnRoad()) {
78 into.push_back(static_cast<GUIMEVehicle*>((*i).second)->getGlID());
79 }
80 }
81}
82
83std::pair<double, double>
88
89
90int
95
96
97void
101
102
103void
107
108
109/****************************************************************************/
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIMEVehicleControl()
Constructor.
virtual std::pair< double, double > getVehicleMeanSpeeds() const override
get current absolute and relative mean vehicle speed in the network
void secureVehicles()
lock access to vehicle removal/additions for thread synchronization
bool addVehicle(const std::string &id, SUMOVehicle *v) override
Tries to insert the vehicle into the internal vehicle container.
virtual int getHaltingVehicleNo() const override
Returns the number of halting vehicles.
void releaseVehicles()
unlock access to vehicle removal/additions for thread synchronization
SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=VehicleDefinitionSource::ROUTEFILE, bool addRouteStops=true) override
Builds a vehicle, increases the number of built vehicles.
void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false) override
Deletes the vehicle.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
void insertVehicleIDs(std::vector< GUIGlID > &into)
Returns the list of all known vehicles by gl-id.
A MSVehicle extended by some values for usage within the gui.
The class responsible for building and deletion of vehicles (gui-version)
The base class for microscopic and mesoscopic vehicles.
static SumoRNG * getParsingRNG()
get parsing RNG
VehicleDefinitionSource
possible origins of a vehicle definition
void initVehicle(MSBaseVehicle *built, const bool ignoreStopErrors, bool addRouteStops, const VehicleDefinitionSource source)
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
VehicleDictType myVehicleDict
Dictionary of vehicles.
The car-following model and parameter.
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Representation of a vehicle.
Definition SUMOVehicle.h:62
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
Structure representing possible vehicle parameter.