LCOV - code coverage report
Current view: top level - app/src/Dynamic/Env/Event - EventSpawnVehicle.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 17 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "Dynamic/Env/Event/EventSpawnVehicle.hpp"
       2             : 
       3             : #include "Dynamic/Env/Env.hpp"
       4             : #include "Dynamic/Env/Event/EventComposite.hpp"
       5             : #include "Dynamic/Env/Event/EventUpdateVehicle.hpp"
       6             : #include "Dynamic/Env/Lane.hpp"
       7             : #include "Dynamic/Env/Position.hpp"
       8             : 
       9             : using namespace std;
      10             : using namespace Dynamic;
      11             : using namespace Dynamic::Env;
      12             : 
      13           0 : EventSpawnVehicle::EventSpawnVehicle(
      14             :     Time                    t_,
      15             :     const Dynamic::Vehicle &vehicle_
      16           0 : ):
      17             :     Event(t_),
      18           0 :     vehicle(vehicle_) {}
      19             : 
      20           0 : void EventSpawnVehicle::process(Env &env) {
      21           0 :     Lane &initialLane = vehicle.pickInitialLane(env);
      22             : 
      23           0 :     if(initialLane.isFull()) {
      24           0 :         initialLane.uninstantiated.push(vehicle);
      25             : 
      26           0 :         if(initialLane.uninstantiated.size() % 10 == 0) {
      27             :             // cerr
      28             :             //     << "[warn][t=" << env.getTime() << "] "
      29             :             //     << "Uninstantiated queue of lane " << initialLane.idAsString()
      30             :             //     << " has size " << initialLane.uninstantiated.size()
      31             :             //     << endl;
      32             :         }
      33             : 
      34           0 :         return;
      35             :     }
      36             : 
      37             :     // clang-format off
      38           0 :     Vehicle &envVehicle = env.addVehicle(
      39           0 :         vehicle,
      40             :         env.getTime(), 
      41           0 :         Position{initialLane, 0}, 
      42             :         initialLane.calculateSpeed()
      43           0 :     );
      44             :     // clang-format on
      45             : 
      46           0 :     Time Dt      = envVehicle.position.lane.queuePosition() / envVehicle.speed;
      47           0 :     Dt           = max(Dt, 0.0);
      48           0 :     Time tFuture = env.getTime() + Dt;
      49             : 
      50             :     // clang-format off
      51           0 :     env.pushEvent(make_shared<EventUpdateVehicle>(
      52             :         tFuture,
      53             :         envVehicle
      54             :     ));
      55             :     // clang-format on
      56             : }

Generated by: LCOV version 1.14