Commit 7a351266 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Fixed an error which prevented the simulation to shutdown properly when using agent sources

parent 141fff30
...@@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file. ...@@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- Visiblity in 3D - Visiblity in 3D
- - Numerous geometrical operations
### Fixed ### Fixed
- -
......
...@@ -158,7 +158,7 @@ void TrajectoriesJPSV04::WriteGeometry(Building* building) ...@@ -158,7 +158,7 @@ void TrajectoriesJPSV04::WriteGeometry(Building* building)
// first the rooms // first the rooms
//to avoid writing navigation line twice //to avoid writing navigation line twice
vector<int> navLineWritten; vector<int> navLineWritten;
rooms_to_plot.push_back("U9"); //rooms_to_plot.push_back("U9");
for (const auto& it:building->GetAllRooms()) for (const auto& it:building->GetAllRooms())
{ {
......
...@@ -150,7 +150,7 @@ bool Simulation::InitArgs(const ArgumentParser& args) ...@@ -150,7 +150,7 @@ bool Simulation::InitArgs(const ArgumentParser& args)
case FORMAT_XML_PLAIN: { case FORMAT_XML_PLAIN: {
OutputHandler* tofile = new FileHandler( OutputHandler* tofile = new FileHandler(
args.GetTrajectoriesFile().c_str()); args.GetTrajectoriesFile().c_str());
Trajectories* output = new TrajectoriesJPSV04(); Trajectories* output = new TrajectoriesJPSV05();
output->SetOutputHandler(tofile); output->SetOutputHandler(tofile);
_iod->AddIO(output); _iod->AddIO(output);
break; break;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using namespace std; using namespace std;
bool AgentsSourcesManager::_isCompleted=false; bool AgentsSourcesManager::_isCompleted=true;
AgentsSourcesManager::AgentsSourcesManager() AgentsSourcesManager::AgentsSourcesManager()
{ {
...@@ -42,7 +42,6 @@ void AgentsSourcesManager::Run() ...@@ -42,7 +42,6 @@ void AgentsSourcesManager::Run()
{ {
Log->Write("INFO:\tStarting agent manager thread"); Log->Write("INFO:\tStarting agent manager thread");
//Generate all agents required for the complete simulation //Generate all agents required for the complete simulation
//It might be more efficient to generate at each frequency step //It might be more efficient to generate at each frequency step
for (const auto& src : _sources) for (const auto& src : _sources)
...@@ -62,25 +61,17 @@ void AgentsSourcesManager::Run() ...@@ -62,25 +61,17 @@ void AgentsSourcesManager::Run()
{ {
int current_time = Pedestrian::GetGlobalTime(); int current_time = Pedestrian::GetGlobalTime();
//first step
//if(current_time==0){
//finished=ProcessAllSources();
// ProcessAllSources();
// //cout<<"here:"<<endl; exit(0);
//}
if ((current_time != _lastUpdateTime) if ((current_time != _lastUpdateTime)
&& ((current_time % updateFrequency) == 0)) && ((current_time % updateFrequency) == 0))
{ {
//cout<<"TIME:"<<current_time<<endl;
finished=ProcessAllSources(); finished=ProcessAllSources();
_lastUpdateTime = current_time; _lastUpdateTime = current_time;
//cout << "source size: " << _sources.size() << endl;
} }
//wait some time //wait some time
//std::this_thread::sleep_for(std::chrono::milliseconds(1)); //std::this_thread::sleep_for(std::chrono::milliseconds(1));
} while (!finished); } while (!finished);
Log->Write("INFO:\tTerminating agent manager thread"); Log->Write("INFO:\tTerminating agent manager thread");
_isCompleted = true;//exit(0); _isCompleted = true;
} }
bool AgentsSourcesManager::ProcessAllSources() const bool AgentsSourcesManager::ProcessAllSources() const
...@@ -442,6 +433,7 @@ void AgentsSourcesManager::GenerateAgents() ...@@ -442,6 +433,7 @@ void AgentsSourcesManager::GenerateAgents()
void AgentsSourcesManager::AddSource(std::shared_ptr<AgentsSource> src) void AgentsSourcesManager::AddSource(std::shared_ptr<AgentsSource> src)
{ {
_sources.push_back(src); _sources.push_back(src);
_isCompleted=false;//at least one source was provided
} }
const std::vector<std::shared_ptr<AgentsSource> >& AgentsSourcesManager::GetSources() const const std::vector<std::shared_ptr<AgentsSource> >& AgentsSourcesManager::GetSources() const
......
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