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-2018 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  if (!ok) {
123  throw InvalidArgument("The lanes to use within MSLaneSpeedTrigger '" + id + "' are not known.");
124  }
125  std::vector<MSLane*> lanes;
126  std::vector<std::string> laneIDs;
127  SUMOSAXAttributes::parseStringVector(objectid, laneIDs);
128  for (std::vector<std::string>::iterator i = laneIDs.begin(); i != laneIDs.end(); ++i) {
129  MSLane* lane = MSLane::dictionary(*i);
130  if (lane == nullptr) {
131  throw InvalidArgument("The lane to use within MSLaneSpeedTrigger '" + id + "' is not known.");
132  }
133  lanes.push_back(lane);
134  }
135  if (lanes.size() == 0) {
136  throw InvalidArgument("No lane defined for MSLaneSpeedTrigger '" + id + "'.");
137  }
138  try {
139  MSLaneSpeedTrigger* trigger = buildLaneSpeedTrigger(net, id, lanes, file);
140  if (file == "") {
142  }
143  } catch (ProcessError& e) {
144  throw InvalidArgument(e.what());
145  }
146 }
147 
148 void
150  bool ok = true;
151 
152  // get the id, throw if not given or empty...
153  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
154  if (!ok) {
155  throw ProcessError();
156  }
157 
158  MSLane* const lane = getLane(attrs, "chargingStation", id);
159  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
160  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
161  const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), ok, 0);
162  const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), ok, 0);
163  const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), ok, 0);
164  const double chargeDelay = attrs.getOpt<double>(SUMO_ATTR_CHARGEDELAY, id.c_str(), ok, 0);
165  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
166  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
167 
168  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
169  throw InvalidArgument("Invalid position for charging station '" + id + "'.");
170  }
171 
172  buildChargingStation(net, id, lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
173 }
174 
175 
176 void
178  bool ok = true;
179  // get the id, throw if not given or empty...
180  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
181  if (!ok) {
182  throw ProcessError();
183  }
184 
185  //get the name, leave blank if not given
186  const std::string ptStopName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
187 
188  // get the lane
189  MSLane* lane = getLane(attrs, toString(element), id);
190  // get the positions
191  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
192  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
193  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
194  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
195  throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
196  }
197  // get the lines
198  std::vector<std::string> lines;
199  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LINES, id.c_str(), ok, "", false), lines);
200  // build the bus stop
201  buildStoppingPlace(net, id, lines, lane, frompos, topos, element, ptStopName);
202 }
203 
204 
205 void
207  if (myCurrentStop == nullptr) {
208  throw InvalidArgument("Could not add access outside a stopping place.");
209  }
210  // get the lane
211  MSLane* lane = getLane(attrs, "access", myCurrentStop->getID());
212  // get the positions
213  bool ok = true;
214  double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0);
215  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
216  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
217  if (!ok || !myHandler->checkStopPos(pos, pos, lane->getLength(), 0, friendlyPos)) {
218  throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane->getID() + "' in stop '" + myCurrentStop->getID() + "'.");
219  }
220  // add bus stop access
221  if (!myCurrentStop->addAccess(lane, pos, length)) {
222  throw InvalidArgument("Duplicate access on lane '" + lane->getID() + "' for stop '" + myCurrentStop->getID() + "'");
223  }
224 }
225 
226 
227 void
229  bool ok = true;
230  // get the id, throw if not given or empty...
231  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
232  if (!ok) {
233  throw ProcessError();
234  }
235  // get the lane
236  MSLane* lane = getLane(attrs, "parkingArea", id);
237  // get the positions
238  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
239  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
240  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
241  unsigned int capacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), ok, 0);
242  bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), ok, false);
243  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, 0);
244  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, 0);
245  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, 0);
246  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
247  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
248  throw InvalidArgument("Invalid position for parking area '" + id + "'.");
249  }
250  // get the lines
251  std::vector<std::string> lines;
252  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LINES, id.c_str(), ok, "", false), lines);
253  // build the parking area
254  beginParkingArea(net, id, lines, lane, frompos, topos, capacity, width, length, angle, name, onRoad);
255 }
256 
257 
258 
259 void
261  bool ok = true;
262  // Check for open parking area
263  if (myParkingArea == nullptr) {
264  throw ProcessError();
265  }
266  // get the positions
267  double x = attrs.get<double>(SUMO_ATTR_X, "", ok);
268  if (!ok) {
269  throw InvalidArgument("Invalid x position for lot entry.");
270  }
271  double y = attrs.get<double>(SUMO_ATTR_Y, "", ok);
272  if (!ok) {
273  throw InvalidArgument("Invalid y position for lot entry.");
274  }
275  double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", ok, 0.);
276  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, "", ok, myParkingArea->getWidth());
277  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", ok, myParkingArea->getLength());
278  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, "", ok, myParkingArea->getAngle());
279  // add the lot entry
280  addLotEntry(x, y, z, width, length, angle);
281 }
282 
283 
284 void
286  const std::string& base) {
287  bool ok = true;
288  // get the id, throw if not given or empty...
289  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
290  if (!ok) {
291  throw ProcessError();
292  }
293  MSLane* lane = nullptr;
294  MSEdge* edge = nullptr;
295  // get the file name to read further definitions from
296  if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
297  std::string edgeID = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
298  edge = MSEdge::dictionary(edgeID);
299  if (edge == nullptr) {
300  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id + "' is not known.");
301  }
302  if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
303  lane = getLane(attrs, "calibrator", id);
304  if (&lane->getEdge() != edge) {
305  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id
306  + "' does not match the calibrator lane '" + lane->getID() + ".");
307  }
308  }
309  } else {
310  lane = getLane(attrs, "calibrator", id);
311  edge = &lane->getEdge();
312  }
313  const double pos = getPosition(attrs, lane, "calibrator", id, edge);
314  const SUMOTime freq = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, DELTA_T); // !!! no error handling
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);
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);
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  std::string objectid = attrs.get<std::string>(SUMO_ATTR_EDGES, id.c_str(), ok);
356  if (!ok) {
357  throw InvalidArgument("The edge to use within MSTriggeredRerouter '" + id + "' is not known.");
358  }
359  MSEdgeVector edges;
360  std::vector<std::string> edgeIDs;
361  SUMOSAXAttributes::parseStringVector(objectid, edgeIDs);
362  for (std::vector<std::string>::iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
363  MSEdge* edge = MSEdge::dictionary(*i);
364  if (edge == nullptr) {
365  throw InvalidArgument("The edge '" + (*i) + "' to use within MSTriggeredRerouter '" + id + "' is not known.");
366  }
367  edges.push_back(edge);
368  }
369  if (edges.size() == 0) {
370  throw InvalidArgument("No edges found for MSTriggeredRerouter '" + id + "'.");
371  }
372  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), ok, 1);
373  bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, false);
374  SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
375  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
376  if (!ok) {
377  throw InvalidArgument("Could not parse MSTriggeredRerouter '" + id + "'.");
378  }
379  MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, file, off, timeThreshold, vTypes);
380  // read in the trigger description
381  if (file == "") {
383  } else if (!XMLSubSys::runParser(*trigger, file)) {
384  throw ProcessError();
385  }
386 }
387 
388 
389 // -------------------------
390 
391 
393 NLTriggerBuilder::buildLaneSpeedTrigger(MSNet& /*net*/, const std::string& id,
394  const std::vector<MSLane*>& destLanes,
395  const std::string& file) {
396  return new MSLaneSpeedTrigger(id, destLanes, file);
397 }
398 
399 
401 NLTriggerBuilder::buildMECalibrator(MSNet& /*net*/, const std::string& id,
402  const MSEdge* edge,
403  double pos,
404  const std::string& file,
405  const std::string& outfile,
406  const SUMOTime freq, MSRouteProbe* probe) {
407  return new METriggeredCalibrator(id, edge, pos, file, outfile, freq, MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)->getLength(), probe);
408 }
409 
410 
412 NLTriggerBuilder::buildCalibrator(MSNet& /*net*/, const std::string& id,
413  MSEdge* edge,
414  MSLane* lane,
415  double pos,
416  const std::string& file,
417  const std::string& outfile,
418  const SUMOTime freq, const MSRouteProbe* probe) {
419  return new MSCalibrator(id, edge, lane, pos, file, outfile, freq, edge->getLength(), probe);
420 }
421 
422 
424 NLTriggerBuilder::buildRerouter(MSNet&, const std::string& id,
425  MSEdgeVector& edges,
426  double prob, const std::string& file, bool off,
427  SUMOTime timeThreshold,
428  const std::string& vTypes) {
429  return new MSTriggeredRerouter(id, edges, prob, file, off, timeThreshold, vTypes);
430 }
431 
432 
433 void
434 NLTriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
435  double frompos, double topos, const SumoXMLTag element, std::string ptStopName) {
436  myCurrentStop = new MSStoppingPlace(id, lines, *lane, frompos, topos, ptStopName);
437  if (!net.addStoppingPlace(element, myCurrentStop)) {
438  delete myCurrentStop;
439  myCurrentStop = nullptr;
440  throw InvalidArgument("Could not build " + toString(element) + " '" + id + "'; probably declared twice.");
441  }
442 }
443 
444 
445 void
446 NLTriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
447  const std::vector<std::string>& lines,
448  MSLane* lane, double frompos, double topos,
449  unsigned int capacity,
450  double width, double length, double angle, const std::string& name,
451  bool onRoad) {
452  // Close previous parking area if there are not lots inside
453  MSParkingArea* stop = new MSParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle, name, onRoad);
454  if (!net.addStoppingPlace(SUMO_TAG_PARKING_AREA, stop)) {
455  delete stop;
456  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
457  } else {
458  myParkingArea = stop;
459  }
460 }
461 
462 
463 void
464 NLTriggerBuilder::addLotEntry(double x, double y, double z,
465  double width, double length, double angle) {
466  if (myParkingArea != nullptr) {
467  if (!myParkingArea->parkOnRoad()) {
468  myParkingArea->addLotEntry(x, y, z, width, length, angle);
469  } else {
470  throw InvalidArgument("Cannot not add lot entry to on-road parking area.");
471  }
472  } else {
473  throw InvalidArgument("Could not add lot entry outside a parking area.");
474  }
475 }
476 
477 
478 void
480  if (myParkingArea != nullptr) {
481  myParkingArea = nullptr;
482  } else {
483  throw InvalidArgument("Could not end a parking area that is not opened.");
484  }
485 }
486 
487 
488 void
490  if (myCurrentStop != nullptr) {
491  myCurrentStop = nullptr;
492  } else {
493  throw InvalidArgument("Could not end a stopping place that is not opened.");
494  }
495 }
496 
497 
498 void
499 NLTriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos, const std::string& name,
500  double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay) {
501  MSChargingStation* chargingStation = new MSChargingStation(id, *lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
502  if (!net.addStoppingPlace(SUMO_TAG_CHARGING_STATION, chargingStation)) {
503  delete chargingStation;
504  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
505  }
506 }
507 
508 std::string
510  const std::string& base,
511  const bool allowEmpty) {
512  // get the file name to read further definitions from
513  bool ok = true;
514  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, nullptr, ok, "");
515  if (file == "") {
516  if (allowEmpty) {
517  return file;
518  }
519  throw InvalidArgument("No filename given.");
520  }
521  // check whether absolute or relative filenames are given
522  if (!FileHelpers::isAbsolute(file)) {
523  return FileHelpers::getConfigurationRelative(base, file);
524  }
525  return file;
526 }
527 
528 
529 MSLane*
531  const std::string& tt,
532  const std::string& tid) {
533  bool ok = true;
534  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANE, tid.c_str(), ok);
535  MSLane* lane = MSLane::dictionary(objectid);
536  if (lane == nullptr) {
537  throw InvalidArgument("The lane " + objectid + " to use within the " + tt + " '" + tid + "' is not known.");
538  }
539  return lane;
540 }
541 
542 
543 double
545  MSLane* lane,
546  const std::string& tt, const std::string& tid,
547  MSEdge* edge) {
548  assert(lane != 0 || edge != 0);
549  const double length = lane != nullptr ? lane->getLength() : edge->getLength();
550  bool ok = true;
551  double pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
552  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
553  if (!ok) {
554  throw InvalidArgument("Error on parsing a position information.");
555  }
556  if (pos < 0) {
557  pos = length + pos;
558  }
559  if (pos > length) {
560  if (friendlyPos) {
561  pos = length - (double) 0.1;
562  } else {
563  if (lane != nullptr) {
564  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane->getID() + "' length.");
565  } else {
566  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the edges's '" + edge->getID() + "' length.");
567  }
568  }
569  }
570  return pos;
571 }
572 
573 
574 /****************************************************************************/
void setHandler(NLHandler *handler)
Sets the parent handler to use for nested parsing.
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.
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)
Builds a stopping place.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:640
a routeprobe detector
long long int SUMOTime
Definition: SUMOTime.h:36
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
Definition: FileHelpers.cpp:75
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.
weights: time range begin
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:514
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:788
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:422
const std::string & getID() const
Returns the id.
Definition: Named.h:78
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
NLTriggerBuilder()
Constructor.
Base (microsim) event class.
Definition: Command.h:54
MSParkingArea * myParkingArea
definition of the currently parsed parking area
double getLength() const
return the length of the edge
Definition: MSEdge.h:568
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:429
void parseAndBeginParkingArea(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a parking area.
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)
builds a microscopic calibrator
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:863
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:241
The simulated network and simulation perfomer.
Definition: MSNet.h:84
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:75
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
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.
Definition: FileHelpers.cpp:90
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:409
A wrapper for a Command function.
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)
builds a mesoscopic calibrator
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.
#define POSITION_EPS
Definition: config.h:172
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:379
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:247
Reroutes vehicles passing an edge.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1730
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
Calibrates the flow on a segment to a specified one.
Definition: MSCalibrator.h:50
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:71
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.
static bool gUseMesoSim
Definition: MSGlobals.h:91
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
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".