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-2022 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/****************************************************************************/
24// Builds trigger objects for microsim
25/****************************************************************************/
26#include <config.h>
27
28#include <string>
30#include <microsim/MSLane.h>
31#include <microsim/MSEdge.h>
32#include <microsim/MSGlobals.h>
48#include "NLHandler.h"
49#include "NLTriggerBuilder.h"
51#include <utils/xml/XMLSubSys.h>
52
53
54#include <mesosim/MELoop.h>
56
57
58// ===========================================================================
59// method definitions
60// ===========================================================================
62 : myHandler(nullptr), myParkingArea(nullptr), myCurrentStop(nullptr) {}
63
64
66
67void
69 myHandler = handler;
70}
71
72
73void
75 WRITE_WARNING(TL("Vaporizers are deprecated. Use rerouters instead."));
76 bool ok = true;
77 // get the id, throw if not given or empty...
78 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
79 if (!ok) {
80 return;
81 }
83 if (e == nullptr) {
84 WRITE_ERROR("Unknown edge ('" + id + "') referenced in a vaporizer.");
85 return;
86 }
87 SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, ok);
88 SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, ok);
89 if (!ok) {
90 return;
91 }
92 if (begin < 0) {
93 WRITE_ERROR("A vaporization begin time is negative (edge id='" + id + "').");
94 return;
95 }
96 if (begin >= end) {
97 WRITE_ERROR("A vaporization ends before it starts (edge id='" + id + "').");
98 return;
99 }
100 if (end >= string2time(OptionsCont::getOptions().getString("begin"))) {
105 }
106}
107
108
109void
111 const std::string& base) {
112 // get the id, throw if not given or empty...
113 bool ok = true;
114 // get the id, throw if not given or empty...
115 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
116 if (!ok) {
117 return;
118 }
119 // get the file name to read further definitions from
120 std::string file = getFileName(attrs, base, true);
121 std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANES, id.c_str(), ok);
122 std::vector<MSLane*> lanes;
123 for (const std::string& laneID : attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), ok)) {
124 MSLane* lane = MSLane::dictionary(laneID);
125 if (lane == nullptr) {
126 throw InvalidArgument("The lane '" + laneID + "' to use within MSLaneSpeedTrigger '" + id + "' is not known.");
127 }
128 lanes.push_back(lane);
129 }
130 if (!ok) {
131 throw InvalidArgument("The lanes to use within MSLaneSpeedTrigger '" + id + "' are not known.");
132 }
133 if (lanes.size() == 0) {
134 throw InvalidArgument("No lane defined for MSLaneSpeedTrigger '" + id + "'.");
135 }
136 try {
137 MSLaneSpeedTrigger* trigger = buildLaneSpeedTrigger(net, id, lanes, file);
138 if (file == "") {
140 }
141 } catch (ProcessError& e) {
142 throw InvalidArgument(e.what());
143 }
144}
145
146
147void
149 bool ok = true;
150
151 // get the id, throw if not given or empty...
152 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
153 if (!ok) {
154 throw ProcessError();
155 }
156
157 MSLane* const lane = getLane(attrs, "chargingStation", id);
158 double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
159 double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
160 const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), ok, 0);
161 const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), ok, 0.95);
162 const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), ok, 0);
163 const SUMOTime chargeDelay = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CHARGEDELAY, id.c_str(), ok, 0);
164 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
165 const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
166
167 if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
168 throw InvalidArgument("Invalid position for charging station '" + id + "'.");
169 }
170
171 buildChargingStation(net, id, lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
172}
173
174
175void
177 bool ok = true;
178
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 /* The following call may either throw InvalidArgument exeption or return NULL:
186 NULL is returned in case when the overhead wire segment should be built over an already
187 ignored internal lane of an intersection, the exeption is thrown in case that
188 the overhead wire segment references a non-existent lane. */
189 MSLane* const lane = getLane(attrs, "overheadWireSegment", id);
190 if (lane == nullptr) {
191 WRITE_MESSAGE("The overheadWireSegment '" + id + "' was not created as it is attached to internal lane. It will be build automatically.");
192 return;
193 }
194
195 if (lane->isInternal()) {
196 WRITE_MESSAGE("The overheadWireSegment '" + id + "' not built as it is attached to internal lane. It will be build automatically.");
197 return;
198 }
199
200 double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
201 double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
202 const bool voltageSource = attrs.getOpt<bool>(SUMO_ATTR_VOLTAGESOURCE, id.c_str(), ok, false);
203 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
204
205 if (!ok || myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID) {
206 frompos = 0;
207 topos = lane->getLength();
208 WRITE_MESSAGE("The overheadWireSegment '" + id + "' has wrong position. Automatically set from 0 to the length of the lane.");
209 //throw InvalidArgument("Invalid position for overheadWireSegment'" + id + "'.");
210 }
211
212 buildOverheadWireSegment(net, id, lane, frompos, topos, voltageSource);
213#ifndef HAVE_EIGEN
216 WRITE_WARNING(TL("Overhead wire solver (Eigen) not compiled in, expect errors in overhead wire simulation"))
217 }
218#endif // !HAVE_EIGEN
219}
220
221void
223 bool ok = true;
224 std::string substationId = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, 0, ok);
225 if (!ok) {
226 throw ProcessError();
227 }
228
230 if (substation == nullptr) {
231 throw InvalidArgument("Traction substation '" + substationId + "' refereced by an OverheadWire Section is not known.");
232 } else if (substation->isAnySectionPreviouslyDefined()) {
233 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).");
234 }
235
236 // @todo This may be a relict of older approach to processing the attributes ...
237 std::string segmentStrings = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENTS, substationId.c_str(), ok);
238 if (!ok) {
239 throw InvalidArgument("Segments referenced by Traction substation '" + substationId + "' are not declared .");
240 }
241
242 // process forbidden internal lanes
243 const std::vector<std::string>& forbiddenInnerLanesIDs = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, substationId.c_str(), ok);
245 for (const std::string& laneID : forbiddenInnerLanesIDs) {
246 MSLane* lane = MSLane::dictionary(laneID);
247 if (lane != nullptr) {
248 substation->addForbiddenLane(lane);
249 } else {
250 throw InvalidArgument("Unknown lane '" + laneID + "' in Traction substation '" + substationId + "'.");
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 const std::vector<std::string>& segmentIDs = attrs.get<std::vector<std::string> >(SUMO_ATTR_OVERHEAD_WIRE_SEGMENTS, substationId.c_str(), ok);
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 (const std::string& segmentID : segmentIDs) {
267 const MSLane* connection = nullptr;
269 std::string neigboringOvrhdSegmentID;
270 MSOverheadWire* neigboringOvrhdSegment;
271 MSTractionSubstation* neigboringOvrhdSegmentTractionSubstation;
272 if (ovrhdSegment == nullptr) {
273 throw InvalidArgument("The OverheadWireSegment with id='" + segmentID + "' referenced by OverheadWireSegment for substation '" + substationId + "' was not defined.");
274 }
275
276 MSTractionSubstation* ts = ovrhdSegment->getTractionSubstation();
277 if (!(ts == substation || ts == nullptr)) {
278 std::string tsName = ts->getID();
279 throw InvalidArgument("The OverheadWireSegment '" + segmentID + "' referenced by OverheadWireSegment for substation '" + substationId + "' is already assigned to substation '" + tsName + "'.");
280 }
281 ovrhdSegment->setTractionSubstation(substation);
282
283 const MSLane* lane = &(ovrhdSegment->getLane());
284
285 /* in version before SUMO 1.0.1 the function getOutgoingLanes() returning MSLane* exists,
286 in new version of SUMO the funciton getOutgoingViaLanes() returning MSLane* and MSEdge* pair exists */
287 const std::vector<std::pair<const MSLane*, const MSEdge*> > outgoingLanesAndEdges = lane->getOutgoingViaLanes();
288 std::vector<const MSLane*> neigboringInnerLanes;
289 neigboringInnerLanes.reserve(outgoingLanesAndEdges.size());
290 for (size_t it = 0; it < outgoingLanesAndEdges.size(); ++it) {
291 neigboringInnerLanes.push_back(outgoingLanesAndEdges[it].first);
292 }
293
294 // Check if an outgoing lane has an overhead wire segment. If not, do nothing, otherwise find connnecting internal lanes and
295 // add overhead wire segments over all detected internal lanes
296 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
297 // If the overhead wire segment is over the outgoing (not internal) lane
298 neigboringOvrhdSegmentID = MSNet::getInstance()->getStoppingPlaceID(*it, NUMERICAL_EPS, SUMO_TAG_OVERHEAD_WIRE_SEGMENT);
299 if (neigboringOvrhdSegmentID != "") {
300 neigboringOvrhdSegment = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(neigboringOvrhdSegmentID, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
301 neigboringOvrhdSegmentTractionSubstation = neigboringOvrhdSegment->getTractionSubstation();
302 } else {
303 neigboringOvrhdSegment = nullptr;
304 neigboringOvrhdSegmentTractionSubstation = nullptr;
305 }
306
307 if (neigboringOvrhdSegmentTractionSubstation == substation && !(*it)->isInternal()) {
308 connection = lane->getInternalFollowingLane(*it);
309 if (connection != nullptr) {
310 //is connection forbidden?
311 if (!(substation->isForbidden(connection) || substation->isForbidden(lane->getInternalFollowingLane(connection)) || substation->isForbidden(connection->getInternalFollowingLane(*it)))) {
312 buildInnerOverheadWireSegments(net, connection, lane->getInternalFollowingLane(connection), connection->getInternalFollowingLane(*it));
313 }
314 }
315 }
316 }
317
318 // Check if an incoming lane has an overhead wire segment. If not, do nothing, otherwise find connnecting internal lanes and
319 // add overhead wire segments over all detected internal lanes
320 neigboringInnerLanes = lane->getNormalIncomingLanes();
321 for (std::vector<const MSLane*>::iterator it = neigboringInnerLanes.begin(); it != neigboringInnerLanes.end(); ++it) {
322 // If the overhead wire segment is over the incoming (not internal) lane
323 neigboringOvrhdSegmentID = MSNet::getInstance()->getStoppingPlaceID(*it, (*it)->getLength() - NUMERICAL_EPS, SUMO_TAG_OVERHEAD_WIRE_SEGMENT);
324 if (neigboringOvrhdSegmentID != "") {
325 neigboringOvrhdSegment = dynamic_cast<MSOverheadWire*>(MSNet::getInstance()->getStoppingPlace(neigboringOvrhdSegmentID, SUMO_TAG_OVERHEAD_WIRE_SEGMENT));
326 neigboringOvrhdSegmentTractionSubstation = neigboringOvrhdSegment->getTractionSubstation();
327 } else {
328 neigboringOvrhdSegment = nullptr;
329 neigboringOvrhdSegmentTractionSubstation = nullptr;
330 }
331
332 if (neigboringOvrhdSegmentTractionSubstation == substation && !(*it)->isInternal()) {
333 connection = (*it)->getInternalFollowingLane(lane);
334 if (connection != nullptr) {
335 //is connection forbidden?
336 if (!(substation->isForbidden(connection) || substation->isForbidden((*it)->getInternalFollowingLane(connection)) || substation->isForbidden(connection->getInternalFollowingLane(lane)))) {
337 buildInnerOverheadWireSegments(net, connection, (*it)->getInternalFollowingLane(connection), connection->getInternalFollowingLane(lane));
338 }
339 }
340 }
341 }
342 }
343
344
345 // ----- *** adding segments into the electric circuit*** -----
346
347 // setting nullptr for substation (a fragment from old version of adding segments into the circuit)
348 for (const std::string& segmentID : segmentIDs) {
350 ovrhdSegment->setTractionSubstation(nullptr);
351 }
352
353 for (const std::string& segmentID : segmentIDs) {
354 if (segmentID == "") {
355 continue;
356 }
358 substation->addOverheadWireSegmentToCircuit(ovrhdSegment);
359 segments.push_back(ovrhdSegment);
360 }
361
362 // adding overhead wire clamp
363 std::string clampsString = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_CLAMPS, nullptr, ok, "");
364 if (clampsString != "" && MSGlobals::gOverheadWireSolver) {
365#ifdef HAVE_EIGEN
366 const std::vector<std::string>& clampIDs = attrs.get<std::vector<std::string> >(SUMO_ATTR_OVERHEAD_WIRE_CLAMPS, nullptr, ok);
367 for (const std::string& clampID : clampIDs) {
368 MSTractionSubstation::OverheadWireClamp* clamp = substation->findClamp(clampID);
369 if (clamp != nullptr) {
370 if (clamp->start->getTractionSubstation() == substation && clamp->end->getTractionSubstation() == substation) {
371 substation->addOverheadWireClampToCircuit(clamp->id, clamp->start, clamp->end);
372 buildOverheadWireClamp(net, clamp->id, const_cast<MSLane*>(&clamp->start->getLane()), const_cast<MSLane*>(&clamp->end->getLane()));
373 clamp->usage = true;
374 } else {
375 if (clamp->start->getTractionSubstation() != substation) {
376 WRITE_WARNING("A connecting overhead wire start segment '" + clamp->start->getID() + "' defined for overhead wire clamp '" + clampID + "' is not assigned to the traction substation '" + substationId + "'.");
377 } else {
378 WRITE_WARNING("A connecting overhead wire end segment '" + clamp->end->getID() + "' defined for overhead wire clamp '" + clampID + "' is not assigned to the traction substation '" + substationId + "'.");
379 }
380 }
381 } else {
382 WRITE_WARNING("The overhead wire clamp '" + clampID + "' 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.");
383 }
384 }
385#else
386 WRITE_WARNING(TL("Overhead circuit solver requested, but solver support (Eigen) not compiled in."));
387#endif
388 }
389
390 if (segments.size() == 0) {
391 throw InvalidArgument("No segments found for overHeadWireSection '" + substationId + "'.");
393#ifdef HAVE_EIGEN
394 // check that the electric circuit makes sense
395 segments[0]->getCircuit()->checkCircuit(substationId);
396#else
397 WRITE_WARNING(TL("Cannot check circuit, overhead circuit solver support (Eigen) not compiled in."));
398#endif
399 }
400}
401
402void
404 bool ok = true;
405
406 // get the id, throw if not given or empty...
407 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
408 if (!ok) {
409 throw ProcessError();
410 }
411
412 // RICE_TODO Limits are fixed, change them to some predefined constants ...
413 const double voltage = attrs.getOpt<double>(SUMO_ATTR_VOLTAGE, id.c_str(), ok, 600);
414 const double currentLimit = attrs.getOpt<double>(SUMO_ATTR_CURRENTLIMIT, id.c_str(), ok, 400);
415 buildTractionSubstation(net, id, voltage, currentLimit);
416}
417
418void
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 }
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(TL("Not building overhead wire clamps, overhead wire solver support (Eigen) not compiled in."));
470#endif
471 } else {
472 WRITE_WARNING(TL("Ignoring overhead wire clamps, they make no sense when overhead wire circuit solver is off."));
473 }
474}
475
476
477void
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 //get the color, use default if not given
490 // default color, copy from GUIVisualizationStoppingPlaceSettings::busStopColor / containerStopColor
491 RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok, RGBColor::INVISIBLE);
492
493 MSLane* lane = getLane(attrs, toString(element), id);
494 // get the positions
495 double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0.);
496 double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
497 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
498 if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
499 throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
500 }
501 const std::vector<std::string>& lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), ok);
502 int defaultCapacity;
503 SumoXMLAttr capacityAttr;
504 if (element != SUMO_TAG_CONTAINER_STOP) {
505 defaultCapacity = MAX2(MSStoppingPlace::getTransportablesAbreast(topos - frompos, element) * 3, 6);
506 capacityAttr = SUMO_ATTR_PERSON_CAPACITY;
507 } else {
508 defaultCapacity = MSStoppingPlace::getTransportablesAbreast(topos - frompos, element);
509 capacityAttr = SUMO_ATTR_CONTAINER_CAPACITY;
510 }
511 const int transportableCapacity = attrs.getOpt<int>(capacityAttr, id.c_str(), ok, defaultCapacity);
512 const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), ok, 0);
513 // build the bus stop
514 buildStoppingPlace(net, id, lines, lane, frompos, topos, element, ptStopName, transportableCapacity, parkingLength, color);
515}
516
517
518void
520 if (myCurrentStop == nullptr) {
521 throw InvalidArgument("Could not add access outside a stopping place.");
522 }
523 // get the lane
524 MSLane* lane = getLane(attrs, "access", myCurrentStop->getID());
526 WRITE_WARNING("Ignoring invalid access from non-pedestrian lane '" + lane->getID() + "' in busStop '" + myCurrentStop->getID() + "'.");
527 return;
528 }
529 // get the positions
530 bool ok = true;
531 double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0);
532 const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
533 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
534 if (!ok || (myHandler->checkStopPos(pos, pos, lane->getLength(), 0, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
535 throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane->getID() + "' in stop '" + myCurrentStop->getID() + "'.");
536 }
537 // add bus stop access
538 if (!myCurrentStop->addAccess(lane, pos, length)) {
539 throw InvalidArgument("Duplicate access on lane '" + lane->getID() + "' for stop '" + myCurrentStop->getID() + "'");
540 }
541}
542
543
544void
546 bool ok = true;
547 // get the id, throw if not given or empty...
548 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
549 if (!ok) {
550 throw ProcessError();
551 }
552 // get the lane
553 MSLane* lane = getLane(attrs, "parkingArea", id);
554 // get the positions
555 double frompos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0);
556 double topos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, lane->getLength());
557 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
558 unsigned int capacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), ok, 0);
559 bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), ok, false);
560 double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, 0);
561 double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, 0);
562 double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), ok, 0);
563 const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok);
564 const std::string departPos = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, id.c_str(), ok);
565 if (!ok || (myHandler->checkStopPos(frompos, topos, lane->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
566 throw InvalidArgument("Invalid position for parking area '" + id + "'.");
567 }
568 const std::vector<std::string>& lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), ok);
569 // build the parking area
570 beginParkingArea(net, id, lines, lane, frompos, topos, capacity, width, length, angle, name, onRoad, departPos);
571}
572
573
574
575void
577 bool ok = true;
578 // Check for open parking area
579 if (myParkingArea == nullptr) {
580 throw ProcessError();
581 }
582 // get the positions
583 double x = attrs.get<double>(SUMO_ATTR_X, "", ok);
584 if (!ok) {
585 throw InvalidArgument("Invalid x position for lot entry.");
586 }
587 double y = attrs.get<double>(SUMO_ATTR_Y, "", ok);
588 if (!ok) {
589 throw InvalidArgument("Invalid y position for lot entry.");
590 }
591 double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", ok, 0.);
592 double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, "", ok, myParkingArea->getWidth());
593 double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", ok, myParkingArea->getLength());
594 double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, "", ok, myParkingArea->getAngle());
595 double slope = attrs.getOpt<double>(SUMO_ATTR_SLOPE, "", ok, 0.);
596 // add the lot entry
597 addLotEntry(x, y, z, width, length, angle, slope);
598}
599
600
601void
603 const std::string& base) {
604 bool ok = true;
605 // get the id, throw if not given or empty...
606 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
607 if (!ok) {
608 throw ProcessError();
609 }
610 MSLane* lane = nullptr;
611 MSEdge* edge = nullptr;
612 // get the file name to read further definitions from
613 if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
614 std::string edgeID = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
615 edge = MSEdge::dictionary(edgeID);
616 if (edge == nullptr) {
617 throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id + "' is not known.");
618 }
619 if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
620 lane = getLane(attrs, "calibrator", id);
621 if (&lane->getEdge() != edge) {
622 throw InvalidArgument("The edge " + edgeID + " to use within the calibrator '" + id
623 + "' does not match the calibrator lane '" + lane->getID() + ".");
624 }
625 }
626 } else {
627 lane = getLane(attrs, "calibrator", id);
628 edge = &lane->getEdge();
629 }
630 const double pos = getPosition(attrs, lane, "calibrator", id, edge);
631 const SUMOTime period = attrs.getOptPeriod(id.c_str(), ok, DELTA_T); // !!! no error handling
632 const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
633 std::string file = getFileName(attrs, base, true);
634 std::string outfile = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), ok, "");
635 std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), ok, "");
636 // differing defaults for backward compatibility, values are dimensionless
637 double invalidJamThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, MSGlobals::gUseMesoSim ? 0.8 : 0.5);
638 MSRouteProbe* probe = nullptr;
639 if (routeProbe != "") {
640 probe = dynamic_cast<MSRouteProbe*>(net.getDetectorControl().getTypedDetectors(SUMO_TAG_ROUTEPROBE).get(routeProbe));
641 if (probe == nullptr) {
642 throw InvalidArgument("The routeProbe '" + routeProbe + "' to use within the calibrator '" + id + "' is not known.");
643 }
644 }
646 if (lane != nullptr && edge->getLanes().size() > 1) {
647 WRITE_WARNING("Meso calibrator '" + id
648 + "' defined for lane '" + lane->getID()
649 + "' will collect data for all lanes of edge '" + edge->getID() + "'.");
650 }
651 METriggeredCalibrator* trigger = buildMECalibrator(net, id, edge, pos, file, outfile, period, probe, invalidJamThreshold, vTypes);
652 if (file == "") {
654 }
655 } else {
656 MSCalibrator* trigger = buildCalibrator(net, id, edge, lane, pos, file, outfile, period, probe, invalidJamThreshold, vTypes);
657 if (file == "") {
659 }
660 }
661}
662
663
664void
666 bool ok = true;
667 // get the id, throw if not given or empty...
668 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
669 if (!ok) {
670 throw ProcessError();
671 }
672 MSEdgeVector edges;
673 for (const std::string& edgeID : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), ok)) {
674 MSEdge* edge = MSEdge::dictionary(edgeID);
675 if (edge == nullptr) {
676 throw InvalidArgument("The edge '" + edgeID + "' to use within MSTriggeredRerouter '" + id + "' is not known.");
677 }
678 edges.push_back(edge);
679 }
680 if (!ok) {
681 throw InvalidArgument("The edge to use within MSTriggeredRerouter '" + id + "' is not known.");
682 }
683 if (edges.size() == 0) {
684 throw InvalidArgument("No edges found for MSTriggeredRerouter '" + id + "'.");
685 }
686 double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), ok, 1);
687 bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, false);
688 SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
689 const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
690 if (!ok) {
691 throw InvalidArgument("Could not parse MSTriggeredRerouter '" + id + "'.");
692 }
693 MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, off, timeThreshold, vTypes);
694 // read in the trigger description
696}
697
698
699// -------------------------
700
701
703NLTriggerBuilder::buildLaneSpeedTrigger(MSNet& /*net*/, const std::string& id,
704 const std::vector<MSLane*>& destLanes,
705 const std::string& file) {
706 return new MSLaneSpeedTrigger(id, destLanes, file);
707}
708
709
711NLTriggerBuilder::buildMECalibrator(MSNet& /*net*/, const std::string& id,
712 const MSEdge* edge,
713 double pos,
714 const std::string& file,
715 const std::string& outfile,
716 const SUMOTime freq,
717 MSRouteProbe* probe,
718 const double invalidJamThreshold,
719 const std::string& vTypes) {
720 return new METriggeredCalibrator(id, edge, pos, file, outfile, freq, MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)->getLength(), probe, invalidJamThreshold, vTypes);
721}
722
723
725NLTriggerBuilder::buildCalibrator(MSNet& /*net*/, const std::string& id,
726 MSEdge* edge,
727 MSLane* lane,
728 double pos,
729 const std::string& file,
730 const std::string& outfile,
731 const SUMOTime freq,
732 const MSRouteProbe* probe,
733 const double invalidJamThreshold,
734 const std::string& vTypes) {
735 return new MSCalibrator(id, edge, lane, pos, file, outfile, freq, edge->getLength(), probe, invalidJamThreshold, vTypes);
736}
737
738
741 MSEdgeVector& edges, double prob, bool off,
742 SUMOTime timeThreshold, const std::string& vTypes) {
743 return new MSTriggeredRerouter(id, edges, prob, off, timeThreshold, vTypes);
744}
745
746
747void
748NLTriggerBuilder::buildStoppingPlace(MSNet& net, std::string id, std::vector<std::string> lines, MSLane* lane,
749 double frompos, double topos, const SumoXMLTag element, std::string ptStopName,
750 int personCapacity, double parkingLength, RGBColor& color) {
751 myCurrentStop = new MSStoppingPlace(id, element, lines, *lane, frompos, topos, ptStopName, personCapacity, parkingLength, color);
752 if (!net.addStoppingPlace(element, myCurrentStop)) {
753 delete myCurrentStop;
754 myCurrentStop = nullptr;
755 throw InvalidArgument("Could not build " + toString(element) + " '" + id + "'; probably declared twice.");
756 }
757}
758
759
760void
761NLTriggerBuilder::beginParkingArea(MSNet& net, const std::string& id,
762 const std::vector<std::string>& lines,
763 MSLane* lane, double frompos, double topos,
764 unsigned int capacity,
765 double width, double length, double angle, const std::string& name,
766 bool onRoad,
767 const std::string& departPos) {
768 // Close previous parking area if there are not lots inside
769 MSParkingArea* stop = new MSParkingArea(id, lines, *lane, frompos, topos, capacity, width, length, angle, name, onRoad, departPos);
770 if (!net.addStoppingPlace(SUMO_TAG_PARKING_AREA, stop)) {
771 delete stop;
772 throw InvalidArgument("Could not build parking area '" + id + "'; probably declared twice.");
773 } else {
774 myParkingArea = stop;
775 }
776}
777
778
779void
780NLTriggerBuilder::addLotEntry(double x, double y, double z,
781 double width, double length,
782 double angle, double slope) {
783 if (myParkingArea != nullptr) {
784 if (!myParkingArea->parkOnRoad()) {
785 myParkingArea->addLotEntry(x, y, z, width, length, angle, slope);
786 } else {
787 throw InvalidArgument("Cannot not add lot entry to on-road parking area.");
788 }
789 } else {
790 throw InvalidArgument("Could not add lot entry outside a parking area.");
791 }
792}
793
794
795void
797 if (myParkingArea != nullptr) {
798 myParkingArea = nullptr;
799 } else {
800 throw InvalidArgument("Could not end a parking area that is not opened.");
801 }
802}
803
804
805void
807 if (myCurrentStop != nullptr) {
808 myCurrentStop = nullptr;
809 } else {
810 throw InvalidArgument("Could not end a stopping place that is not opened.");
811 }
812}
813
814
815void
816NLTriggerBuilder::buildChargingStation(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos, const std::string& name,
817 double chargingPower, double efficiency, bool chargeInTransit, SUMOTime chargeDelay) {
818 MSChargingStation* chargingStation = new MSChargingStation(id, *lane, frompos, topos, name, chargingPower, efficiency, chargeInTransit, chargeDelay);
819 if (!net.addStoppingPlace(SUMO_TAG_CHARGING_STATION, chargingStation)) {
820 delete chargingStation;
821 throw InvalidArgument("Could not build charging station '" + id + "'; probably declared twice.");
822 }
823 myCurrentStop = chargingStation;
824}
825
826void
827NLTriggerBuilder::buildOverheadWireSegment(MSNet& net, const std::string& id, MSLane* lane, double frompos, double topos,
828 bool voltageSource) {
829 MSOverheadWire* overheadWireSegment = new MSOverheadWire(id, *lane, frompos, topos, voltageSource);
830 if (!net.addStoppingPlace(SUMO_TAG_OVERHEAD_WIRE_SEGMENT, overheadWireSegment)) {
831 delete overheadWireSegment;
832 throw InvalidArgument("Could not build overheadWireSegment '" + id + "'; probably declared twice.");
833 }
834}
835
836void
837NLTriggerBuilder::buildInnerOverheadWireSegments(MSNet& net, const MSLane* connection, const MSLane* frontConnection, const MSLane* behindConnection) {
838 if (frontConnection == NULL && behindConnection == NULL) {
839 buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
840 } else if (frontConnection != NULL && behindConnection == NULL) {
841 buildOverheadWireSegment(net, "ovrhd_inner_" + frontConnection->getID(), const_cast<MSLane*>(frontConnection), 0, frontConnection->getLength(), false);
842 buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
843 } else if (frontConnection == NULL && behindConnection != NULL) {
844 buildOverheadWireSegment(net, "ovrhd_inner_" + behindConnection->getID(), const_cast<MSLane*>(behindConnection), 0, behindConnection->getLength(), false);
845 buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
846 } else if (frontConnection != NULL && behindConnection != NULL) {
847 buildOverheadWireSegment(net, "ovrhd_inner_" + frontConnection->getID(), const_cast<MSLane*>(frontConnection), 0, frontConnection->getLength(), false);
848 buildOverheadWireSegment(net, "ovrhd_inner_" + behindConnection->getID(), const_cast<MSLane*>(behindConnection), 0, behindConnection->getLength(), false);
849 buildOverheadWireSegment(net, "ovrhd_inner_" + connection->getID(), const_cast<MSLane*>(connection), 0, connection->getLength(), false);
850 }
851}
852
853void
854NLTriggerBuilder::buildTractionSubstation(MSNet& net, std::string id, double voltage, double currentLimit) {
855 MSTractionSubstation* myTractionSubstation = new MSTractionSubstation(id, voltage, currentLimit);
856 if (!net.addTractionSubstation(myTractionSubstation)) {
857 delete myTractionSubstation;
858 throw InvalidArgument("Could not build traction substation '" + id + "'; probably declared twice.");
859 }
860}
861
862void
863NLTriggerBuilder::buildOverheadWireClamp(MSNet& /*net*/, const std::string& /*id*/, MSLane* /*lane_start*/, MSLane* /*lane_end*/) {
864}
865
866std::string
868 const std::string& base,
869 const bool allowEmpty) {
870 // get the file name to read further definitions from
871 bool ok = true;
872 std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, nullptr, ok, "");
873 if (file == "") {
874 if (allowEmpty) {
875 return file;
876 }
877 throw InvalidArgument("No filename given.");
878 }
879 // check whether absolute or relative filenames are given
880 if (!FileHelpers::isAbsolute(file)) {
881 return FileHelpers::getConfigurationRelative(base, file);
882 }
883 return file;
884}
885
886
887MSLane*
889 const std::string& tt,
890 const std::string& tid) {
891 bool ok = true;
892 std::string objectid = attrs.get<std::string>(SUMO_ATTR_LANE, tid.c_str(), ok);
893 MSLane* lane = MSLane::dictionary(objectid);
894 if (lane == nullptr) {
895 // Either a lane that is non-existent/broken, or a lane that is internal and has been ignored.
896 // We assume that internal lane names start with ':'.
897 if (objectid[0] == ':' && !MSGlobals::gUsingInternalLanes) {
898 return nullptr;
899 }
900 // Throw the exception only in case that the lane really does not exist in the network file
901 // or it is broken.
902 throw InvalidArgument("The lane " + objectid + " to use within the " + tt + " '" + tid + "' is not known.");
903 }
904 return lane;
905}
906
907
908double
910 MSLane* lane,
911 const std::string& tt, const std::string& tid,
912 MSEdge* edge) {
913 assert(lane != 0 || edge != 0);
914 const double length = lane != nullptr ? lane->getLength() : edge->getLength();
915 bool ok = true;
916 double pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
917 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
918 if (!ok) {
919 throw InvalidArgument("Error on parsing a position information.");
920 }
921 if (pos < 0) {
922 pos = length + pos;
923 }
924 if (pos > length) {
925 if (friendlyPos) {
926 pos = length - (double) 0.1;
927 } else {
928 if (lane != nullptr) {
929 throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane->getID() + "' length.");
930 } else {
931 throw InvalidArgument("The position of " + tt + " '" + tid + "' lies beyond the edges's '" + edge->getID() + "' length.");
932 }
933 }
934 }
935 return pos;
936}
937
940 return myParkingArea == nullptr ? myCurrentStop : myParkingArea;
941}
942
943
944/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:267
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
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:56
@ 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_CONTAINER_STOP
A container stop.
@ 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.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LINES
@ SUMO_ATTR_LANE
@ 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_DEPARTPOS
@ SUMO_ATTR_CHARGEINTRANSIT
Allow/disallow charge in transit in Charging Stations.
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_NAME
@ SUMO_ATTR_SLOPE
@ 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_CURRENTLIMIT
current limit of the traction substation [A]
@ 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_COLOR
A color information.
@ 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_OVERHEAD_WIRE_SEGMENTS
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Base (microsim) event class.
Definition: Command.h:50
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:47
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:168
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:478
double getLength() const
return the length of the edge
Definition: MSEdge.h:658
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:945
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:471
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gUseMesoSim
Definition: MSGlobals.h:103
static bool gOverheadWireSolver
Definition: MSGlobals.h:118
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:109
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:78
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getLength() const
Returns the lane's length.
Definition: MSLane.h:575
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:2440
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:856
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2968
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2199
bool isInternal() const
Definition: MSLane.cpp:2330
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:2978
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
Changes the speed allowed on a set of lanes.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:1271
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:442
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:472
bool addTractionSubstation(MSTractionSubstation *substation)
Adds a traction substation.
Definition: MSNet.cpp:1277
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:1296
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1287
MSTractionSubstation * findTractionSubstation(const std::string &substationId)
find electrical substation by its id
Definition: MSNet.cpp:1367
Definition of overhead wire segment.
MSTractionSubstation * getTractionSubstation() const
void setTractionSubstation(MSTractionSubstation *substation)
A lane area vehicles can halt at.
Definition: MSParkingArea.h:58
double getAngle() const
Returns the lot rectangle angle.
double getLength() const
Returns the lot rectangle length.
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle, double slope)
Add a lot entry to parking area.
double getWidth() const
Returns the lot rectangle width.
bool parkOnRoad() const
whether vehicles park on the road
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:58
A lane area vehicles can halt at.
int getTransportablesAbreast() const
virtual bool addAccess(MSLane *lane, const double pos, double length)
adds an access point to this stop
const MSLane & getLane() const
Returns the lane this stop is located at.
Traction substaction powering one or more overhead wire sections.
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)
Find an overhead wire clamp by its ID.
void addForbiddenLane(MSLane *lane)
Reroutes vehicles passing an edge.
The XML-Handler for network loading.
Definition: NLHandler.h:79
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, MSEdgeVector &edges, double prob, bool off, SUMOTime timeThreshold, const std::string &vTypes)
builds an rerouter
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.
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, const std::string &departPos)
Begin a parking area.
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 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.
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.
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a 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.
void buildTractionSubstation(MSNet &net, std::string id, double voltage, double currentLimit)
Builds a traction substation.
void addLotEntry(double x, double y, double z, double width, double length, double angle, double slope)
Add a lot entry to current 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.
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.
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
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, RGBColor &color)
Builds a stopping place.
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, SUMOTime chargeDelay)
Builds a charging station.
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.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
T get(const std::string &id) const
Retrieves an item.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
static const RGBColor INVISIBLE
Definition: RGBColor.h:195
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.
SUMOTime getOptPeriod(const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read the SUMOTime 'period' attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.