Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MSDevice_Battery.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2025 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#pragma once
23#include <config.h>
24
26#include <microsim/MSVehicle.h>
30
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35class SUMOVehicle;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
48public:
49
53 static void insertOptions(OptionsCont& oc);
54
65 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, MSDevice_StationFinder* sf);
66
67public:
70
73
82 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed) override;
84
86 const std::string deviceName() const override {
87 return "battery";
88 }
89
94 void saveState(OutputDevice& out) const override;
95
100 void loadState(const SUMOSAXAttributes& attrs) override;
101
103 std::string getParameter(const std::string& key) const override;
104
106 void setParameter(const std::string& key, const std::string& value) override;
107
109 void notifyParking() override;
110
112 void generateOutput(OutputDevice* tripinfoOut) const override;
113
114private:
126 MSDevice_Battery(SUMOVehicle& holder, const std::string& id, const double actualBatteryCapacity, const double maximumBatteryCapacity,
127 const double stoppingThreshold, const double maximumChargeRate, const std::string& chargeLevelTable, const std::string& chargeCurveTable);
128
129public:
131 double getActualBatteryCapacity() const;
132
134 double getMaximumBatteryCapacity() const;
135
137 double getMaximumPower() const;
138
140 bool isChargingStopped() const;
141
143 bool isChargingInTransit() const;
144
147
149 SUMOTime estimateChargingDuration(const double toCharge, const double csPower) const;
150
152 double getConsum() const;
153
155 double getTotalConsumption() const;
156
158 double getTotalRegenerated() const;
159
161 std::string getChargingStationID() const;
162
166
168 double getEnergyCharged() const;
169
171 int getVehicleStopped() const;
172
174 double getStoppingThreshold() const;
175
177 double getMaximumChargeRate() const;
178
180 bool tracksFuel() const;
181
184
186 void setActualBatteryCapacity(const double actualBatteryCapacity);
187
189 void setMaximumBatteryCapacity(const double maximumBatteryCapacity);
190
192 void setStoppingThreshold(const double stoppingThreshold);
193
195 void setMaximumChargeRate(const double chargeRate);
196
198 void setChargeLimit(const double limit);
199
202
205
208
211
212protected:
214 static double readParameterValue(SUMOVehicle& v, const SumoXMLAttr& attr, const std::string& paramName, double defaultVal);
215
218
221
224
227
230
233
236
239
242
244 double myConsum;
245
248
251
254
257
260
263
266
269
272
275
276
277private:
280
283};
long long int SUMOTime
Definition GUI.h:36
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::map< double, double > LinearApproxMap
Battery device for electric vehicles.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed) override
Checks for waiting steps when the vehicle moves.
MSChargingStation::ChargeType getChargeType() const
Get the charge type.
SUMOTime getChargingStartTime() const
Get charging start time.
void saveState(OutputDevice &out) const override
Saves the state of the device.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
int myVehicleStopped
Parameter, How many timestep the vehicle is stopped.
bool myChargingInTransit
Parameter, Flag: Vehicles it's charging in transit (by default is false)
LinearApproxHelpers::LinearApproxMap myChargeCurve
Charge curve data points storage.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in Wh.
int getVehicleStopped() const
Get number of timestep that vehicle is stopped.
void setChargeLimit(const double limit)
Set (temporary) charge limit.
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0].
void increaseVehicleStoppedTimer()
Increase myVehicleStopped.
const std::string deviceName() const override
return the name for this type of device
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBattery...
double getMaximumChargeRate() const
Get current charge rate in W depending on the state of charge.
void setParameter(const std::string &key, const std::string &value) override
try to set the given parameter for this device. Throw exception for unsupported key
void increaseChargingStartTime()
Increase Charging Start time.
MSChargingStation * myPreviousNeighbouringChargingStation
Parameter, Pointer to charging station neighbouring with myActChargingStation in which vehicle was pl...
MSChargingStation::ChargeType myChargeType
the accepted charge type
MSChargingStation * getChargingStation() const
void notifyParking() override
called to update state for parking vehicles
void loadState(const SUMOSAXAttributes &attrs) override
Loads the state of the device from the given description.
void setStoppingThreshold(const double stoppingThreshold)
Set vehicle's stopping threshold.
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in Wh.
SUMOTime estimateChargingDuration(const double toCharge, const double csPower) const
Estimate the charging duration given the current battery state.
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.
void generateOutput(OutputDevice *tripinfoOut) const override
Called on vehicle deletion to extend tripinfo.
std::string getParameter(const std::string &key) const override
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool myTrackFuel
whether to track fuel consumption instead of electricity
double getMaximumPower() const
Get the maximum power when accelerating.
double myEnergyCharged
Parameter, Energy charged in each timestep.
double myLastAngle
Parameter, Vehicle's last angle.
void setMaximumChargeRate(const double chargeRate)
Set vehicle's stopping threshold.
double getStoppingThreshold() const
Get stopping threshold.
double myTotalRegenerated
Parameter, total vehicle energy regeneration.
double myMaximumChargeRate
Parameter, maximum charge rate in W.
SUMOTime myChargingStartTime
Parameter, Moment, which the vehicle has beging to charging.
bool isChargingInTransit() const
Get true if Vehicle it's charging, false if not.
void resetChargingStartTime()
Reset charging start time.
double myTotalConsumption
Parameter, total vehicle energy consumption.
MSDevice_Battery & operator=(const MSDevice_Battery &)
Invalidated assignment operator.
void resetVehicleStoppedTimer()
Reset myVehicleStopped.
bool tracksFuel() const
Whether the battery device is actually used as a tank of a combustion vehicle.
int myDepletedCount
Count how many times the vehicle experienced a depleted battery.
double myChargeLimit
(Temporary) limitation in W of the maximum charge rate = charging strategy result
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.
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.
MSDevice_Battery(const MSDevice_Battery &)
Invalidated copy constructor.
A device which collects vehicular emissions.
A device which triggers rerouting to nearby charging stations.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62