43 const std::string& name,
double chargingPower,
double totalPower,
double efficency,
bool chargeInTransit,
46 myChargeInTransit(chargeInTransit), myChargeType(stringToChargeType(chargeType)), myTotalPowerCheckEvent(nullptr) {
47 if (chargingPower < 0) {
53 if (efficency < 0 || efficency > 1) {
58 if (chargeDelay < 0) {
63 if (waitingTime < 0) {
75 double totalPower,
double efficency,
bool chargeInTransit,
SUMOTime chargeDelay,
const std::string& chargeType,
SUMOTime waitingTime) :
76 MSChargingStation(chargingStationID, const_cast<
MSLane&>(parkingArea->getLane()), parkingArea->getBeginLanePosition(), parkingArea->getEndLanePosition(),
77 name, chargingPower, totalPower, efficency, chargeInTransit, chargeDelay, chargeType, waitingTime) {
179 if (totalPower <= 0) {
199 std::vector<Charge*> thisStepCharges;
204 Charge& lastcharge = kv.second.back();
205 if (lastcharge.
timeStep == currentTime) {
207 thisStepCharges.push_back(&lastcharge);
210 if (thisStepCharges.size() < 2) {
215 std::cout <<
"checkTotalPower: CS="
217 if (sumReqWh > capWh && sumReqWh > 0) {
218 std::cout <<
" exceeded, needs rebalancing!";
220 std::cout << std::endl;
222 if (sumReqWh > capWh && sumReqWh > 0) {
223 const double ratio = capWh / sumReqWh;
224 for (
auto* charge : thisStepCharges) {
228 const double deliveredWh = charge->WCharged * ratio;
229 const double excessWh = charge->WCharged - deliveredWh;
230 charge->WCharged = deliveredWh;
231 if (charge->chargingEfficiency > 0 &&
TS > 0) {
234 charge->chargingPower = (deliveredWh * 3600.0) / (charge->chargingEfficiency *
TS);
236 charge->actualBatteryCapacity = abc - excessWh;
237 charge->totalEnergyCharged -= excessWh;
246 <<
" vehID=" << charge->vehicleID
247 <<
" requestedWh=" << (deliveredWh + excessWh)
248 <<
" deliveredWh=" << deliveredWh
249 <<
" deliveredW=" << charge->chargingPower
250 <<
" ratio=" << ratio << std::endl;
254 std::cout <<
"===============\n\n";
282 std::string status =
"";
285 status =
"chargingStopped";
287 status =
"chargingInTransit";
289 status =
"noCharging";
293 status =
"waitingChargeInTransit";
295 status =
"waitingChargeStopped";
297 status =
"noWaitingCharge";
317 int chargingSteps = 0;
319 chargingSteps += (int)item.second.size();
330 while (iStart < (
int)chargeSteps.size()) {
331 int iEnd = iStart + 1;
332 double charged = chargeSteps[iStart].WCharged;
333 while (iEnd < (
int)chargeSteps.size() && chargeSteps[iEnd].timeStep == chargeSteps[iEnd - 1].timeStep +
DELTA_T) {
334 charged += chargeSteps[iEnd].WCharged;
337 writeVehicle(output, chargeSteps, iStart, iEnd, charged);
349 std::vector<std::string> terminatedChargers;
351 const Charge& lastCharge = item.second.back();
354 if (finished || includeUnfinished) {
356 terminatedChargers.push_back(item.first);
362 double minCharge = lastCharge.
WCharged;
363 double maxCharge = lastCharge.
WCharged;
366 for (
const auto& charge : item.second) {
367 charged += charge.WCharged;
368 if (charge.chargingPower < minPower) {
369 minPower = charge.chargingPower;
371 if (charge.chargingPower > maxPower) {
372 maxPower = charge.chargingPower;
374 if (charge.WCharged < minCharge) {
375 minCharge = charge.WCharged;
377 if (charge.WCharged > maxCharge) {
378 maxCharge = charge.WCharged;
380 if (charge.chargingEfficiency < minEfficiency) {
381 minEfficiency = charge.chargingEfficiency;
383 if (charge.chargingEfficiency > maxEfficiency) {
384 maxEfficiency = charge.chargingEfficiency;
410 for (
auto vehID : terminatedChargers) {
418 const Charge& first = chargeSteps[iStart];
425 for (
int i = iStart; i < iEnd; i++) {
426 const Charge& c = chargeSteps[i];
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_CHARGING_EVENT
A charging event (charging a vehicle at a charging station)
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_ATTR_PARTIALCHARGE
energy provided by charging station at certain timestep
@ SUMO_ATTR_TOTALENERGYCHARGED
@ SUMO_ATTR_MINPOWER
minimum charging power encountered during the charging event
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_MINEFFICIENCY
minimum charging efficiency encountered during the charging event
@ SUMO_ATTR_MAXCHARGE
maximum energy charged during one time step of the charging event
@ SUMO_ATTR_TOTALENERGYCHARGED_VEHICLE
total energy charged into a single vehicle
@ SUMO_ATTR_CHARGINGSTATIONID
Charging Station ID.
@ SUMO_ATTR_ACTUALBATTERYCAPACITY
@ SUMO_ATTR_ENERGYCHARGED
tgotal of Energy charged
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_MAXEFFICIENCY
maximum charging efficiency encountered during the charging event
@ SUMO_ATTR_CHARGINGSTEPS
number of steps that a vehicle is charging
@ SUMO_ATTR_CHARGINGEND
timesteps in which charging ends
@ SUMO_ATTR_EFFICIENCY
Eficiency of the charge in Charging Stations.
@ SUMO_ATTR_CHARGINGBEGIN
timestep in which charging begins
@ SUMO_ATTR_MINCHARGE
minimum energy charged during one time step of the charging event
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations (different of waiting time)
@ SUMO_ATTR_TIME
trigger: the time of the step
@ SUMO_ATTR_CHARGING_STATUS
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setChargeInTransit(bool value)
set charging in transit
void writeChargingStationOutput(OutputDevice &output)
write charging station values
void setTotalChargingPower(double totalPower)
set charging station's total power
double myTotalCharge
total energy charged by this charging station
double getTotalChargingPower() const
Get charging station's total power.
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
MSChargingStation(const std::string &chargingStationID, MSLane &lane, double startPos, double endPos, const std::string &name, double chargingPower, double totalPower, double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string &chargeType, SUMOTime waitingTime)
constructor
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
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
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
const MSParkingArea * getParkingArea() const
Get the parking area the charging station is placed on.
Battery device for electric vehicles.
void setEnergyCharged(const double energyCharged)
Set Energy Charged in Wh.
SUMOTime getChargingStartTime() const
Get charging start time.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in Wh.
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in Wh.
void setActualBatteryCapacity(const double actualBatteryCapacity)
Set actual vehicle's Battery Capacity in kWh.
double getStoppingThreshold() const
Get stopping threshold.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
A lane area vehicles can halt at.
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
SUMOVehicle & getHolder() const
Returns the vehicle that holds this device.
const std::string & getID() const
Returns the name of the vehicle type.
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getSpeed() const =0
Returns the object's current speed.
A wrapper for a Command function.
struct to save information for the chargingStation output
double totalEnergyCharged
double maxBatteryCapacity
double actualBatteryCapacity
double chargingEfficiency