SUMO - Simulation of Urban MObility
GNECalibratorVehicleType.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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
26 
28 
29 
30 // ===========================================================================
31 // member method definitions
32 // ===========================================================================
33 
35  GNEAdditional(viewNet->getNet()->generateAdditionalID(SUMO_TAG_VTYPE), viewNet, GLO_CALIBRATOR, SUMO_TAG_VTYPE, "", false) {
36  // fill calibrator vehicle type with default values
38 }
39 
40 
42  GNEAdditional(id, viewNet, GLO_CALIBRATOR, SUMO_TAG_VTYPE, "", false) {
43  // fill calibrator vehicle type with default values
45 }
46 
47 
49  double accel, double decel, double sigma, double tau, double length, double minGap, double maxSpeed,
50  double speedFactor, double speedDev, const RGBColor& color, SUMOVehicleClass vClass, const std::string& emissionClass,
51  SUMOVehicleShape shape, double width, const std::string& filename, double impatience, const std::string& laneChangeModel,
52  const std::string& carFollowModel, int personCapacity, int containerCapacity, double boardingDuration,
53  double loadingDuration, const std::string& latAlignment, double minGapLat, double maxSpeedLat) :
54  GNEAdditional(vehicleTypeID, viewNet, GLO_CALIBRATOR, SUMO_TAG_VTYPE, "", false),
55  myAccel(accel),
56  myDecel(decel),
57  mySigma(sigma),
58  myTau(tau),
59  myLength(length),
60  myMinGap(minGap),
61  myMaxSpeed(maxSpeed),
62  mySpeedFactor(speedFactor),
63  mySpeedDev(speedDev),
64  myColor(color),
65  myVClass(vClass),
66  myEmissionClass(emissionClass),
67  myShape(shape),
68  myWidth(width),
69  myFilename(filename),
70  myImpatience(impatience),
71  myLaneChangeModel(laneChangeModel),
72  myCarFollowModel(carFollowModel),
73  myPersonCapacity(personCapacity),
74  myContainerCapacity(containerCapacity),
75  myBoardingDuration(boardingDuration),
76  myLoadingDuration(loadingDuration),
77  myLatAlignment(latAlignment),
78  myMinGapLat(minGapLat),
79  myMaxSpeedLat(maxSpeedLat) {
80 }
81 
82 
84 
85 
86 void
88  // This additional cannot be moved
89 }
90 
91 
92 void
94  // This additional cannot be moved
95 }
96 
97 
98 void
100  // Currently this additional doesn't own a Geometry
101 }
102 
103 
104 Position
106  return Position();
107 }
108 
109 
110 std::string
112  return myViewNet->getNet()->getMicrosimID();
113 }
114 
115 
116 void
118  // Currently This additional isn't drawn
119 }
120 
121 
122 std::string
124  switch (key) {
125  case SUMO_ATTR_ID:
126  return getAdditionalID();
127  case SUMO_ATTR_ACCEL:
128  return toString(myAccel);
129  case SUMO_ATTR_DECEL:
130  return toString(myDecel);
131  case SUMO_ATTR_SIGMA:
132  return toString(mySigma);
133  case SUMO_ATTR_TAU:
134  return toString(myTau);
135  case SUMO_ATTR_LENGTH:
136  return toString(myLength);
137  case SUMO_ATTR_MINGAP:
138  return toString(myMinGap);
139  case SUMO_ATTR_MAXSPEED:
140  return toString(myMaxSpeed);
142  return toString(mySpeedFactor);
143  case SUMO_ATTR_SPEEDDEV:
144  return toString(mySpeedDev);
145  case SUMO_ATTR_COLOR:
146  return toString(myColor);
147  case SUMO_ATTR_VCLASS:
148  return toString(myVClass);
150  return myEmissionClass;
151  case SUMO_ATTR_GUISHAPE:
153  case SUMO_ATTR_WIDTH:
154  return toString(myWidth);
155  case SUMO_ATTR_IMGFILE:
156  return myFilename;
158  return toString(myImpatience);
160  return myLaneChangeModel;
162  return myCarFollowModel;
164  return toString(myPersonCapacity);
170  return toString(myLoadingDuration);
172  return myLatAlignment;
174  return toString(myMinGapLat);
176  return toString(myMaxSpeedLat);
177  case GNE_ATTR_GENERIC:
178  return getGenericParametersStr();
179  default:
180  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
181  }
182 }
183 
184 
185 void
186 GNECalibratorVehicleType::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
187  if (value == getAttribute(key)) {
188  return; //avoid needless changes, later logic relies on the fact that attributes have changed
189  }
190  switch (key) {
191  case SUMO_ATTR_ID:
192  case SUMO_ATTR_ACCEL:
193  case SUMO_ATTR_DECEL:
194  case SUMO_ATTR_SIGMA:
195  case SUMO_ATTR_TAU:
196  case SUMO_ATTR_LENGTH:
197  case SUMO_ATTR_MINGAP:
198  case SUMO_ATTR_MAXSPEED:
200  case SUMO_ATTR_SPEEDDEV:
201  case SUMO_ATTR_COLOR:
202  case SUMO_ATTR_VCLASS:
204  case SUMO_ATTR_GUISHAPE:
205  case SUMO_ATTR_WIDTH:
206  case SUMO_ATTR_IMGFILE:
217  case GNE_ATTR_GENERIC:
218  undoList->p_add(new GNEChange_Attribute(this, key, value));
219  break;
220  default:
221  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
222  }
223 }
224 
225 
226 bool
227 GNECalibratorVehicleType::isValid(SumoXMLAttr key, const std::string& value) {
228  switch (key) {
229  case SUMO_ATTR_ID:
230  return isValidAdditionalID(value);
231  case SUMO_ATTR_ACCEL:
232  return canParse<double>(value);
233  case SUMO_ATTR_DECEL:
234  return canParse<double>(value);
235  case SUMO_ATTR_SIGMA:
236  return canParse<double>(value) && (parse<double>(value) >= 0) && (parse<double>(value) <= 1);
237  case SUMO_ATTR_TAU:
238  return canParse<double>(value);
239  case SUMO_ATTR_LENGTH:
240  return canParse<double>(value) && (parse<double>(value) > 0);
241  case SUMO_ATTR_MINGAP:
242  return canParse<double>(value);
243  case SUMO_ATTR_MAXSPEED:
244  return canParse<double>(value);
246  return canParse<double>(value);
247  case SUMO_ATTR_SPEEDDEV:
248  return canParse<double>(value);
249  case SUMO_ATTR_COLOR:
250  return canParse<RGBColor>(value);
251  case SUMO_ATTR_VCLASS:
252  return canParseVehicleClasses(value);
254  if ((value == "zero") || (value == "LDV") || (value == "LDV_G_EU0") || (value == "LDV_G_EU1") || (value == "LDV_G_EU2") || (value == "LDV_G_EU3") || (value == "LDV_G_EU4") || (value == "LDV_G_EU5") ||
255  (value == "LDV_G_EU6") || (value == "LDV_G_East") || (value == "LDV_D_EU0") || (value == "LDV_D_EU1") || (value == "LDV_D_EU2") || (value == "LDV_D_EU3") || (value == "LDV_D_EU4") || (value == "LDV_D_EU5") || (value == "LDV_D_EU6") ||
256  (value == "PC") || (value == "PC_Alternative") || (value == "PC_G_EU0") || (value == "PC_G_EU1") || (value == "PC_G_EU2") || (value == "PC_G_EU3") || (value == "PC_G_EU4") || (value == "PC_G_EU5") || (value == "PC_G_EU6") || (value == "PC_G_East") ||
257  (value == "PC_D_EU0") || (value == "PC_D_EU1") || (value == "PC_D_EU2") || (value == "PC_D_EU3") || (value == "PC_D_EU4") || (value == "PC_D_EU5") || (value == "PC_D_EU6") || (value == "Bus") || (value == "Coach") || (value == "HDV") || (value == "HDV_G") ||
258  (value == "HDV_D_EU0") || (value == "HDV_D_EU1") || (value == "HDV_D_EU2") || (value == "HDV_D_EU3") || (value == "HDV_D_EU4") || (value == "HDV_D_EU5") || (value == "HDV_D_EU6") || (value == "HDV_D_East")) {
259  return true;
260  } else {
261  return false;
262  }
263  case SUMO_ATTR_GUISHAPE:
264  return canParseVehicleShape(value);
265  case SUMO_ATTR_WIDTH:
266  return canParse<double>(value);
267  case SUMO_ATTR_IMGFILE:
270  return canParse<double>(value);
276  return canParse<int>(value);
278  return canParse<int>(value);
280  return canParse<double>(value);
282  return canParse<double>(value);
286  return canParse<double>(value);
288  return canParse<double>(value);
289  case GNE_ATTR_GENERIC:
290  return isGenericParametersValid(value);
291  default:
292  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
293  }
294 }
295 
296 
297 std::string
299  return getTagStr() + ": " + getID();
300 }
301 
302 
303 std::string
305  return getTagStr();
306 }
307 
308 // ===========================================================================
309 // private
310 // ===========================================================================
311 
312 void
313 GNECalibratorVehicleType::setAttribute(SumoXMLAttr key, const std::string& value) {
314  switch (key) {
315  case SUMO_ATTR_ID:
316  changeAdditionalID(value);
317  break;
318  case SUMO_ATTR_ACCEL:
319  myAccel = parse<double>(value);
320  break;
321  case SUMO_ATTR_DECEL:
322  myDecel = parse<double>(value);
323  break;
324  case SUMO_ATTR_SIGMA:
325  mySigma = parse<double>(value);
326  break;
327  case SUMO_ATTR_TAU:
328  myTau = parse<double>(value);
329  break;
330  case SUMO_ATTR_LENGTH:
331  myLength = parse<double>(value);
332  break;
333  case SUMO_ATTR_MINGAP:
334  myMinGap = parse<double>(value);
335  break;
336  case SUMO_ATTR_MAXSPEED:
337  myMaxSpeed = parse<double>(value);
338  break;
340  mySpeedFactor = parse<double>(value);
341  break;
342  case SUMO_ATTR_SPEEDDEV:
343  mySpeedDev = parse<double>(value);
344  break;
345  case SUMO_ATTR_COLOR:
346  myColor = parse<RGBColor>(value);
347  break;
348  case SUMO_ATTR_VCLASS:
349  myVClass = getVehicleClassID(value);
350  break;
352  myEmissionClass = value;
353  break;
354  case SUMO_ATTR_GUISHAPE:
355  myShape = getVehicleShapeID(value);
356  break;
357  case SUMO_ATTR_WIDTH:
358  myWidth = parse<double>(value);
359  break;
360  case SUMO_ATTR_IMGFILE:
361  myFilename = value;
362  break;
364  myImpatience = parse<double>(value);
365  break;
367  myLaneChangeModel = value;
368  break;
370  myCarFollowModel = value;
371  break;
373  myPersonCapacity = parse<int>(value);
374  break;
376  myContainerCapacity = parse<int>(value);
377  break;
379  myBoardingDuration = parse<double>(value);
380  break;
382  myLoadingDuration = parse<double>(value);
383  break;
385  myLatAlignment = value;
386  break;
388  myMinGapLat = parse<double>(value);
389  break;
391  myMaxSpeedLat = parse<double>(value);
392  break;
393  case GNE_ATTR_GENERIC:
395  break;
396  default:
397  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
398  }
399 }
400 
401 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
double myTau
Car-following model parameter.
double myMinGap
Empty space after leader [m].
double myMaxSpeedLat
The maximum lateral speed when using the sublane-model.
static StringBijection< SumoXMLTag > CarFollowModels
car following models
description of a vehicle type
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
returns Additional ID
void updateGeometry(bool updateGrid)
update pre-computed geometry information
Stores the information about how to visualize structures.
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
double myImpatience
Willingess of drivers to impede vehicles with higher priority. See below for semantics.
double myWidth
The vehicle&#39;s width [m] (only used for drawing)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double myAccel
The acceleration ability of vehicles of this type (in m/s^2)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
std::string getParentName() const
Returns the name of the parent object.
GNECalibratorVehicleType(GNEViewNet *viewNet)
constructor (Used only in GNECalibratorDialog)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double myDecel
The deceleration ability of vehicles of this type (in m/s^2)
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
std::string myLatAlignment
The preferred lateral alignment when using the sublane-model. One of (left, right, center, compact, nice, arbitrary).
void changeAdditionalID(const std::string &newID)
change ID of additional
generic attribute
double myLength
The vehicle&#39;s netto-length (length) (in m)
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
bool canParseVehicleShape(const std::string &shape)
Checks whether the given string contains only known vehicle shape.
double mySigma
Car-following model parameter.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Position getPositionInView() const
Returns position of additional in view.
std::string myCarFollowModel
The model used for car following.
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
RGBColor myColor
This vehicle type&#39;s color.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
int myPersonCapacity
The number of persons (excluding an autonomous driver) the vehicle can transport. ...
double mySpeedDev
The deviation of the speedFactor; see below for details.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
friend class GNEChange_Attribute
declare friend class
SUMOVehicleClass myVClass
An abstract vehicle class.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const std::string getID() const
function to support debugging
SUMOVehicleShape myShape
How this vehicle is rendered.
std::string myEmissionClass
An abstract emission class.
std::string myFilename
Image file for rendering vehicles of this type (should be grayscale to allow functional coloring) ...
a Calibrator
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
double myBoardingDuration
The time required by a person to board the vehicle.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
const std::string & getTagStr() const
get tag assigned to this object in string format
std::string getGenericParametersStr() const
return generic parameters in string format
GNENet * getNet() const
get the net object
double myLoadingDuration
The time required to load a container onto the vehicle.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
double myMinGapLat
The minimum lateral gap at a speed difference of 100km/h when using the sublane-model.
bool hasString(const std::string &str) const
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
A color information.
double myMaxSpeed
The vehicle&#39;s maximum velocity (in m/s)
static StringBijection< LaneChangeModel > LaneChangeModels
lane change models
double mySpeedFactor
The vehicles expected multiplicator for lane speed limits.
std::string myLaneChangeModel
The model used for changing lanes.
int myContainerCapacity
The number of containers the vehicle can transport.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...