Commit cc943d2b authored by tobias schroedter's avatar tobias schroedter

Added Event handling for FF_Router_Trips

parent b5f8a348
...@@ -546,6 +546,10 @@ double Simulation::RunBody(double maxSimTime) ...@@ -546,6 +546,10 @@ double Simulation::RunBody(double maxSimTime)
} }
} }
if (_routingEngine->isNeedUpdate()){
_routingEngine->UpdateRouter();
}
//update the routes and locations //update the routes and locations
UpdateRoutesAndLocations(); UpdateRoutesAndLocations();
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* *
**/ **/
#include <string> #include <string>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
...@@ -537,6 +536,7 @@ void EventManager::ProcessEvent() ...@@ -537,6 +536,7 @@ void EventManager::ProcessEvent()
TempCloseDoor(event.GetId()); TempCloseDoor(event.GetId());
break; break;
} }
_building->GetRoutingEngine()->setNeedUpdate(true);
} }
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
class Building; class Building;
class Router; class Router;
class GlobalRouterTrips;
class QuickestPathRouter; class QuickestPathRouter;
class RoutingEngine; class RoutingEngine;
class Event; class Event;
......
...@@ -98,3 +98,7 @@ void Router::SetTrips(const Trips& trips){ ...@@ -98,3 +98,7 @@ void Router::SetTrips(const Trips& trips){
_trips = trips; _trips = trips;
std::cout << _trips << std::endl; std::cout << _trips << std::endl;
} }
void Router::Update(){
}
\ No newline at end of file
...@@ -142,7 +142,7 @@ public: ...@@ -142,7 +142,7 @@ public:
void SetTrips(const Trips& trips); void SetTrips(const Trips& trips);
virtual void Update();
}; };
#endif /* _ROUTING_H */ #endif /* _ROUTING_H */
...@@ -131,3 +131,21 @@ bool RoutingEngine::Init(Building* building) ...@@ -131,3 +131,21 @@ bool RoutingEngine::Init(Building* building)
return status; 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;
}
...@@ -113,6 +113,13 @@ private: ...@@ -113,6 +113,13 @@ private:
std::vector<Router*> _routersCollection; std::vector<Router*> _routersCollection;
/// collection of all trips/routes /// collection of all trips/routes
Trips _tripsCollection; Trips _tripsCollection;
bool _needUpdate = false;
public:
bool isNeedUpdate() const;
void setNeedUpdate(bool needUpdate);
void UpdateRouter();
}; };
#endif /* ROUTINGENGINE_H_ */ #endif /* ROUTINGENGINE_H_ */
...@@ -706,4 +706,8 @@ bool FFRouterTrips::MustReInit() { ...@@ -706,4 +706,8 @@ bool FFRouterTrips::MustReInit() {
void FFRouterTrips::SetRecalc(double t) { void FFRouterTrips::SetRecalc(double t) {
_timeToRecalc = t + _recalc_interval; _timeToRecalc = t + _recalc_interval;
}
void FFRouterTrips::Update(){
this->ReInit();
} }
\ No newline at end of file
...@@ -194,6 +194,8 @@ public: ...@@ -194,6 +194,8 @@ public:
bool MustReInit(); bool MustReInit();
void SetRecalc(double t); void SetRecalc(double t);
virtual void Update();
private: private:
protected: protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment