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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
23 // Builds trigger objects for microsim
24 /****************************************************************************/
25 #include <config.h>
26 
27 #include <string>
29 #include <microsim/MSLane.h>
30 #include <microsim/MSEdge.h>
31 #include <microsim/MSGlobals.h>
32 #include <microsim/MSParkingArea.h>
46 #include "NLHandler.h"
47 #include "NLTriggerBuilder.h"
49 #include <utils/xml/XMLSubSys.h>
50 
51 
52 #include <mesosim/MELoop.h>
54 
55 
56 // ===========================================================================
57 // method definitions
58 // ===========================================================================
60  : myHandler(nullptr), myParkingArea(nullptr), myCurrentStop(nullptr) {}
61 
62 
64 
65 void
67  myHandler = handler;
68 }
69 
70 
71 void
73  WRITE_WARNING("Vaporizers are deprecated. Use rerouters instead.");
74  bool ok = true;
75  // get the id, throw if not given or empty...
76  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
77  if (!ok) {
78  return;
79  }
80  MSEdge* e = MSEdge::dictionary(id);
81  if (e == nullptr) {
82  WRITE_ERROR("Unknown edge ('" + id + "') referenced in a vaporizer.");
83  return;
84  }
85  SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, ok);
86  SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, ok);
87  if (!ok) {
88  return;
89  }
90  if (begin < 0) {
91  WRITE_ERROR("A vaporization begin time is negative (edge id='" + id + "').");
92  return;
93  }
94  if (begin >= end) {
95  WRITE_ERROR("A vaporization ends before it starts (edge id='" + id + "').");
96  return;
97  }
98  if (end >= string2time(OptionsCont::getOptions().getString("begin"))) {
103  }
104 }
105 
106 
107 
108 void
110  const std::string& base) {
111  // get the id, throw if not given or empty...
112  bool ok = true;
113  // get the id, throw if not given or empty...
114  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
115  if (!ok) {
116  return;
117  }
118  // get the file name to read further definitions from
119  std::string file = getFileName(attrs, base, true);
120  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANES, id.c_str(), ok);
121  std::vector<MSLane*> lanes;
122  for (const std::string& laneID : attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), ok)) {
123  MSLane* lane = MSLane::dictionary(laneID);
124  if (lane == nullptr) {
125  throw InvalidArgument("The lane '" + laneID + "' to use within MSLaneSpeedTrigger '" + id + "' is not known.");
126  }
127  lanes.push_back(lane);
128  }
129  if (!ok) {
130  throw InvalidArgument("The lanes to use within MSLaneSpeedTrigger '" + id + "' are not known.");
131  }
132  if (lanes.size() == 0) {
133  throw InvalidArgument("No lane defined for MSLaneSpeedTrigger '" + id + "'.");
134  }
135  try {
136  MSLaneSpeedTrigger* trigger = buildLaneSpeedTrigger(net, id, lanes, file);
137  if (file == "") {
139  }
140  } catch (ProcessError& e) {
141  throw InvalidArgument(e.what());
142  }
143 }
144 
145 void
147  bool ok = true;
148 
149  // get the id, throw if not given or empty...
150  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
151  if (!ok) {
152  throw ProcessError();
153  }
154 
155  MSLane* const lane = getLane(attrs, "chargingStation", id);
156  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
157  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
158  const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), ok, 0);
159  const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), ok, 0);
160  const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), ok, 0);
161  const double chargeDelay = attrs.getOpt<double>(SUMO_ATTR_CHARGEDELAY, id.c_str(), ok, 0);
162  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
163  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
164 
165  if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
166  throw InvalidArgument("Invalid position for charging station '" + id + "'.");
167  }
168 
169  buildChargingStation(net, id, lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
170 }
171 
172 void
174  bool ok = true;
175 
176  // get the id, throw if not given or empty...
177  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
178  if (!ok) {
179  throw ProcessError();
180  }
181 
182  /* The following call may either throw InvalidArgument exeption or return NULL:
183  NULL is returned in case when the overhead wire segment should be built over an already
184  ignored internal lane of an intersection, the exeption is thrown in case that
185  the overhead wire segment references a non-existent lane. */
186  MSLane* const lane = getLane(attrs, "overheadWireSegment", id);
187  if (lane == nullptr) {
188  WRITE_MESSAGE("The overheadWireSegment '" + id + "' was not created as it is attached to internal lane. It will be build automatically.");
189  return;
190  }
191 
192  if (lane->isInternal()) {
193  WRITE_MESSAGE("The overheadWireSegment '" + id + "' not built as it is attached to internal lane. It will be build automatically.");
194  return;
195  }
196 
197  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
198  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
199  const bool voltageSource = attrs.getOpt<bool>(SUMO_ATTR_VOLTAGESOURCE, id.c_str(), ok, false);
200  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
201 
202  if (!ok || myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID) {
203  frompos = 0;
204  topos = lane->getLength();
205  WRITE_MESSAGE("The overheadWireSegment '" + id + "' has wrong position. Automatically set from 0 to the length of the lane.");
206  //throw InvalidArgument("Invalid position for overheadWireSegment'" + id + "'.");
207  }
208 
209  buildOverheadWireSegment(net, id, lane, frompos, topos, voltageSource);
210 #ifndef HAVE_EIGEN
212  myHaveWarnedAboutEigen = true;
213  WRITE_WARNING("Overhead wire solver (Eigen) not compiled in, expect errors in overhead wire simulation")
214  }
215 #endif // !HAVE_EIGEN
216 }
217 
218 void
220  bool ok = true;
221  std::string substationId = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, 0, ok);
222  if (!ok) {
223  throw ProcessError();
224  }
225 
226  MSTractionSubstation* substation = MSNet::getInstance()->findTractionSubstation(substationId);
227  if (substation == nullptr) {
228  throw InvalidArgument("Traction substation '" + substationId + "' refereced by an OverheadWire Section is not known.");
229  } else if (substation->isAnySectionPreviouslyDefined()) {
230  throw InvalidArgument("Traction substation '" + substationId + "' refereced by an OverheadWire Section is probably referenced twice (a known limitation of the actual version of overhead wire simulation).");
231  }
232 
233  // @todo This may be a relict of older approach to processing the attributes ...
234  std::string segmentStrings = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SECTION, substationId.c_str(), ok);
235  if (!ok) {
236  throw InvalidArgument("Segments referenced by Traction Substation '" + substationId + "' are not declared .");
237  }
238 
239  // process forbidden internal lanes
241  std::string forbiddenInnerLanesStrings = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, 0, ok, "");
242  if (forbiddenInnerLanesStrings != "") {
243  std::vector<std::string> forbiddenInnerLanesIDs = attrs.getStringVector(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN);
245  for (std::vector<std::string>::iterator i = forbiddenInnerLanesIDs.begin(); i != forbiddenInnerLanesIDs.end(); ++i) {
246  MSLane* lane = MSLane::dictionary(*i);
247  if (lane != nullptr) {
248  substation->addForbiddenLane(lane);
249  }
250  }
251  }
252 
253 
254  // @todo Check this as well ...
255  // Original version from 2018
256  // std::vector<std::string> segmentIDs;
257  // SUMOSAXAttributes::parseStringVector(segmentStrings, segmentIDs);
258  std::vector<std::string> segmentIDs = attrs.getStringVector(SUMO_ATTR_OVERHEAD_WIRE_SECTION);
259  std::vector<MSOverheadWire*> segments;
260 
261  // ----------------------------------------------
262  // Add overhead wire segments over internal lanes
263  // ----------------------------------------------
264 
265  // Adding internal overhead wire segments (segments on neighboring inner lanes if a connection between two regular lane with overhead wire segment exists)
266  for (std::vector<std::string>::iterator it_segment = segmentIDs.begin(); it_segment != segmentIDs.end(); ++it_segment) {
267 
268  const MSLane* connection = nullptr;
270  std::string neigboringOvrhdSegmentID;
271  MSOverheadWire* neigboringOvrhdSegment;
272  MSTractionSubstation* neigboringOvrhdSegmentTractionSubstation;
273  if (ovrhdSegment == nullptr) {
274  throw InvalidArgument("The OverheadWireSegment with id='" + (*it_segment) + "' referenced by OverheadWireSgment for substation '" + substationId + "' was not defined.");
275  }
276 
277  MSTractionSubstation* ts = ovrhdSegment->getTractionSubstation();
278  if (!(ts == substation || ts == nullptr)) {
279  std::string tsName = ts->getID();
280  throw InvalidArgument("The OverheadWireSegment '" + (*it_segment) + "' referenced by OverheadWireSgment for substation '" + substationId + "' is already assigned to substation '" + tsName + "'.");
281  }
282  ovrhdSegment->setTractionSubstation(substation);
283 
284  const MSLane* lane = &(ovrhdSegment->getLane());
285 
286  /* in version before SUMO 1.0.1 the function getOutgoingLanes() returning MSLane* exists,
287  in new version of SUMO the funciton getOutgoingViaLanes() returning MSLane* and MSEdge* pair exists */
288  const std::vector<std::pair<const MSLane*, const MSEdge*> > outgoingLanesAndEdges = lane->getOutgoingViaLanes();
289  std::vector<const MSLane*> neigboringInnerLanes;
290  neigboringInnerLanes.reserve(outgoingLanesAndEdges.size());
291  for (size_t it = 0; it < outgoingLanesAndEdges.size(); ++it) {
292  neigboringInnerLanes.push_back(outgoingLanesAndEdges[it].first);
293  }
294 
295  // Check if an outgoing lane has an overhead wire segment. If not, do nothing, otherwise find connnecting internal lanes and
296  // add overhead wire segments over all detected internal lanes
297  for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
298  // If the overhead wire segment is over the outgoing (not internal) lane
299  neigboringOvrhdSegmentID = MSNet::getInstance()->getStoppingPlaceID(*it, NUMERICAL_EPS, SUMO_TAG_OVERHEAD_WIRE_SEGMENT);
300  if (neigboringOvrhdSegmentID != "") {
301  neigboringOvrhdSegment = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(neigboringOvrhdSegmentID, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
302  neigboringOvrhdSegmentTractionSubstation = neigboringOvrhdSegment->getTractionSubstation();
303  } else {
304  neigboringOvrhdSegment = nullptr;
305  neigboringOvrhdSegmentTractionSubstation = nullptr;
306  }
307 
308  if (neigboringOvrhdSegmentTractionSubstation == substation && !(*it)->isInternal()) {
309  connection = lane->getInternalFollowingLane(*it);
310  if (connection != nullptr) {
311  //is connection forbidden?
312  if (!(substation->isForbidden(connection) || substation->isForbidden(lane->getInternalFollowingLane(connection)) || substation->isForbidden(connection->getInternalFollowingLane(*it)))) {
313  buildInnerOverheadWireSegments(net, connection, lane->getInternalFollowingLane(connection), connection->getInternalFollowingLane(*it));
314  }
315  }
316  }
317  }
318 
319  // Check if an incoming lane has an overhead wire segment. If not, do nothing, otherwise find connnecting internal lanes and
320  // add overhead wire segments over all detected internal lanes
321  neigboringInnerLanes = lane->getNormalIncomingLanes();
322  for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
323  // If the overhead wire segment is over the incoming (not internal) lane
324  neigboringOvrhdSegmentID = MSNet::getInstance()->getStoppingPlaceID(*it, (*it)->getLength() - NUMERICAL_EPS, SUMO_TAG_OVERHEAD_WIRE_SEGMENT);
325  if (neigboringOvrhdSegmentID != "") {
326  neigboringOvrhdSegment = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(neigboringOvrhdSegmentID, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
327  neigboringOvrhdSegmentTractionSubstation = neigboringOvrhdSegment->getTractionSubstation();
328  } else {
329  neigboringOvrhdSegment = nullptr;
330  neigboringOvrhdSegmentTractionSubstation = nullptr;
331  }
332 
333  if (neigboringOvrhdSegmentTractionSubstation == substation && !(*it)->isInternal()) {
334  connection = (*it)->getInternalFollowingLane(lane);
335  if (connection != nullptr) {
336  //is connection forbidden?
337  if (!(substation->isForbidden(connection) || substation->isForbidden((*it)->getInternalFollowingLane(connection)) || substation->isForbidden(connection->getInternalFollowingLane(lane)))) {
338  buildInnerOverheadWireSegments(net, connection, (*it)->getInternalFollowingLane(connection), connection->getInternalFollowingLane(lane));
339  }
340  }
341  }
342  }
343  }
344 
345 
346  // ----- *** adding segments into the electric circuit*** -----
347 
348  // setting nullptr for substation (a fragment from old version of adding segments into the circuit)
349  for (std::vector<std::string>::iterator it_segment = segmentIDs.begin(); it_segment != segmentIDs.end(); ++it_segment) {
351  ovrhdSegment->setTractionSubstation(nullptr);
352  }
353 
354  for (std::vector<std::string>::iterator it_segment = segmentIDs.begin(); it_segment != segmentIDs.end(); ++it_segment) {
355  if (*it_segment == "") {
356  continue;
357  }
359  substation->addOverheadWireSegmentToCircuit(ovrhdSegment);
360  segments.push_back(ovrhdSegment);
361  }
362 
363  // adding overhead wire clamp
364  std::string clampsString = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_CLAMPS, 0, ok, "");
365  if (clampsString != "" && MSGlobals::gOverheadWireSolver) {
366 #ifdef HAVE_EIGEN
367  std::vector<std::string> clampIDs = attrs.getStringVector(SUMO_ATTR_OVERHEAD_WIRE_CLAMPS);
369  for (std::vector<std::string>::iterator it_clamp = clampIDs.begin(); it_clamp != clampIDs.end(); ++it_clamp) {
370  clamp = substation->findClamp(*it_clamp);
371  if (clamp != nullptr) {
372  if (clamp->start->getTractionSubstation() == substation && clamp->end->getTractionSubstation() == substation) {
373  substation->addOverheadWireClampToCircuit(clamp->id, clamp->start, clamp->end);
374  buildOverheadWireClamp(net, clamp->id, const_cast<MSLane*>(&clamp->start->getLane()), const_cast<MSLane*>(&clamp->end->getLane()));
375  clamp->usage = true;
376  } else {
377  if (clamp->start->getTractionSubstation() != substation) {
378  WRITE_WARNING("A connecting overhead wire start segment '" + clamp->start->getID() + "' defined for overhead wire clamp '" + (*it_clamp) + "' is not assigned to the traction substation '" + substationId + "'.");
379  } else {
380  WRITE_WARNING("A connecting overhead wire end segment '" + clamp->end->getID() + "' defined for overhead wire clamp '" + (*it_clamp) + "' is not assigned to the traction substation '" + substationId + "'.");
381  }
382  }
383  } else {
384  WRITE_WARNING("The overhead wire clamp '" + (*it_clamp) + "' defined in an overhead wire section was not assigned to the substation '" + substationId + "'. Please define proper <overheadWireClamp .../> in additional files before defining overhead wire section.");
385  }
386  }
387 #else
388  WRITE_WARNING("Overhead circuit solver requested, but solver support (Eigen) not compiled in.");
389 #endif
390  }
391 
392  if (segments.size() == 0) {
393  throw InvalidArgument("No segments found for overHeadWireSection '" + substationId + "'.");
394  } else if (MSGlobals::gOverheadWireSolver) {
395 #ifdef HAVE_EIGEN
396  // check that the electric circuit makes sense
397  segments[0]->getCircuit()->checkCircuit(substationId);
398 #else
399  WRITE_WARNING("Cannot check circuit, overhead circuit solver support (Eigen) not compiled in.");
400 #endif
401  }
402 }
403 
404 void
406  bool ok = true;
407 
408  // get the id, throw if not given or empty...
409  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
410  if (!ok) {
411  throw ProcessError();
412  }
413 
414  const double voltage = attrs.getOpt<double>(SUMO_ATTR_VOLTAGE, id.c_str(), ok, 600);
415  buildTractionSubstation(net, id, voltage);
416 }
417 
418 void
421 #ifdef HAVE_EIGEN
422  bool ok = true;
423  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
424  if (!ok) {
425  throw ProcessError();
426  }
427 
428  std::string substationId = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, 0, ok);
429  if (!ok) {
430  throw ProcessError();
431  }
432  MSTractionSubstation* substation = MSNet::getInstance()->findTractionSubstation(substationId);
433  if (substation == nullptr) {
434  throw InvalidArgument("Traction substation '" + substationId + "' using within an overheadWireClamp '" + id + "' is not known.");
435  }
436 
437  std::string overhead_fromItsStart = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRE_CLAMP_START, 0, ok);
438  if (!ok) {
439  throw ProcessError();
440  }
441  MSOverheadWire* ovrhdSegment_fromItsStart = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(overhead_fromItsStart, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
442  if (ovrhdSegment_fromItsStart == nullptr) {
443  throw InvalidArgument("The overheadWireSegment '" + overhead_fromItsStart + "' to use within overheadWireClamp '" + id + "' is not known.");
444  }
445  /*if (ovrhdSegment_fromItsStart->getTractionSubstation() != substation) {
446  throw InvalidArgument("The overheadWireSegment '" + overhead_fromItsStart + "' to use within overheadWireClamp is assign to a different overhead wire section or substation.");
447  }
448  */
449  std::string overhead_fromItsEnd = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRE_CLAMP_END, 0, ok);
450  if (!ok) {
451  throw ProcessError();
452  }
453  MSOverheadWire* ovrhdSegment_fromItsEnd = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(overhead_fromItsEnd, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
454  if (ovrhdSegment_fromItsEnd == nullptr) {
455  throw InvalidArgument("The overheadWireSegment '" + overhead_fromItsEnd + "' to use within overheadWireClamp '" + id + "' is not known.");
456  }
457  /*
458  if (ovrhdSegment_fromItsEnd->getTractionSubstation() != substation) {
459  throw InvalidArgument("The overheadWireSegment '" + overhead_fromItsEnd + "' to use within overheadWireClamp is assign to a different overhead wire section or substation.");
460  }
461  */
462  if (substation->findClamp(id) == nullptr) {
463  substation->addClamp(id, ovrhdSegment_fromItsStart, ovrhdSegment_fromItsEnd);
464  } else {
465  WRITE_ERROR("The overhead wire clamp '" + id + "' is probably declared twice.")
466  }
467 #else
468  UNUSED_PARAMETER(attrs);
469  WRITE_WARNING("Not building overhead wire clamps, overhead wire solver support (Eigen) not compiled in.");
470 #endif
471  } else {
472  WRITE_WARNING("Ignoring overhead wire clamps, they make no sense when overhead wire circuit solver is off.");
473  }
474 }
475 
476 
477 void
479  bool ok = true;
480  // get the id, throw if not given or empty...
481  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
482  if (!ok) {
483  throw ProcessError();
484  }
485 
486  //get the name, leave blank if not given
487  const std::string ptStopName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
488 
489  MSLane* lane = getLane(attrs, toString(element), id);
490  // get the positions
491  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
492  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
493  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
494  if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
495  throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
496  }
497  const std::vector<std::string>& lines = attrs.getOptStringVector(SUMO_ATTR_LINES, id.c_str(), ok, false);
498  const int defaultCapacity = MAX2(MSStoppingPlace::getPersonsAbreast(topos - frompos) * 3, 6);
499  const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), ok, defaultCapacity);
500  const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), ok, 0);
501  // build the bus stop
502  buildStoppingPlace(net, id, lines, lane, frompos, topos, element, ptStopName, personCapacity, parkingLength);
503 }
504 
505 
506 void
508  if (myCurrentStop == nullptr) {
509  throw InvalidArgument("Could not add access outside a stopping place.");
510  }
511  // get the lane
512  MSLane* lane = getLane(attrs, "access", myCurrentStop->getID());
513  if (!lane->allowsVehicleClass(SVC_PEDESTRIAN)) {
514  WRITE_WARNING("Ignoring invalid access from non-pedestrian lane '" + lane->getID() + "' in busStop '" + myCurrentStop->getID() + "'.");
515  return;
516  }
517  // get the positions
518  bool ok = true;
519  double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0);
520  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
521  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
522  if (!ok || (myHandler->checkStopPos(pos, pos, lane->getLength(), 0, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
523  throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane->getID() + "' in stop '" + myCurrentStop->getID() + "'.");
524  }
525  // add bus stop access
526  if (!myCurrentStop->addAccess(lane, pos, length)) {
527  throw InvalidArgument("Duplicate access on lane '" + lane->getID() + "' for stop '" + myCurrentStop->getID() + "'");
528  }
529 }
530 
531 
532 void
534  bool ok = true;
535  // get the id, throw if not given or empty...
536  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
537  if (!ok) {
538  throw ProcessError();
539  }
540  // get the lane
541  MSLane* lane = getLane(attrs, "parkingArea", id);
542  // get the positions
543  double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
544  double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
545  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
546  unsigned int capacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), ok, 0);
547  bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), ok, false);
548  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, 0);
549  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, 0);
550  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, 0);
551  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
552  if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
553  throw InvalidArgument("Invalid position for parking area '" + id + "'.");
554  }
555  const std::vector<std::string>& lines = attrs.getOptStringVector(SUMO_ATTR_LINES, id.c_str(), ok, false);
556  // build the parking area
557  beginParkingArea(net, id, lines, lane, frompos, topos, capacity, width, length, angle, name, onRoad);
558 }
559 
560 
561 
562 void
564  bool ok = true;
565  // Check for open parking area
566  if (myParkingArea == nullptr) {
567  throw ProcessError();
568  }
569  // get the positions
570  double x = attrs.get<double>(SUMO_ATTR_X, "", ok);
571  if (!ok) {
572  throw InvalidArgument("Invalid x position for lot entry.");
573  }
574  double y = attrs.get<double>(SUMO_ATTR_Y, "", ok);
575  if (!ok) {
576  throw InvalidArgument("Invalid y position for lot entry.");
577  }
578  double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", ok, 0.);
579  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, "", ok, myParkingArea->getWidth());
580  double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", ok, myParkingArea->getLength());
581  double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, "", ok, myParkingArea->getAngle());
582  // add the lot entry
583  addLotEntry(x, y, z, width, length, angle);
584 }
585 
586 
587 void
589  const std::string& base) {
590  bool ok = true;
591  // get the id, throw if not given or empty...
592  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
593  if (!ok) {
594  throw ProcessError();
595  }
596  MSLane* lane = nullptr;
597  MSEdge* edge = nullptr;
598  // get the file name to read further definitions from
599  if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
600  std::string edgeID = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
601  edge = MSEdge::dictionary(edgeID);
602  if (edge == nullptr) {
603  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id + "' is not known.");
604  }
605  if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
606  lane = getLane(attrs, "calibrator", id);
607  if (&lane->getEdge() != edge) {
608  throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id
609  + "' does not match the calibrator lane '" + lane->getID() + ".");
610  }
611  }
612  } else {
613  lane = getLane(attrs, "calibrator", id);
614  edge = &lane->getEdge();
615  }
616  const double pos = getPosition(attrs, lane, "calibrator", id, edge);
617  const SUMOTime freq = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, DELTA_T); // !!! no error handling
618  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
619  std::string file = getFileName(attrs, base, true);
620  std::string outfile = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), ok, "");
621  std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), ok, "");
622  // differing defaults for backward compatibility, values are dimensionless
623  double invalidJamThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, MSGlobals::gUseMesoSim ? 0.8 : 0.5);
624  MSRouteProbe* probe = nullptr;
625  if (routeProbe != "") {
626  probe = dynamic_cast<MSRouteProbe*>(net.getDetectorControl().getTypedDetectors(SUMO_TAG_ROUTEPROBE).get(routeProbe));
627  if (probe == nullptr) {
628  throw InvalidArgument("The routeProbe '" + routeProbe + "' to use within the calibrator '" + id + "' is not known.");
629  }
630  }
632  if (lane != nullptr && edge->getLanes().size() > 1) {
633  WRITE_WARNING("Meso calibrator '" + id
634  + "' defined for lane '" + lane->getID()
635  + "' will collect data for all lanes of edge '" + edge->getID() + "'.");
636  }
637  METriggeredCalibrator* trigger = buildMECalibrator(net, id, edge, pos, file, outfile, freq, probe, invalidJamThreshold, vTypes);
638  if (file == "") {
640  }
641  } else {
642  MSCalibrator* trigger = buildCalibrator(net, id, edge, lane, pos, file, outfile, freq, probe, invalidJamThreshold, vTypes);
643  if (file == "") {
645  }
646  }
647 }
648 
649 
650 void
652  const std::string& base) {
653  bool ok = true;
654  // get the id, throw if not given or empty...
655  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
656  if (!ok) {
657  throw ProcessError();
658  }
659  // get the file name to read further definitions from
660  std::string file = getFileName(attrs, base, true);
661  MSEdgeVector edges;
662  for (const std::string& edgeID : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), ok)) {
663  MSEdge* edge = MSEdge::dictionary(edgeID);
664  if (edge == nullptr) {
665  throw InvalidArgument("The edge '" + edgeID + "' to use within MSTriggeredRerouter '" + id + "' is not known.");
666  }
667  edges.push_back(edge);
668  }
669  if (!ok) {
670  throw InvalidArgument("The edge to use within MSTriggeredRerouter '" + id + "' is not known.");
671  }
672  if (edges.size() == 0) {
673  throw InvalidArgument("No edges found for MSTriggeredRerouter '" + id + "'.");
674  }
675  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), ok, 1);
676  bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, false);
677  SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
678  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
679  if (!ok) {
680  throw InvalidArgument("Could not parse MSTriggeredRerouter '" + id + "'.");
681  }
682  MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, file, off, timeThreshold, vTypes);
683  // read in the trigger description
684  if (file == "") {
686  } else if (!XMLSubSys::runParser(*trigger, file)) {
687  throw ProcessError();
688  }
689 }
690 
691 
692 // -------------------------
693 
694 
696 NLTriggerBuilder::buildLaneSpeedTrigger(MSNet& /*net*/, const std::string& id,
697  const std::vector<MSLane*>& destLanes,
698  const std::string& file) {
699  return new MSLaneSpeedTrigger(id, destLanes, file);
700 }
701 
702 
704 NLTriggerBuilder::buildMECalibrator(MSNet& /*net*/, const std::string& id,
705  const MSEdge* edge,
706  double pos,
707  const std::string& file,
708  const std::string& outfile,
709  const SUMOTime freq,
710  MSRouteProbe* probe,
711  const double invalidJamThreshold,
712  const std::string& vTypes) {
713  return new METriggeredCalibrator(id, edge, pos, file, outfile, freq, MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)->getLength(), probe, invalidJamThreshold, vTypes);
714 }
715 
716 
718 NLTriggerBuilder::buildCalibrator(MSNet& /*net*/, const std::string& id,
719  MSEdge* edge,
720  MSLane* lane,
721  double pos,
722  const std::string& file,
723  const std::string& outfile,
724  const SUMOTime freq,
725  const MSRouteProbe* probe,
726  const double invalidJamThreshold,
727  const std::string& vTypes) {
728  return new MSCalibrator(id, edge, lane, pos, file, outfile, freq, edge->getLength(), probe, invalidJamThreshold, vTypes);
729 }
730 
731 
733 NLTriggerBuilder::buildRerouter(MSNet&, const std::string& id,
734  MSEdgeVector& edges,
735  double prob, const std::string& file, bool off,
736  SUMOTime timeThreshold,
737  const std::string& vTypes) {
738  return new MSTriggeredRerouter(id, edges, prob, file, off, timeThreshold, vTypes);
739 }
740 
741 
742 void
743 NLTriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
744  double frompos, double topos, const SumoXMLTag element, std::string ptStopName, int personCapacity, double parkingLength) {
745  myCurrentStop = new MSStoppingPlace(id, lines, *lane, frompos, topos, ptStopName, personCapacity, parkingLength);
746  if (!net.addStoppingPlace(element, myCurrentStop)) {
747  delete myCurrentStop;
748  myCurrentStop = nullptr;
749  throw InvalidArgument("Could not build " + toString(element) + " '" + id + "'; probably declared twice.");
750  }
751 }
752 
753 
754 void
755 NLTriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
756  const std::vector<std::string>& lines,
757  MSLane* lane, double frompos, double topos,
758  unsigned int capacity,
759  double width, double length, double angle, const std::string& name,
760  bool onRoad) {
761  // Close previous parking area if there are not lots inside
762  MSParkingArea* stop = new MSParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle, name, onRoad);
763  if (!net.addStoppingPlace(SUMO_TAG_PARKING_AREA, stop)) {
764  delete stop;
765  throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
766  } else {
767  myParkingArea = stop;
768  }
769 }
770 
771 
772 void
773 NLTriggerBuilder::addLotEntry(double x, double y, double z,
774  double width, double length, double angle) {
775  if (myParkingArea != nullptr) {
776  if (!myParkingArea->parkOnRoad()) {
777  myParkingArea->addLotEntry(x, y, z, width, length, angle);
778  } else {
779  throw InvalidArgument("Cannot not add lot entry to on-road parking area.");
780  }
781  } else {
782  throw InvalidArgument("Could not add lot entry outside a parking area.");
783  }
784 }
785 
786 
787 void
789  if (myParkingArea != nullptr) {
790  myParkingArea = nullptr;
791  } else {
792  throw InvalidArgument("Could not end a parking area that is not opened.");
793  }
794 }
795 
796 
797 void
799  if (myCurrentStop != nullptr) {
800  myCurrentStop = nullptr;
801  } else {
802  throw InvalidArgument("Could not end a stopping place that is not opened.");
803  }
804 }
805 
806 
807 void
808 NLTriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos, const std::string& name,
809  double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay) {
810  MSChargingStation* chargingStation = new MSChargingStation(id, *lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
811  if (!net.addStoppingPlace(SUMO_TAG_CHARGING_STATION, chargingStation)) {
812  delete chargingStation;
813  throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
814  }
815  myCurrentStop = chargingStation;
816 }
817 
818 void
819 NLTriggerBuilder::buildOverheadWireSegment(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos,
820  bool voltageSource) {
821  MSOverheadWire* overheadWireSegment = new MSOverheadWire(id, *lane, frompos, topos, voltageSource);
822  if (!net.addStoppingPlace(SUMO_TAG_OVERHEAD_WIRE_SEGMENT, overheadWireSegment)) {
823  delete overheadWireSegment;
824  throw InvalidArgument("Could not build overheadWireSegment '" + id + "'; probably declared twice.");
825  }
826 }
827 
828 void
829 NLTriggerBuilder::buildInnerOverheadWireSegments(MSNet& net, const MSLane* connection, const MSLane* frontConnection, const MSLane* behindConnection) {
830  if (frontConnection == NULL && behindConnection == NULL) {
831  buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
832  } else if (frontConnection != NULL && behindConnection == NULL) {
833  buildOverheadWireSegment(net, "ovrhd_inner_" + frontConnection->getID(), const_cast<MSLane*>(frontConnection), 0, frontConnection->getLength(), false);
834  buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
835  } else if (frontConnection == NULL && behindConnection != NULL) {
836  buildOverheadWireSegment(net, "ovrhd_inner_" + behindConnection->getID(), const_cast<MSLane*>(behindConnection), 0, behindConnection->getLength(), false);
837  buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
838  } else if (frontConnection != NULL && behindConnection != NULL) {
839  buildOverheadWireSegment(net, "ovrhd_inner_" + frontConnection->getID(), const_cast<MSLane*>(frontConnection), 0, frontConnection->getLength(), false);
840  buildOverheadWireSegment(net, "ovrhd_inner_" + behindConnection->getID(), const_cast<MSLane*>(behindConnection), 0, behindConnection->getLength(), false);
841  buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
842  }
843 }
844 
845 void
846 NLTriggerBuilder::buildTractionSubstation(MSNet& net, std::string id, double voltage) {
847  MSTractionSubstation* myTractionSubstation = new MSTractionSubstation(id, voltage);
848  if (!net.addTractionSubstation(myTractionSubstation)) {
849  delete myTractionSubstation;
850  throw InvalidArgument("Could not build traction substation '" + id + "'; probably declared twice.");
851  }
852 }
853 
854 void
855 NLTriggerBuilder::buildOverheadWireClamp(MSNet& /*net*/, const std::string& /*id*/, MSLane* /*lane_start*/, MSLane* /*lane_end*/) {
856 }
857 
858 std::string
860  const std::string& base,
861  const bool allowEmpty) {
862  // get the file name to read further definitions from
863  bool ok = true;
864  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, nullptr, ok, "");
865  if (file == "") {
866  if (allowEmpty) {
867  return file;
868  }
869  throw InvalidArgument("No filename given.");
870  }
871  // check whether absolute or relative filenames are given
872  if (!FileHelpers::isAbsolute(file)) {
873  return FileHelpers::getConfigurationRelative(base, file);
874  }
875  return file;
876 }
877 
878 
879 MSLane*
881  const std::string& tt,
882  const std::string& tid) {
883  bool ok = true;
884  std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANE, tid.c_str(), ok);
885  MSLane* lane = MSLane::dictionary(objectid);
886  if (lane == nullptr) {
887  // Either a lane that is non-existent/broken, or a lane that is internal and has been ignored.
888  // We assume that internal lane names start with ':'.
889  if (objectid[0] == ':' && !MSGlobals::gUsingInternalLanes) {
890  return nullptr;
891  }
892  // Throw the exception only in case that the lane really does not exist in the network file
893  // or it is broken.
894  throw InvalidArgument("The lane " + objectid + " to use within the " + tt + " '" + tid + "' is not known.");
895  }
896  return lane;
897 }
898 
899 
900 double
902  MSLane* lane,
903  const std::string& tt, const std::string& tid,
904  MSEdge* edge) {
905  assert(lane != 0 || edge != 0);
906  const double length = lane != nullptr ? lane->getLength() : edge->getLength();
907  bool ok = true;
908  double pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
909  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
910  if (!ok) {
911  throw InvalidArgument("Error on parsing a position information.");
912  }
913  if (pos < 0) {
914  pos = length + pos;
915  }
916  if (pos > length) {
917  if (friendlyPos) {
918  pos = length - (double) 0.1;
919  } else {
920  if (lane != nullptr) {
921  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane->getID() + "' length.");
922  } else {
923  throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the edges's '" + edge->getID() + "' length.");
924  }
925  }
926  }
927  return pos;
928 }
929 
932  return myParkingArea == nullptr ? myCurrentStop : myParkingArea;
933 }
934 
935 
936 /****************************************************************************/
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LINES
@ SUMO_ATTR_LANE
@ SUMO_ATTR_OVERHEAD_WIRE_SECTION
@ SUMO_ATTR_FILE
@ SUMO_ATTR_Y
@ SUMO_ATTR_SUBSTATIONID
id of a traction substation substation
@ SUMO_ATTR_Z
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ SUMO_ATTR_X
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_OFF
@ SUMO_ATTR_ROUTEPROBE
@ SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN
forbidden lanes for overhead wire segment
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_OVERHEAD_WIRE_CLAMP_END
id of the overhead wire segment, to the end of which the overhead wire clamp is connected
@ SUMO_ATTR_LANES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_CHARGEINTRANSIT
Allow/disallow charge in transit in Charging Stations.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_FREQUENCY
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_OVERHEAD_WIRE_CLAMPS
overhead wire clamps for overhead wire segment
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ SUMO_ATTR_OUTPUT
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_PROB
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_ONROAD
@ SUMO_ATTR_OVERHEAD_WIRE_CLAMP_START
id of the overhead wire segment, to the start of which the overhead wire clamp is connected
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_EFFICIENCY
Eficiency of the charge in Charging Stations.
@ SUMO_ATTR_ID
@ SUMO_ATTR_VOLTAGESOURCE
a voltage source on the overhead wire segment [bool]
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MAX2(T a, T b)
Definition: StdDefs.h:79
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
Base (microsim) event class.
Definition: Command.h:49
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
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 registerParent(const int tag, GenericSAXHandler *handler)
Assigning a parent handler which is enabled when the specified tag is closed.
Calibrates the flow on a segment to a specified one.
Calibrates the flow on a segment to a specified one.
Definition: MSCalibrator.h:48
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
A road/street connecting two junctions.
Definition: MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:405
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
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....
Definition: MSEdge.cpp:814
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:398
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gUseMesoSim
Definition: MSGlobals.h:88
static bool gOverheadWireSolver
Definition: MSGlobals.h:103
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:94
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:66
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
Definition: MSLane.cpp:2140
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:812
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2644
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1908
bool isInternal() const
Definition: MSLane.cpp:2036
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:2654
Changes the speed allowed on a set of lanes.
The simulated network and simulation perfomer.
Definition: MSNet.h:89
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:1082
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:434
bool addTractionSubstation(MSTractionSubstation *substation)
Adds a traction substation.
Definition: MSNet.cpp:1088
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition: MSNet.cpp:1107
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1098
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:464
MSTractionSubstation * findTractionSubstation(const std::string &substationId)
find electrical substation by its id
Definition: MSNet.cpp:1177
Definition of overhead wire segment.
MSTractionSubstation * getTractionSubstation() const
void setTractionSubstation(MSTractionSubstation *substation)
A lane area vehicles can halt at.
Definition: MSParkingArea.h:57
double getAngle() const
Returns the lot rectangle angle.
double getLength() const
Returns the lot rectangle length.
double getWidth() const
Returns the lot rectangle width.
bool parkOnRoad() const
whether vehicles park on the road
Definition: MSParkingArea.h:90
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle)
Add a lot entry to parking area.
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:58
A lane area vehicles can halt at.
int getPersonsAbreast() const
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
void addOverheadWireClampToCircuit(const std::string id, MSOverheadWire *startSegment, MSOverheadWire *endSegment)
void addClamp(const std::string &id, MSOverheadWire *startPos, MSOverheadWire *endPos)
bool isForbidden(const MSLane *lane)
void addOverheadWireSegmentToCircuit(MSOverheadWire *newOverheadWireSegment)
OverheadWireClamp * findClamp(std::string id)
void addForbiddenLane(MSLane *lane)
Reroutes vehicles passing an edge.
The XML-Handler for network loading.
Definition: NLHandler.h:79
NLTriggerBuilder()
Constructor.
virtual void buildOverheadWireClamp(MSNet &net, const std::string &id, MSLane *lane_start, MSLane *lane_end)
MSParkingArea * myParkingArea
definition of the currently parsed parking area
void parseAndBuildTractionSubstation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds a traction substation.
void addAccess(MSNet &net, const SUMOSAXAttributes &attrs)
Parses the values and adds an access point to the currently parsed stopping place.
void parseAndBuildOverheadWireSegment(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire segment.
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
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
void buildInnerOverheadWireSegments(MSNet &net, const MSLane *connection, const MSLane *frontConnection, const MSLane *behindConnection)
Builds an overhead wire inner segments.
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.
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
Builds a lane speed trigger.
virtual void endParkingArea()
End a parking area.
void parseAndBuildLaneSpeedTrigger(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a lane speed trigger.
void parseAndAddLotEntry(const SUMOSAXAttributes &attrs)
Parses his values and adds a lot entry to current parking area.
NLHandler * myHandler
The parent handler to set for subhandlers.
void buildTractionSubstation(MSNet &net, std::string id, double voltage)
Builds a traction substation.
MSLane * getLane(const SUMOSAXAttributes &attrs, const std::string &tt, const std::string &tid)
Returns the lane defined by attribute "lane".
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
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
void parseAndBuildOverheadWireSection(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire section.
void setHandler(NLHandler *handler)
Sets the parent handler to use for nested parsing.
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 double invalidJamThreshold, const std::string &vTypes)
builds a microscopic calibrator
virtual ~NLTriggerBuilder()
Destructor.
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 parseAndBuildChargingStation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a charging station.
void parseAndBuildOverheadWireClamp(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire clamp.
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a rerouter.
virtual void endStoppingPlace()
End a stopping place.
virtual void buildOverheadWireSegment(MSNet &net, const std::string &id, MSLane *lane, double frompos, double topos, bool voltageSource)
Builds an overhead wire segment.
MSStoppingPlace * myCurrentStop
The currently parsed stop to add access points to.
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, double parkingLength)
Builds a stopping place.
MSStoppingPlace * getCurrentStop()
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 double invalidJamThreshold, const std::string &vTypes)
builds a mesoscopic calibrator
void parseAndBuildStoppingPlace(MSNet &net, const SUMOSAXAttributes &attrs, const SumoXMLTag element)
Parses the values and builds a stopping places for busses, trains or container vehicles.
void parseAndBeginParkingArea(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a parking area.
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 current parking area.
const std::string & getID() const
Returns the id.
Definition: Named.h:73
T get(const std::string &id) const
Retrieves an item.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
Encapsulated SAX-Attributes.
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.
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<>
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
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.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
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.
A wrapper for a Command function.
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.
Definition: XMLSubSys.cpp:148