Eclipse SUMO - Simulation of Urban MObility
SUMOVehicleParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Structure representing possible vehicle parameter
21 /****************************************************************************/
22 #include <config.h>
26 #include <utils/common/ToString.h>
29 
30 #include "SUMOVehicleParameter.h"
31 
32 // ===========================================================================
33 // member method definitions
34 // ===========================================================================
35 
37  : tag(SUMO_TAG_NOTHING), vtypeid(DEFAULT_VTYPE_ID), color(RGBColor::DEFAULT_COLOR),
38  depart(-1), departProcedure(DEPART_GIVEN),
39  departLane(0), departLaneProcedure(DepartLaneDefinition::DEFAULT),
40  departPos(0), departPosProcedure(DepartPosDefinition::DEFAULT),
41  departPosLat(0), departPosLatProcedure(DepartPosLatDefinition::DEFAULT),
42  departSpeed(-1), departSpeedProcedure(DepartSpeedDefinition::DEFAULT),
43  departEdge(0), departEdgeProcedure(DepartEdgeDefinition::DEFAULT),
44  arrivalLane(0), arrivalLaneProcedure(ArrivalLaneDefinition::DEFAULT),
45  arrivalPos(0), arrivalPosProcedure(ArrivalPosDefinition::DEFAULT),
46  arrivalPosLat(0), arrivalPosLatProcedure(ArrivalPosLatDefinition::DEFAULT),
47  arrivalSpeed(-1), arrivalSpeedProcedure(ArrivalSpeedDefinition::DEFAULT),
48  repetitionNumber(-1), repetitionsDone(-1), repetitionOffset(-1), repetitionProbability(-1), repetitionEnd(-1),
49  line(), fromTaz(), toTaz(), personNumber(0), containerNumber(0),
50  speedFactor(-1),
51  parametersSet(0)
52 { }
53 
54 
56 }
57 
58 
59 bool
60 SUMOVehicleParameter::defaultOptionOverrides(const OptionsCont& oc, const std::string& optionName) const {
61  return oc.exists(optionName) && oc.isSet(optionName) && oc.getBool("defaults-override");
62 }
63 
64 
65 void
66 SUMOVehicleParameter::write(OutputDevice& dev, const OptionsCont& oc, const SumoXMLTag tag, const std::string& typeID) const {
68  if (typeID == "") {
71  }
72  } else {
73  dev.writeAttr(SUMO_ATTR_TYPE, typeID);
74  }
75  // write depart depending of tag
76  if ((tag == SUMO_TAG_FLOW) || (tag == SUMO_TAG_PERSONFLOW) ||
79  } else {
81  }
82  // optional parameter
83  // departlane
84  if (wasSet(VEHPARS_DEPARTLANE_SET) && !defaultOptionOverrides(oc, "departlane")) {
86  } else if (oc.exists("departlane") && oc.isSet("departlane")) {
87  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTLANE, oc.getString("departlane"));
88  }
89  // departpos
90  if (wasSet(VEHPARS_DEPARTPOS_SET) && !defaultOptionOverrides(oc, "departpos")) {
92  } else if (oc.exists("departpos") && oc.isSet("departpos")) {
93  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTPOS, oc.getString("departpos"));
94  }
95  // departPosLat
98  }
99  // departspeed
100  if (wasSet(VEHPARS_DEPARTSPEED_SET) && !defaultOptionOverrides(oc, "departspeed")) {
102  } else if (oc.exists("departspeed") && oc.isSet("departspeed")) {
103  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTSPEED, oc.getString("departspeed"));
104  }
105  // departedge
106  if (wasSet(VEHPARS_DEPARTEDGE_SET) && !defaultOptionOverrides(oc, "departedge")) {
108  } else if (oc.exists("departedge") && oc.isSet("departedge")) {
109  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTEDGE, oc.getString("departedge"));
110  }
111  // arrivallane
112  if (wasSet(VEHPARS_ARRIVALLANE_SET) && !defaultOptionOverrides(oc, "arrivallane")) {
114  } else if (oc.exists("arrivallane") && oc.isSet("arrivallane")) {
115  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALLANE, oc.getString("arrivallane"));
116  }
117  // arrivalpos
118  if (wasSet(VEHPARS_ARRIVALPOS_SET) && !defaultOptionOverrides(oc, "arrivalpos")) {
120  } else if (oc.exists("arrivalpos") && oc.isSet("arrivalpos")) {
121  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALPOS, oc.getString("arrivalpos"));
122  }
123  // arrivalPosLat
126  }
127  // arrivalspeed
128  if (wasSet(VEHPARS_ARRIVALSPEED_SET) && !defaultOptionOverrides(oc, "arrivalspeed")) {
130  } else if (oc.exists("arrivalspeed") && oc.isSet("arrivalspeed")) {
131  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALSPEED, oc.getString("arrivalspeed"));
132  }
133  // color
134  if (wasSet(VEHPARS_COLOR_SET)) {
136  }
137  // line
138  if (wasSet(VEHPARS_LINE_SET)) {
140  }
141  // from TAZ
144  }
145  // to TAZ
146  if (wasSet(VEHPARS_TO_TAZ_SET)) {
148  }
149  // person number
152  }
153  // container number
156  }
157  // individual speedFactor
160  }
161 }
162 
163 
164 void
166  dev.openTag(SUMO_TAG_STOP);
167  if (busstop != "") {
169  }
170  if (containerstop != "") {
172  }
173  if (chargingStation != "") {
175  }
176  if (parkingarea != "") {
178  }
179  if ((busstop == "") && (containerstop == "") && (parkingarea == "") && (chargingStation == "")) {
180  if (lane != "") {
182  } else {
184  }
185  if ((parametersSet & STOP_START_SET) != 0) {
187  }
188  if ((parametersSet & STOP_END_SET) != 0) {
190  }
191  }
192  if ((parametersSet & STOP_ARRIVAL_SET) && (arrival >= 0)) {
194  }
195  if ((parametersSet & STOP_DURATION_SET) && (duration >= 0)) {
197  }
198  if ((parametersSet & STOP_UNTIL_SET) && (until >= 0)) {
200  }
201  if ((parametersSet & STOP_EXTENSION_SET) && (extension >= 0)) {
203  }
204  writeTriggers(dev);
205  if ((parametersSet & STOP_PARKING_SET) != 0) {
207  }
208  if ((parametersSet & STOP_EXPECTED_SET) != 0) {
210  }
213  }
214  if ((parametersSet & STOP_TRIP_ID_SET) != 0) {
216  }
217  if ((parametersSet & STOP_LINE_SET) != 0) {
219  }
220  if ((parametersSet & STOP_SPLIT_SET) != 0) {
222  }
223  if ((parametersSet & STOP_JOIN_SET) != 0) {
225  }
226  if ((parametersSet & STOP_SPEED_SET) != 0) {
228  }
229  // only write friendly position if is true
230  if (friendlyPos == true) {
232  }
233  // only write act type if isn't empty
234  if (!actType.empty()) {
236  }
237  if (close) {
238  dev.closeTag();
239  }
240 }
241 
242 
243 bool
244 SUMOVehicleParameter::parseDepart(const std::string& val, const std::string& element, const std::string& id,
245  SUMOTime& depart, DepartDefinition& dd, std::string& error) {
246  if (val == "triggered") {
247  dd = DEPART_TRIGGERED;
248  } else if (val == "containerTriggered") {
250  } else if (val == "split") {
251  dd = DEPART_SPLIT;
252  } else if (val == "now") {
253  // only used via TraCI. depart must be set by the calling code
254  dd = DEPART_NOW;
255  } else {
256  try {
257  depart = string2time(val);
258  dd = DEPART_GIVEN;
259  if (depart < 0) {
260  error = "Negative departure time in the definition of '" + id + "'.";
261  return false;
262  }
263  } catch (...) {
264  if (id.empty()) {
265  error = "Invalid departure time for " + element + ". Must be one of (\"triggered\", \"containerTriggered\", \"now\", or a float >= 0)";
266  } else {
267  error = "Invalid departure time for " + element + " '" + id + "';\n must be one of (\"triggered\", \"containerTriggered\", \"now\", or a float >= 0)";
268  }
269  return false;
270  }
271  }
272  return true;
273 }
274 
275 
276 bool
277 SUMOVehicleParameter::parseDepartLane(const std::string& val, const std::string& element, const std::string& id,
278  int& lane, DepartLaneDefinition& dld, std::string& error) {
279  bool ok = true;
280  lane = 0;
282  if (val == "random") {
284  } else if (val == "free") {
286  } else if (val == "allowed") {
288  } else if (val == "best") {
290  } else if (val == "first") {
292  } else {
293  try {
294  lane = StringUtils::toInt(val);
295  if (lane < 0) {
296  ok = false;
297  }
298  } catch (...) {
299  ok = false;
300  }
301  }
302  if (!ok) {
303  if (id.empty()) {
304  error = "Invalid departLane definition for " + element + ". Must be one of (\"random\", \"free\", \"allowed\", \"best\", \"first\", or an int>=0)";
305  } else {
306  error = "Invalid departLane definition for " + element + " '" + id + "';\n must be one of (\"random\", \"free\", \"allowed\", \"best\", \"first\", or an int>=0)";
307  }
308  }
309  return ok;
310 }
311 
312 
313 bool
314 SUMOVehicleParameter::parseDepartPos(const std::string& val, const std::string& element, const std::string& id,
315  double& pos, DepartPosDefinition& dpd, std::string& error) {
316  bool ok = true;
317  pos = 0.;
319  if (val == "random") {
321  } else if (val == "random_free") {
323  } else if (val == "free") {
325  } else if (val == "base") {
327  } else if (val == "last") {
329  } else if (val == "stop") {
331  } else {
332  try {
333  pos = StringUtils::toDouble(val);
334  } catch (...) {
335  ok = false;
336  }
337  }
338  if (!ok) {
339  if (id.empty()) {
340  error = "Invalid departPos definition for " + element + ". Must be one of (\"random\", \"random_free\", \"free\", \"base\", \"last\" or a float)";
341  } else {
342  error = "Invalid departPos definition for " + element + " '" + id + "';\n must be one of (\"random\", \"random_free\", \"free\", \"base\", \"last\" or a float)";
343  }
344  }
345  return ok;
346 }
347 
348 
349 bool
350 SUMOVehicleParameter::parseDepartPosLat(const std::string& val, const std::string& element, const std::string& id,
351  double& pos, DepartPosLatDefinition& dpd, std::string& error) {
352  bool ok = true;
353  pos = 0.;
355  if (val == "random") {
357  } else if (val == "random_free") {
359  } else if (val == "free") {
361  } else if (val == "right") {
363  } else if (val == "center") {
365  } else if (val == "left") {
367  } else {
368  try {
369  pos = StringUtils::toDouble(val);
370  } catch (...) {
371  ok = false;
372  }
373  }
374  if (!ok) {
375  if (id.empty()) {
376  error = "Invalid departPosLat definition for " + element + ". Must be one of (\"random\", \"random_free\", \"free\", \"right\", \"center\", \"left\", or a float)";
377  } else {
378  error = "Invalid departPosLat definition for " + element + " '" + id + "';\n must be one of (\"random\", \"random_free\", \"free\", \"right\", \"center\", \"left\", or a float)";
379  }
380  }
381  return ok;
382 }
383 
384 
385 bool
386 SUMOVehicleParameter::parseDepartSpeed(const std::string& val, const std::string& element, const std::string& id,
387  double& speed, DepartSpeedDefinition& dsd, std::string& error) {
388  bool ok = true;
389  speed = -1.;
391  if (val == "random") {
393  } else if (val == "max") {
395  } else if (val == "desired") {
397  } else if (val == "speedLimit") {
399  } else {
400  try {
401  speed = StringUtils::toDouble(val);
402  if (speed < 0) {
403  ok = false;
404  }
405  } catch (...) {
406  ok = false;
407  }
408  }
409  if (!ok) {
410  if (id.empty()) {
411  error = "Invalid departSpeed definition for " + element + ". Must be one of (\"random\", \"max\", or a float>=0)";
412  } else {
413  error = "Invalid departSpeed definition for " + element + " '" + id + "';\n must be one of (\"random\", \"max\", or a float>=0)";
414  }
415  }
416  return ok;
417 }
418 
419 
420 bool
421 SUMOVehicleParameter::parseDepartEdge(const std::string& val, const std::string& element, const std::string& id,
422  int& edgeIndex, DepartEdgeDefinition& ded, std::string& error) {
423  bool ok = true;
424  edgeIndex = -1;
426  if (val == "random") {
428  } else {
429  try {
430  edgeIndex = StringUtils::toInt(val);
431  if (edgeIndex < 0) {
432  ok = false;
433  }
434  } catch (...) {
435  ok = false;
436  }
437  }
438  if (!ok) {
439  if (id.empty()) {
440  error = "Invalid departEdge definition for " + element + ". Must be one of (\"random\", \"free\", or an int>=0)";
441  } else {
442  error = "Invalid departEdge definition for " + element + " '" + id + "';\n must be one of (\"random\", \"free\", or an int>=0)";
443  }
444  }
445  return ok;
446 }
447 
448 
449 bool
450 SUMOVehicleParameter::parseArrivalLane(const std::string& val, const std::string& element, const std::string& id,
451  int& lane, ArrivalLaneDefinition& ald, std::string& error) {
452  bool ok = true;
453  lane = 0;
455  if (val == "current") {
457  } else {
458  try {
459  lane = StringUtils::toInt(val);
460  if (lane < 0) {
461  ok = false;
462  }
463  } catch (...) {
464  ok = false;
465  }
466  }
467  if (!ok) {
468  if (id.empty()) {
469  error = "Invalid arrivalLane definition for " + element + ". Must be one of (\"current\", or an int>=0)";
470  } else {
471  error = "Invalid arrivalLane definition for " + element + " '" + id + "';\n must be one of (\"current\", or an int>=0)";
472  }
473  }
474  return ok;
475 }
476 
477 
478 bool
479 SUMOVehicleParameter::parseArrivalPos(const std::string& val, const std::string& element, const std::string& id,
480  double& pos, ArrivalPosDefinition& apd, std::string& error) {
481  bool ok = true;
482  pos = 0.;
484  if (val == "random") {
486  } else if (val == "center") {
488  } else if (val == "max") {
490  } else {
491  try {
492  pos = StringUtils::toDouble(val);
493  } catch (...) {
494  ok = false;
495  }
496  }
497  if (!ok) {
498  if (id.empty()) {
499  error = "Invalid arrivalPos definition for " + element + ". Must be one of (\"random\", \"max\", or a float)";
500  } else {
501  error = "Invalid arrivalPos definition for " + element + " '" + id + "';\n must be one of (\"random\", \"max\", or a float)";
502  }
503  }
504  return ok;
505 }
506 
507 
508 bool
509 SUMOVehicleParameter::parseArrivalPosLat(const std::string& val, const std::string& element, const std::string& id,
510  double& pos, ArrivalPosLatDefinition& apd, std::string& error) {
511  bool ok = true;
512  pos = 0.;
514  if (val == "right") {
516  } else if (val == "center") {
518  } else if (val == "left") {
520  } else {
521  try {
522  pos = StringUtils::toDouble(val);
523  } catch (...) {
524  ok = false;
525  }
526  }
527  if (!ok) {
528  if (id.empty()) {
529  error = "Invalid arrivalPosLat definition for " + element + ". Must be one of (\"right\", \"center\", \"left\", or a float)";
530  } else {
531  error = "Invalid arrivalPosLat definition for " + element + " '" + id + "';\n must be one of (\"right\", \"center\", \"left\", or a float)";
532  }
533  }
534  return ok;
535 }
536 
537 
538 bool
539 SUMOVehicleParameter::parseArrivalSpeed(const std::string& val, const std::string& element, const std::string& id,
540  double& speed, ArrivalSpeedDefinition& asd, std::string& error) {
541  bool ok = true;
542  speed = -1.;
544  if (val == "current") {
546  } else {
547  try {
548  speed = StringUtils::toDouble(val);
549  if (speed < 0) {
550  ok = false;
551  }
552  } catch (...) {
553  ok = false;
554  }
555  }
556  if (!ok) {
557  if (id.empty()) {
558  error = "Invalid arrivalSpeed definition for " + element + ". Must be one of (\"current\", or a float>=0)";
559  } else {
560  error = "Invalid arrivalSpeed definition for " + element + " '" + id + "';\n must be one of (\"current\", or a float>=0)";
561  }
562  }
563  return ok;
564 }
565 
566 
567 double
568 SUMOVehicleParameter::interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string& id, bool silent) {
569  if (pos < 0) {
570  pos = maximumValue + pos;
571  }
572  if (pos > maximumValue && pos != std::numeric_limits<double>::infinity()) {
573  if (!silent) {
574  WRITE_WARNING("Invalid " + toString(attr) + " " + toString(pos) + " given for " + id + ". Using edge end instead.");
575  }
576  pos = maximumValue;
577  }
578  return pos;
579 }
580 
581 
582 bool
583 SUMOVehicleParameter::parsePersonModes(const std::string& modes, const std::string& element, const std::string& id, SVCPermissions& modeSet, std::string& error) {
584  // separte modes in different strings, and check if modes are valid
585  for (StringTokenizer st(modes); st.hasNext();) {
586  const std::string mode = st.next();
587  if (mode == "car") {
588  modeSet |= SVC_PASSENGER;
589  } else if (mode == "taxi") {
590  modeSet |= SVC_TAXI;
591  } else if (mode == "bicycle") {
592  modeSet |= SVC_BICYCLE;
593  } else if (mode == "public") {
594  modeSet |= SVC_BUS;
595  } else {
596  if (id.empty()) {
597  error = "Unknown person mode '" + mode + "'. Must be a combination of (\"car\", \"bicycle\" or \"public\")";
598  } else {
599  error = "Unknown person mode '" + mode + "' for " + element + " '" + id + "';\n must be a combination of (\"car\", \"bicycle\" or \"public\")";
600  }
601  return false;
602  }
603  }
604  return true;
605 }
606 
607 
608 void
609 SUMOVehicleParameter::parseStopTriggers(const std::vector<std::string>& triggers, bool expectTrigger, Stop& stop) {
610  if (triggers.size() == 0 && expectTrigger) {
611  stop.triggered = true;
612  }
613  for (std::string val : triggers) {
614  if (val == toString(SUMO_TAG_PERSON)) {
615  stop.triggered = true;
616  } else if (val == toString(SUMO_TAG_CONTAINER)) {
617  stop.containerTriggered = true;
618  } else if (val == toString(SUMO_ATTR_JOIN)) {
619  stop.joinTriggered = true;
620  } else {
621  try {
622  stop.triggered = StringUtils::toBool(val);
623  } catch (BoolFormatException&) {
624  WRITE_ERROR("Value of stop attribute 'trigger' must be 'person', 'container', 'join' or a boolean");
625  }
626  }
627  }
628 }
629 
630 
631 void
633  if ((parametersSet & STOP_TRIGGER_SET) != 0) {
634  std::vector<std::string> triggers;
635  if (triggered) {
636  triggers.push_back(toString(SUMO_TAG_PERSON));
637  }
638  if (containerTriggered) {
639  triggers.push_back(toString(SUMO_TAG_CONTAINER));
640  }
641  if (joinTriggered) {
642  triggers.push_back(toString(SUMO_ATTR_JOIN));
643  }
644  dev.writeAttr(SUMO_ATTR_TRIGGERED, triggers);
645  }
646 }
647 
648 
649 std::string
652  return "triggered";
654  return "containerTriggered";
655  } else if (departProcedure == DEPART_SPLIT) {
656  return "split";
657  } else {
658  return time2string(depart);
659  }
660 }
661 
662 
663 std::string
665  std::string val;
666  switch (departLaneProcedure) {
668  val = toString(departLane);
669  break;
671  val = "random";
672  break;
674  val = "free";
675  break;
677  val = "allowed";
678  break;
680  val = "best";
681  break;
683  val = "first";
684  break;
686  default:
687  break;
688  }
689  return val;
690 }
691 
692 
693 std::string
695  std::string val;
696  switch (departPosProcedure) {
698  val = toString(departPos);
699  break;
701  val = "random";
702  break;
704  val = "random_free";
705  break;
707  val = "free";
708  break;
710  val = "last";
711  break;
713  val = "base";
714  break;
716  val = "stop";
717  break;
719  default:
720  break;
721  }
722  return val;
723 }
724 
725 
726 std::string
728  std::string val;
729  switch (departPosLatProcedure) {
731  val = toString(departPos);
732  break;
734  val = "random";
735  break;
737  val = "random_free";
738  break;
740  val = "free";
741  break;
743  val = "right";
744  break;
746  val = "center";
747  break;
749  val = "left";
750  break;
752  default:
753  break;
754  }
755  return val;
756 }
757 
758 
759 std::string
761  std::string val;
762  switch (departSpeedProcedure) {
764  val = toString(departSpeed);
765  break;
767  val = "random";
768  break;
770  val = "max";
771  break;
773  val = "desired";
774  break;
776  val = "speedLimit";
777  break;
779  default:
780  break;
781  }
782  return val;
783 }
784 
785 
786 std::string
788  std::string val;
789  switch (departEdgeProcedure) {
791  val = toString(departEdge);
792  break;
794  val = "random";
795  break;
797  default:
798  break;
799  }
800  return val;
801 }
802 
803 
804 std::string
806  std::string val;
807  switch (arrivalLaneProcedure) {
809  val = toString(arrivalLane);
810  break;
812  val = "current";
813  break;
815  default:
816  break;
817  }
818  return val;
819 }
820 
821 
822 std::string
824  std::string val;
825  switch (arrivalPosProcedure) {
827  val = toString(arrivalPos);
828  break;
830  val = "random";
831  break;
833  val = "center";
834  break;
836  val = "max";
837  break;
839  default:
840  break;
841  }
842  return val;
843 }
844 
845 
846 std::string
848  std::string val;
849  switch (arrivalPosLatProcedure) {
851  val = toString(arrivalPos);
852  break;
854  val = "right";
855  break;
857  val = "center";
858  break;
860  val = "left";
861  break;
863  default:
864  break;
865  }
866  return val;
867 }
868 
869 
870 std::string
872  std::string val;
873  switch (arrivalSpeedProcedure) {
875  val = toString(arrivalSpeed);
876  break;
878  val = "current";
879  break;
881  default:
882  break;
883  }
884  return val;
885 }
886 
887 
888 /****************************************************************************/
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
long long int SUMOTime
Definition: SUMOTime.h:31
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
const std::string DEFAULT_VTYPE_ID
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const int VEHPARS_DEPARTEDGE_SET
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int VEHPARS_COLOR_SET
const int STOP_EXPECTED_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ RANDOM
The lane is chosen randomly.
@ BEST_FREE
The least occupied lane from best lanes.
@ GIVEN
The lane is given.
@ ALLOWED_FREE
The least occupied lane from lanes which allow the continuation.
@ DEFAULT
No information given; use default.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
@ FREE
The least occupied lane is used.
const int VEHPARS_TO_TAZ_SET
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
@ GIVEN
The speed is given.
@ DEFAULT
No information given; use default.
@ CURRENT
The current speed is used.
DepartPosLatDefinition
@ RANDOM
The lateral position is chosen randomly.
@ RIGHT
At the rightmost side of the lane.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ LEFT
At the leftmost side of the lane.
@ FREE
A free lateral position is chosen.
@ CENTER
At the center of the lane.
@ RANDOM_FREE
If a fixed number of random choices fails, a free lateral position is chosen.
DepartPosDefinition
Possible ways to choose the departure position.
@ RANDOM
The position is chosen randomly.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ STOP
depart position is endPos of first stop
@ FREE
A free position is chosen.
@ BASE
Back-at-zero position.
@ LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
const int STOP_SPEED_SET
const int STOP_UNTIL_SET
const int VEHPARS_SPEEDFACTOR_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
@ DEFAULT
No information given; use default.
@ CURRENT
The current lane shall be used.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ RANDOM
The speed is chosen randomly.
@ MAX
The maximum safe speed is used.
@ GIVEN
The speed is given.
@ LIMIT
The maximum lane speed is used (speedLimit)
@ DEFAULT
No information given; use default.
@ DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
const int VEHPARS_DEPARTLANE_SET
const int STOP_SPLIT_SET
const int VEHPARS_ARRIVALPOSLAT_SET
DepartEdgeDefinition
Possible ways to choose the departure edge.
@ RANDOM
The edge is chosen randomly.
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int STOP_START_SET
const int VEHPARS_FROM_TAZ_SET
const int STOP_JOIN_SET
const int VEHPARS_ARRIVALSPEED_SET
const int STOP_EXTENSION_SET
const int STOP_TRIGGER_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ RANDOM
The arrival position is chosen randomly.
@ MAX
The maximum arrival position is used.
@ GIVEN
The arrival position is given.
@ DEFAULT
No information given; use default.
@ CENTER
Half the road length.
const int STOP_END_SET
const int VEHPARS_LINE_SET
const int VEHPARS_PERSON_NUMBER_SET
const int STOP_EXPECTED_CONTAINERS_SET
const int VEHPARS_DEPARTSPEED_SET
ArrivalPosLatDefinition
Possible ways to choose the departure position.
@ RIGHT
At the rightmost side of the lane.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ LEFT
At the leftmost side of the lane.
@ CENTER
At the center of the lane.
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
DepartDefinition
Possible ways to depart.
@ DEPART_SPLIT
The departure is triggered by a train split.
@ DEPART_GIVEN
The time is given.
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_TRIGGERED
The departure is person triggered.
@ DEPART_NOW
The vehicle is discarded if emission fails (not fully implemented yet)
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_STOP
stop for vehicles
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route (used in NETEDIT)
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONFLOW
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_LANE
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_SPEEDFACTOR
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeNonEmptyAttr(const SumoXMLAttr attr, const std::string &val)
writes a string attribute only if it is not the empty string and not the string "default"
Definition: OutputDevice.h:264
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at (used only in NETEDIT)
std::string lane
The lane to stop at.
void write(OutputDevice &dev, bool close=true) const
Writes the stop as XML.
SUMOTime extension
The maximum time extension for boarding / loading.
bool friendlyPos
enable or disable friendly position (used by NETEDIT)
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
std::string chargingStation
(Optional) charging station if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
void writeTriggers(OutputDevice &dev) const
write trigger attribute
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by NETEDIT)
bool triggered
whether an arriving person lets the vehicle continue
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool joinTriggered
whether an joined vehicle lets this vehicle continue
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
virtual ~SUMOVehicleParameter()
Destructor.
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
double speedFactor
individual speedFactor (overriding distribution from vType)
SUMOVehicleParameter()
Constructor.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
std::string getDepart() const
obtain depart parameter in string format
double departPos
(optional) The position the vehicle shall depart from
std::string getDepartEdge() const
obtain depart edge parameter in string format
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
DepartEdgeDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
bool defaultOptionOverrides(const OptionsCont &oc, const std::string &optionName) const
Returns whether the defaults shall be used.
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static bool parseDepartEdge(const std::string &val, const std::string &element, const std::string &id, int &edgeIndex, DepartEdgeDefinition &ded, std::string &error)
Validates a given departEdge value.
int containerNumber
The static number of containers in the vehicle when it departs.
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
bool hasNext()
returns the information whether further substrings exist
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter