Commit 277817e3 authored by tobias schroedter's avatar tobias schroedter

Merge branch '294-events' into develop

parents 83393342 051c7c11
Pipeline #19388 passed with stages
in 10 minutes and 22 seconds
......@@ -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();
......
......@@ -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);
}
}
......
......@@ -31,7 +31,6 @@
class Building;
class Router;
class GlobalRouterTrips;
class QuickestPathRouter;
class RoutingEngine;
class Event;
......
......@@ -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
......@@ -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 */
......@@ -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;
}
......@@ -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_ */
......@@ -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
......@@ -184,6 +184,8 @@ public:
bool MustReInit();
void SetRecalc(double t);
virtual void Update();
private:
protected:
......
......@@ -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
......@@ -194,6 +194,8 @@ public:
bool MustReInit();
void SetRecalc(double t);
virtual void Update();
private:
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