From cc943d2b9e32dd5de99669e9ea084623cc59ce1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schr=C3=B6dter?= <t.schroedter@fz-juelich.de> Date: Sat, 30 Mar 2019 12:31:41 +0100 Subject: [PATCH] Added Event handling for FF_Router_Trips --- Simulation.cpp | 4 ++++ events/EventManager.cpp | 2 +- events/EventManager.h | 1 - routing/Router.cpp | 4 ++++ routing/Router.h | 2 +- routing/RoutingEngine.cpp | 18 ++++++++++++++++++ routing/RoutingEngine.h | 7 +++++++ routing/ff_router_trips/ffRouterTrips.cpp | 4 ++++ routing/ff_router_trips/ffRouterTrips.h | 2 ++ 9 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Simulation.cpp b/Simulation.cpp index 98081c63..2e0054d4 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 a60104f1..89927342 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 a70385c6..c43d86a6 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 a3b8224d..8220db8e 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 dcd5687b..eb9b2c93 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 28779705..5e09f5b8 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 94fac8e7..ef5bb52a 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 349aefeb..8ec0a604 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 1bd335a1..0c498905 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: -- GitLab