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-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// Charging Station for Electric vehicles
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <list>
26#include <string>
27#include <iostream>
28#include <fstream>
29#include <sstream>
31
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36class MSLane;
37class MSBusStop;
38class OptionsCont;
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
50
51public:
57
61 static inline std::string chargeTypeToString(ChargeType type) {
62 if (type == CHARGETYPE_NORMAL) {
63 return "normal";
64 } else if (type == CHARGETYPE_BATTERYEXCHANGE) {
65 return "battery-exchange";
66 } else if (type == CHARGETYPE_FUEL) {
67 return "fuel";
68 } else {
69 WRITE_WARNING(TL("Encountered an unknown charge type. Assuming charge type 'normal'."));
70 return "normal";
71 }
72 }
73
77 static inline ChargeType stringToChargeType(const std::string& repr) {
78 if (repr == "normal") {
80 } else if (repr == "battery-exchange") {
82 } else if (repr == "fuel") {
84 } else {
85 WRITE_WARNINGF("Encountered an unknown charge type string '%'. Assuming charge type 'normal'.", repr);
87 }
88 }
89
90public:
91
93 MSChargingStation(const std::string& chargingStationID, MSLane& lane, double startPos, double endPos,
94 const std::string& name, double chargingPower, double efficency, bool chargeInTransit,
95 SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime);
96
97 MSChargingStation(const std::string& chargingStationID, const MSParkingArea* parkingArea, const std::string& name, double chargingPower,
98 double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType,
99 SUMOTime waitingTime);
100
103
105 double getChargingPower(bool usingFuel) const;
106
108 double getEfficency() const;
109
111 bool getChargeInTransit() const;
112
114 SUMOTime getChargeDelay() const;
115
118
120 SUMOTime getWaitingTime() const;
121
125 const MSParkingArea* getParkingArea() const;
126
128 void setChargingPower(double chargingPower);
129
131 void setEfficiency(double efficiency);
132
134 void setChargeDelay(SUMOTime delay);
135
137 void setChargeInTransit(bool value);
138
140 void setChargingVehicle(bool value);
141
146 bool vehicleIsInside(const double position) const;
147
149 bool isCharging() const;
150
151 double getTotalCharged() const {
152 return myTotalCharge;
153 }
154
156 void addChargeValueForOutput(double WCharged, MSDevice_Battery* battery);
157
160
162 void writeAggregatedChargingStationOutput(OutputDevice& output, bool includeUnfinished = false);
163
164protected:
165
167 struct Charge {
169 Charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status,
170 double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _chargingPower,
171 double _chargingEfficiency, double _totalEnergyCharged) :
172 timeStep(_timeStep),
173 vehicleID(_vehicleID),
174 vehicleType(_vehicleType),
175 status(_status),
176 WCharged(_WCharged),
177 actualBatteryCapacity(_actualBatteryCapacity),
178 maxBatteryCapacity(_maxBatteryCapacity),
179 chargingPower(_chargingPower),
180 chargingEfficiency(_chargingEfficiency),
181 totalEnergyCharged(_totalEnergyCharged) {}
182
183 // @brief vehicle TimeStep
185 // @brief vehicle ID
186 std::string vehicleID;
187 // @brief vehicle Type
188 std::string vehicleType;
190 std::string status;
191 // @brief W charged
192 double WCharged;
193 // @brief actual battery capacity AFTER charging
195 // @brief battery max capacity
197 // @brief current charging power of charging station
199 // @brief current efficiency of charging station
201 // @brief current energy charged by charging stations AFTER charging
203 };
204
205 static void writeVehicle(OutputDevice& out, const std::vector<Charge>& chargeSteps, int iStart, int iEnd, double charged);
206
208 double myChargingPower = 0;
209
211 double myEfficiency = 0;
212
215
218
221
224
226 bool myChargingVehicle = false;
227
229 double myTotalCharge = 0;
230
232 const MSParkingArea* myParkingArea = nullptr;
233
235 std::map<std::string, std::vector<Charge> > myChargeValues;
237 std::vector<std::string> myChargedVehicles;
238
239private:
242
245};
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
MSChargingStation & operator=(const MSChargingStation &)=delete
Invalidated assignment operator.
double myChargingPower
Charging station's charging power.
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)
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
SUMOTime myWaitingTime
waiting time
static std::string chargeTypeToString(ChargeType type)
Get the string representation of a charge type.
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.
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