Eclipse SUMO - Simulation of Urban MObility
MSDevice_Battery.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-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 /****************************************************************************/
19 // The Battery parameters for the vehicle
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
25 #include <microsim/MSVehicle.h>
27 #include <utils/common/SUMOTime.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class SUMOVehicle;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
49  static void insertOptions(OptionsCont& oc);
50 
61  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
62 
63 public:
66 
69 
78  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
80 
82  const std::string deviceName() const {
83  return "battery";
84  }
85 
87  std::string getParameter(const std::string& key) const;
88 
90  void setParameter(const std::string& key, const std::string& value);
91 
93  void notifyParking();
94 
95 private:
103  MSDevice_Battery(SUMOVehicle& holder, const std::string& id, const double actualBatteryCapacity, const double maximumBatteryCapacity,
104  const double powerMax, const double stoppingTreshold, const EnergyParams& param);
105 
106  void checkParam(const SumoXMLAttr paramKey, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
107 
108 public:
110  double getActualBatteryCapacity() const;
111 
113  double getMaximumBatteryCapacity() const;
114 
116  double getMaximumPower() const;
117 
119  bool isChargingStopped() const;
120 
122  bool isChargingInTransit() const;
123 
126 
128  double getConsum() const;
129 
131  double getTotalConsumption() const;
132 
134  double getTotalRegenerated() const;
135 
137  std::string getChargingStationID() const;
138 
140  double getEnergyCharged() const;
141 
143  int getVehicleStopped() const;
144 
146  double getStoppingTreshold() const;
147 
149  void setActualBatteryCapacity(const double actualBatteryCapacity);
150 
152  void setMaximumBatteryCapacity(const double maximumBatteryCapacity);
153 
155  void setPowerMax(const double new_Pmax);
156 
158  void setStoppingTreshold(const double stoppingTreshold);
159 
161  void resetChargingStartTime();
162 
165 
168 
171 
173  const EnergyParams& getEnergyParams() const {
174  return myParam;
175  }
176 
177 protected:
180 
183 
185  double myPowerMax;
186 
189 
192 
194  double myLastAngle;
195 
198 
201 
204 
206  double myConsum;
207 
210 
213 
216 
219 
222 
225 
228 
229 private:
232 
235 };
236 
237 
long long int SUMOTime
Definition: SUMOTime.h:32
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An upper class for objects with additional parameters.
Definition: EnergyParams.h:41
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)
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
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.
void setStoppingTreshold(const double stoppingTreshold)
Set vehicle's stopping treshold.
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBattery...
double myPowerMax
Parameter, The Maximum Power when accelerating, [myPowerMax >= 0].
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void increaseChargingStartTime()
Increase Charging Start time.
MSChargingStation * myPreviousNeighbouringChargingStation
Parameter, Pointer to charging station neighbouring with myActChargingStation in which vehicle was pl...
MSDevice_Battery & operator=(const MSDevice_Battery &)
Invalidated assignment operator.
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.
void checkParam(const SumoXMLAttr paramKey, const double lower=0., const double upper=std::numeric_limits< double >::infinity())
bool myTrackFuel
whether to track fuel consumption instead of electricity
void setPowerMax(const double new_Pmax)
Set maximum power when accelerating.
double getMaximumPower() const
Get the maximum power when accelerating.
double myEnergyCharged
Parameter, Energy charged in each timestep.
double myLastAngle
Parameter, Vehicle's last angle.
double myTotalRegenerated
Parameter, total vehicle energy regeneration.
EnergyParams myParam
Parameter collection.
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 setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
MSDevice_Battery(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double powerMax, const double stoppingTreshold, const EnergyParams &param)
Constructor.
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 myStoppingTreshold
Parameter, stopping vehicle treshold [myStoppingTreshold >= 0].
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.
double getStoppingTreshold() const
Get stopping treshold.
const EnergyParams & getEnergyParams() const
retrieve parameters for the energy consumption model
bool isChargingStopped() const
Get true if Vehicle is charging, false if not.
MSDevice_Battery(const MSDevice_Battery &)
Invalidated copy constructor.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60