LCOV - code coverage report
Current view: top level - src/microsim - MSVehicleTransfer.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 1 1
Test Date: 2024-10-24 15:46:30 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2003-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    MSVehicleTransfer.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @date    Sep 2003
      19              : ///
      20              : // A mover of vehicles that got stucked due to grid locks
      21              : // This class also serves as container for parking vehicles
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : 
      26              : #include <string>
      27              : #include <vector>
      28              : #include <map>
      29              : #include <set>
      30              : #include <utils/foxtools/MFXSynchQue.h>
      31              : 
      32              : 
      33              : // ===========================================================================
      34              : // class declarations
      35              : // ===========================================================================
      36              : class MSEdge;
      37              : class MSLane;
      38              : class MSVehicle;
      39              : class MSVehicleControl;
      40              : class SUMOSAXAttributes;
      41              : 
      42              : 
      43              : // ===========================================================================
      44              : // class definitions
      45              : // ===========================================================================
      46              : /**
      47              :  * @class MSVehicleTransfer
      48              :  * This object (each simulation owns exactly one) is responsible for the
      49              :  *  transfer of vehicles that got stuck within the network due to grid locks.
      50              :  *  It also manages vehicles that are removed from the network because of stops
      51              :  *  with the parking attribute.
      52              :  *
      53              :  * The method add is called by a lane if a vehicle stood to long at this
      54              :  *  lane's end. After being added to this transfer object and removed from the
      55              :  *  lane, it is moved over the consecutive edges. On each edge, it is tried to
      56              :  *  insert the vehicle again. The lanes are of course chosen by examining the
      57              :  *  vehicle's real route.
      58              :  *
      59              :  * This object is used as a singleton
      60              :  */
      61              : class MSVehicleTransfer {
      62              : public:
      63              :     /// @brief Destructor
      64              :     virtual ~MSVehicleTransfer();
      65              : 
      66              : 
      67              :     /** @brief Adds a vehicle to this transfer object
      68              :      *
      69              :      * The vehicle is removed from the network as it would end the trip.
      70              :      * If the vehicle's next edge is his last one, the vehicle is also
      71              :      *  removed from the vehicle control.
      72              :      *
      73              :      * @param[in] veh The vehicle to add
      74              :      */
      75              :     void add(const SUMOTime t, MSVehicle* veh);
      76              : 
      77              : 
      78              :     /** @brief Remove a vehicle from this transfer object
      79              :      *
      80              :      * The vehicle is removed from the transfer if present.
      81              :      * This should be necessary only in the context of TraCI removals.
      82              :      *
      83              :      * @param[in] veh The vehicle to remove
      84              :      */
      85              :     void remove(MSVehicle* veh);
      86              : 
      87              : 
      88              :     /** @brief Checks "movement" of stored vehicles
      89              :      *
      90              :      * Checks whether one of the stored vehicles may be inserted back into
      91              :      *  the network. If not, the vehicle may move virtually to the next lane
      92              :      *  of its route
      93              :      *
      94              :      * @param[in] time The current simulation time
      95              :      */
      96              :     void checkInsertions(SUMOTime time);
      97              : 
      98              : 
      99              :     /** @brief Saves the current state into the given stream */
     100              :     void saveState(OutputDevice& out);
     101              : 
     102              :     /** @brief Remove all vehicles before quick-loading state */
     103              :     void clearState();
     104              : 
     105              :     /** @brief Loads one transfer vehicle state from the given descriptionn */
     106              :     void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset, MSVehicleControl& vc);
     107              : 
     108              :     /** @brief Returns the instance of this object
     109              :      * @return The singleton instance
     110              :      */
     111              :     static MSVehicleTransfer* getInstance();
     112              : 
     113              :     /// @brief The minimum speed while teleporting
     114              :     static const double TeleportMinSpeed;
     115              : 
     116              : private:
     117              :     /// @brief Constructor
     118              :     MSVehicleTransfer();
     119              : 
     120              : 
     121              : protected:
     122              :     /**
     123              :      * @struct VehicleInformation
     124              :      * @brief Holds the information needed to move the vehicle over the network
     125              :      */
     126              :     struct VehicleInformation {
     127              :         /// @brief the time at which this vehicle was removed from the network
     128              :         SUMOTime myTransferTime;
     129              :         /// @brief The vehicle itself
     130              :         MSVehicle* myVeh;
     131              :         /// @brief The time at which the vehicle should be moved virtually one edge further
     132              :         SUMOTime myProceedTime;
     133              :         /// @brief whether the vehicle is or was parking
     134              :         bool myParking;
     135              :         /// @brief whether the vehicle is or was jumping
     136              :         bool myJumping;
     137              : 
     138              :         /** @brief Constructor
     139              :          * @param[in] veh The teleported vehicle
     140              :          * @param[in] insertTime The time the vehicle was inserted at
     141              :          * @param[in] proceedTime The time at which the vehicle should be moved virtually one edge further
     142              :          */
     143              :         VehicleInformation(SUMOTime t, MSVehicle* veh, SUMOTime proceedTime, bool parking, bool jumping)
     144        19493 :             : myTransferTime(t), myVeh(veh), myProceedTime(proceedTime), myParking(parking), myJumping(jumping) { }
     145              : 
     146              :         /// @brief sort by vehicle ID for repeatable parallel simulation
     147              :         bool operator<(const VehicleInformation& v2) const;
     148              :     };
     149              : 
     150              : 
     151              :     /// @brief The information about stored vehicles to move virtually
     152              :     MFXSynchQue<VehicleInformation, std::vector<VehicleInformation> > myVehicles;
     153              : 
     154              :     /// @brief The static singleton-instance
     155              :     static MSVehicleTransfer* myInstance;
     156              : 
     157              : };
        

Generated by: LCOV version 2.0-1