84 myLastSimDuration(0), myLastIdleDuration(0),
85 myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
159 if (links.size() == 0) {
166 MSTrafficLightLogic::LinkVectorVector::const_iterator j;
167 for (j = links.begin(); j != links.end(); ++j) {
168 MSTrafficLightLogic::LinkVector::const_iterator j2;
169 for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
228 FXMutexLock locker(
myLock);
235 std::vector<GUIGlID> ret;
237 if (!(*i)->isInternal() || includeInternal) {
238 ret.push_back((*i)->getGlID());
247 std::vector<GUIGlID> ret;
248 std::vector<std::string> ids;
250 std::string sid = (*i).second->getMicrosimID();
251 if (find(ids.begin(), ids.end(), sid) == ids.end()) {
252 ret.push_back((*i).second->getGlID());
264 for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
267 if (wrapper !=
nullptr) {
284 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
286 if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
293 std::map<MSJunction*, std::string> junction2TLL;
295 for (
const auto& links : tls->getLinks()) {
296 for (
const MSLink* l : links) {
297 junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
308 const std::vector<MSLane*>& lanes = edge->
getLanes();
309 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
310 b.
add((*j)->getShape().getBoxBoundary());
314 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
315 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
319 throw ProcessError(
"Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
326 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
327 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
436 ret->
mkItem(
"loaded vehicles [#]",
true,
438 ret->
mkItem(
"insertion-backlogged vehicles [#]",
true,
440 ret->
mkItem(
"departed vehicles [#]",
true,
442 ret->
mkItem(
"running vehicles [#]",
true,
444 ret->
mkItem(
"arrived vehicles [#]",
true,
446 ret->
mkItem(
"discarded vehicles [#]",
true,
448 ret->
mkItem(
"collisions [#]",
true,
450 ret->
mkItem(
"teleports [#]",
true,
452 ret->
mkItem(
"halting [#]",
true,
454 ret->
mkItem(
"stopped [#]",
true,
456 ret->
mkItem(
"avg. speed [m/s]",
true,
458 ret->
mkItem(
"avg. relative speed",
true,
461 ret->
mkItem(
"loaded persons [#]",
true,
463 ret->
mkItem(
"running persons [#]",
true,
465 ret->
mkItem(
"jammed persons [#]",
true,
535 if (net !=
nullptr) {
538 throw ProcessError(
"A gui-network was not yet constructed.");
586 edgeAttrs.insert(tmp.begin(), tmp.end());
589 if (a !=
"from" && a !=
"to") {
601 std::vector<std::string>
604 return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
609 double value,
double begTime,
double endTime)
const {
611 if (edge !=
nullptr) {
612 myWeightStorage->addEffort(edge, begTime, endTime, value);
614 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" +
id +
"'.");
620 double val,
double beg,
double end)
const {
623 if (fromEdge !=
nullptr && toEdge !=
nullptr) {
625 if (item.first == toEdge) {
626 const MSEdge* edge = item.second;
627 while (edge !=
nullptr && edge->
isInternal()) {
628 myWeightStorage->addEffort(edge, beg, end, val);
633 }
else if (fromEdge ==
nullptr) {
634 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" + from +
"'.");
636 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" + to +
"'.");
645 std::vector<std::string> attrs = discoveryHandler.
getEdgeAttrs();
650 +
".\n Found " +
toString(attrs.size())
651 +
" attributes: " +
toString(attrs));
653 WRITE_WARNING(
"No data defined after simulation begin time");
657 std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
658 retrieverDefsInternal.reserve(attrs.size());
659 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
660 for (
const std::string& attr : attrs) {
671 std::vector<std::string>
673 std::vector<std::string> result;
675 result.push_back(item.first);
701 if (!(*i)->isInternal()) {
702 const std::vector<MSLane*>& lanes = (*i)->getLanes();
703 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
704 static_cast<GUILane*
>(*j)->updateColor(s);
709 (*i)->updateColor(s);
@ GLO_NETWORK
The network - empty.
GUISelectedStorage gSelected
A global holder of selected objects.
std::vector< MSEdge * > MSEdgeVector
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double getHeight() const
Returns the height of the boundary (y-axis)
double getWidth() const
Returns the width of the boudary (x-axis)
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
Class passing values from a GUIGlObject to another object.
static void updateAll()
Updates all instances (passes values)
The main window of the SUMO-gui.
void handleEvent_SimulationStep(GUIEvent *e)
Changes the speed allowed on a set of lanes (gui version)
A road/street connecting two junctions (gui-version)
static double getTotalLength(bool includeInternal, bool eachLane)
static std::vector< GUIGlID > getIDs(bool includeInternal)
static void clearDictionary()
Clears the dictionary (the objects will not be deleted)
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Boundary getBoundary() const
Returns the boundary of the junction.
Representation of a lane in the micro simulation (gui-version)
The class responsible for building and deletion of vehicles (gui-version)
static GUIMainWindow * getInstance()
get instance
class for discovering edge attributes
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
SUMOTime firstIntervalBegin
std::set< std::string > edgeAttrs
std::vector< std::string > getEdgeAttrs()
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
A MSNet extended by some values for usage within the gui.
double getAvgTripSpeed() const
double getAvgRouteLength() const
double getAvgDuration() const
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
void unlock()
release exclusive access to the simulation state
double getUPS() const
Returns the update per seconds rate.
bool loadEdgeData(const std::string &file)
load edgeData from file
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
long myLastVehicleMovementCount
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
MSTransportableControl & getPersonControl() override
Returns the person control.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration asociated with this GLObject
bool isSelected(const MSTrafficLightLogic *tll) const override
return wheter the given logic (or rather it's wrapper) is selected in the GUI
long myOverallVehicleCount
void simulationStep()
Performs a single simulation step (locking the simulation)
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
void initGUIStructures()
Initialises gui wrappers.
long myOverallSimDuration
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
const Boundary & getBoundary() const
returns the bounder of the network
double getRTFactor() const
Returns the simulation speed as a factor to real time.
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
double getAvgWalkDuration() const
int getLinkTLID(const MSLink *const link) const
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
std::vector< GUICalibrator * > myCalibratorWrapper
A calibrator dictionary.
double getMeanUPS() const
Returns the update per seconds rate.
void initTLMap()
Initialises the tl-logic map and wrappers.
int getLinkTLIndex(const MSLink *const link) const
Boundary myBoundary
The networks boundary.
double getAvgWalkTimeLoss() const
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
double getAvgWalkRouteLength() const
void lock()
grant exclusive access to the simulation state
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
void updateGUI() const override
update view after simulation.loadState
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
double getAvgTimeLoss() const
double getAvgDepartDelay() const
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
double getAvgWaitingTime() const
friend class GUITrafficLightLogicWrapper
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void guiSimulationStep()
Some further steps needed for gui processing.
MSTransportableControl & getContainerControl() override
Returns the container control.
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
LayeredRTree myGrid
The visualization speed-up.
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
double getFPS() const
retrieve FPS
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
Storage for geometrical objects extended by mutexes.
GUI-version of the transportable control for building gui persons and containers.
The class responsible for building and deletion of vehicles (gui-version)
Stores the information about how to visualize structures.
static const double MISSING_DATA
void Insert(const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
Insert entry (delegate to appropriate layer)
static const std::map< std::string, MSCalibrator * > & getInstances()
return all calibrator instances
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
A road/street connecting two junctions.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
const MSConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges with internal vias, restricted by vClass.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool isInternal() const
return whether this edge is an internal edge
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....
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
const Position & getPosition() const
The simulated network and simulation perfomer.
MSTransportableControl * myPersonControl
Controls person building and deletion;.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
double myVersion
the network version
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void simulationStep()
Performs a single simulation step.
MSTransportableControl * myContainerControl
Controls container building and deletion;.
SUMOTime myEdgeDataEndTime
end of loaded edgeData
MSInsertionControl & getInsertionControl()
Returns the insertion control.
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
bool logSimulationDuration() const
Returns whether duration shall be logged.
long long int myVehiclesMoved
The overall number of vehicle movements.
MSDetectorControl * myDetectorControl
Controls detectors;.
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
MSTrafficLightLogic * getActive(const std::string &id) const
Returns the active program of a named tls.
The parent class for traffic light logics.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
int getLoadedNumber() const
Returns the number of build transportables.
int getJammedNumber() const
Returns the number of times a transportables was jammed.
The class responsible for building and deletion of vehicles.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
int getLoadedVehicleNo() const
Returns the number of build vehicles.
int getCollisionCount() const
return the number of collisions
int getStoppedVehiclesCount() const
return the number of vehicles that are currently stopped
double getVehicleMeanSpeed() const
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
int getTeleportCount() const
return the number of teleports (including collisions)
double getVehicleMeanSpeedRelative() const
int getDiscardedVehicleNo() const
Returns the number of discarded vehicles.
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
int size() const
Returns the number of stored items within the container.
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
Complete definition about what shall be retrieved and where to store it.
An XML-handler for network weights.
void addAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Adds an additional object (detector/shape/trigger) for visualisation.
Encapsulated SAX-Attributes.
virtual std::vector< std::string > getAttributeNames() const =0
Retrieves all attribute names.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.