diff --git a/Simulation.cpp b/Simulation.cpp index cecdfa4956a208ae83b6731911b1a7175bd55726..28f82698e50279270e34e6a9a40e56fe8b644085 100644 --- a/Simulation.cpp +++ b/Simulation.cpp @@ -546,6 +546,11 @@ double Simulation::RunBody(double maxSimTime) } } + // here the used routers are update, when needed due to external changes + if (_routingEngine->NeedsUpdate()){ + _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..b2a65e3272e767389d7cb020d87fc8e970fa078d 100644 --- a/routing/Router.h +++ b/routing/Router.h @@ -142,7 +142,11 @@ public: void SetTrips(const Trips& trips); - + /** + * Update the router, when geometry changed due to external changes. + * Remark: Depends on router if needed! + */ + virtual void Update(); }; #endif /* _ROUTING_H */ diff --git a/routing/RoutingEngine.cpp b/routing/RoutingEngine.cpp index 287797055546c37bb5913b8fd4643e849fed7dec..494f7f51c51cd7e8b4c4a2b7e10b3fba2e63152d 100644 --- a/routing/RoutingEngine.cpp +++ b/routing/RoutingEngine.cpp @@ -131,3 +131,21 @@ bool RoutingEngine::Init(Building* building) return status; } +bool RoutingEngine::NeedsUpdate() 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..ef09a04055249caeeb6406642fdaad9067de06a2 100644 --- a/routing/RoutingEngine.h +++ b/routing/RoutingEngine.h @@ -107,12 +107,29 @@ public: */ bool Init(Building* building); + /** + * Returns if routers need to be updated + * @return routers need to be updated + */ + bool NeedsUpdate() const; + + /** + * Set if routers need to be updated + * @param needUpdate + */ + void setNeedUpdate(bool needUpdate); + + /** + * Updates all used routers + */ + void UpdateRouter(); private: /// collections of all routers used std::vector<Router*> _routersCollection; /// collection of all trips/routes Trips _tripsCollection; + bool _needUpdate = false; }; #endif /* ROUTINGENGINE_H_ */ diff --git a/routing/ff_router/ffRouter.cpp b/routing/ff_router/ffRouter.cpp index 3152fd5969e5be31193312c1f823828df015ebe1..a71235d6733ecda4f2f0aa3a403b2e09b864f401 100644 --- a/routing/ff_router/ffRouter.cpp +++ b/routing/ff_router/ffRouter.cpp @@ -640,4 +640,8 @@ bool FFRouter::MustReInit() { void FFRouter::SetRecalc(double t) { _timeToRecalc = t + _recalc_interval; +} + +void FFRouter::Update(){ + this->ReInit(); } \ No newline at end of file diff --git a/routing/ff_router/ffRouter.h b/routing/ff_router/ffRouter.h index c25ce40113e929bbcd0b51fbda6df7b3169a6e60..110033bff90badb8d0a33f964bbcdd67040e12f4 100644 --- a/routing/ff_router/ffRouter.h +++ b/routing/ff_router/ffRouter.h @@ -184,6 +184,8 @@ public: bool MustReInit(); void SetRecalc(double t); + virtual void Update(); + private: protected: 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: