Eclipse SUMO - Simulation of Urban MObility
MSDevice_Battery.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2013-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // The Battery parameters for the vehicle
21 /****************************************************************************/
22 #include <config.h>
23 
27 #include <utils/common/SUMOTime.h>
28 #include <utils/geom/GeomHelper.h>
31 #include <microsim/MSNet.h>
32 #include <microsim/MSLane.h>
33 #include <microsim/MSEdge.h>
34 #include <microsim/MSVehicle.h>
35 #include "MSDevice_StationFinder.h"
36 #include "MSDevice_Emissions.h"
37 #include "MSDevice_Battery.h"
38 
39 #define DEFAULT_MAX_CAPACITY 35000
40 #define DEFAULT_CHARGE_RATIO 0.5
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 // ---------------------------------------------------------------------------
47 // static initialisation methods
48 // ---------------------------------------------------------------------------
49 void
51  insertDefaultAssignmentOptions("battery", "Battery", oc);
52  // custom options
53  oc.doRegister("device.battery.track-fuel", new Option_Bool(false));
54  oc.addDescription("device.battery.track-fuel", "Battery", TL("Track fuel consumption for non-electric vehicles"));
55 }
56 
57 
58 void
59 MSDevice_Battery::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, MSDevice_StationFinder* sf) {
60  // Check if vehicle should get a battery
61  if (sf != nullptr || equippedByDefaultAssignmentOptions(OptionsCont::getOptions(), "battery", v, false)) {
62  // obtain parameter values
63  const double maximumBatteryCapacity = readParameterValue(v, SUMO_ATTR_MAXIMUMBATTERYCAPACITY, "battery.capacity", DEFAULT_MAX_CAPACITY);
64  const double actualBatteryCapacity = readParameterValue(v, SUMO_ATTR_ACTUALBATTERYCAPACITY, "battery.chargeLevel", maximumBatteryCapacity * DEFAULT_CHARGE_RATIO);
65  const double stoppingThreshold = readParameterValue(v, SUMO_ATTR_STOPPINGTHRESHOLD, "battery.stoppingThreshold", 0.1);
66 
67  // battery constructor
68  MSDevice_Battery* device = new MSDevice_Battery(v, "battery_" + v.getID(),
69  actualBatteryCapacity, maximumBatteryCapacity, stoppingThreshold);
70 
71  // Add device to vehicle
72  into.push_back(device);
73 
74  if (sf != nullptr) {
75  sf->setBattery(device);
76  }
77  }
78 }
79 
80 
81 double
82 MSDevice_Battery::readParameterValue(SUMOVehicle& v, const SumoXMLAttr& attr, const std::string& paramName, double defaultVal) {
83  const std::string& oldParam = toString(attr);
84  const SUMOVTypeParameter& typeParams = v.getVehicleType().getParameter();
85  if (v.getParameter().hasParameter(oldParam) || typeParams.hasParameter(oldParam)) {
86  WRITE_WARNINGF(TL("Battery device in vehicle '%' still uses old parameter '%'. Please update to 'device.%'."), v.getID(), oldParam, paramName);
87  if (v.getParameter().getParameter(oldParam, "-") == "-") {
88  return typeParams.getDouble(oldParam, defaultVal);
89  }
90  return StringUtils::toDouble(v.getParameter().getParameter(oldParam, "0"));
91  }
92  return getFloatParam(v, OptionsCont::getOptions(), paramName, defaultVal);
93 }
94 
95 
96 // ---------------------------------------------------------------------------
97 // MSDevice_Battery-methods
98 // ---------------------------------------------------------------------------
99 MSDevice_Battery::MSDevice_Battery(SUMOVehicle& holder, const std::string& id, const double actualBatteryCapacity, const double maximumBatteryCapacity,
100  const double stoppingThreshold) :
101  MSVehicleDevice(holder, id),
102  myActualBatteryCapacity(0), // [actualBatteryCapacity <= maximumBatteryCapacity]
103  myMaximumBatteryCapacity(0), // [maximumBatteryCapacity >= 0]
104  myStoppingThreshold(0), // [stoppingThreshold >= 0]
105  myLastAngle(std::numeric_limits<double>::infinity()),
106  myChargingStopped(false), // Initially vehicle don't charge stopped
107  myChargingInTransit(false), // Initially vehicle don't charge in transit
108  myChargingStartTime(0), // Initially charging start time (must be if the vehicle was launched at the charging station)
109  myConsum(0), // Initially the vehicle is stopped and therefore the consum is zero.
110  myTotalConsumption(0.0),
111  myTotalRegenerated(0.0),
112  myActChargingStation(nullptr), // Initially the vehicle isn't over a Charging Station
113  myPreviousNeighbouringChargingStation(nullptr), // Initially the vehicle wasn't over a Charging Station
114  myEnergyCharged(0), // Initially the energy charged is zero
115  myVehicleStopped(0) { // Initially the vehicle is stopped and the corresponding variable is 0
116 
117  if (maximumBatteryCapacity < 0) {
118  WRITE_WARNINGF(TL("Battery builder: Vehicle '%' doesn't have a valid value for parameter % (%)."), getID(), toString(SUMO_ATTR_MAXIMUMBATTERYCAPACITY), toString(maximumBatteryCapacity));
119  } else {
120  myMaximumBatteryCapacity = maximumBatteryCapacity;
121  }
122 
123  if (actualBatteryCapacity > maximumBatteryCapacity) {
124  WRITE_WARNINGF(TL("Battery builder: Vehicle '%' has a % (%) greater than its % (%). A max battery capacity value will be assigned."),
125  getID(), toString(SUMO_ATTR_ACTUALBATTERYCAPACITY), toString(actualBatteryCapacity), toString(SUMO_ATTR_MAXIMUMBATTERYCAPACITY), toString(maximumBatteryCapacity));
127  } else {
128  myActualBatteryCapacity = actualBatteryCapacity;
129  }
130 
131  if (stoppingThreshold < 0) {
132  WRITE_WARNINGF(TL("Battery builder: Vehicle '%' doesn't have a valid value for parameter % (%)."), getID(), toString(SUMO_ATTR_STOPPINGTHRESHOLD), toString(stoppingThreshold));
133  } else {
134  myStoppingThreshold = stoppingThreshold;
135  }
136 
137  myTrackFuel = PollutantsInterface::getFuel(holder.getVehicleType().getEmissionClass()) != "Electricity" && OptionsCont::getOptions().getBool("device.battery.track-fuel");
139  WRITE_WARNINGF(TL("The battery device is active for vehicle '%' but no emission class is set. "
140  "Please consider setting an explicit emission class or battery outputs might be inconsistent with emission outputs!"),
141  holder.getID());
142  }
143 }
144 
145 
147 }
148 
149 
150 bool MSDevice_Battery::notifyMove(SUMOTrafficObject& tObject, double /* oldPos */, double /* newPos */, double /* newSpeed */) {
151  if (!tObject.isVehicle()) {
152  return false;
153  }
154  SUMOVehicle& veh = static_cast<SUMOVehicle&>(tObject);
155  // Start vehicleStoppedTimer if the vehicle is stopped. In other case reset timer
156  if (veh.getSpeed() < myStoppingThreshold) {
157  // Increase vehicle stopped timer
159  } else {
160  // Reset vehicle Stopped
162  }
163 
164  // Update Energy from the battery
165  EnergyParams* const params = myHolder.getEmissionParameters();
166  if (getMaximumBatteryCapacity() != 0) {
167  params->setDouble(SUMO_ATTR_ANGLE, myLastAngle == std::numeric_limits<double>::infinity() ? 0. : GeomHelper::angleDiff(myLastAngle, veh.getAngle()));
169  // no explicit emission class, we fall back to the energy model; a warning has been issued on creation
171  veh.getSlope(), params) * TS;
172  } else {
175  veh.getSpeed(), veh.getAcceleration(),
176  veh.getSlope(), params) * TS;
177  }
178  if (veh.isParking()) {
179  // recuperation from last braking step is ok but further consumption should cease
180  myConsum = MIN2(myConsum, 0.0);
181  }
182 
183  // Energy lost/gained from vehicle movement (via vehicle energy model) [Wh]
185 
186  // Track total energy consumption and regeneration
187  if (myConsum > 0.0) {
189  } else {
191  }
192 
193  // saturate between 0 and myMaximumBatteryCapacity [Wh]
194  if (getActualBatteryCapacity() < 0) {
196  if (getMaximumBatteryCapacity() > 0) {
197  WRITE_WARNINGF(TL("Battery of vehicle '%' is depleted."), veh.getID());
198  }
201  }
202  myLastAngle = veh.getAngle();
203  }
204 
205  // Check if vehicle has under their position one charge Station
206  const std::string chargingStationID = MSNet::getInstance()->getStoppingPlaceID(veh.getLane(), veh.getPositionOnLane(), SUMO_TAG_CHARGING_STATION);
207 
208  // If vehicle is over a charging station
209  if (chargingStationID != "") {
210  // if the vehicle is almost stopped, or charge in transit is enabled, then charge vehicle
211  MSChargingStation* const cs = static_cast<MSChargingStation*>(MSNet::getInstance()->getStoppingPlace(chargingStationID, SUMO_TAG_CHARGING_STATION));
212  const MSParkingArea* pa = cs->getParkingArea();
213  if (((veh.getSpeed() < myStoppingThreshold) || cs->getChargeInTransit()) && (pa == nullptr || veh.isParking())) {
214  // Set Flags Stopped/intransit to
215  if (veh.getSpeed() < myStoppingThreshold) {
216  // vehicle ist almost stopped, then is charging stopped
217  myChargingStopped = true;
218 
219  // therefore isn't charging in transit
220  myChargingInTransit = false;
221  } else {
222  // vehicle is moving, and the Charging station allow charge in transit
223  myChargingStopped = false;
224 
225  // Therefore charge in transit
226  myChargingInTransit = true;
227  }
228 
229  // get pointer to charging station
231 
232  // Only update charging start time if vehicle allow charge in transit, or in other case
233  // if the vehicle not allow charge in transit but it's stopped.
235  // Update Charging start time
237  }
238 
239  // time it takes the vehicle at the station < charging station time delay?
241  // Enable charging vehicle
243 
244  // Calulate energy charged
246 
247  // Update Battery charge
249  }
250  // add charge value for output to myActChargingStation
252  }
253  // else disable charging vehicle
254  else {
255  cs->setChargingVehicle(false);
256  }
257  // disable charging vehicle from previous (not current) ChargingStation (reason: if there is no gap between two different chargingStations = the vehicle switches from used charging station to other one in a single timestap)
260  }
262  }
263  // In other case, vehicle will be not charged
264  else {
265  // Disable flags
266  myChargingInTransit = false;
267  myChargingStopped = false;
268 
269  // Disable charging vehicle
270  if (myActChargingStation != nullptr) {
272  }
273 
274  // Set charging station pointer to NULL
275  myActChargingStation = nullptr;
276 
277  // Set energy charged to 0
278  myEnergyCharged = 0.00;
279 
280  // Reset timer
282  }
283 
284  // Always return true.
285  return true;
286 }
287 
288 
289 void
292  out.writeAttr(SUMO_ATTR_ID, getID());
293  std::vector<std::string> internals;
294  internals.push_back(toString(myActualBatteryCapacity));
295  internals.push_back(toString(myLastAngle));
296  internals.push_back(toString(myChargingStopped));
297  internals.push_back(toString(myChargingInTransit));
298  internals.push_back(toString(myChargingStartTime));
299  internals.push_back(toString(myTotalConsumption));
300  internals.push_back(toString(myTotalRegenerated));
301  internals.push_back(toString(myEnergyCharged));
302  internals.push_back(toString(myVehicleStopped));
303  internals.push_back(getChargingStationID());
304  std::string prevChargingID = (myPreviousNeighbouringChargingStation == nullptr) ? "NULL" : myPreviousNeighbouringChargingStation->getID();
305  internals.push_back(prevChargingID);
306  out.writeAttr(SUMO_ATTR_STATE, toString(internals));
307  out.closeTag();
308 }
309 
310 
311 void
313  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
315  bis >> myLastAngle;
316  bis >> myChargingStopped;
317  bis >> myChargingInTransit;
318  bis >> myChargingStartTime;
319  bis >> myTotalConsumption;
320  bis >> myTotalRegenerated;
321  bis >> myEnergyCharged;
322  bis >> myVehicleStopped;
323  std::string chargingID;
324  bis >> chargingID;
325  if (chargingID != "NULL") {
327  }
328  std::string prevChargingID;
329  bis >> prevChargingID;
330  if (prevChargingID != "NULL") {
332  }
333 }
334 
335 
336 void
337 MSDevice_Battery::setActualBatteryCapacity(const double actualBatteryCapacity) {
338  if (actualBatteryCapacity < 0) {
340  } else if (actualBatteryCapacity > myMaximumBatteryCapacity) {
342  } else {
343  myActualBatteryCapacity = actualBatteryCapacity;
344  }
345 }
346 
347 
348 void
349 MSDevice_Battery::setMaximumBatteryCapacity(const double maximumBatteryCapacity) {
350  if (myMaximumBatteryCapacity < 0) {
351  WRITE_WARNINGF(TL("Trying to set into the battery device of vehicle '%' an invalid % (%)."), getID(), toString(SUMO_ATTR_MAXIMUMBATTERYCAPACITY), toString(maximumBatteryCapacity));
352  } else {
353  myMaximumBatteryCapacity = maximumBatteryCapacity;
354  }
355 }
356 
357 
358 void
359 MSDevice_Battery::setStoppingThreshold(const double stoppingThreshold) {
360  if (stoppingThreshold < 0) {
361  WRITE_WARNINGF(TL("Trying to set into the battery device of vehicle '%' an invalid % (%)."), getID(), toString(SUMO_ATTR_STOPPINGTHRESHOLD), toString(stoppingThreshold));
362  } else {
363  myStoppingThreshold = stoppingThreshold;
364  }
365 }
366 
367 
368 void
371 }
372 
373 
374 void
377 }
378 
379 
380 void
382  myVehicleStopped = 0;
383 }
384 
385 
386 void
389 }
390 
391 
392 double
395 }
396 
397 
398 double
401 }
402 
403 
404 double
406  return myConsum;
407 }
408 
409 double
411  return myTotalConsumption;
412 }
413 
414 
415 double
417  return myTotalRegenerated;
418 }
419 
420 
421 bool
423  return myChargingStopped;
424 }
425 
426 
427 bool
429  return myChargingInTransit;
430 }
431 
432 
433 SUMOTime
435  return myChargingStartTime;
436 }
437 
438 
439 std::string
441  if (myActChargingStation != nullptr) {
442  return myActChargingStation->getID();
443  } else {
444  return "NULL";
445  }
446 }
447 
448 double
450  return myEnergyCharged;
451 }
452 
453 
454 int
456  return myVehicleStopped;
457 }
458 
459 
460 double
462  return myStoppingThreshold;
463 }
464 
465 
466 std::string
467 MSDevice_Battery::getParameter(const std::string& key) const {
470  } else if (key == toString(SUMO_ATTR_ENERGYCONSUMED)) {
471  return toString(getConsum());
472  } else if (key == toString(SUMO_ATTR_TOTALENERGYCONSUMED)) {
473  return toString(getTotalConsumption());
474  } else if (key == toString(SUMO_ATTR_TOTALENERGYREGENERATED)) {
475  return toString(getTotalRegenerated());
476  } else if (key == toString(SUMO_ATTR_ENERGYCHARGED)) {
477  return toString(getEnergyCharged());
478  } else if (key == toString(SUMO_ATTR_MAXIMUMBATTERYCAPACITY)) {
480  } else if (key == toString(SUMO_ATTR_CHARGINGSTATIONID)) {
481  return getChargingStationID();
482  } else if (key == toString(SUMO_ATTR_VEHICLEMASS)) {
483  WRITE_WARNING(TL("Getting the vehicle mass via parameters is deprecated, please use getMass for the vehicle or its type."));
485  }
486  throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
487 }
488 
489 
490 void
491 MSDevice_Battery::setParameter(const std::string& key, const std::string& value) {
492  double doubleValue;
493  try {
494  doubleValue = StringUtils::toDouble(value);
495  } catch (NumberFormatException&) {
496  throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
497  }
499  setActualBatteryCapacity(doubleValue);
500  } else if (key == toString(SUMO_ATTR_MAXIMUMBATTERYCAPACITY)) {
501  setMaximumBatteryCapacity(doubleValue);
502  } else if (key == toString(SUMO_ATTR_VEHICLEMASS)) {
503  WRITE_WARNING(TL("Setting the vehicle mass via parameters is deprecated, please use setMass for the vehicle or its type."));
505  } else {
506  throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
507  }
508 }
509 
510 
511 void
513  // @note: only charing is performed but no energy is consumed
515  myConsum = 0;
516 }
517 
518 
519 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define DEFAULT_CHARGE_RATIO
#define DEFAULT_MAX_CAPACITY
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
SUMOTime DELTA_T
Definition: SUMOTime.cpp:38
#define TS
Definition: SUMOTime.h:42
const long long int VTYPEPARS_EMISSIONCLASS_SET
@ SUMO_TAG_DEVICE
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ENERGYCONSUMED
Energy consumed.
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_MASS
@ SUMO_ATTR_STOPPINGTHRESHOLD
Stopping threshold.
@ SUMO_ATTR_CHARGINGSTATIONID
Charging Station ID.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_ACTUALBATTERYCAPACITY
@ SUMO_ATTR_VEHICLEMASS
Vehicle mass.
@ SUMO_ATTR_ENERGYCHARGED
tgotal of Energy charged
@ SUMO_ATTR_ID
@ SUMO_ATTR_TOTALENERGYREGENERATED
Total energy regenerated.
@ SUMO_ATTR_TOTALENERGYCONSUMED
Total energy consumed.
@ SUMO_ATTR_STATE
The state of a link.
T MIN2(T a, T b)
Definition: StdDefs.h:76
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
An upper class for objects with additional parameters.
Definition: EnergyParams.h:43
double getDouble(SumoXMLAttr attr) const
void setDouble(SumoXMLAttr attr, double value)
Sets a parameter.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Definition: GeomHelper.cpp:178
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
double getChargingPower(bool usingFuel) const
Get charging station's charging power in the.
bool getChargeInTransit() const
Get chargeInTransit.
void setChargingVehicle(bool value)
enable or disable charging vehicle
void addChargeValueForOutput(double WCharged, MSDevice_Battery *battery)
add charge value for output
SUMOTime getChargeDelay() const
Get Charge Delay.
double getEfficency() const
Get efficiency of the charging station.
const MSParkingArea * getParkingArea() const
Get the parking area the charging station is placed on.
Battery device for electric vehicles.
SUMOTime getChargingStartTime() const
Get charging start time.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
void notifyParking()
called to update state for parking vehicles
int myVehicleStopped
Parameter, How many timestep the vehicle is stopped.
bool myChargingInTransit
Parameter, Flag: Vehicles it's charging in transit (by default is false)
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in Wh.
int getVehicleStopped() const
Get number of timestep that vehicle is stopped.
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0].
void increaseVehicleStoppedTimer()
Increase myVehicleStopped.
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBattery...
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void saveState(OutputDevice &out) const
Saves the state of the device.
void increaseChargingStartTime()
Increase Charging Start time.
MSChargingStation * myPreviousNeighbouringChargingStation
Parameter, Pointer to charging station neighbouring with myActChargingStation in which vehicle was pl...
void setStoppingThreshold(const double stoppingThreshold)
Set vehicle's stopping threshold.
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in Wh.
bool myChargingStopped
Parameter, Flag: Vehicles it's charging stopped (by default is false)
double getConsum() const
Get consum.
void setActualBatteryCapacity(const double actualBatteryCapacity)
Set actual vehicle's Battery Capacity in kWh.
bool myTrackFuel
whether to track fuel consumption instead of electricity
double myEnergyCharged
Parameter, Energy charged in each timestep.
double myLastAngle
Parameter, Vehicle's last angle.
double getStoppingThreshold() const
Get stopping threshold.
double myTotalRegenerated
Parameter, total vehicle energy regeneration.
SUMOTime myChargingStartTime
Parameter, Moment, wich the vehicle has beging to charging.
bool isChargingInTransit() const
Get true if Vehicle it's charging, false if not.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
void resetChargingStartTime()
Reset charging start time.
double myTotalConsumption
Parameter, total vehicle energy consumption.
const std::string deviceName() const
return the name for this type of device
void resetVehicleStoppedTimer()
Reset myVehicleStopped.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
double getTotalRegenerated() const
Get total regenerated.
double getTotalConsumption() const
Get total consumption.
MSChargingStation * myActChargingStation
Parameter, Pointer to current charging station in which vehicle is placed (by default is NULL)
~MSDevice_Battery()
Destructor.
double myConsum
Parameter, Vehicle consum during a time step (by default is 0.)
double getEnergyCharged() const
Get charged energy.
std::string getChargingStationID() const
Get current Charging Station ID.
void setMaximumBatteryCapacity(const double maximumBatteryCapacity)
Set total vehicle's Battery Capacity in kWh.
MSDevice_Battery(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double stoppingThreshold)
Constructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, MSDevice_StationFinder *sf)
Build devices for the given vehicle, if needed.
static double readParameterValue(SUMOVehicle &v, const SumoXMLAttr &attr, const std::string &paramName, double defaultVal)
Read device parameters from input.
double myStoppingThreshold
Parameter, stopping vehicle threshold [myStoppingThreshold >= 0].
bool isChargingStopped() const
Get true if Vehicle is charging, false if not.
A device which triggers rerouting to nearby charging stations.
void setBattery(MSDevice_Battery *battery)
static double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, const std::string &paramName, const double deflt, bool required=false)
Definition: MSDevice.cpp:206
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:155
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.h:203
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:182
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition: MSNet.cpp:1373
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1364
A lane area vehicles can halt at.
Definition: MSParkingArea.h:60
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
Definition: OptionsCont.cpp:76
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
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 & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static const HelpersEnergy & getEnergyHelper()
get energy helper
static std::string getFuel(const SUMOEmissionClass c)
Returns the fuel type of the given emission class.
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams *param)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual double getAcceleration() const =0
Returns the object's acceleration.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Structure representing possible vehicle parameter.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
virtual double getAngle() const =0
Get the vehicle's angle.
virtual EnergyParams * getEmissionParameters() const =0
Returns the vehicle's emission model parameter.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
Definition: json.hpp:4471