 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
81 myLastSimDuration(0), myLastIdleDuration(0),
82 myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
141 for (std::vector<MSTrafficLightLogic*>::const_iterator i = logics.begin(); i != logics.end(); ++i) {
154 if (links.size() == 0) {
161 MSTrafficLightLogic::LinkVectorVector::const_iterator j;
162 for (j = links.begin(); j != links.end(); ++j) {
163 MSTrafficLightLogic::LinkVector::const_iterator j2;
164 for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
224 FXMutexLock locker(
myLock);
231 std::vector<GUIGlID> ret;
233 if (!(*i)->isInternal() || includeInternal) {
234 ret.push_back((*i)->getGlID());
243 std::vector<GUIGlID> ret;
244 std::vector<std::string> ids;
246 std::string sid = (*i).second->getMicrosimID();
247 if (find(ids.begin(), ids.end(), sid) == ids.end()) {
248 ret.push_back((*i).second->getGlID());
260 for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
263 if (wrapper !=
nullptr) {
274 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
276 if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
283 std::map<MSJunction*, std::string> junction2TLL;
285 for (
const auto& links : tls->getLinks()) {
286 for (
const MSLink* l : links) {
287 junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
298 const std::vector<MSLane*>& lanes = edge->
getLanes();
299 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
300 b.
add((*j)->getShape().getBoxBoundary());
304 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
305 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
309 throw ProcessError(
"Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
316 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
317 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
427 ret->
mkItem(
"loaded vehicles [#]",
true,
429 ret->
mkItem(
"insertion-backlogged vehicles [#]",
true,
431 ret->
mkItem(
"departed vehicles [#]",
true,
433 ret->
mkItem(
"running vehicles [#]",
true,
435 ret->
mkItem(
"arrived vehicles [#]",
true,
437 ret->
mkItem(
"discarded vehicles [#]",
true,
439 ret->
mkItem(
"collisions [#]",
true,
441 ret->
mkItem(
"teleports [#]",
true,
443 ret->
mkItem(
"halting [#]",
true,
445 ret->
mkItem(
"avg. speed [m/s]",
true,
447 ret->
mkItem(
"avg. relative speed",
true,
450 ret->
mkItem(
"loaded persons [#]",
true,
452 ret->
mkItem(
"running persons [#]",
true,
454 ret->
mkItem(
"jammed persons [#]",
true,
517 if (net !=
nullptr) {
520 throw ProcessError(
"A gui-network was not yet constructed.");
568 edgeAttrs.insert(tmp.begin(), tmp.end());
575 std::vector<std::string>
578 return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
583 double value,
double begTime,
double endTime)
const {
585 if (edge !=
nullptr) {
586 myWeightStorage->addEffort(edge, begTime, endTime, value);
588 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" +
id +
"'.");
598 std::vector<std::string> attrs = discoveryHandler.
getEdgeAttrs();
600 +
"' Found " +
toString(attrs.size())
601 +
" attributes: " +
toString(attrs));
604 std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
605 retrieverDefsInternal.reserve(attrs.size());
606 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
607 for (
const std::string& attr : attrs) {
618 std::vector<std::string>
620 std::vector<std::string> result;
622 result.push_back(item.first);
637 if (!(*i)->isInternal()) {
638 const std::vector<MSLane*>& lanes = (*i)->getLanes();
639 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
640 static_cast<GUILane*
>(*j)->updateColor(s);
645 (*i)->updateColor(s);
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
double getUPS() const
Returns the update per seconds rate.
Boundary myBoundary
The networks boundary.
Stores time-dependant events and executes them at the proper time.
class for discovering edge attributes
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
LayeredRTree myGrid
The visualization speed-up.
A window containing a gl-object's parameter.
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
double getMeanUPS() const
Returns the update per seconds rate.
double getAvgRouteLength() const
int getLinkTLID(MSLink *link) const
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
void simulationStep()
Performs a single simulation step.
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
double ymin() const
Returns minimum y-coordinate.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
MSTransportableControl & getContainerControl() override
Returns the container control.
bool isSelected(const MSTrafficLightLogic *tll) const override
return wheter the given logic (or rather it's wrapper) is selected in the GUI
double getVehicleMeanSpeed() const
Boundary getBoundary() const
Returns the boundary of the junction.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
void initTLMap()
Initialises the tl-logic map and wrappers.
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
The simulated network and simulation perfomer.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
SUMOTime myEdgeDataEndTime
end of loaded edgeData
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
@ SUMO_TAG_LANE
begin/end of the description of a single lane
double xmax() const
Returns maximum x-coordinate.
double myVersion
the network version
double getHeight() const
Returns the height of the boundary (y-axis)
static OptionsCont & getOptions()
Retrieves the options.
int getLoadedVehicleNo() const
Returns the number of build vehicles.
The class responsible for building and deletion of vehicles (gui-version)
bool logSimulationDuration() const
Returns whether duration shall be logged.
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
double getAvgWalkTimeLoss() const
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
Storage for geometrical objects extended by mutexes.
The class responsible for building and deletion of vehicles (gui-version)
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
A storage for edge travel times and efforts.
MSTrafficLightLogic * getActive(const std::string &id) const
Returns the active program of a named tls.
int getDiscardedVehicleNo() const
Returns the number of discarded vehicles.
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
double getAvgWalkDuration() const
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
bool loadEdgeData(const std::string &file)
load edgeData from file
long long int myVehiclesMoved
The overall number of vehicle movements.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
double getAvgDepartDelay() const
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
double getAvgWaitingTime() const
double getVehicleMeanSpeedRelative() const
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
friend class GUITrafficLightLogicWrapper
Complete definition about what shall be retrieved and where to store it.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int size() const
Returns the number of stored items within the container.
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
double xmin() const
Returns minimum x-coordinate.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
MSTransportableControl & getPersonControl() override
Returns the person control.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
double getAvgDuration() const
A class that stores a 2D geometrical boundary.
const Boundary & getBoundary() const
returns the bounder of the network
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
double getWidth() const
Returns the width of the boudary (x-axis)
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
long myOverallSimDuration
static void clearDictionary()
Clears the dictionary (the objects will not be deleted)
A point in 2D or 3D with translation and scaling methods.
void initGUIStructures()
Initialises gui wrappers.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
static void updateAll()
Updates all instances (passes values)
Class passing values from a GUIGlObject to another object.
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
A road/street connecting two junctions.
std::vector< std::string > getEdgeAttrs()
The parent class for traffic light logics.
void Insert(const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
Insert entry (delegate to appropriate layer)
long myOverallVehicleCount
int getCollisionCount() const
return the number of collisions
const Position & getPosition() const
void lock()
grant exclusive access to the simulation state
long myLastVehicleMovementCount
int getJammedNumber() const
Returns the number of times a transportables was jammed.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
double getAvgTripSpeed() const
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a lane in the micro simulation (gui-version)
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
A road/street connecting two junctions (gui-version)
double getAvgTimeLoss() const
double getFPS() const
retrieve FPS
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
T get(const std::string &id) const
Retrieves an item.
std::vector< MSEdge * > MSEdgeVector
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
void unlock()
release exclusive access to the simulation state
double getRTFactor() const
Returns the simulation speed as a factor to real time.
MSTransportableControl * myContainerControl
Controls container building and deletion;.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
static double getTotalLength(bool includeInternal, bool eachLane)
GUISelectedStorage gSelected
A global holder of selected objects.
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
int getLinkTLIndex(MSLink *link) const
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
The class responsible for building and deletion of vehicles.
MSDetectorControl * myDetectorControl
Controls detectors;.
static std::vector< GUIGlID > getIDs(bool includeInternal)
int getLoadedNumber() const
Returns the number of build transportables.
@ SUMO_ATTR_END
weights: time range end
Boundary & grow(double by)
extends the boundary by the given amount
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
double getAvgWalkRouteLength() const
int getTeleportCount() const
return the number of teleports (including collisions)
Stores the information about how to visualize structures.
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
A MSNet extended by some values for usage within the gui.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
void simulationStep()
Performs a single simulation step (locking the simulation)
GUI-version of the transportable control for building gui persons and containers.
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
An XML-handler for network weights.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Encapsulated SAX-Attributes.
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
const std::string & getID() const
Returns the id.
virtual std::vector< std::string > getAttributeNames() const =0
Retrieves all attribute names.
void guiSimulationStep()
Some further steps needed for gui processing.
#define WRITE_MESSAGE(msg)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSTransportableControl * myPersonControl
Controls person building and deletion;.
@ GLO_NETWORK
The network - empty.
std::set< std::string > edgeAttrs
double ymax() const
Returns maximum y-coordinate.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.