diff --git a/Simulation.cpp b/Simulation.cpp index 98081c63f424fd45da587bbae19018f1e8b1d7ce..2e0054d4727c6736d817ec52550c5939f4227ee9 100644 --- a/Simulation.cpp +++ b/Simulation.cpp @@ -546,6 +546,10 @@ double Simulation::RunBody(double maxSimTime) } } + if (_routingEngine->isNeedUpdate()){ + _routingEngine->UpdateRouter(); + } + //update the routes and locations UpdateRoutesAndLocations(); diff --git a/events/EventManager.cpp b/events/EventManager.cpp index a60104f15de87a132b85265e3caf37ff9095e670..899273427301ed63a63b369033a73a0e0a3396f5 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -25,7 +25,6 @@ * **/ - #include <string> #include <cstdlib> #include <iostream> @@ -537,6 +536,7 @@ void EventManager::ProcessEvent() TempCloseDoor(event.GetId()); break; } + _building->GetRoutingEngine()->setNeedUpdate(true); } } diff --git a/events/EventManager.h b/events/EventManager.h index a70385c6c0ff631a73847e0a1bd3915381b60eb0..c43d86a62fa46c89101d574a1e024c9707872c13 100644 --- a/events/EventManager.h +++ b/events/EventManager.h @@ -31,7 +31,6 @@ class Building; class Router; -class GlobalRouterTrips; class QuickestPathRouter; class RoutingEngine; class Event; diff --git a/routing/Router.cpp b/routing/Router.cpp index a3b8224d3f47c49e9f70dfb9ac286100331a4f27..8220db8ed2e0ddcaefcddbcefa87138c84a114c1 100644 --- a/routing/Router.cpp +++ b/routing/Router.cpp @@ -98,3 +98,7 @@ void Router::SetTrips(const Trips& trips){ _trips = trips; std::cout << _trips << std::endl; } + +void Router::Update(){ + +} \ No newline at end of file diff --git a/routing/Router.h b/routing/Router.h index dcd5687be747d82dd999ece20e7a90eebc2f8185..eb9b2c93a4eba6dc12c741695fef10f85c6ce3cf 100644 --- a/routing/Router.h +++ b/routing/Router.h @@ -142,7 +142,7 @@ public: void SetTrips(const Trips& trips); - + virtual void Update(); }; #endif /* _ROUTING_H */ diff --git a/routing/RoutingEngine.cpp b/routing/RoutingEngine.cpp index 287797055546c37bb5913b8fd4643e849fed7dec..5e09f5b8f5cfcfab27b2a65dd465567109195a62 100644 --- a/routing/RoutingEngine.cpp +++ b/routing/RoutingEngine.cpp @@ -131,3 +131,21 @@ bool RoutingEngine::Init(Building* building) return status; } +bool RoutingEngine::isNeedUpdate() const +{ + return _needUpdate; +} + +void RoutingEngine::setNeedUpdate(bool needUpdate) +{ + _needUpdate = needUpdate; +} + +void RoutingEngine::UpdateRouter() +{ + for (auto* router : _routersCollection){ + router->Update(); + } + _needUpdate = false; +} + diff --git a/routing/RoutingEngine.h b/routing/RoutingEngine.h index 94fac8e77b44a56b5b4734c656da47e546490659..ef5bb52a7d72437fdfce1b3286edb3dced5925b9 100644 --- a/routing/RoutingEngine.h +++ b/routing/RoutingEngine.h @@ -113,6 +113,13 @@ private: std::vector<Router*> _routersCollection; /// collection of all trips/routes Trips _tripsCollection; + bool _needUpdate = false; +public: + bool isNeedUpdate() const; + + void setNeedUpdate(bool needUpdate); + + void UpdateRouter(); }; #endif /* ROUTINGENGINE_H_ */ diff --git a/routing/ff_router_trips/ffRouterTrips.cpp b/routing/ff_router_trips/ffRouterTrips.cpp index 349aefebd7bcb1b9382982a886ab677b5dd0f99a..8ec0a604b1151082b7446c3eb86655567af72dd0 100644 --- a/routing/ff_router_trips/ffRouterTrips.cpp +++ b/routing/ff_router_trips/ffRouterTrips.cpp @@ -706,4 +706,8 @@ bool FFRouterTrips::MustReInit() { void FFRouterTrips::SetRecalc(double t) { _timeToRecalc = t + _recalc_interval; +} + +void FFRouterTrips::Update(){ + this->ReInit(); } \ No newline at end of file diff --git a/routing/ff_router_trips/ffRouterTrips.h b/routing/ff_router_trips/ffRouterTrips.h index 1bd335a11c63f241a6c3e66ded3e8e45e3343578..0c49890526176c0789a936a8023261a581799c65 100644 --- a/routing/ff_router_trips/ffRouterTrips.h +++ b/routing/ff_router_trips/ffRouterTrips.h @@ -194,6 +194,8 @@ public: bool MustReInit(); void SetRecalc(double t); + virtual void Update(); + private: protected: