Eclipse SUMO - Simulation of Urban MObility
NLTriggerBuilder.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
20 // Builds trigger objects for microsim
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
31 #include <microsim/MSLane.h>
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSGlobals.h>
34 #include <microsim/MSParkingArea.h>
47 #include "NLHandler.h"
48 #include "NLTriggerBuilder.h"
50 #include <utils/xml/XMLSubSys.h>
51 
52 
53 #include <mesosim/MELoop.h>
55 
56 
57 // ===========================================================================
58 // method definitions
59 // ===========================================================================
61  : myHandler(nullptr), myParkingArea(nullptr), myCurrentStop(nullptr) {}
62 
63 
65 
66 void
68  myHandler = handler;
69 }
70 
71 
72 void
74  WRITE_WARNING("Vaporizers are deprecated. Use rerouters instead.");
75  bool ok = true;
76  // get the id, throw if not given or empty...
77  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
78  if (!ok) {
79  return;
80  }
81  MSEdge* e = MSEdge::dictionary(id);
82  if (e == nullptr) {
83  WRITE_ERROR("Unknown edge ('" + id + "') referenced in a vaporizer.");
84  return;
85  }
86  SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, ok);
87  SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, ok);
88  if (!ok) {
89  return;
90  }
91  if (begin < 0) {
92  WRITE_ERROR("A vaporization begin time is negative (edge id='" + id + "').");
93  return;
94  }
95  if (begin >= end) {
96  WRITE_ERROR("A vaporization ends before it starts (edge id='" + id + "').");
97  return;
98  }
99  if (end >= string2time(OptionsCont::getOptions().getString("begin"))) {
104  }
105 }
106 
107 
108 
109 void
111  const std::string& base) {
112  // get the id, throw if not given or empty...
113  bool ok = true;
114  // get the id, throw if not given or empty...
115  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
116  if (!ok) {
117  return;
118  }
119  // get the file name to read further definitions from
120  std::string file = getFileName(attrs, base, true);
121  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANES, id.c_str(), ok);
122  std::vector<MSLane*> lanes;
123  for (const std::string& laneID : attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), ok)) {
124  MSLane* lane = MSLane::dictionary(laneID);
125  if (lane == nullptr) {
126  throw InvalidArgument("The lane '" + laneID + "' to use within MSLaneSpeedTrigger '" + id + "' is not known.");
127  }
128  lanes.push_back(lane);
129  }
130  if (!ok) {
131  throw InvalidArgument("The lanes to use within MSLaneSpeedTrigger '" + id + "' are not known.");
132  }
133  if (lanes.size() == 0) {
134  throw InvalidArgument("No lane defined for MSLaneSpeedTrigger '" + id + "'.");
135  }
136  try {
137  MSLaneSpeedTrigger* trigger = buildLaneSpeedTrigger(net, id, lanes, file);
138  if (file == "") {
140  }
141  } catch (ProcessError& e) {
142  throw InvalidArgument(e.what());
143  }
144 }
145 
146 void
148  bool ok = true;
149 
150  // get the id, throw if not given or empty...
151  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
152  if (!ok) {
153  throw ProcessError();
154  }
155 
156  MSLane* const lane = getLane(attrs, "chargingStation", id);
157  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
158  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
159  const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), ok, 0);
160  const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), ok, 0);
161  const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), ok, 0);
162  const double chargeDelay = attrs.getOpt<double>(SUMO_ATTR_CHARGEDELAY, id.c_str(), ok, 0);
163  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
164  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
165 
166  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
167  throw InvalidArgument("Invalid position for charging station '" + id + "'.");
168  }
169 
170  buildChargingStation(net, id, lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
171 }
172 
173 
174 void
176  bool ok = true;
177  // get the id, throw if not given or empty...
178  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
179  if (!ok) {
180  throw ProcessError();
181  }
182 
183  //get the name, leave blank if not given
184  const std::string ptStopName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
185 
186  MSLane* lane = getLane(attrs, toString(element), id);
187  // get the positions
188  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
189  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
190  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
191  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
192  throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
193  }
194  const std::vector<std::string>& lines = attrs.getOptStringVector(SUMO_ATTR_LINES, id.c_str(), ok, false);
195  const int defaultCapacity = MAX2(MSStoppingPlace::getPersonsAbreast(topos - frompos) * 3, 6);
196  const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), ok, defaultCapacity);
197  // build the bus stop
198  buildStoppingPlace(net, id, lines, lane, frompos, topos, element, ptStopName, personCapacity);
199 }
200 
201 
202 void
204  if (myCurrentStop == nullptr) {
205  throw InvalidArgument("Could not add access outside a stopping place.");
206  }
207  // get the lane
208  MSLane* lane = getLane(attrs, "access", myCurrentStop->getID());
209  if (!lane->allowsVehicleClass(SVC_PEDESTRIAN)) {
210  WRITE_WARNING("Ignoring invalid access from non-pedestrian lane '" + lane->getID() + "' in busStop '" + myCurrentStop->getID() + "'.");
211  return;
212  }
213  // get the positions
214  bool ok = true;
215  double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0);
216  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
217  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
218  if (!ok || !myHandler->checkStopPos(pos, pos, lane->getLength(), 0, friendlyPos)) {
219  throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane->getID() + "' in stop '" + myCurrentStop->getID() + "'.");
220  }
221  // add bus stop access
222  if (!myCurrentStop->addAccess(lane, pos, length)) {
223  throw InvalidArgument("Duplicate access on lane '" + lane->getID() + "' for stop '" + myCurrentStop->getID() + "'");
224  }
225 }
226 
227 
228 void
230  bool ok = true;
231  // get the id, throw if not given or empty...
232  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
233  if (!ok) {
234  throw ProcessError();
235  }
236  // get the lane
237  MSLane* lane = getLane(attrs, "parkingArea", id);
238  // get the positions
239  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
240  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
241  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
242  unsigned int capacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), ok, 0);
243  bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), ok, false);
244  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, 0);
245  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, 0);
246  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, 0);
247  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
248  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
249  throw InvalidArgument("Invalid position for parking area '" + id + "'.");
250  }
251  const std::vector<std::string>& lines = attrs.getOptStringVector(SUMO_ATTR_LINES, id.c_str(), ok, false);
252  // build the parking area
253  beginParkingArea(net, id, lines, lane, frompos, topos, capacity, width, length, angle, name, onRoad);
254 }
255 
256 
257 
258 void
260  bool ok = true;
261  // Check for open parking area
262  if (myParkingArea == nullptr) {
263  throw ProcessError();
264  }
265  // get the positions
266  double x = attrs.get<double>(SUMO_ATTR_X, "", ok);
267  if (!ok) {
268  throw InvalidArgument("Invalid x position for lot entry.");
269  }
270  double y = attrs.get<double>(SUMO_ATTR_Y, "", ok);
271  if (!ok) {
272  throw InvalidArgument("Invalid y position for lot entry.");
273  }
274  double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", ok, 0.);
275  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, "", ok, myParkingArea->getWidth());
276  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", ok, myParkingArea->getLength());
277  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, "", ok, myParkingArea->getAngle());
278  // add the lot entry
279  addLotEntry(x, y, z, width, length, angle);
280 }
281 
282 
283 void
285  const std::string& base) {
286  bool ok = true;
287  // get the id, throw if not given or empty...
288  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
289  if (!ok) {
290  throw ProcessError();
291  }
292  MSLane* lane = nullptr;
293  MSEdge* edge = nullptr;
294  // get the file name to read further definitions from
295  if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
296  std::string edgeID = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
297  edge = MSEdge::dictionary(edgeID);
298  if (edge == nullptr) {
299  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id + "' is not known.");
300  }
301  if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
302  lane = getLane(attrs, "calibrator", id);
303  if (&lane->getEdge() != edge) {
304  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id
305  + "' does not match the calibrator lane '" + lane->getID() + ".");
306  }
307  }
308  } else {
309  lane = getLane(attrs, "calibrator", id);
310  edge = &lane->getEdge();
311  }
312  const double pos = getPosition(attrs, lane, "calibrator", id, edge);
313  const SUMOTime freq = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, DELTA_T); // !!! no error handling
314  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
315  std::string file = getFileName(attrs, base, true);
316  std::string outfile = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), ok, "");
317  std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), ok, "");
318  MSRouteProbe* probe = nullptr;
319  if (routeProbe != "") {
320  probe = dynamic_cast<MSRouteProbe*>(net.getDetectorControl().getTypedDetectors(SUMO_TAG_ROUTEPROBE).get(routeProbe));
321  if (probe == nullptr) {
322  throw InvalidArgument("The routeProbe '" + routeProbe + "' to use within the calibrator '" + id + "' is not known.");
323  }
324  }
326  if (lane != nullptr && edge->getLanes().size() > 1) {
327  WRITE_WARNING("Meso calibrator '" + id
328  + "' defined for lane '" + lane->getID()
329  + "' will collect data for all lanes of edge '" + edge->getID() + "'.");
330  }
331  METriggeredCalibrator* trigger = buildMECalibrator(net, id, edge, pos, file, outfile, freq, probe, vTypes);
332  if (file == "") {
333  trigger->registerParent(SUMO_TAG_CALIBRATOR, myHandler);
334  }
335  } else {
336  MSCalibrator* trigger = buildCalibrator(net, id, edge, lane, pos, file, outfile, freq, probe, vTypes);
337  if (file == "") {
339  }
340  }
341 }
342 
343 
344 void
346  const std::string& base) {
347  bool ok = true;
348  // get the id, throw if not given or empty...
349  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
350  if (!ok) {
351  throw ProcessError();
352  }
353  // get the file name to read further definitions from
354  std::string file = getFileName(attrs, base, true);
355  MSEdgeVector edges;
356  for (const std::string& edgeID : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), ok)) {
357  MSEdge* edge = MSEdge::dictionary(edgeID);
358  if (edge == nullptr) {
359  throw InvalidArgument("The edge '" + edgeID + "' to use within MSTriggeredRerouter '" + id + "' is not known.");
360  }
361  edges.push_back(edge);
362  }
363  if (!ok) {
364  throw InvalidArgument("The edge to use within MSTriggeredRerouter '" + id + "' is not known.");
365  }
366  if (edges.size() == 0) {
367  throw InvalidArgument("No edges found for MSTriggeredRerouter '" + id + "'.");
368  }
369  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), ok, 1);
370  bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, false);
371  SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
372  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
373  if (!ok) {
374  throw InvalidArgument("Could not parse MSTriggeredRerouter '" + id + "'.");
375  }
376  MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, file, off, timeThreshold, vTypes);
377  // read in the trigger description
378  if (file == "") {
380  } else if (!XMLSubSys::runParser(*trigger, file)) {
381  throw ProcessError();
382  }
383 }
384 
385 
386 // -------------------------
387 
388 
390 NLTriggerBuilder::buildLaneSpeedTrigger(MSNet& /*net*/, const std::string& id,
391  const std::vector<MSLane*>& destLanes,
392  const std::string& file) {
393  return new MSLaneSpeedTrigger(id, destLanes, file);
394 }
395 
396 
398 NLTriggerBuilder::buildMECalibrator(MSNet& /*net*/, const std::string& id,
399  const MSEdge* edge,
400  double pos,
401  const std::string& file,
402  const std::string& outfile,
403  const SUMOTime freq,
404  MSRouteProbe* probe,
405  const std::string& vTypes) {
406  return new METriggeredCalibrator(id, edge, pos, file, outfile, freq, MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)->getLength(), probe, vTypes);
407 }
408 
409 
411 NLTriggerBuilder::buildCalibrator(MSNet& /*net*/, const std::string& id,
412  MSEdge* edge,
413  MSLane* lane,
414  double pos,
415  const std::string& file,
416  const std::string& outfile,
417  const SUMOTime freq,
418  const MSRouteProbe* probe,
419  const std::string& vTypes) {
420  return new MSCalibrator(id, edge, lane, pos, file, outfile, freq, edge->getLength(), probe, vTypes);
421 }
422 
423 
425 NLTriggerBuilder::buildRerouter(MSNet&, const std::string& id,
426  MSEdgeVector& edges,
427  double prob, const std::string& file, bool off,
428  SUMOTime timeThreshold,
429  const std::string& vTypes) {
430  return new MSTriggeredRerouter(id, edges, prob, file, off, timeThreshold, vTypes);
431 }
432 
433 
434 void
435 NLTriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
436  double frompos, double topos, const SumoXMLTag element, std::string ptStopName, int personCapacity) {
437  myCurrentStop = new MSStoppingPlace(id, lines, *lane, frompos, topos, ptStopName, personCapacity);
438  if (!net.addStoppingPlace(element, myCurrentStop)) {
439  delete myCurrentStop;
440  myCurrentStop = nullptr;
441  throw InvalidArgument("Could not build " + toString(element) + " '" + id + "'; probably declared twice.");
442  }
443 }
444 
445 
446 void
447 NLTriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
448  const std::vector<std::string>& lines,
449  MSLane* lane, double frompos, double topos,
450  unsigned int capacity,
451  double width, double length, double angle, const std::string& name,
452  bool onRoad) {
453  // Close previous parking area if there are not lots inside
454  MSParkingArea* stop = new MSParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle, name, onRoad);
455  if (!net.addStoppingPlace(SUMO_TAG_PARKING_AREA, stop)) {
456  delete stop;
457  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
458  } else {
459  myParkingArea = stop;
460  }
461 }
462 
463 
464 void
465 NLTriggerBuilder::addLotEntry(double x, double y, double z,
466  double width, double length, double angle) {
467  if (myParkingArea != nullptr) {
468  if (!myParkingArea->parkOnRoad()) {
469  myParkingArea->addLotEntry(x, y, z, width, length, angle);
470  } else {
471  throw InvalidArgument("Cannot not add lot entry to on-road parking area.");
472  }
473  } else {
474  throw InvalidArgument("Could not add lot entry outside a parking area.");
475  }
476 }
477 
478 
479 void
481  if (myParkingArea != nullptr) {
482  myParkingArea = nullptr;
483  } else {
484  throw InvalidArgument("Could not end a parking area that is not opened.");
485  }
486 }
487 
488 
489 void
491  if (myCurrentStop != nullptr) {
492  myCurrentStop = nullptr;
493  } else {
494  throw InvalidArgument("Could not end a stopping place that is not opened.");
495  }
496 }
497 
498 
499 void
500 NLTriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos, const std::string& name,
501  double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay) {
502  MSChargingStation* chargingStation = new MSChargingStation(id, *lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
503  if (!net.addStoppingPlace(SUMO_TAG_CHARGING_STATION, chargingStation)) {
504  delete chargingStation;
505  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
506  }
507  myCurrentStop = chargingStation;
508 }
509 
510 std::string
512  const std::string& base,
513  const bool allowEmpty) {
514  // get the file name to read further definitions from
515  bool ok = true;
516  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, nullptr, ok, "");
517  if (file == "") {
518  if (allowEmpty) {
519  return file;
520  }
521  throw InvalidArgument("No filename given.");
522  }
523  // check whether absolute or relative filenames are given
524  if (!FileHelpers::isAbsolute(file)) {
525  return FileHelpers::getConfigurationRelative(base, file);
526  }
527  return file;
528 }
529 
530 
531 MSLane*
533  const std::string& tt,
534  const std::string& tid) {
535  bool ok = true;
536  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANE, tid.c_str(), ok);
537  MSLane* lane = MSLane::dictionary(objectid);
538  if (lane == nullptr) {
539  throw InvalidArgument("The lane " + objectid + " to use within the " + tt + " '" + tid + "' is not known.");
540  }
541  return lane;
542 }
543 
544 
545 double
547  MSLane* lane,
548  const std::string& tt, const std::string& tid,
549  MSEdge* edge) {
550  assert(lane != 0 || edge != 0);
551  const double length = lane != nullptr ? lane->getLength() : edge->getLength();
552  bool ok = true;
553  double pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
554  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
555  if (!ok) {
556  throw InvalidArgument("Error on parsing a position information.");
557  }
558  if (pos < 0) {
559  pos = length + pos;
560  }
561  if (pos > length) {
562  if (friendlyPos) {
563  pos = length - (double) 0.1;
564  } else {
565  if (lane != nullptr) {
566  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane->getID() + "' length.");
567  } else {
568  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the edges's '" + edge->getID() + "' length.");
569  }
570  }
571  }
572  return pos;
573 }
574 
577  return myParkingArea == nullptr ? myCurrentStop : myParkingArea;
578 }
579 
580 /****************************************************************************/
void setHandler(NLHandler *handler)
Sets the parent handler to use for nested parsing.
int getPersonsAbreast() const
void parseAndAddLotEntry(const SUMOSAXAttributes &attrs)
Parses his values and adds a lot entry to current parking area.
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
SumoXMLTag
Numbers representing SUMO-XML - element names.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:670
a routeprobe detector
long long int SUMOTime
Definition: SUMOTime.h:35
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
void addAccess(MSNet &net, const SUMOSAXAttributes &attrs)
Parses the values and adds an access point to the currently parsed stopping place.
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold, const std::string &vTypes)
builds an rerouter
A lane area vehicles can halt at.
A calibrator placed over edge.
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:61
Allow/disallow charge in transit in Charging Stations.
T get(const std::string &id) const
Retrieves an item.
void parseAndBuildChargingStation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a charging station.
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a rerouter.
virtual void buildStoppingPlace(MSNet &net, std::string id, std::vector< std::string > lines, MSLane *lane, double frompos, double topos, const SumoXMLTag element, std::string string, int personCapacity)
Builds a stopping place.
weights: time range begin
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:165
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
T MAX2(T a, T b)
Definition: StdDefs.h:80
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:541
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:804
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:430
const std::string & getID() const
Returns the id.
Definition: Named.h:77
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
NLTriggerBuilder()
Constructor.
Base (microsim) event class.
Definition: Command.h:53
MSParkingArea * myParkingArea
definition of the currently parsed parking area
double getLength() const
return the length of the edge
Definition: MSEdge.h:582
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:113
virtual ~NLTriggerBuilder()
Destructor.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:437
void parseAndBeginParkingArea(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a parking area.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:893
void addLotEntry(double x, double y, double z, double width, double length, double angle)
Add a lot entry to current parking area.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
The simulated network and simulation perfomer.
Definition: MSNet.h:92
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Changes the speed allowed on a set of lanes.
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSStoppingPlace * getCurrentStop()
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
Encapsulated SAX-Attributes.
Calibrates the flow on a segment to a specified one.
NLHandler * myHandler
The parent handler to set for subhandlers.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
virtual void endParkingArea()
End a parking area.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:430
A wrapper for a Command function.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
void parseAndBuildLaneSpeedTrigger(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a lane speed trigger.
virtual void beginParkingArea(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, double frompos, double topos, unsigned int capacity, double width, double length, double angle, const std::string &name, bool onRoad)
Begin a parking area.
void registerParent(const int tag, GenericSAXHandler *handler)
Assigning a parent handler which is enabled when the specified tag is closed.
MSStoppingPlace * myCurrentStop
The currently parsed stop to add access points to.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
void parseAndBuildStoppingPlace(MSNet &net, const SUMOSAXAttributes &attrs, const SumoXMLTag element)
Parses the values and builds a stopping places for busses, trains or container vehicles.
virtual METriggeredCalibrator * buildMECalibrator(MSNet &net, const std::string &id, const MSEdge *edge, double pos, const std::string &file, const std::string &outfile, const SUMOTime freq, MSRouteProbe *probe, const std::string &vTypes)
builds a mesoscopic calibrator
#define POSITION_EPS
Definition: config.h:169
const std::vector< std::string > getOptStringVector(int attr, const char *objectid, bool &ok, bool report=true) const
convenience function to avoid the default argument and the template stuff at getOpt<> ...
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane *> &destLanes, const std::string &file)
Builds a lane speed trigger.
bool parkOnRoad() const
whether vehicles park on the road
Definition: MSParkingArea.h:92
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:400
std::string getFileName(const SUMOSAXAttributes &attrs, const std::string &base, const bool allowEmpty=false)
Helper method to obtain the filename.
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle)
Add a lot entry to parking area.
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
double getLength() const
Returns the lot rectangle length.
The XML-Handler for network loading.
Definition: NLHandler.h:81
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
Reroutes vehicles passing an edge.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1855
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual void endStoppingPlace()
End a stopping place.
double getWidth() const
Returns the lot rectangle width.
virtual void buildChargingStation(MSNet &net, const std::string &id, MSLane *lane, double frompos, double topos, const std::string &name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay)
Builds a charging station.
weights: time range end
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:106
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:806
Calibrates the flow on a segment to a specified one.
Definition: MSCalibrator.h:51
A variable speed sign.
Eficiency of the charge in Charging Stations.
Delay in the charge of charging stations.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
double getPosition(const SUMOSAXAttributes &attrs, MSLane *lane, const std::string &tt, const std::string &tid, MSEdge *edge=0)
returns the position on the lane checking it
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
virtual MSCalibrator * buildCalibrator(MSNet &net, const std::string &id, MSEdge *edge, MSLane *lane, double pos, const std::string &file, const std::string &outfile, const SUMOTime freq, const MSRouteProbe *probe, const std::string &vTypes)
builds a microscopic calibrator
static bool gUseMesoSim
Definition: MSGlobals.h:91
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
double getAngle() const
Returns the lot rectangle angle.
MSLane * getLane(const SUMOSAXAttributes &attrs, const std::string &tt, const std::string &tid)
Returns the lane defined by attribute "lane".