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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
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(RouteIndexDefinition::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  arrivalEdge(-1), arrivalEdgeProcedure(RouteIndexDefinition::DEFAULT),
49  repetitionNumber(-1), repetitionsDone(-1), repetitionOffset(-1), repetitionProbability(-1), repetitionEnd(-1),
50  line(), fromTaz(), toTaz(), personNumber(0), containerNumber(0),
51  speedFactor(-1),
52  calibratorSpeed(-1),
53  parametersSet(0)
54 { }
55 
56 
58 }
59 
60 
61 bool
62 SUMOVehicleParameter::defaultOptionOverrides(const OptionsCont& oc, const std::string& optionName) const {
63  return oc.exists(optionName) && oc.isSet(optionName) && oc.getBool("defaults-override");
64 }
65 
66 
67 void
68 SUMOVehicleParameter::write(OutputDevice& dev, const OptionsCont& oc, const SumoXMLTag altTag, const std::string& typeID) const {
69  if (!id.empty()) {
70  // only used by calibrator flows
71  dev.openTag(altTag).writeAttr(SUMO_ATTR_ID, id);
72  }
73  if (typeID == "") {
76  }
77  } else {
78  dev.writeAttr(SUMO_ATTR_TYPE, typeID);
79  }
80  // write depart depending of tag
81  if ((altTag == SUMO_TAG_FLOW) || (altTag == SUMO_TAG_PERSONFLOW) ||
82  (altTag == GNE_TAG_FLOW_ROUTE) || (altTag == GNE_TAG_FLOW_WITHROUTE)) {
84  } else {
86  }
87  // optional parameter
88  // departlane
89  if (wasSet(VEHPARS_DEPARTLANE_SET) && !defaultOptionOverrides(oc, "departlane")) {
91  } else if (oc.exists("departlane") && oc.isSet("departlane")) {
92  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTLANE, oc.getString("departlane"));
93  }
94  // departpos
95  if (wasSet(VEHPARS_DEPARTPOS_SET) && !defaultOptionOverrides(oc, "departpos")) {
97  } else if (oc.exists("departpos") && oc.isSet("departpos")) {
98  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTPOS, oc.getString("departpos"));
99  }
100  // departPosLat
103  }
104  // departspeed
105  if (wasSet(VEHPARS_DEPARTSPEED_SET) && !defaultOptionOverrides(oc, "departspeed")) {
107  } else if (oc.exists("departspeed") && oc.isSet("departspeed")) {
108  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTSPEED, oc.getString("departspeed"));
109  }
110  // departedge
111  if (wasSet(VEHPARS_DEPARTEDGE_SET) && !defaultOptionOverrides(oc, "departedge")) {
113  } else if (oc.exists("departedge") && oc.isSet("departedge")) {
114  dev.writeNonEmptyAttr(SUMO_ATTR_DEPARTEDGE, oc.getString("departedge"));
115  }
116  // arrivallane
117  if (wasSet(VEHPARS_ARRIVALLANE_SET) && !defaultOptionOverrides(oc, "arrivallane")) {
119  } else if (oc.exists("arrivallane") && oc.isSet("arrivallane")) {
120  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALLANE, oc.getString("arrivallane"));
121  }
122  // arrivalpos
123  if (wasSet(VEHPARS_ARRIVALPOS_SET) && !defaultOptionOverrides(oc, "arrivalpos")) {
125  } else if (oc.exists("arrivalpos") && oc.isSet("arrivalpos")) {
126  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALPOS, oc.getString("arrivalpos"));
127  }
128  // arrivalPosLat
131  }
132  // arrivalspeed
133  if (wasSet(VEHPARS_ARRIVALSPEED_SET) && !defaultOptionOverrides(oc, "arrivalspeed")) {
135  } else if (oc.exists("arrivalspeed") && oc.isSet("arrivalspeed")) {
136  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALSPEED, oc.getString("arrivalspeed"));
137  }
138  // arrivalEdge
139  if (wasSet(VEHPARS_ARRIVALEDGE_SET) && !defaultOptionOverrides(oc, "arrivaledge") && arrivalEdge >= 0) {
141  } else if (oc.exists("arrivaledge") && oc.isSet("arrivaledge")) {
142  dev.writeNonEmptyAttr(SUMO_ATTR_ARRIVALEDGE, oc.getString("arrivaledge"));
143  }
144  // color
145  if (wasSet(VEHPARS_COLOR_SET)) {
147  }
148  // line
149  if (wasSet(VEHPARS_LINE_SET)) {
151  }
152  // from TAZ
155  }
156  // to TAZ
157  if (wasSet(VEHPARS_TO_TAZ_SET)) {
159  }
160  // person number
163  }
164  // container number
167  }
168  // individual speedFactor
171  }
172  // speed (only used by calibrators)
175  }
176 }
177 
178 
179 void
180 SUMOVehicleParameter::Stop::write(OutputDevice& dev, const bool close, const bool writeTagAndParents) const {
181  if (writeTagAndParents) {
182  dev.openTag(SUMO_TAG_STOP);
183  if (busstop != "") {
185  }
186  if (containerstop != "") {
188  }
189  if (chargingStation != "") {
191  }
192  if (parkingarea != "") {
194  }
195  if ((busstop == "") && (containerstop == "") && (parkingarea == "") && (chargingStation == "")) {
196  if (lane != "") {
198  } else {
200  }
201  if ((parametersSet & STOP_START_SET) != 0) {
203  }
204  if ((parametersSet & STOP_END_SET) != 0) {
206  }
207  }
208  }
209  if ((parametersSet & STOP_POSLAT_SET) != 0 && posLat != INVALID_DOUBLE) {
211  }
212  if ((parametersSet & STOP_ARRIVAL_SET) && (arrival >= 0)) {
214  }
215  if ((parametersSet & STOP_DURATION_SET) && (duration >= 0)) {
217  }
218  if ((parametersSet & STOP_UNTIL_SET) && (until >= 0)) {
220  }
221  if ((parametersSet & STOP_STARTED_SET) && (started >= 0)) {
223  }
224  if ((parametersSet & STOP_ENDED_SET) && (ended >= 0)) {
226  }
227  if ((parametersSet & STOP_EXTENSION_SET) && (extension >= 0)) {
229  }
230  writeTriggers(dev);
231  if ((parametersSet & STOP_PARKING_SET) != 0) {
233  }
234  if ((parametersSet & STOP_EXPECTED_SET) != 0 && awaitedPersons.size() > 0) {
236  }
237  if ((parametersSet & STOP_PERMITTED_SET) != 0 && permitted.size() > 0) {
239  }
240  if ((parametersSet & STOP_EXPECTED_CONTAINERS_SET) != 0 && awaitedContainers.size() > 0) {
242  }
243  if ((parametersSet & STOP_TRIP_ID_SET) != 0) {
245  }
246  if ((parametersSet & STOP_LINE_SET) != 0) {
248  }
249  if ((parametersSet & STOP_SPLIT_SET) != 0) {
251  }
252  if ((parametersSet & STOP_JOIN_SET) != 0) {
254  }
255  if ((parametersSet & STOP_SPEED_SET) != 0) {
257  }
258  // only write friendly position if is true
259  if (friendlyPos == true) {
261  }
262  // only write act type if isn't empty
263  if (!actType.empty()) {
265  }
266  if (close) {
267  dev.closeTag();
268  }
269 }
270 
271 
272 bool
273 SUMOVehicleParameter::parseDepart(const std::string& val, const std::string& element, const std::string& id,
274  SUMOTime& depart, DepartDefinition& dd, std::string& error, const std::string& attr) {
275  if (val == "triggered") {
276  dd = DEPART_TRIGGERED;
277  } else if (val == "containerTriggered") {
279  } else if (val == "split") {
280  dd = DEPART_SPLIT;
281  } else if (val == "now") {
282  // only used via TraCI. depart must be set by the calling code
283  dd = DEPART_NOW;
284  } else {
285  try {
286  depart = string2time(val);
287  dd = DEPART_GIVEN;
288  if (depart < 0) {
289  error = "Negative " + attr + " time in the definition of " + element + " '" + id + "'.";
290  return false;
291  }
292  } catch (...) {
293  if (id.empty()) {
294  error = "Invalid " + attr + " time for " + element + ". Must be one of (\"triggered\", \"containerTriggered\", \"now\", or a float >= 0)";
295  } else {
296  error = "Invalid " + attr + " time for " + element + " '" + id + "';\n must be one of (\"triggered\", \"containerTriggered\", \"now\", or a float >= 0)";
297  }
298  return false;
299  }
300  }
301  return true;
302 }
303 
304 
305 bool
306 SUMOVehicleParameter::parseDepartLane(const std::string& val, const std::string& element, const std::string& id,
307  int& lane, DepartLaneDefinition& dld, std::string& error) {
308  bool ok = true;
309  lane = 0;
311  if (val == "random") {
313  } else if (val == "free") {
315  } else if (val == "allowed") {
317  } else if (val == "best") {
319  } else if (val == "first") {
321  } else {
322  try {
323  lane = StringUtils::toInt(val);
324  if (lane < 0) {
325  ok = false;
326  }
327  } catch (...) {
328  ok = false;
329  }
330  }
331  if (!ok) {
332  if (id.empty()) {
333  error = "Invalid departLane definition for " + element + ". Must be one of (\"random\", \"free\", \"allowed\", \"best\", \"first\", or an int>=0)";
334  } else {
335  error = "Invalid departLane definition for " + element + " '" + id + "';\n must be one of (\"random\", \"free\", \"allowed\", \"best\", \"first\", or an int>=0)";
336  }
337  }
338  return ok;
339 }
340 
341 
342 bool
343 SUMOVehicleParameter::parseDepartPos(const std::string& val, const std::string& element, const std::string& id,
344  double& pos, DepartPosDefinition& dpd, std::string& error) {
345  bool ok = true;
346  pos = 0.;
348  if (val == "random") {
350  } else if (val == "random_free") {
352  } else if (val == "free") {
354  } else if (val == "base") {
356  } else if (val == "last") {
358  } else if (val == "stop") {
360  } else {
361  try {
362  pos = StringUtils::toDouble(val);
363  } catch (...) {
364  ok = false;
365  }
366  }
367  if (!ok) {
368  if (id.empty()) {
369  error = "Invalid departPos definition for " + element + ". Must be one of (\"random\", \"random_free\", \"free\", \"base\", \"last\" or a float)";
370  } else {
371  error = "Invalid departPos definition for " + element + " '" + id + "';\n must be one of (\"random\", \"random_free\", \"free\", \"base\", \"last\" or a float)";
372  }
373  }
374  return ok;
375 }
376 
377 
378 bool
379 SUMOVehicleParameter::parseDepartPosLat(const std::string& val, const std::string& element, const std::string& id,
380  double& pos, DepartPosLatDefinition& dpd, std::string& error) {
381  bool ok = true;
382  pos = 0.;
384  if (val == "random") {
386  } else if (val == "random_free") {
388  } else if (val == "free") {
390  } else if (val == "right") {
392  } else if (val == "center") {
394  } else if (val == "left") {
396  } else {
397  try {
398  pos = StringUtils::toDouble(val);
399  } catch (...) {
400  ok = false;
401  }
402  }
403  if (!ok) {
404  if (id.empty()) {
405  error = "Invalid departPosLat definition for " + element + ". Must be one of (\"random\", \"random_free\", \"free\", \"right\", \"center\", \"left\", or a float)";
406  } else {
407  error = "Invalid departPosLat definition for " + element + " '" + id + "';\n must be one of (\"random\", \"random_free\", \"free\", \"right\", \"center\", \"left\", or a float)";
408  }
409  }
410  return ok;
411 }
412 
413 
414 bool
415 SUMOVehicleParameter::parseDepartSpeed(const std::string& val, const std::string& element, const std::string& id,
416  double& speed, DepartSpeedDefinition& dsd, std::string& error) {
417  bool ok = true;
418  speed = -1.;
420  if (val == "random") {
422  } else if (val == "max") {
424  } else if (val == "desired") {
426  } else if (val == "speedLimit") {
428  } else if (val == "last") {
430  } else if (val == "avg") {
432  } else {
433  try {
434  speed = StringUtils::toDouble(val);
435  if (speed < 0) {
436  ok = false;
437  }
438  } catch (...) {
439  ok = false;
440  }
441  }
442  if (!ok) {
443  if (id.empty()) {
444  error = "Invalid departSpeed definition for " + element + ". Must be one of (\"random\", \"max\", or a float>=0)";
445  } else {
446  error = "Invalid departSpeed definition for " + element + " '" + id + "';\n must be one of (\"random\", \"max\", or a float>=0)";
447  }
448  }
449  return ok;
450 }
451 
452 
453 bool
454 SUMOVehicleParameter::parseRouteIndex(const std::string& val, const std::string& element, const std::string& id,
455  const SumoXMLAttr attr, int& edgeIndex, RouteIndexDefinition& rid, std::string& error) {
456  bool ok = true;
457  edgeIndex = -1;
459  if (val == "random") {
461  } else {
462  try {
463  edgeIndex = StringUtils::toInt(val);
464  if (edgeIndex < 0) {
465  ok = false;
466  }
467  } catch (...) {
468  ok = false;
469  }
470  }
471  if (!ok) {
472  if (id.empty()) {
473  error = "Invalid " + toString(attr) + " definition for " + element + ". Must be one of (\"random\", \"free\", or an int>=0)";
474  } else {
475  error = "Invalid " + toString(attr) + " definition for " + element + " '" + id + "';\n must be one of (\"random\", \"free\", or an int>=0)";
476  }
477  }
478  return ok;
479 }
480 
481 
482 bool
483 SUMOVehicleParameter::parseArrivalLane(const std::string& val, const std::string& element, const std::string& id,
484  int& lane, ArrivalLaneDefinition& ald, std::string& error) {
485  bool ok = true;
486  lane = 0;
488  if (val == "current") {
490  } else if (val == "random") {
492  } else if (val == "first") {
494  } else {
495  try {
496  lane = StringUtils::toInt(val);
497  if (lane < 0) {
498  ok = false;
499  }
500  } catch (...) {
501  ok = false;
502  }
503  }
504  if (!ok) {
505  if (id.empty()) {
506  error = "Invalid arrivalLane definition for " + element + ". Must be one of (\"current\", or an int>=0)";
507  } else {
508  error = "Invalid arrivalLane definition for " + element + " '" + id + "';\n must be one of (\"current\", or an int>=0)";
509  }
510  }
511  return ok;
512 }
513 
514 
515 bool
516 SUMOVehicleParameter::parseArrivalPos(const std::string& val, const std::string& element, const std::string& id,
517  double& pos, ArrivalPosDefinition& apd, std::string& error) {
518  bool ok = true;
519  pos = 0.;
521  if (val == "random") {
523  } else if (val == "center") {
525  } else if (val == "max") {
527  } else {
528  try {
529  pos = StringUtils::toDouble(val);
530  } catch (...) {
531  ok = false;
532  }
533  }
534  if (!ok) {
535  if (id.empty()) {
536  error = "Invalid arrivalPos definition for " + element + ". Must be one of (\"random\", \"max\", or a float)";
537  } else {
538  error = "Invalid arrivalPos definition for " + element + " '" + id + "';\n must be one of (\"random\", \"max\", or a float)";
539  }
540  }
541  return ok;
542 }
543 
544 
545 bool
546 SUMOVehicleParameter::parseArrivalPosLat(const std::string& val, const std::string& element, const std::string& id,
547  double& pos, ArrivalPosLatDefinition& apd, std::string& error) {
548  bool ok = true;
549  pos = 0.;
551  if (val == "right") {
553  } else if (val == "center") {
555  } else if (val == "left") {
557  } else {
558  try {
559  pos = StringUtils::toDouble(val);
560  } catch (...) {
561  ok = false;
562  }
563  }
564  if (!ok) {
565  if (id.empty()) {
566  error = "Invalid arrivalPosLat definition for " + element + ". Must be one of (\"right\", \"center\", \"left\", or a float)";
567  } else {
568  error = "Invalid arrivalPosLat definition for " + element + " '" + id + "';\n must be one of (\"right\", \"center\", \"left\", or a float)";
569  }
570  }
571  return ok;
572 }
573 
574 
575 bool
576 SUMOVehicleParameter::parseArrivalSpeed(const std::string& val, const std::string& element, const std::string& id,
577  double& speed, ArrivalSpeedDefinition& asd, std::string& error) {
578  bool ok = true;
579  speed = -1.;
581  if (val == "current") {
583  } else {
584  try {
585  speed = StringUtils::toDouble(val);
586  if (speed < 0) {
587  ok = false;
588  }
589  } catch (...) {
590  ok = false;
591  }
592  }
593  if (!ok) {
594  if (id.empty()) {
595  error = "Invalid arrivalSpeed definition for " + element + ". Must be one of (\"current\", or a float>=0)";
596  } else {
597  error = "Invalid arrivalSpeed definition for " + element + " '" + id + "';\n must be one of (\"current\", or a float>=0)";
598  }
599  }
600  return ok;
601 }
602 
603 
604 double
605 SUMOVehicleParameter::interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string& id, bool silent) {
606  if (pos < 0) {
607  pos = maximumValue + pos;
608  }
609  if (pos > maximumValue && pos != std::numeric_limits<double>::infinity()) {
610  if (!silent) {
611  WRITE_WARNING("Invalid " + toString(attr) + " " + toString(pos) + " given for " + id + ". Using edge end instead.");
612  }
613  pos = maximumValue;
614  }
615  return pos;
616 }
617 
618 
619 bool
620 SUMOVehicleParameter::parsePersonModes(const std::string& modes, const std::string& element, const std::string& id, SVCPermissions& modeSet, std::string& error) {
621  // separte modes in different strings, and check if modes are valid
622  for (StringTokenizer st(modes); st.hasNext();) {
623  const std::string mode = st.next();
624  if (mode == "car") {
625  modeSet |= SVC_PASSENGER;
626  } else if (mode == "taxi") {
627  modeSet |= SVC_TAXI;
628  } else if (mode == "bicycle") {
629  modeSet |= SVC_BICYCLE;
630  } else if (mode == "public") {
631  modeSet |= SVC_BUS;
632  } else {
633  if (id.empty()) {
634  error = "Unknown person mode '" + mode + "'. Must be a combination of (\"car\", \"bicycle\" or \"public\")";
635  } else {
636  error = "Unknown person mode '" + mode + "' for " + element + " '" + id + "';\n must be a combination of (\"car\", \"bicycle\" or \"public\")";
637  }
638  return false;
639  }
640  }
641  return true;
642 }
643 
644 
645 void
646 SUMOVehicleParameter::parseStopTriggers(const std::vector<std::string>& triggers, bool expectTrigger, Stop& stop) {
647  if (triggers.size() == 0 && expectTrigger) {
648  stop.triggered = true;
649  }
650  for (std::string val : triggers) {
651  if (val == toString(SUMO_TAG_PERSON)) {
652  stop.triggered = true;
653  } else if (val == toString(SUMO_TAG_CONTAINER)) {
654  stop.containerTriggered = true;
655  } else if (val == toString(SUMO_ATTR_JOIN)) {
656  stop.joinTriggered = true;
657  } else {
658  try {
659  stop.triggered = StringUtils::toBool(val);
660  } catch (BoolFormatException&) {
661  WRITE_ERROR("Value of stop attribute 'trigger' must be 'person', 'container', 'join' or a boolean");
662  }
663  }
664  }
665 }
666 
667 
668 void
670  if ((parametersSet & STOP_TRIGGER_SET) != 0) {
671  std::vector<std::string> triggers;
672  if (triggered) {
673  triggers.push_back(toString(SUMO_TAG_PERSON));
674  }
675  if (containerTriggered) {
676  triggers.push_back(toString(SUMO_TAG_CONTAINER));
677  }
678  if (joinTriggered) {
679  triggers.push_back(toString(SUMO_ATTR_JOIN));
680  }
681  dev.writeAttr(SUMO_ATTR_TRIGGERED, triggers);
682  }
683 }
684 
685 
686 std::string
689  return "triggered";
691  return "containerTriggered";
692  } else if (departProcedure == DEPART_SPLIT) {
693  return "split";
694  } else {
695  return time2string(depart);
696  }
697 }
698 
699 
700 std::string
702  std::string val;
703  switch (departLaneProcedure) {
705  val = toString(departLane);
706  break;
708  val = "random";
709  break;
711  val = "free";
712  break;
714  val = "allowed";
715  break;
717  val = "best";
718  break;
720  val = "first";
721  break;
723  default:
724  break;
725  }
726  return val;
727 }
728 
729 
730 std::string
732  std::string val;
733  switch (departPosProcedure) {
735  val = toString(departPos);
736  break;
738  val = "random";
739  break;
741  val = "random_free";
742  break;
744  val = "free";
745  break;
747  val = "last";
748  break;
750  val = "base";
751  break;
753  val = "stop";
754  break;
756  default:
757  break;
758  }
759  return val;
760 }
761 
762 
763 std::string
765  std::string val;
766  switch (departPosLatProcedure) {
768  val = toString(departPos);
769  break;
771  val = "random";
772  break;
774  val = "random_free";
775  break;
777  val = "free";
778  break;
780  val = "right";
781  break;
783  val = "center";
784  break;
786  val = "left";
787  break;
789  default:
790  break;
791  }
792  return val;
793 }
794 
795 
796 std::string
798  std::string val;
799  switch (departSpeedProcedure) {
801  val = toString(departSpeed);
802  break;
804  val = "random";
805  break;
807  val = "max";
808  break;
810  val = "desired";
811  break;
813  val = "speedLimit";
814  break;
816  val = "last";
817  break;
819  default:
820  break;
821  }
822  return val;
823 }
824 
825 
826 std::string
828  std::string val;
829  switch (departEdgeProcedure) {
831  val = toString(departEdge);
832  break;
834  val = "random";
835  break;
837  default:
838  break;
839  }
840  return val;
841 }
842 
843 std::string
845  std::string val;
846  switch (arrivalEdgeProcedure) {
848  val = toString(arrivalEdge);
849  break;
851  val = "random";
852  break;
854  default:
855  break;
856  }
857  return val;
858 }
859 
860 
861 
862 
863 std::string
865  std::string val;
866  switch (arrivalLaneProcedure) {
868  val = toString(arrivalLane);
869  break;
871  val = "current";
872  break;
874  val = "random";
875  break;
877  val = "first";
878  break;
880  default:
881  break;
882  }
883  return val;
884 }
885 
886 
887 std::string
889  std::string val;
890  switch (arrivalPosProcedure) {
892  val = toString(arrivalPos);
893  break;
895  val = "random";
896  break;
898  val = "center";
899  break;
901  val = "max";
902  break;
904  default:
905  break;
906  }
907  return val;
908 }
909 
910 
911 std::string
913  std::string val;
914  switch (arrivalPosLatProcedure) {
916  val = toString(arrivalPos);
917  break;
919  val = "right";
920  break;
922  val = "center";
923  break;
925  val = "left";
926  break;
928  default:
929  break;
930  }
931  return val;
932 }
933 
934 
935 std::string
937  std::string val;
938  switch (arrivalSpeedProcedure) {
940  val = toString(arrivalSpeed);
941  break;
943  val = "current";
944  break;
946  default:
947  break;
948  }
949  return val;
950 }
951 
952 
953 /****************************************************************************/
@ DEFAULT
default cursor
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
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:32
@ 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 VEHPARS_ARRIVALEDGE_SET
RouteIndexDefinition
Possible ways to choose the departure and arrival edge.
@ RANDOM
The edge is chosen randomly.
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int VEHPARS_COLOR_SET
const int STOP_POSLAT_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
Possible ways to choose the lateral departure position.
@ 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.
@ RANDOM
The lane is chosen randomly.
@ GIVEN
The arrival lane is given.
@ DEFAULT
No information given; use default.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
@ CURRENT
The current lane shall be used.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int STOP_PERMITTED_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)
@ LAST
The speed of the last vehicle. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
@ AVG
The average speed on the lane. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
const int VEHPARS_DEPARTLANE_SET
const int STOP_SPLIT_SET
const int VEHPARS_ARRIVALPOSLAT_SET
const int STOP_START_SET
const int VEHPARS_FROM_TAZ_SET
const int STOP_JOIN_SET
const int VEHPARS_ARRIVALSPEED_SET
const int VEHPARS_CALIBRATORSPEED_SET
const int STOP_EXTENSION_SET
const int STOP_ENDED_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 STOP_STARTED_SET
const int VEHPARS_PERSON_NUMBER_SET
const int STOP_EXPECTED_CONTAINERS_SET
const int VEHPARS_DEPARTSPEED_SET
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival 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_ARRIVALEDGE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ 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_POSITION_LAT
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_PERMITTED
@ 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
const double INVALID_DOUBLE
Definition: StdDefs.h:63
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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:61
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:292
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at (used only in NETEDIT)
std::string lane
The lane to stop at.
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
double posLat
the lateral offset when stopping
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::set< std::string > permitted
IDs of persons or containers that may board/load at this 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
void write(OutputDevice &dev, const bool close=true, const bool writeTagAndParents=true) const
Writes the stop as XML.
SUMOTime ended
the time at which this stop was ended
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
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.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
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.
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.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
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
double calibratorSpeed
speed (used by calibrator flows
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.
std::string getArrivalEdge() const
obtain arrival edge parameter in string format
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
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 parseRouteIndex(const std::string &val, const std::string &element, const std::string &id, const SumoXMLAttr attr, int &edgeIndex, RouteIndexDefinition &rid, std::string &error)
Validates a given departEdge or arrivalEdge value.
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.
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.
int arrivalEdge
(optional) The final edge within the route of the vehicle
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)
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
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
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