Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSChargingStation.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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/****************************************************************************/
21// Charging Station for Electric vehicles
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <list>
27#include <string>
28#include <iostream>
29#include <fstream>
30#include <sstream>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSLane;
38class MSBusStop;
39class OptionsCont;
41class Command;
42
43// ===========================================================================
44// class definitions
45// ===========================================================================
51
52public:
58
62 static inline std::string chargeTypeToString(ChargeType type) {
63 if (type == CHARGETYPE_NORMAL) {
64 return "normal";
65 } else if (type == CHARGETYPE_BATTERYEXCHANGE) {
66 return "battery-exchange";
67 } else if (type == CHARGETYPE_FUEL) {
68 return "fuel";
69 } else {
70 WRITE_WARNING(TL("Encountered an unknown charge type. Assuming charge type 'normal'."));
71 return "normal";
72 }
73 }
74
78 static inline ChargeType stringToChargeType(const std::string& repr) {
79 if (repr == "normal") {
81 } else if (repr == "battery-exchange") {
83 } else if (repr == "fuel") {
85 } else {
86 WRITE_WARNINGF("Encountered an unknown charge type string '%'. Assuming charge type 'normal'.", repr);
88 }
89 }
90
91public:
92
94 MSChargingStation(const std::string& chargingStationID, MSLane& lane, double startPos, double endPos,
95 const std::string& name, double chargingPower, double totalPower, double efficency, bool chargeInTransit,
96 SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime);
97
98 MSChargingStation(const std::string& chargingStationID, const MSParkingArea* parkingArea, const std::string& name, double chargingPower,
99 double totalPower, double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType,
100 SUMOTime waitingTime);
101
104
106 double getChargingPower(bool usingFuel) const;
107
109 double getEfficency() const;
110
112 bool getChargeInTransit() const;
113
115 SUMOTime getChargeDelay() const;
116
119
121 SUMOTime getWaitingTime() const;
122
126 const MSParkingArea* getParkingArea() const;
127
129 void setChargingPower(double chargingPower);
130
132 void setEfficiency(double efficiency);
133
135 void setChargeDelay(SUMOTime delay);
136
138 void setChargeInTransit(bool value);
139
141 void setChargingVehicle(bool value);
142
144 SUMOTime checkTotalPower(SUMOTime currentTime);
145
150 bool vehicleIsInside(const double position) const;
151
153 bool isCharging() const;
154
155 double getTotalCharged() const {
156 return myTotalCharge;
157 }
158
160 void addChargeValueForOutput(double WCharged, MSDevice_Battery* battery);
161
164
166 void writeAggregatedChargingStationOutput(OutputDevice& output, bool includeUnfinished = false);
167
168protected:
169
171 struct Charge {
173 Charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status,
174 double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _chargingPower,
175 double _chargingEfficiency, double _totalEnergyCharged) :
176 timeStep(_timeStep),
177 vehicleID(_vehicleID),
178 vehicleType(_vehicleType),
179 status(_status),
180 WCharged(_WCharged),
181 actualBatteryCapacity(_actualBatteryCapacity),
182 maxBatteryCapacity(_maxBatteryCapacity),
183 chargingPower(_chargingPower),
184 chargingEfficiency(_chargingEfficiency),
185 totalEnergyCharged(_totalEnergyCharged) {}
186
187 // @brief vehicle TimeStep
189 // @brief vehicle ID
190 std::string vehicleID;
191 // @brief vehicle Type
192 std::string vehicleType;
194 std::string status;
195 // @brief W charged
196 double WCharged;
197 // @brief actual battery capacity AFTER charging
199 // @brief battery max capacity
201 // @brief current charging power of charging station
203 // @brief current efficiency of charging station
205 // @brief current energy charged by charging stations AFTER charging
207 };
208
209 static void writeVehicle(OutputDevice& out, const std::vector<Charge>& chargeSteps, int iStart, int iEnd, double charged);
210
213
216
218 double myEfficiency = 0;
219
222
225
228
231
233 bool myChargingVehicle = false;
234
236 double myTotalCharge = 0;
237
239 const MSParkingArea* myParkingArea = nullptr;
240
242 std::map<std::string, std::vector<Charge> > myChargeValues;
244 std::vector<std::string> myChargedVehicles;
245
247 std::map<std::string, MSDevice_Battery*> myChargedBatteries;
248
251
252
253private:
256
259};
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
ChargeType
Charging types of charging stations.
Base (microsim) event class.
Definition Command.h:50
MSChargingStation & operator=(const MSChargingStation &)=delete
Invalidated assignment operator.
void setChargeInTransit(bool value)
set charging in transit
void writeChargingStationOutput(OutputDevice &output)
write charging station values
double myTotalCharge
total energy charged by this charging station
static void writeVehicle(OutputDevice &out, const std::vector< Charge > &chargeSteps, int iStart, int iEnd, double charged)
std::map< std::string, MSDevice_Battery * > myChargedBatteries
map with the Batteries charged by this charging station (key = vehicleID)
double getChargingPower(bool usingFuel) const
Get charging station's charging power.
const ChargeType myChargeType
charge type
bool getChargeInTransit() const
Get chargeInTransit.
void setChargingVehicle(bool value)
enable or disable charging vehicle
std::vector< std::string > myChargedVehicles
order vehicles by time of first charge
double myEfficiency
Efficiency of the charging station.
void setEfficiency(double efficiency)
set efficiency of the charging station
void setChargingPower(double chargingPower)
set charging station's charging power
Command * myTotalPowerCheckEvent
Event for checking at every time-step if myTotalPower has been exceeded.
double myTotalChargingPower
The maximal charging power available to serve all charging vehicles (value <= 0 take no effect)
SUMOTime myWaitingTime
waiting time
static std::string chargeTypeToString(ChargeType type)
Get the string representation of a charge type.
double myNominalChargingPower
Charging station's nominal charging power per vehicle.
bool myChargeInTransit
Allow charge in transit.
bool vehicleIsInside(const double position) const
Check if a vehicle is inside in the Charge Station.
const MSParkingArea * myParkingArea
parkingArea the charging station is placed on
MSChargingStation(const MSChargingStation &)=delete
Invalidated copy constructor.
double getTotalCharged() const
std::map< std::string, std::vector< Charge > > myChargeValues
map with the charges of this charging station (key = vehicleID)
void addChargeValueForOutput(double WCharged, MSDevice_Battery *battery)
add charge value for output
SUMOTime getChargeDelay() const
Get Charge Delay.
void writeAggregatedChargingStationOutput(OutputDevice &output, bool includeUnfinished=false)
write ungrouped output (flush data after writing)
void setChargeDelay(SUMOTime delay)
set charging delay of the charging station
double getEfficency() const
Get efficiency of the charging station.
ChargeType getChargeType() const
Get charge type.
SUMOTime myChargeDelay
Charge Delay.
~MSChargingStation()
destructor
bool myChargingVehicle
Check if in the current TimeStep chargingStation is charging a vehicle.
bool isCharging() const
Return true if in the current time step charging station is charging a vehicle.
SUMOTime getWaitingTime() const
Get waiting time.
SUMOTime checkTotalPower(SUMOTime currentTime)
update the delivered power to all charging vehicles after all requests are known
static ChargeType stringToChargeType(const std::string &repr)
Get the charge type from its string representation.
const MSParkingArea * getParkingArea() const
Get the parking area the charging station is placed on.
Battery device for electric vehicles.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
A lane area vehicles can halt at.
A lane area vehicles can halt at.
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
struct to save information for the chargingStation output
Charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status, double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _chargingPower, double _chargingEfficiency, double _totalEnergyCharged)
constructor