LCOV - code coverage report
Current view: top level - src/microsim/trigger - MSChargingStation.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 13 13 100.0 %
Date: 2024-05-07 15:28:01 Functions: 1 1 100.0 %

          Line data    Source code
       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             : /****************************************************************************/
      14             : /// @file    MSChargingStation.h
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Tamas Kurczveil
      17             : /// @author  Pablo Alvarez Lopez
      18             : /// @date    20-12-13
      19             : ///
      20             : // Chargin 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>
      30             : #include <microsim/MSStoppingPlace.h>
      31             : 
      32             : 
      33             : // ===========================================================================
      34             : // class declarations
      35             : // ===========================================================================
      36             : class MSLane;
      37             : class MSBusStop;
      38             : class OptionsCont;
      39             : class MSDevice_Battery;
      40             : 
      41             : 
      42             : // ===========================================================================
      43             : // class definitions
      44             : // ===========================================================================
      45             : /**
      46             :  * @class ChargingStation
      47             :  * @brief Definition of charging stations
      48             :  */
      49             : class MSChargingStation : public MSStoppingPlace {
      50             : 
      51             : public:
      52             :     /// @brief constructor
      53             :     MSChargingStation(const std::string& chargingStationID, MSLane& lane, double startPos, double endPos,
      54             :                       const std::string& name, double chargingPower, double efficency, bool chargeInTransit,
      55             :                       SUMOTime chargeDelay, const std::string& chargeType, SUMOTime waitingTime);
      56             : 
      57             :     MSChargingStation(const std::string& chargingStationID, const MSParkingArea* parkingArea, const std::string& name, double chargingPower,
      58             :                       double efficency, bool chargeInTransit, SUMOTime chargeDelay, const std::string& chargeType,
      59             :                       SUMOTime waitingTime);
      60             : 
      61             :     /// @brief destructor
      62             :     ~MSChargingStation();
      63             : 
      64             :     /// @brief Get charging station's charging power in the
      65             :     double getChargingPower(bool usingFuel) const;
      66             : 
      67             :     /// @brief Get efficiency of the charging station
      68             :     double getEfficency() const;
      69             : 
      70             :     /// @brief Get chargeInTransit
      71             :     bool getChargeInTransit() const;
      72             : 
      73             :     /// @brief Get Charge Delay
      74             :     SUMOTime getChargeDelay() const;
      75             : 
      76             :     /// @brief Get charge type
      77             :     const std::string& getChargeType() const;
      78             : 
      79             :     /// @brief Get waiting time
      80             :     SUMOTime getWaitingTime() const;
      81             : 
      82             :     /** @brief Get the parking area the charging station is placed on
      83             :      * @return pointer to the parking area or nullptr
      84             :      */
      85             :     const MSParkingArea* getParkingArea() const;
      86             : 
      87             :     /// @brief enable or disable charging vehicle
      88             :     void setChargingVehicle(bool value);
      89             : 
      90             :     /** @brief Check if a vehicle is inside in  the Charge Station
      91             :      * @param[in] position Position of vehicle in the LANE
      92             :      * @return true if is between StartPostion and EndPostion
      93             :      */
      94             :     bool vehicleIsInside(const double position) const;
      95             : 
      96             :     /// @brief Return true if in the current time step charging station is charging a vehicle
      97             :     bool isCharging() const;
      98             : 
      99             :     double getTotalCharged() const {
     100           6 :         return myTotalCharge;
     101             :     }
     102             : 
     103             :     /// @brief add charge value for output
     104             :     void addChargeValueForOutput(double WCharged, MSDevice_Battery* battery);
     105             : 
     106             :     /// @brief write charging station values
     107             :     void writeChargingStationOutput(OutputDevice& output);
     108             : 
     109             : protected:
     110             : 
     111             :     /// @brief struct to save information for the chargingStation output
     112             :     struct Charge {
     113             :         /// @brief constructor
     114        5792 :         Charge(SUMOTime _timeStep, std::string _vehicleID, std::string _vehicleType, std::string _status,
     115             :                double _WCharged, double _actualBatteryCapacity, double _maxBatteryCapacity, double _chargingPower,
     116        5792 :                double _chargingEfficiency, double _totalEnergyCharged) :
     117        5792 :             timeStep(_timeStep),
     118        5792 :             vehicleID(_vehicleID),
     119        5792 :             vehicleType(_vehicleType),
     120        5792 :             status(_status),
     121        5792 :             WCharged(_WCharged),
     122        5792 :             actualBatteryCapacity(_actualBatteryCapacity),
     123        5792 :             maxBatteryCapacity(_maxBatteryCapacity),
     124        5792 :             chargingPower(_chargingPower),
     125        5792 :             chargingEfficiency(_chargingEfficiency),
     126        5792 :             totalEnergyCharged(_totalEnergyCharged) {}
     127             : 
     128             :         // @brief vehicle TimeStep
     129             :         SUMOTime timeStep;
     130             :         // @brief vehicle ID
     131             :         std::string vehicleID;
     132             :         // @brief vehicle Type
     133             :         std::string vehicleType;
     134             :         /// @brief status
     135             :         std::string status;
     136             :         // @brief W charged
     137             :         double WCharged;
     138             :         // @brief actual battery capacity AFTER charging
     139             :         double actualBatteryCapacity;
     140             :         // @brief battery max capacity
     141             :         double maxBatteryCapacity;
     142             :         // @brief current charging power of charging station
     143             :         double chargingPower;
     144             :         // @brief current efficiency of charging station
     145             :         double chargingEfficiency;
     146             :         // @brief current energy charged by charging stations AFTER charging
     147             :         double totalEnergyCharged;
     148             :     };
     149             : 
     150             :     static void writeVehicle(OutputDevice& out, const std::vector<Charge>& chargeSteps, int iStart, int iEnd, double charged);
     151             : 
     152             :     /// @brief Charging station's charging power
     153             :     double myChargingPower = 0;
     154             : 
     155             :     /// @brief Efficiency of the charging station
     156             :     double myEfficiency = 0;
     157             : 
     158             :     /// @brief Allow charge in transit
     159             :     bool myChargeInTransit;
     160             : 
     161             :     /// @brief Charge Delay
     162             :     SUMOTime myChargeDelay = 0;
     163             : 
     164             :     /// @brief charge type
     165             :     const std::string myChargeType = "normal";
     166             : 
     167             :     /// @brief waiting time
     168             :     SUMOTime myWaitingTime = 0;
     169             : 
     170             :     /// @brief Check if in the current TimeStep chargingStation is charging a vehicle
     171             :     bool myChargingVehicle = false;
     172             : 
     173             :     /// @brief total energy charged by this charging station
     174             :     double myTotalCharge = 0;
     175             : 
     176             :     /// @brief parkingArea the charging station is placed on
     177             :     const MSParkingArea* myParkingArea = nullptr;
     178             : 
     179             :     /// @brief map with the charges of this charging station (key = vehicleID)
     180             :     std::map<std::string, std::vector<Charge> > myChargeValues;
     181             :     /// @brief order vehicles by time of first charge
     182             :     std::vector<std::string> myChargedVehicles;
     183             : 
     184             : private:
     185             :     /// @brief Invalidated copy constructor.
     186             :     MSChargingStation(const MSChargingStation&) = delete;
     187             : 
     188             :     /// @brief Invalidated assignment operator.
     189             :     MSChargingStation& operator=(const MSChargingStation&) = delete;
     190             : };

Generated by: LCOV version 1.14