Commit 9f7e1b9f authored by tobias schroedter's avatar tobias schroedter

Merge remote-tracking branch 'origin/develop' into develop

parents 72738834 2023eb22
Pipeline #20210 passed with stages
in 8 minutes and 44 seconds
......@@ -19,11 +19,12 @@
// Created by laemmel on 30.03.16.
//
#include <filesystem>
#include "GeoFileParser.h"
#include "../tinyxml/tinyxml.h"
#include "../geometry/SubRoom.h"
#include "../geometry/WaitingArea.h"
namespace fs = std::filesystem;
......@@ -293,7 +294,11 @@ bool GeoFileParser::LoadGeometry(Building* building)
TiXmlNode * xNodeFile = xTransNode->FirstChild("file");
if(xNodeFile)
{
fs::path p(_configuration->GetProjectRootDir());
std::string transFilename = xNodeFile->FirstChild()->ValueStr();
p /= transFilename;
transFilename = p.string();
Log->Write("INFO:\tParsing transition from file <%s>", transFilename.c_str());
TiXmlDocument docTrans(transFilename);
if (!docTrans.LoadFile()) {
......@@ -383,7 +388,10 @@ bool GeoFileParser::LoadRoutingInfo(Building* building)
TiXmlNode* xGoalsNodeFile = xGoalsNode->FirstChild("file");
if(xGoalsNodeFile)
{
fs::path p(_configuration->GetProjectRootDir());
std::string goalFilename = xGoalsNodeFile->FirstChild()->ValueStr();
p /= goalFilename;
goalFilename = p.string();
Log->Write("INFO:\tGoal file <%s> will be parsed", goalFilename.c_str());
TiXmlDocument docGoal(goalFilename);
if (!docGoal.LoadFile()) {
......@@ -455,7 +463,7 @@ bool GeoFileParser::parseDoorNode(TiXmlElement * xDoor, int id, Building* buildi
case DoorState::TEMP_CLOSE:
building->GetTransition(id)->TempClose();
break;
case DoorState::ERROR:
case DoorState::Error:
Log->Write("WARNING:\t Unknown door state: <%s>. open or close. Default: open",
stateStr.c_str());
building->GetTransition(id)->Open();
......@@ -554,7 +562,10 @@ bool GeoFileParser::LoadTrafficInfo(Building* building)
TiXmlNode* xFileNode = xRootNode->FirstChild("file");
if(xFileNode)
{
fs::path p(_configuration->GetProjectRootDir());
std::string trafficFilename = xFileNode->FirstChild()->ValueStr();
p /= trafficFilename;
trafficFilename = p.string();
Log->Write("Info:\t traffic file found <%s>", trafficFilename.c_str());
TiXmlDocument docTraffic(trafficFilename);
if (!docTraffic.LoadFile()) {
......
......@@ -357,6 +357,28 @@ std::string getSourceFileName(const std::string & GetProjectFile)
}
}
std::string getEventFileName(const std::string & GetProjectFile)
{
std::string ret="";
TiXmlDocument doc(GetProjectFile);
if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \tGetEventFileName could not parse the project file");
return ret;
}
TiXmlNode* xMainNode = doc.RootElement();
string eventfile = "";
if (xMainNode->FirstChild("events_file")) {
ret = xMainNode->FirstChild("events_file")->FirstChild()->Value();
Log->Write("INFO: \tevents <" + eventfile + ">");
} else {
Log->Write("INFO: \tNo events found");
return ret;
}
return ret;
}
std::string getGoalFileName(const std::string & GetProjectFile)
{
......@@ -388,6 +410,7 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
{
std::string sourceFileName = getSourceFileName(building->GetProjectFilename());
std::string goalFileName = getGoalFileName(building->GetProjectFilename());
std::string eventFileName = getEventFileName(building->GetProjectFilename());
(void) seed; (void) nPeds;
char tmp[100] = "";
sprintf(tmp, "#description: jpscore (%s)", JPSCORE_VERSION);
......@@ -398,10 +421,21 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
Write(tmp);
sprintf(tmp,"#geometry: %s",building->GetGeometryFilename().c_str());
Write(tmp);
sprintf(tmp,"#sources: %s", sourceFileName.c_str());
Write(tmp);
sprintf(tmp,"#goals: %s", goalFileName.c_str());
Write(tmp);
if(sourceFileName != "")
{
sprintf(tmp,"#sources: %s", sourceFileName.c_str());
Write(tmp);
}
if(goalFileName != "")
{
sprintf(tmp,"#goals: %s", goalFileName.c_str());
Write(tmp);
}
if( eventFileName != "")
{
sprintf(tmp,"#events: %s", eventFileName.c_str());
Write(tmp);
}
Write("#ID: the agent ID");
Write("#FR: the current frame");
Write("#X,Y,Z: the agents coordinates (in metres)");
......
......@@ -21,6 +21,9 @@
#define NOMINMAX
#include "PedDistributionParser.h"
#include <cstdarg> // va_start and va_end
#include <filesystem>
namespace fs = std::filesystem;
PedDistributionParser::PedDistributionParser(const Configuration* configuration)
:_configuration(configuration)
{
......@@ -174,7 +177,10 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
//------- parse sources from external file
if(xFileNode)
{
fs::path p(_configuration->GetProjectRootDir());
std::string sourceFilename = xFileNode->FirstChild()->ValueStr();
p /= sourceFilename;
sourceFilename = p.string();
Log->Write("Info:\t Source file found <%s>", sourceFilename.c_str());
TiXmlDocument docSource(sourceFilename);
if (!docSource.LoadFile()) {
......
......@@ -422,42 +422,46 @@ void Simulation::PrintStatistics(double simTime)
goal->GetID(), goal->GetDoorUsage(),
goal->GetLastPassingTime());
string statsfile = _config->GetTrajectoriesFile()+"_flow_exit_id_"+to_string(goal->GetID())+".dat";
string statsfile = "flow_exit_id_"+to_string(goal->GetID())+".txt";
if(goal->GetOutflowRate() < (std::numeric_limits<double>::max)())
{
char tmp[50];
sprintf(tmp, "%.2f", goal->GetOutflowRate());
statsfile = _config->GetTrajectoriesFile()+"_flow_exit_id_"+to_string(goal->GetID())+"_rate_"+tmp+".dat";
statsfile = "flow_exit_id_"+to_string(goal->GetID())+"_rate_"+tmp+".txt";
}
Log->Write("More Information in the file: %s", statsfile.c_str());
auto output = new FileHandler(statsfile.c_str());
output->Write("#Simulation time: %.2f", simTime);
output->Write("#Flow at exit "+goal->GetCaption()+"( ID "+to_string(goal->GetID())+" )");
output->Write("#Time (s) cummulative number of agents \n");
output->Write(goal->GetFlowCurve());
{
auto statOutput = new FileHandler(statsfile.c_str());
statOutput->Write("#Simulation time: %.2f", simTime);
statOutput->Write("#Flow at exit "+goal->GetCaption()+"( ID "+to_string(goal->GetID())+" )");
statOutput->Write("#Time (s) cummulative number of agents \n");
statOutput->Write(goal->GetFlowCurve());
statOutput->FileHandler::~FileHandler();
}
}
}
Log->Write("\nUsage of Crossings");
Log->Write("==========");
for (const auto& itr : _building->GetAllCrossings()) {
Crossing* goal = itr.second;
if (goal->GetDoorUsage()) {
Log->Write(
"\nCrossing ID [%d] in Room ID [%d] used by [%d] pedestrians. Last passing time [%0.2f] s",
goal->GetID(), itr.first/1000, goal->GetDoorUsage(),
goal->GetLastPassingTime());
string statsfile = _config->GetTrajectoriesFile() + "_flow_crossing_id_"
+ to_string(itr.first/1000) + "_" + to_string(itr.first % 1000) +".dat";
Log->Write("More Information in the file: %s", statsfile.c_str());
auto output = new FileHandler(statsfile.c_str());
output->Write("#Simulation time: %.2f", simTime);
output->Write("#Flow at crossing " + goal->GetCaption() + "( ID " + to_string(goal->GetID())
Crossing* goal = itr.second;
if (goal->GetDoorUsage()) {
Log->Write(
"\nCrossing ID [%d] in Room ID [%d] used by [%d] pedestrians. Last passing time [%0.2f] s",
goal->GetID(), itr.first/1000, goal->GetDoorUsage(),
goal->GetLastPassingTime());
string statsfile = "flow_crossing_id_"
+ to_string(itr.first/1000) + "_" + to_string(itr.first % 1000) +".dat";
Log->Write("More Information in the file: %s", statsfile.c_str());
auto output = new FileHandler(statsfile.c_str());
output->Write("#Simulation time: %.2f", simTime);
output->Write("#Flow at crossing " + goal->GetCaption() + "( ID " + to_string(goal->GetID())
+ " ) in Room ( ID "+ to_string(itr.first / 1000) + " )");
output->Write("#Time (s) cummulative number of agents \n");
output->Write(goal->GetFlowCurve());
}
output->Write("#Time (s) cummulative number of agents \n");
output->Write(goal->GetFlowCurve());
}
}
Log->Write("\n");
......@@ -522,7 +526,6 @@ double Simulation::RunBody(double maxSimTime)
bar->SetStyle("\u2588", "-"); //for linux
#endif
int initialnPeds = _nPeds;
// main program loop
while ((_nPeds || (!_agentSrcManager.IsCompleted()&& _gotSources) ) && t<maxSimTime) {
t = 0+(frameNr-1)*_deltaT;
......@@ -627,8 +630,8 @@ double Simulation::RunBody(double maxSimTime)
Transition* Trans = itr.second;
if(Trans->IsTempClose())
{
if ((Trans->GetMaxDoorUsage() != std::numeric_limits<int>::max()) ||
(Trans->GetOutflowRate() != std::numeric_limits<double>::max()) ){
if ((Trans->GetMaxDoorUsage() != (std::numeric_limits<int>::max)()) ||
(Trans->GetOutflowRate() != (std::numeric_limits<double>::max)()) ){
// || (Trans->GetOutflowRate() != std::numeric_limits<double>::max)){
Trans->UpdateClosingTime( _deltaT);
if(Trans->GetClosingTime() <= _deltaT){
......
......@@ -226,7 +226,7 @@ enum USERMODE {
};
// Describes the door
enum class DoorState { OPEN, CLOSE, TEMP_CLOSE, ERROR };
enum class DoorState { OPEN, CLOSE, TEMP_CLOSE, Error };
inline DoorState StringToDoorState(std::string name){
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
......@@ -243,7 +243,7 @@ inline DoorState StringToDoorState(std::string name){
return DoorState::CLOSE;
}
return DoorState::ERROR;
return DoorState::Error;
};
constexpr double magicnum(int i) {
......
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