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(0), myParkingArea(0), myCurrentStop(0) {}
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, 0, ok);
78  if (!ok) {
79  return;
80  }
81  MSEdge* e = MSEdge::dictionary(id);
82  if (e == 0) {
83  WRITE_ERROR("Unknown edge ('" + id + "') referenced in a vaporizer.");
84  return;
85  }
86  SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, 0, ok);
87  SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, 0, 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, 0, 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 == 0) {
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, 0, 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, 0, 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, 0, 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  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, 0);
243  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, 0);
244  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, 0);
245  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
246  if (!ok || !myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos)) {
247  throw InvalidArgument("Invalid position for parking area '" + id + "'.");
248  }
249  // get the lines
250  std::vector<std::string> lines;
251  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LINES, id.c_str(), ok, "", false), lines);
252  // build the parking area
253  beginParkingArea(net, id, lines, lane, frompos, topos, capacity, width, length, angle, name);
254 }
255 
256 
257 
258 void
260  bool ok = true;
261  // Check for open parking area
262  if (myParkingArea == 0) {
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, 0, ok);
289  if (!ok) {
290  throw ProcessError();
291  }
292  MSLane* lane = 0;
293  MSEdge* edge = 0;
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 == 0) {
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  std::string file = getFileName(attrs, base, true);
315  std::string outfile = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), ok, "");
316  std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), ok, "");
317  MSRouteProbe* probe = 0;
318  if (routeProbe != "") {
319  probe = dynamic_cast<MSRouteProbe*>(net.getDetectorControl().getTypedDetectors(SUMO_TAG_ROUTEPROBE).get(routeProbe));
320  if (probe == 0) {
321  throw InvalidArgument("The routeProbe '" + routeProbe + "' to use within the calibrator '" + id + "' is not known.");
322  }
323  }
325  if (lane != 0 && edge->getLanes().size() > 1) {
326  WRITE_WARNING("Meso calibrator '" + id
327  + "' defined for lane '" + lane->getID()
328  + "' will collect data for all lanes of edge '" + edge->getID() + "'.");
329  }
330  METriggeredCalibrator* trigger = buildMECalibrator(net, id, edge, pos, file, outfile, freq, probe);
331  if (file == "") {
332  trigger->registerParent(SUMO_TAG_CALIBRATOR, myHandler);
333  }
334  } else {
335  MSCalibrator* trigger = buildCalibrator(net, id, edge, lane, pos, file, outfile, freq, probe);
336  if (file == "") {
338  }
339  }
340 }
341 
342 
343 void
345  const std::string& base) {
346  bool ok = true;
347  // get the id, throw if not given or empty...
348  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
349  if (!ok) {
350  throw ProcessError();
351  }
352  // get the file name to read further definitions from
353  std::string file = getFileName(attrs, base, true);
354  std::string objectid = attrs.get<std::string>(SUMO_ATTR_EDGES, id.c_str(), ok);
355  if (!ok) {
356  throw InvalidArgument("The edge to use within MSTriggeredRerouter '" + id + "' is not known.");
357  }
358  MSEdgeVector edges;
359  std::vector<std::string> edgeIDs;
360  SUMOSAXAttributes::parseStringVector(objectid, edgeIDs);
361  for (std::vector<std::string>::iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
362  MSEdge* edge = MSEdge::dictionary(*i);
363  if (edge == 0) {
364  throw InvalidArgument("The edge '" + (*i) + "' to use within MSTriggeredRerouter '" + id + "' is not known.");
365  }
366  edges.push_back(edge);
367  }
368  if (edges.size() == 0) {
369  throw InvalidArgument("No edges found for MSTriggeredRerouter '" + id + "'.");
370  }
371  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), ok, 1);
372  bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, false);
373  SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
374  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
375  if (!ok) {
376  throw InvalidArgument("Could not parse MSTriggeredRerouter '" + id + "'.");
377  }
378  MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, file, off, timeThreshold, vTypes);
379  // read in the trigger description
380  if (file == "") {
382  } else if (!XMLSubSys::runParser(*trigger, file)) {
383  throw ProcessError();
384  }
385 }
386 
387 
388 // -------------------------
389 
390 
392 NLTriggerBuilder::buildLaneSpeedTrigger(MSNet& /*net*/, const std::string& id,
393  const std::vector<MSLane*>& destLanes,
394  const std::string& file) {
395  return new MSLaneSpeedTrigger(id, destLanes, file);
396 }
397 
398 
400 NLTriggerBuilder::buildMECalibrator(MSNet& /*net*/, const std::string& id,
401  const MSEdge* edge,
402  double pos,
403  const std::string& file,
404  const std::string& outfile,
405  const SUMOTime freq, MSRouteProbe* probe) {
406  return new METriggeredCalibrator(id, edge, pos, file, outfile, freq, MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)->getLength(), probe);
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, const MSRouteProbe* probe) {
418  return new MSCalibrator(id, edge, lane, pos, file, outfile, freq, edge->getLength(), probe);
419 }
420 
421 
423 NLTriggerBuilder::buildRerouter(MSNet&, const std::string& id,
424  MSEdgeVector& edges,
425  double prob, const std::string& file, bool off,
426  SUMOTime timeThreshold,
427  const std::string& vTypes) {
428  return new MSTriggeredRerouter(id, edges, prob, file, off, timeThreshold, vTypes);
429 }
430 
431 
432 void
433 NLTriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
434  double frompos, double topos, const SumoXMLTag element, std::string ptStopName) {
435  myCurrentStop = new MSStoppingPlace(id, lines, *lane, frompos, topos, ptStopName);
436  if (!net.addStoppingPlace(element, myCurrentStop)) {
437  delete myCurrentStop;
438  myCurrentStop = 0;
439  throw InvalidArgument("Could not build " + toString(element) + " '" + id + "'; probably declared twice.");
440  }
441 }
442 
443 
444 void
445 NLTriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
446  const std::vector<std::string>& lines,
447  MSLane* lane, double frompos, double topos,
448  unsigned int capacity,
449  double width, double length, double angle, const std::string& name) {
450  // Close previous parking area if there are not lots inside
451  MSParkingArea* stop = new MSParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle, name);
452  if (!net.addStoppingPlace(SUMO_TAG_PARKING_AREA, stop)) {
453  delete stop;
454  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
455  } else {
456  myParkingArea = stop;
457  }
458 }
459 
460 
461 void
462 NLTriggerBuilder::addLotEntry(double x, double y, double z,
463  double width, double length, double angle) {
464  if (myParkingArea != 0) {
465  myParkingArea->addLotEntry(x, y, z, width, length, angle);
466  } else {
467  throw InvalidArgument("Could not add lot entry outside a parking area.");
468  }
469 }
470 
471 
472 void
474  if (myParkingArea != 0) {
475  myParkingArea = 0;
476  } else {
477  throw InvalidArgument("Could not end a parking area that is not opened.");
478  }
479 }
480 
481 
482 void
484  if (myCurrentStop != 0) {
485  myCurrentStop = 0;
486  } else {
487  throw InvalidArgument("Could not end a stopping place that is not opened.");
488  }
489 }
490 
491 
492 void
493 NLTriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos, const std::string& name,
494  double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay) {
495  MSChargingStation* chargingStation = new MSChargingStation(id, *lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
496  if (!net.addStoppingPlace(SUMO_TAG_CHARGING_STATION, chargingStation)) {
497  delete chargingStation;
498  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
499  }
500 }
501 
502 std::string
504  const std::string& base,
505  const bool allowEmpty) {
506  // get the file name to read further definitions from
507  bool ok = true;
508  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, 0, ok, "");
509  if (file == "") {
510  if (allowEmpty) {
511  return file;
512  }
513  throw InvalidArgument("No filename given.");
514  }
515  // check whether absolute or relative filenames are given
516  if (!FileHelpers::isAbsolute(file)) {
517  return FileHelpers::getConfigurationRelative(base, file);
518  }
519  return file;
520 }
521 
522 
523 MSLane*
525  const std::string& tt,
526  const std::string& tid) {
527  bool ok = true;
528  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANE, tid.c_str(), ok);
529  MSLane* lane = MSLane::dictionary(objectid);
530  if (lane == 0) {
531  throw InvalidArgument("The lane " + objectid + " to use within the " + tt + " '" + tid + "' is not known.");
532  }
533  return lane;
534 }
535 
536 
537 double
539  MSLane* lane,
540  const std::string& tt, const std::string& tid,
541  MSEdge* edge) {
542  assert(lane != 0 || edge != 0);
543  const double length = lane != 0 ? lane->getLength() : edge->getLength();
544  bool ok = true;
545  double pos = attrs.get<double>(SUMO_ATTR_POSITION, 0, ok);
546  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
547  if (!ok) {
548  throw InvalidArgument("Error on parsing a position information.");
549  }
550  if (pos < 0) {
551  pos = length + pos;
552  }
553  if (pos > length) {
554  if (friendlyPos) {
555  pos = length - (double) 0.1;
556  } else {
557  if (lane != 0) {
558  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane->getID() + "' length.");
559  } else {
560  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the edges's '" + edge->getID() + "' length.");
561  }
562  }
563  }
564  return pos;
565 }
566 
567 
568 /****************************************************************************/
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:617
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.
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)
Begin a parking area.
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:160
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:507
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:742
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:373
const std::string & getID() const
Returns the id.
Definition: Named.h:69
#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:563
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:380
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:835
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:242
The simulated network and simulation perfomer.
Definition: MSNet.h:85
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:402
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.
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.
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:372
std::string getFileName(const SUMOSAXAttributes &attrs, const std::string &base, const bool allowEmpty=false)
Helper method to obtain the filename.
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:248
Reroutes vehicles passing an edge.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1708
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:71
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".