LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDevice_StationFinder.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 2 4 50.0 %
Date: 2024-04-29 15:38:36 Functions: 0 1 0.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    MSDevice_StationFinder.h
      15             : /// @author  Michael Behrisch
      16             : /// @date    2023-05-24
      17             : ///
      18             : // A device which triggers rerouting to nearby charging stations
      19             : /****************************************************************************/
      20             : #pragma once
      21             : #include <config.h>
      22             : 
      23             : #include "MSVehicleDevice.h"
      24             : 
      25             : 
      26             : // ===========================================================================
      27             : // class declarations
      28             : // ===========================================================================
      29             : class MSDevice_Battery;
      30             : class MSStoppingPlace;
      31             : 
      32             : 
      33             : // ===========================================================================
      34             : // class definitions
      35             : // ===========================================================================
      36             : /**
      37             :  * @class MSDevice_StationFinder
      38             :  * @brief A device which triggers rerouting to nearby charging stations
      39             :  *
      40             :  * Each device checks the battery status by being
      41             :  *  called each time step and initiaiting the search for a compatible
      42             :  *  charging station if the battery level is too low.
      43             :  *
      44             :  * @see MSDevice
      45             :  */
      46             : class MSDevice_StationFinder : public MSVehicleDevice {
      47             : public:
      48             :     /** @brief Inserts MSDevice_StationFinder-options
      49             :      */
      50             :     static void insertOptions(OptionsCont& oc);
      51             : 
      52             : 
      53             :     /** @brief Build devices for the given vehicle, if needed
      54             :      *
      55             :      * The options are read and evaluated whether stationFinder-devices shall be built
      56             :      *  for the given vehicle.
      57             :      *
      58             :      * For each seen vehicle, the global vehicle index is increased.
      59             :      *
      60             :      * The built device is stored in the given vector.
      61             :      *
      62             :      * @param[in] v The vehicle for which a device may be built
      63             :      * @param[in, filled] into The vector to store the built device in
      64             :      */
      65             :     static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
      66             : 
      67             : 
      68             : public:
      69             :     /** @brief Constructor
      70             :      *
      71             :      * @param[in] holder The vehicle that holds this device
      72             :      */
      73             :     MSDevice_StationFinder(SUMOVehicle& holder);
      74             : 
      75             :     /// @brief Destructor.
      76             :     ~MSDevice_StationFinder();
      77             : 
      78             :     /// @name Methods called on vehicle movement / state change, overwriting MSDevice
      79             :     /// @{
      80             : 
      81             :     /** @brief Computes current emission values and adds them to their sums
      82             :         *
      83             :         * The vehicle's current emission values
      84             :         *  are computed using the current velocity and acceleration.
      85             :         *
      86             :         * @param[in] veh The regarded vehicle
      87             :         * @param[in] oldPos Position before the move-micro-timestep.
      88             :         * @param[in] newPos Position after the move-micro-timestep.
      89             :         * @param[in] newSpeed The vehicle's current speed
      90             :         * @return false, if the vehicle is beyond the lane, true otherwise
      91             :         * @see MSMoveReminder
      92             :         * @see MSMoveReminder::notifyMove
      93             :         * @see PollutantsInterface
      94             :         */
      95             :     bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
      96             : 
      97             :     /** @brief Computes idling emission values and adds them to the emission sums
      98             :         *
      99             :         * Idling implied by zero velocity, acceleration and slope
     100             :         *
     101             :         * @param[in] veh The vehicle
     102             :         *
     103             :         * @see MSMoveReminder::notifyMove
     104             :         * @see PollutantsInterface
     105             :         */
     106             :     bool notifyIdle(SUMOTrafficObject& veh);
     107             : 
     108             :     /// @}
     109             : 
     110             :     /// @brief return the name for this type of device
     111           0 :     const std::string deviceName() const {
     112           0 :         return "stationfinder";
     113             :     }
     114             : 
     115             :     /** @brief Called on writing tripinfo output
     116             :      *
     117             :      * @param[in] os The stream to write the information into
     118             :      * @exception IOError not yet implemented
     119             :      * @see MSDevice::tripInfoOutput
     120             :      */
     121             :     void generateOutput(OutputDevice* tripinfoOut) const;
     122             : 
     123             :     void setBattery(MSDevice_Battery* battery) {
     124          16 :         myBattery = battery;
     125          16 :     }
     126             : 
     127             : protected:
     128             :     /** @brief Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
     129             :      *
     130             :      */
     131             :     void notifyMoveInternal(const SUMOTrafficObject& veh,
     132             :                             const double frontOnLane,
     133             :                             const double timeOnLane,
     134             :                             const double meanSpeedFrontOnLane,
     135             :                             const double meanSpeedVehicleOnLane,
     136             :                             const double travelledDistanceFrontOnLane,
     137             :                             const double travelledDistanceVehicleOnLane,
     138             :                             const double meanLengthOnLane);
     139             : 
     140             : private:
     141             :     /// @brief The corresponding battery device
     142             :     MSDevice_Battery* myBattery;
     143             : 
     144             :     /// @brief The safety buffer when calculating expected consumption
     145             :     double myReserveFactor;
     146             : 
     147             :     /// @brief To which station we are currently travelling
     148             :     MSStoppingPlace* myChargingStation;
     149             : 
     150             : private:
     151             :     /// @brief Invalidated copy constructor.
     152             :     MSDevice_StationFinder(const MSDevice_StationFinder&);
     153             : 
     154             :     /// @brief Invalidated assignment operator.
     155             :     MSDevice_StationFinder& operator=(const MSDevice_StationFinder&);
     156             : 
     157             : };

Generated by: LCOV version 1.14