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