83 myLastSimDuration(0), myLastIdleDuration(0),
84 myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
147 for (std::vector<MSTrafficLightLogic*>::const_iterator i = logics.begin(); i != logics.end(); ++i) {
160 if (links.size() == 0) {
167 MSTrafficLightLogic::LinkVectorVector::const_iterator j;
168 for (j = links.begin(); j != links.end(); ++j) {
169 MSTrafficLightLogic::LinkVector::const_iterator j2;
170 for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
230 FXMutexLock locker(
myLock);
237 std::vector<GUIGlID> ret;
239 if (!(*i)->isInternal() || includeInternal) {
240 ret.push_back((*i)->getGlID());
249 std::vector<GUIGlID> ret;
250 std::vector<std::string> ids;
252 std::string sid = (*i).second->getMicrosimID();
253 if (find(ids.begin(), ids.end(), sid) == ids.end()) {
254 ret.push_back((*i).second->getGlID());
266 for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
269 if (wrapper !=
nullptr) {
286 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
288 if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
295 std::map<MSJunction*, std::string> junction2TLL;
297 for (
const auto& links : tls->getLinks()) {
298 for (
const MSLink* l : links) {
299 junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
310 const std::vector<MSLane*>& lanes = edge->
getLanes();
311 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
312 b.
add((*j)->getShape().getBoxBoundary());
316 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
317 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
321 throw ProcessError(
"Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
328 const float cmin[2] = { (float)b.
xmin(), (float)b.
ymin() };
329 const float cmax[2] = { (float)b.
xmax(), (float)b.
ymax() };
438 ret->
mkItem(
"loaded vehicles [#]",
true,
440 ret->
mkItem(
"insertion-backlogged vehicles [#]",
true,
442 ret->
mkItem(
"departed vehicles [#]",
true,
444 ret->
mkItem(
"running vehicles [#]",
true,
446 ret->
mkItem(
"arrived vehicles [#]",
true,
448 ret->
mkItem(
"discarded vehicles [#]",
true,
450 ret->
mkItem(
"collisions [#]",
true,
452 ret->
mkItem(
"teleports [#]",
true,
454 ret->
mkItem(
"halting [#]",
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,
528 if (net !=
nullptr) {
531 throw ProcessError(
"A gui-network was not yet constructed.");
579 edgeAttrs.insert(tmp.begin(), tmp.end());
582 if (a !=
"from" && a !=
"to") {
592 std::vector<std::string>
595 return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
600 double value,
double begTime,
double endTime)
const {
602 if (edge !=
nullptr) {
603 myWeightStorage->addEffort(edge, begTime, endTime, value);
605 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" +
id +
"'.");
611 double val,
double beg,
double end)
const {
614 if (fromEdge !=
nullptr && toEdge !=
nullptr) {
616 if (item.first == toEdge) {
617 const MSEdge* edge = item.second;
618 while (edge !=
nullptr && edge->
isInternal()) {
619 myWeightStorage->addEffort(edge, beg, end, val);
624 }
else if (fromEdge ==
nullptr) {
625 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" + from +
"'.");
627 WRITE_ERROR(
"Trying to set the effort for the unknown edge '" + to +
"'.");
636 std::vector<std::string> attrs = discoveryHandler.
getEdgeAttrs();
638 +
"' Found " +
toString(attrs.size())
639 +
" attributes: " +
toString(attrs));
642 std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
643 retrieverDefsInternal.reserve(attrs.size());
644 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
645 for (
const std::string& attr : attrs) {
656 std::vector<std::string>
658 std::vector<std::string> result;
660 result.push_back(item.first);
675 if (!(*i)->isInternal()) {
676 const std::vector<MSLane*>& lanes = (*i)->getLanes();
677 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
678 static_cast<GUILane*
>(*j)->updateColor(s);
683 (*i)->updateColor(s);
@ GLO_NETWORK
The network - empty.
GUISelectedStorage gSelected
A global holder of selected objects.
std::vector< MSEdge * > MSEdgeVector
#define WRITE_MESSAGE(msg)
@ 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_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)
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)
class for discovering edge attributes
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
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.
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.
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
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
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
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)
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.