Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 : /****************************************************************************/
14 : /// @file SUMOVehicleParameter.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Axel Wegener
18 : /// @author Michael Behrisch
19 : /// @date 2006-01-24
20 : ///
21 : // Structure representing possible vehicle parameter
22 : /****************************************************************************/
23 : #pragma once
24 : #include <config.h>
25 :
26 : #include <string>
27 : #include <utils/common/Parameterised.h>
28 : #include <utils/common/RGBColor.h>
29 : #include <utils/common/SUMOTime.h>
30 : #include <utils/common/SUMOVehicleClass.h>
31 : #include <utils/distribution/Distribution_Parameterized.h>
32 :
33 :
34 : // ===========================================================================
35 : // class declarations
36 : // ===========================================================================
37 : class OutputDevice;
38 : class OptionsCont;
39 :
40 :
41 : // ===========================================================================
42 : // value definitions
43 : // ===========================================================================
44 : const long long int VEHPARS_COLOR_SET = 1;
45 : const long long int VEHPARS_VTYPE_SET = 2;
46 : const long long int VEHPARS_DEPARTLANE_SET = 2 << 1;
47 : const long long int VEHPARS_DEPARTPOS_SET = 2 << 2;
48 : const long long int VEHPARS_DEPARTSPEED_SET = 2 << 3;
49 : const long long int VEHPARS_END_SET = 2 << 4;
50 : const long long int VEHPARS_NUMBER_SET = 2 << 5;
51 : const long long int VEHPARS_PERIOD_SET = 2 << 6;
52 : const long long int VEHPARS_VPH_SET = 2 << 7;
53 : const long long int VEHPARS_PROB_SET = 2 << 8;
54 : const long long int VEHPARS_POISSON_SET = 2 << 9;
55 : const long long int VEHPARS_ROUTE_SET = 2 << 10;
56 : const long long int VEHPARS_ARRIVALLANE_SET = 2 << 11;
57 : const long long int VEHPARS_ARRIVALPOS_SET = 2 << 12;
58 : const long long int VEHPARS_ARRIVALSPEED_SET = 2 << 13;
59 : const long long int VEHPARS_LINE_SET = 2 << 14;
60 : const long long int VEHPARS_FROM_TAZ_SET = 2 << 15;
61 : const long long int VEHPARS_TO_TAZ_SET = 2 << 16;
62 : const long long int VEHPARS_FORCE_REROUTE = 2 << 17;
63 : const long long int VEHPARS_PERSON_CAPACITY_SET = 2 << 18;
64 : const long long int VEHPARS_PERSON_NUMBER_SET = 2 << 19;
65 : const long long int VEHPARS_CONTAINER_NUMBER_SET = 2 << 20;
66 : const long long int VEHPARS_DEPARTPOSLAT_SET = 2 << 21;
67 : const long long int VEHPARS_ARRIVALPOSLAT_SET = 2 << 22;
68 : const long long int VEHPARS_VIA_SET = 2 << 23;
69 : const long long int VEHPARS_SPEEDFACTOR_SET = 2 << 24;
70 : const long long int VEHPARS_DEPARTEDGE_SET = 2 << 25;
71 : const long long int VEHPARS_ARRIVALEDGE_SET = 2 << 26;
72 : const long long int VEHPARS_CALIBRATORSPEED_SET = 2 << 27;
73 : const long long int VEHPARS_JUNCTIONMODEL_PARAMS_SET = 2 << 28;
74 : const long long int VEHPARS_CFMODEL_PARAMS_SET = 2 << 29;
75 : const long long int VEHPARS_PARKING_BADGES_SET = (long long int)2 << 30;
76 : const long long int VEHPARS_INSERTION_CHECKS_SET = (long long int)2 << 31;
77 :
78 : const int STOP_INDEX_END = -1;
79 : const int STOP_INDEX_FIT = -2;
80 : const int STOP_INDEX_REPEAT = -3;
81 :
82 : const int STOP_START_SET = 1;
83 : const int STOP_END_SET = 2;
84 : const int STOP_DURATION_SET = 2 << 1;
85 : const int STOP_UNTIL_SET = 2 << 2;
86 : const int STOP_EXTENSION_SET = 2 << 3;
87 : const int STOP_TRIGGER_SET = 2 << 4;
88 : const int STOP_PARKING_SET = 2 << 5;
89 : const int STOP_EXPECTED_SET = 2 << 6;
90 : const int STOP_CONTAINER_TRIGGER_SET = 2 << 7;
91 : const int STOP_EXPECTED_CONTAINERS_SET = 2 << 8;
92 : const int STOP_TRIP_ID_SET = 2 << 9;
93 : const int STOP_LINE_SET = 2 << 10;
94 : const int STOP_SPEED_SET = 2 << 11;
95 : const int STOP_SPLIT_SET = 2 << 12;
96 : const int STOP_JOIN_SET = 2 << 13;
97 : const int STOP_ARRIVAL_SET = 2 << 14;
98 : const int STOP_PERMITTED_SET = 2 << 15;
99 : const int STOP_ENDED_SET = 2 << 16;
100 : const int STOP_STARTED_SET = 2 << 17;
101 : const int STOP_POSLAT_SET = 2 << 18;
102 : const int STOP_ONDEMAND_SET = 2 << 19;
103 : const int STOP_JUMP_SET = 2 << 20;
104 : const int STOP_JUMP_UNTIL_SET = 2 << 21;
105 : const int STOP_PRIORITY_SET = 2 << 22;
106 :
107 : const double MIN_STOP_LENGTH = 2 * POSITION_EPS;
108 :
109 : const std::string LINE_ANY = "ANY";
110 :
111 : // ===========================================================================
112 : // enum definitions
113 : // ===========================================================================
114 : /**
115 : * @enum DepartDefinition
116 : * @brief Possible ways to depart
117 : */
118 : enum class DepartDefinition {
119 : /// @brief The time is given
120 : GIVEN,
121 : /// @brief The departure is person triggered
122 : TRIGGERED,
123 : /// @brief The departure is container triggered
124 : CONTAINER_TRIGGERED,
125 : /// @brief The vehicle is discarded if emission fails (not fully implemented yet)
126 : NOW,
127 : /// @brief The departure is triggered by a train split
128 : SPLIT,
129 : /// @brief The departure is at simulation start
130 : BEGIN,
131 : /// @brief Tag for the last element in the enum for safe int casting
132 : DEF_MAX
133 : };
134 :
135 :
136 : /**
137 : * @enum DepartLaneDefinition
138 : * @brief Possible ways to choose a lane on depart
139 : */
140 : enum class DepartLaneDefinition {
141 : /// @brief No information given; use default
142 : DEFAULT,
143 : /// @brief The lane is given
144 : GIVEN,
145 : /// @brief The lane is chosen randomly
146 : RANDOM,
147 : /// @brief The least occupied lane is used
148 : FREE,
149 : /// @brief The least occupied lane from lanes which allow the continuation
150 : ALLOWED_FREE,
151 : /// @brief The least occupied lane from best lanes
152 : BEST_FREE,
153 : /// @brief The lane most likely according the speedFactor (from best lanes)
154 : BEST_PROB,
155 : /// @brief The rightmost lane the vehicle may use
156 : FIRST_ALLOWED
157 : };
158 :
159 :
160 : /**
161 : * @enum DepartPosDefinition
162 : * @brief Possible ways to choose the departure position
163 : */
164 : enum class DepartPosDefinition {
165 : /// @brief No information given; use default
166 : DEFAULT,
167 : /// @brief The position is given
168 : GIVEN,
169 : /// @brief The position is set by the vehroute device
170 : GIVEN_VEHROUTE,
171 : /// @brief A random position is chosen
172 : RANDOM,
173 : /// @brief A free position is chosen
174 : FREE,
175 : /// @brief Back-at-zero position
176 : BASE,
177 : /// @brief Insert behind the last vehicle as close as possible to still allow the specified departSpeed. Fallback to DepartPosDefinition::BASE if there is no vehicle on the departLane yet.
178 : LAST,
179 : /// @brief If a fixed number of random choices fails, a free position is chosen
180 : RANDOM_FREE,
181 : /// @brief The position may be chosen freely in a polygon defined by a taz
182 : RANDOM_LOCATION,
183 : /// @brief depart position for a split vehicle is in front of the continuing vehicle
184 : SPLIT_FRONT,
185 : /// @brief depart position is endPos of first stop
186 : STOP
187 : };
188 :
189 :
190 : /**
191 : * @enum DepartPosLatDefinition
192 : * @brief Possible ways to choose the lateral departure position
193 : */
194 : enum class DepartPosLatDefinition {
195 : /// @brief No information given; use default
196 : DEFAULT,
197 : /// @brief The position is given
198 : GIVEN,
199 : /// @brief The position is set by the vehroute device
200 : GIVEN_VEHROUTE,
201 : /// @brief At the rightmost side of the lane
202 : RIGHT,
203 : /// @brief At the center of the lane
204 : CENTER,
205 : /// @brief At the leftmost side of the lane
206 : LEFT,
207 : /// @brief The lateral position is chosen randomly
208 : RANDOM,
209 : /// @brief A free lateral position is chosen
210 : FREE,
211 : /// @brief If a fixed number of random choices fails, a free lateral position is chosen
212 : RANDOM_FREE
213 : };
214 :
215 :
216 : /**
217 : * @enum DepartSpeedDefinition
218 : * @brief Possible ways to choose the departure speed
219 : */
220 : enum class DepartSpeedDefinition {
221 : /// @brief No information given; use default
222 : DEFAULT,
223 : /// @brief The speed is given
224 : GIVEN,
225 : /// @brief The speed is set by the vehroute device
226 : GIVEN_VEHROUTE,
227 : /// @brief The speed is chosen randomly
228 : RANDOM,
229 : /// @brief The maximum safe speed is used
230 : MAX,
231 : /// @brief The maximum lane speed is used (speedLimit * speedFactor)
232 : DESIRED,
233 : /// @brief The maximum lane speed is used (speedLimit)
234 : LIMIT,
235 : /// @brief The speed of the last vehicle. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on the departLane yet.
236 : LAST,
237 : /// @brief The average speed on the lane. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on the departLane yet.
238 : AVG
239 : };
240 :
241 :
242 : /**
243 : * @enum RouteIndexDefinition
244 : * @brief Possible ways to choose the departure and arrival edge
245 : */
246 : enum class RouteIndexDefinition {
247 : /// @brief No information given; use default
248 : DEFAULT,
249 : /// @brief The edge index is given
250 : GIVEN,
251 : /// @brief The edge is chosen randomly
252 : RANDOM,
253 : };
254 :
255 :
256 : /**
257 : * @enum ArrivalLaneDefinition
258 : * @brief Possible ways to choose the arrival lane
259 : */
260 : enum class ArrivalLaneDefinition {
261 : /// @brief No information given; use default
262 : DEFAULT = 0,
263 : /// @brief The current lane shall be used
264 : CURRENT = 1,
265 : /// @brief The arrival lane is given
266 : GIVEN = 2,
267 : /// @brief The lane is chosen randomly
268 : RANDOM = 3,
269 : /// @brief The rightmost lane the vehicle may use
270 : FIRST_ALLOWED = 4
271 : };
272 :
273 :
274 : /**
275 : * @enum ArrivalPosDefinition
276 : * @brief Possible ways to choose the arrival position
277 : */
278 : enum class ArrivalPosDefinition {
279 : /// @brief No information given; use default
280 : DEFAULT,
281 : /// @brief The arrival position is given
282 : GIVEN,
283 : /// @brief The arrival position is chosen randomly
284 : RANDOM,
285 : /// @brief Half the road length
286 : CENTER,
287 : /// @brief The maximum arrival position is used
288 : MAX
289 : };
290 :
291 :
292 : /**
293 : * @enum ArrivalPosLatDefinition
294 : * @brief Possible ways to choose the lateral arrival position
295 : */
296 : enum class ArrivalPosLatDefinition {
297 : /// @brief No information given; use default
298 : DEFAULT,
299 : /// @brief The position is given
300 : GIVEN,
301 : /// @brief At the rightmost side of the lane
302 : RIGHT,
303 : /// @brief At the center of the lane
304 : CENTER,
305 : /// @brief At the leftmost side of the lane
306 : LEFT
307 : };
308 :
309 :
310 : /**
311 : * @enum ArrivalSpeedDefinition
312 : * @brief Possible ways to choose the arrival speed
313 : */
314 : enum class ArrivalSpeedDefinition {
315 : /// @brief No information given; use default
316 : DEFAULT,
317 : /// @brief The speed is given
318 : GIVEN,
319 : /// @brief The current speed is used
320 : CURRENT
321 : };
322 :
323 :
324 : // ===========================================================================
325 : // struct definitions
326 : // ===========================================================================
327 : /**
328 : * @class SUMOVehicleParameter
329 : * @brief Structure representing possible vehicle parameter
330 : *
331 : * When used within a vehicle, parameter are usually const except for selected items
332 : * adaptable via TraCI which are flagged as mutable below
333 : * The fields yielding with "Procedure" describe whether the according value
334 : * shall be used or another procedure is used to choose the value.
335 : * @see DepartLaneDefinition
336 : * @see DepartPosDefinition
337 : * @see DepartSpeedDefinition
338 : */
339 : class SUMOVehicleParameter : public Parameterised {
340 : public:
341 : /** @brief Constructor
342 : *
343 : * Initialises the structure with default values
344 : */
345 : SUMOVehicleParameter();
346 :
347 : /// @brief Destructor
348 : virtual ~SUMOVehicleParameter();
349 :
350 : /** @struct Stop
351 : * @brief Definition of vehicle stop (position and duration)
352 : */
353 : class Stop : public Parameterised {
354 : public:
355 : /// @brief Destructor
356 2787707 : virtual ~Stop() {}
357 :
358 : /** @brief Writes the stop as XML
359 : *
360 : * @param[in, out] dev The device to write into
361 : * @exception IOError not yet implemented
362 : */
363 : void write(OutputDevice& dev, const bool close = true, const bool writeTagAndParents = true) const;
364 :
365 : /// @brief return list of stopping place ids
366 : std::vector<std::string> getStoppingPlaceIDs() const;
367 :
368 : /// @brief write trigger attribute
369 : std::vector<std::string> getTriggers() const;
370 :
371 : /// @brief The edge to stop at
372 : std::string edge;
373 :
374 : /// @brief The lane to stop at
375 : std::string lane;
376 :
377 : /// @brief (Optional) bus stop if one is assigned to the stop
378 : std::string busstop;
379 :
380 : /// @brief (Optional) container stop if one is assigned to the stop
381 : std::string containerstop;
382 :
383 : /// @brief (Optional) parking area if one is assigned to the stop
384 : std::string parkingarea;
385 :
386 : /// @brief (Optional) charging station if one is assigned to the stop
387 : std::string chargingStation;
388 :
389 : /// @brief (Optional) overhead line segment if one is assigned to the stop
390 : std::string overheadWireSegment;
391 :
392 : /// @brief The stopping position start
393 : double startPos = 0.;
394 :
395 : /// @brief The stopping position end
396 : double endPos = 0.;
397 :
398 : /// @brief The (expected) time at which the vehicle reaches the stop
399 : SUMOTime arrival = -1;
400 :
401 : /// @brief The stopping duration
402 : SUMOTime duration = -1;
403 : Distribution_Parameterized durationDist;
404 :
405 : /// @brief The time at which the vehicle may continue its journey
406 : SUMOTime until = -1;
407 :
408 : /// @brief The maximum time extension for boarding / loading
409 : SUMOTime extension = -1;
410 :
411 : /// @brief The earliest pickup time for a taxi stop
412 : SUMOTime waitUntil = -1;
413 :
414 : /// @brief whether an arriving person lets the vehicle continue
415 : bool triggered = false;
416 :
417 : /// @brief whether an arriving container lets the vehicle continue
418 : bool containerTriggered = false;
419 :
420 : /// @brief whether an joined vehicle lets this vehicle continue
421 : bool joinTriggered = false;
422 :
423 : /// @brief whether the vehicle is removed from the net while stopping
424 : ParkingType parking = ParkingType::ONROAD;
425 :
426 : /// @brief IDs of persons the vehicle has to wait for until departing
427 : std::set<std::string> awaitedPersons;
428 :
429 : /// @brief IDs of persons or containers that may board/load at this stop
430 : std::set<std::string> permitted;
431 :
432 : /// @brief IDs of containers the vehicle has to wait for until departing
433 : std::set<std::string> awaitedContainers;
434 :
435 : /// @brief enable or disable friendly position (used by netedit)
436 : bool friendlyPos = false;
437 :
438 : /// @brief act Type (only used by Persons) (used by netedit)
439 : std::string actType;
440 :
441 : /// @brief id of the trip within a cyclical public transport route
442 : std::string tripId;
443 :
444 : /// @brief the new line id of the trip within a cyclical public transport route
445 : std::string line;
446 :
447 : /// @brief the id of the vehicle (train portion) that splits of upon reaching this stop
448 : std::string split;
449 :
450 : /// @brief the id of the vehicle (train portion) to which this vehicle shall be joined
451 : std::string join;
452 :
453 : /// @brief the speed at which this stop counts as reached (waypoint mode)
454 : double speed = 0.;
455 :
456 : /// @brief the lateral offset when stopping
457 : double posLat = INVALID_DOUBLE;
458 :
459 : /// @brief whether the stop may be skipped
460 : bool onDemand = false;
461 :
462 : /// @brief priority for weighting/skipping stops
463 : double priority = -1;
464 :
465 : /// @brief transfer time if there shall be a jump from this stop to the next route edge
466 : SUMOTime jump = -1;
467 :
468 : /// @brief earlierst jump end if there shall be a jump from this stop to the next route edge
469 : SUMOTime jumpUntil = -1;
470 :
471 : /// @brief the time at which this stop was reached
472 : mutable SUMOTime started = -1;
473 :
474 : /// @brief the time at which this stop was ended
475 : mutable SUMOTime ended = -1;
476 :
477 : /// @brief lanes and positions connected to this stop (only used by duarouter where Stop is used to store stopping places)
478 : std::vector<std::tuple<std::string, double, double> > accessPos;
479 :
480 : /// @brief at which position in the stops list
481 : int index = 0;
482 :
483 : /// @brief at which position within the route (only used for state saving)
484 : mutable int routeIndex = 0;
485 :
486 : /// @brief Information for the output which parameter were set
487 : int parametersSet = 0;
488 :
489 : /// @brief Whether this stop was triggered by a collision
490 : bool collision = false;
491 :
492 : /// @brief Whether this stop was triggered by a car failure / mechanical problem / lack of energy
493 : bool breakDown = false;
494 :
495 : /// @brief return flags as per Vehicle::getStops
496 : int getFlags() const;
497 : };
498 :
499 : /** @brief Returns whether the given parameter was set
500 : * @param[in] what The parameter which one asks for
501 : * @return Whether the given parameter was set
502 : */
503 : bool wasSet(long long int what) const {
504 1621362642 : return (parametersSet & what) != 0;
505 : }
506 :
507 : /** @brief Writes the parameters as a beginning element
508 : *
509 : * @param[in, out] dev The device to write into
510 : * @param[in] oc The options to get defaults from
511 : * @param[in] altTag The "root" tag to write (defaults to vehicle)
512 : * @param[in] typeID The typeID to write (defaults to member vtypeid)
513 : * @exception IOError not yet implemented
514 : */
515 : void write(OutputDevice& dev, const OptionsCont& oc, const SumoXMLTag altTag = SUMO_TAG_VEHICLE, const std::string& typeID = "") const;
516 :
517 : /** @brief Returns whether the defaults shall be used
518 : * @param[in] oc The options to get the options from
519 : * @param[in] optionName The name of the option to determine whether its value shall be used
520 : * @return Whether the option is set and --defaults-override was set
521 : */
522 : bool defaultOptionOverrides(const OptionsCont& oc, const std::string& optionName) const;
523 :
524 : /// @name Depart/arrival-attributes verification
525 : /// @{
526 : /** @brief Validates a given depart value
527 : * @param[in] val The depart value to parse
528 : * @param[in] element The name of the type of the parsed element, for building the error message
529 : * @param[in] id The id of the parsed element, for building the error message
530 : * @param[out] depart The parsed depart time, if given
531 : * @param[out] dd The parsed departProcedure definition
532 : * @param[out] error Error message, if an error occurs
533 : * @return Whether the given value is a valid depart definition
534 : */
535 : static bool parseDepart(const std::string& val, const std::string& element, const std::string& id,
536 : SUMOTime& depart, DepartDefinition& dd, std::string& error, const std::string& attr = "departure");
537 :
538 : /** @brief Validates a given departLane value
539 : * @param[in] val The departLane value to parse
540 : * @param[in] element The name of the type of the parsed element, for building the error message
541 : * @param[in] id The id of the parsed element, for building the error message
542 : * @param[out] lane The parsed lane, if given
543 : * @param[out] dld The parsed departLane definition
544 : * @param[out] error Error message, if an error occurs
545 : * @return Whether the given value is a valid departLane definition
546 : */
547 : static bool parseDepartLane(const std::string& val, const std::string& element, const std::string& id,
548 : int& lane, DepartLaneDefinition& dld, std::string& error);
549 :
550 : /** @brief Validates a given departPos value
551 : * @param[in] val The departPos value to parse
552 : * @param[in] element The name of the type of the parsed element, for building the error message
553 : * @param[in] id The id of the parsed element, for building the error message
554 : * @param[out] pos The parsed position, if given
555 : * @param[out] dpd The parsed departPos definition
556 : * @param[out] error Error message, if an error occurs
557 : * @return Whether the given value is a valid departPos definition
558 : */
559 : static bool parseDepartPos(const std::string& val, const std::string& element, const std::string& id,
560 : double& pos, DepartPosDefinition& dpd, std::string& error);
561 :
562 : /** @brief Validates a given departPosLat value
563 : * @param[in] val The departPosLat value to parse
564 : * @param[in] element The name of the type of the parsed element, for building the error message
565 : * @param[in] id The id of the parsed element, for building the error message
566 : * @param[out] pos The parsed position, if given
567 : * @param[out] dpd The parsed departPosLat definition
568 : * @param[out] error Error message, if an error occurs
569 : * @return Whether the given value is a valid departPosLat definition
570 : */
571 : static bool parseDepartPosLat(const std::string& val, const std::string& element, const std::string& id,
572 : double& pos, DepartPosLatDefinition& dpd, std::string& error);
573 :
574 : /** @brief Validates a given departSpeed value
575 : * @param[in] val The departSpeed value to parse
576 : * @param[in] element The name of the type of the parsed element, for building the error message
577 : * @param[in] id The id of the parsed element, for building the error message
578 : * @param[out] speed The parsed speed, if given
579 : * @param[out] dsd The parsed departSpeed definition
580 : * @param[out] error Error message, if an error occurs
581 : * @return Whether the given value is a valid departSpeed definition
582 : */
583 : static bool parseDepartSpeed(const std::string& val, const std::string& element, const std::string& id,
584 : double& speed, DepartSpeedDefinition& dsd, std::string& error);
585 :
586 : /** @brief Validates a given departEdge or arrivalEdge value
587 : * @param[in] val The departEdge value to parse
588 : * @param[in] element The name of the type of the parsed element, for building the error message
589 : * @param[in] id The id of the parsed element, for building the error message
590 : * @param[out] edgeIndex The parsed edge index, if given
591 : * @param[out] ded The parsed departEdge definition
592 : * @param[out] error Error message, if an error occurs
593 : * @return Whether the given value is a valid departEdge definition
594 : */
595 : static bool parseRouteIndex(const std::string& val, const std::string& element, const std::string& id,
596 : const SumoXMLAttr attr,
597 : int& edgeIndex, RouteIndexDefinition& rid, std::string& error);
598 :
599 : /** @brief Validates a given arrivalLane value
600 : * @param[in] val The arrivalLane value to parse
601 : * @param[in] element The name of the type of the parsed element, for building the error message
602 : * @param[in] id The id of the parsed element, for building the error message
603 : * @param[out] lane The parsed lane, if given
604 : * @param[out] ald The parsed arrivalLane definition
605 : * @param[out] error Error message, if an error occurs
606 : * @return Whether the given value is a valid arrivalLane definition
607 : */
608 : static bool parseArrivalLane(const std::string& val, const std::string& element, const std::string& id,
609 : int& lane, ArrivalLaneDefinition& ald, std::string& error);
610 :
611 : /** @brief Validates a given arrivalPos value
612 : * @param[in] val The arrivalPos value to parse
613 : * @param[in] element The name of the type of the parsed element, for building the error message
614 : * @param[in] id The id of the parsed element, for building the error message
615 : * @param[out] pos The parsed position, if given
616 : * @param[out] apd The parsed arrivalPos definition
617 : * @param[out] error Error message, if an error occurs
618 : * @return Whether the given value is a valid arrivalPos definition
619 : */
620 : static bool parseArrivalPos(const std::string& val, const std::string& element, const std::string& id,
621 : double& pos, ArrivalPosDefinition& apd, std::string& error);
622 :
623 : /** @brief Validates a given arrivalPosLat value
624 : * @param[in] val The arrivalPosLat value to parse
625 : * @param[in] element The name of the type of the parsed element, for building the error message
626 : * @param[in] id The id of the parsed element, for building the error message
627 : * @param[out] pos The parsed position, if given
628 : * @param[out] apd The parsed arrivalPosLat definition
629 : * @param[out] error Error message, if an error occurs
630 : * @return Whether the given value is a valid arrivalPosLat definition
631 : */
632 : static bool parseArrivalPosLat(const std::string& val, const std::string& element, const std::string& id,
633 : double& pos, ArrivalPosLatDefinition& apd, std::string& error);
634 :
635 :
636 : /** @brief Validates a given arrivalSpeed value
637 : * @param[in] val The arrivalSpeed value to parse
638 : * @param[in] element The name of the type of the parsed element, for building the error message
639 : * @param[in] id The id of the parsed element, for building the error message
640 : * @param[out] speed The parsed speed, if given
641 : * @param[out] asd The parsed arrivalSpeed definition
642 : * @param[out] error Error message, if an error occurs
643 : * @return Whether the given value is a valid arrivalSpeed definition
644 : */
645 : static bool parseArrivalSpeed(const std::string& val, const std::string& element, const std::string& id,
646 : double& speed, ArrivalSpeedDefinition& asd, std::string& error);
647 : /// @}
648 :
649 : /** @brief Interprets negative edge positions and fits them onto a given edge
650 : * @param[in] pos The position to be interpreted
651 : * @param[in] maximumValue The maximum allowed value (edge length)
652 : * @param[in] attr The attribute from which the value originated
653 : * @param[in] id The id of the object to which this attribute belongs
654 : * @return Whether the interpreted position
655 : */
656 : static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string& id, bool silent = false);
657 :
658 : /** @brief Validates a given person modes value
659 : * @param[in] modes The modes value to parse
660 : * @param[in] element The name of the type of the parsed element, for building the error message
661 : * @param[in] id The id of the parsed element, for building the error message
662 : * @param[out] modeSet The parsed modes definition
663 : * @param[out] error Error message, if an error occurs
664 : * @return Whether the given value is a valid arrivalSpeed definition
665 : */
666 : static bool parsePersonModes(const std::string& modes, const std::string& element, const std::string& id, SVCPermissions& modeSet, std::string& error);
667 :
668 : /// @brief parses stop trigger values
669 : static void parseStopTriggers(const std::vector<std::string>& triggers, bool expectTrigger, Stop& stop);
670 :
671 : /// @brief parses parking type value
672 : static ParkingType parseParkingType(const std::string& value);
673 :
674 : /// @brief parses insertion checks
675 : static int parseInsertionChecks(const std::string& value);
676 :
677 : /// @brief The vehicle tag
678 : SumoXMLTag tag;
679 :
680 : /// @brief The vehicle's id
681 : std::string id;
682 :
683 : /// @brief The vehicle's route id
684 : std::string routeid;
685 :
686 : /// @brief The vehicle's type id
687 : std::string vtypeid;
688 :
689 : /// @brief The vehicle's color, TraCI may change this
690 : mutable RGBColor color;
691 :
692 : /// @name Departure definition
693 : /// @{
694 : /// @brief The vehicle's departure time
695 : SUMOTime depart;
696 :
697 : /// @brief Information how the vehicle shall choose the depart time
698 : DepartDefinition departProcedure;
699 :
700 : /// @brief (optional) The lane the vehicle shall depart from (index in edge)
701 : int departLane;
702 :
703 : /// @brief Information how the vehicle shall choose the lane to depart from
704 : DepartLaneDefinition departLaneProcedure;
705 :
706 : /// @brief (optional) The position the vehicle shall depart from
707 : double departPos;
708 :
709 : /// @brief Information how the vehicle shall choose the departure position
710 : DepartPosDefinition departPosProcedure;
711 :
712 : /// @brief (optional) The lateral position the vehicle shall depart from
713 : double departPosLat;
714 :
715 : /// @brief Information how the vehicle shall choose the lateral departure position
716 : DepartPosLatDefinition departPosLatProcedure;
717 :
718 : /// @brief (optional) The initial speed of the vehicle
719 : double departSpeed;
720 :
721 : /// @brief Information how the vehicle's initial speed shall be chosen
722 : DepartSpeedDefinition departSpeedProcedure;
723 :
724 : /// @brief (optional) The initial edge within the route of the vehicle
725 : int departEdge;
726 :
727 : /// @brief Information how the vehicle's initial edge shall be chosen
728 : RouteIndexDefinition departEdgeProcedure;
729 :
730 : /// @}
731 :
732 : /// @name Arrival definition
733 : /// @{
734 : /// @brief (optional) The lane the vehicle shall arrive on (not used yet)
735 : int arrivalLane;
736 :
737 : /// @brief Information how the vehicle shall choose the lane to arrive on
738 : ArrivalLaneDefinition arrivalLaneProcedure;
739 :
740 : /// @brief (optional) The position the vehicle shall arrive on
741 : double arrivalPos;
742 :
743 : /// @brief Information how the vehicle shall choose the arrival position
744 : ArrivalPosDefinition arrivalPosProcedure;
745 :
746 : /// @brief (optional) The lateral position the vehicle shall arrive on
747 : double arrivalPosLat;
748 :
749 : /// @brief Information how the vehicle shall choose the lateral arrival position
750 : ArrivalPosLatDefinition arrivalPosLatProcedure;
751 :
752 : /// @brief (optional) The final speed of the vehicle (not used yet)
753 : double arrivalSpeed;
754 :
755 : /// @brief Information how the vehicle's end speed shall be chosen
756 : ArrivalSpeedDefinition arrivalSpeedProcedure;
757 :
758 : /// @brief (optional) The final edge within the route of the vehicle
759 : int arrivalEdge;
760 :
761 : /// @brief Information how the vehicle's final edge shall be chosen
762 : RouteIndexDefinition arrivalEdgeProcedure;
763 :
764 : /// @}
765 :
766 : /// @name Repetition definition
767 : /// @{
768 : /// @brief The number of times the vehicle shall be repeatedly inserted
769 : long long int repetitionNumber;
770 :
771 : /// @brief The number of times the vehicle was already inserted
772 : long long int repetitionsDone;
773 :
774 : /// @brief The time offset between vehicle reinsertions
775 : SUMOTime repetitionOffset;
776 :
777 : /// @brief The offset between depart and the time for the next vehicle insertions
778 : SUMOTime repetitionTotalOffset;
779 :
780 : /// @brief The probability for emitting a vehicle per second
781 : double repetitionProbability;
782 :
783 : /// @brief The rate for emitting vehicles with a poisson distribution
784 : double poissonRate;
785 :
786 : /// @brief The time at which the flow ends (only needed when using repetitionProbability)
787 : SUMOTime repetitionEnd;
788 :
789 : /// @}
790 :
791 : /// @brief The vehicle's line (mainly for public transport)
792 : mutable std::string line;
793 :
794 : /// @brief The vehicle's origin zone (district)
795 : std::string fromTaz;
796 :
797 : /// @brief The vehicle's destination zone (district)
798 : std::string toTaz;
799 :
800 : /// @brief List of the stops the vehicle will make, TraCI may add entries here
801 : mutable std::vector<Stop> stops;
802 :
803 : /// @brief List of the via-edges the vehicle must visit
804 : mutable std::vector<std::string> via;
805 :
806 : /// @brief The parking access rights
807 : std::vector<std::string> parkingBadges;
808 :
809 : /// @brief The modes a person or container can use
810 : SVCPermissions modes;
811 :
812 : /// @brief The types of usable (auto-generated) vehicles for a person / container
813 : std::string vTypes;
814 :
815 : /// @brief The static number of persons in the vehicle when it departs (not including boarding persons)
816 : int personNumber;
817 :
818 : /// @brief The static number of containers in the vehicle when it departs
819 : int containerNumber;
820 :
821 : /// @brief individual speedFactor (overriding distribution from vType)
822 : double speedFactor;
823 :
824 : /// @brief speed (used by calibrator flows
825 : double calibratorSpeed;
826 :
827 : /// @brief bitset of InsertionCheck
828 : int insertionChecks;
829 :
830 : /// @brief Information for the router which parameter were set, TraCI may modify this (when changing color)
831 : mutable long long int parametersSet;
832 :
833 : public:
834 : /// @brief increment flow
835 : void incrementFlow(double scale, SumoRNG* rng = nullptr);
836 :
837 : protected:
838 : /// @brief obtain depart parameter in string format
839 : std::string getDepart() const;
840 :
841 : /// @brief obtain depart lane parameter in string format
842 : std::string getDepartLane() const;
843 :
844 : /// @brief obtain depart pos parameter in string format
845 : std::string getDepartPos() const;
846 :
847 : /// @brief obtain depart pos lat parameter in string format
848 : std::string getDepartPosLat() const;
849 :
850 : /// @brief obtain depart speed parameter in string format
851 : std::string getDepartSpeed() const;
852 :
853 : /// @brief obtain depart edge parameter in string format
854 : std::string getDepartEdge() const;
855 :
856 : /// @brief obtain arrival lane parameter in string format
857 : std::string getArrivalLane() const;
858 :
859 : /// @brief obtain arrival pos parameter in string format
860 : std::string getArrivalPos() const;
861 :
862 : /// @brief obtain arrival pos lat parameter in string format
863 : std::string getArrivalPosLat() const;
864 :
865 : /// @brief obtain arrival speed parameter in string format
866 : std::string getArrivalSpeed() const;
867 :
868 : /// @brief obtain arrival edge parameter in string format
869 : std::string getArrivalEdge() const;
870 :
871 : /// @brief get insertion checks in string format
872 : std::string getInsertionChecks() const;
873 :
874 : /// @brief check if given insertion checks are valid
875 : bool areInsertionChecksValid(const std::string& value) const;
876 :
877 : };
878 :
879 : typedef std::vector<SUMOVehicleParameter::Stop> StopParVector;
|