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-2020 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>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class SUMOVehicle;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
44 public:
48  static void insertOptions(OptionsCont& oc);
49 
60  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
61 
62 public:
65 
68 
77  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
79 
81  const std::string deviceName() const {
82  return "battery";
83  }
84 
86  std::string getParameter(const std::string& key) const;
87 
89  void setParameter(const std::string& key, const std::string& value);
90 
92  void notifyParking();
93 
94 private:
102  MSDevice_Battery(SUMOVehicle& holder, const std::string& id, const double actualBatteryCapacity, const double maximumBatteryCapacity,
103  const double powerMax, const double stoppingTreshold, const std::map<int, double>& param);
104 
105  void checkParam(const SumoXMLAttr paramKey, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
106 
107 public:
109  double getActualBatteryCapacity() const;
110 
112  double getMaximumBatteryCapacity() const;
113 
115  double getMaximumPower() const;
116 
118  bool isChargingStopped() const;
119 
121  bool isChargingInTransit() const;
122 
124  double getChargingStartTime() const;
125 
127  double getConsum() const;
128 
130  std::string getChargingStationID() const;
131 
133  double getEnergyCharged() const;
134 
136  int getVehicleStopped() const;
137 
139  double getStoppingTreshold() const;
140 
142  void setActualBatteryCapacity(const double actualBatteryCapacity);
143 
145  void setMaximumBatteryCapacity(const double maximumBatteryCapacity);
146 
148  void setPowerMax(const double new_Pmax);
149 
151  void setStoppingTreshold(const double stoppingTreshold);
152 
154  void resetChargingStartTime();
155 
158 
161 
164 
166  const std::map<int, double>& getEnergyParams() const {
167  return myParam;
168  }
169 
170 protected:
173 
176 
178  double myPowerMax;
179 
182 
184  std::map<int, double> myParam;
185 
187  double myLastAngle;
188 
191 
194 
197 
199  double myConsum;
200 
203 
206 
209 
212 
213 private:
216 
219 };
220 
221 
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Battery device for electric vehicles.
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 kWh.
int getVehicleStopped() const
Get number of timestep that vehicle is stopped.
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in kWh, [myMaximumBatteryCapacity >= 0].
void increaseVehicleStoppedTimer()
Increase myVehicleStopped.
double myChargingStartTime
Parameter, Moment, wich the vehicle has beging to charging.
void setStoppingTreshold(const double stoppingTreshold)
Set vehicle's stopping treshold.
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in kWh, [myActualBatteryCapacity <= myMaximumBatter...
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.
double getChargingStartTime() const
Get charging start time.
std::map< int, double > myParam
Parameter collection.
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 kWh.
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())
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.
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.
const std::string deviceName() const
return the name for this type of device
MSDevice_Battery(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double powerMax, const double stoppingTreshold, const std::map< int, double > &param)
Constructor.
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
const std::map< int, double > & getEnergyParams() const
retrieve parameters for the energy consumption model
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.
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:58