Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPScore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
92
Issues
92
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JuPedSim
JPScore
Commits
a33375a4
Verified
Commit
a33375a4
authored
Jul 01, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring parse header and fixing CI
parent
7bb3233c
Pipeline
#22079
passed with stages
in 23 minutes and 56 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
164 deletions
+176
-164
IO/IniFileParser.cpp
IO/IniFileParser.cpp
+172
-162
IO/IniFileParser.h
IO/IniFileParser.h
+2
-0
demos/scenario_11_sources/inifile.xml
demos/scenario_11_sources/inifile.xml
+2
-2
No files found.
IO/IniFileParser.cpp
View file @
a33375a4
...
...
@@ -134,16 +134,131 @@ bool IniFileParser::Parse(std::string iniFile)
//check the structure of inifile
if
(
xMainNode
->
FirstChild
(
"header"
))
{
//logfile
TiXmlNode
*
xHeader
=
xMainNode
->
FirstChild
(
"header"
);
ParseHeader
(
xHeader
);
}
//if header
else
{
ParseHeader
(
xMainNode
);
}
//else header
// JPSfire
// -------------------------------------
// read walkingspeed
#ifdef JPSFIRE
std
::
shared_ptr
<
WalkingSpeed
>
W
(
new
WalkingSpeed
(
iniFile
)
);
_config
->
SetWalkingSpeed
(
W
);
// read ToxicityAnalysis
std
::
shared_ptr
<
ToxicityAnalysis
>
T
(
new
ToxicityAnalysis
(
iniFile
,
_config
->
GetFps
()));
_config
->
SetToxicityAnalysis
(
T
);
#endif
// -------------------------------------
//pick up which model to use
//get the wanted ped model id
_model
=
xmltoi
(
xMainNode
->
FirstChildElement
(
"agents"
)
->
Attribute
(
"operational_model_id"
),
-
1
);
if
(
_model
==-
1
)
{
Log
->
Write
(
"ERROR:
\t
missing operational_model_id attribute in the agent section."
);
Log
->
Write
(
"ERROR:
\t
please specify the model id to use"
);
return
false
;
}
bool
parsingModelSuccessful
=
false
;
for
(
TiXmlElement
*
xModel
=
xMainNode
->
FirstChild
(
"operational_models"
)
->
FirstChildElement
(
"model"
);
xModel
;
xModel
=
xModel
->
NextSiblingElement
(
"model"
))
{
if
(
!
xModel
->
Attribute
(
"description"
))
{
Log
->
Write
(
"ERROR:
\t
missing attribute description in models?"
);
return
false
;
}
string
modelName
=
string
(
xModel
->
Attribute
(
"description"
));
int
model_id
=
xmltoi
(
xModel
->
Attribute
(
"operational_model_id"
),
-
1
);
if
((
_model
==
MODEL_GCFM
)
&&
(
model_id
==
MODEL_GCFM
))
{
if
(
modelName
!=
"gcfm"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gcfm?"
);
return
false
;
}
if
(
!
ParseGCFMModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
//only parsing one model
break
;
}
else
if
((
_model
==
MODEL_GOMPERTZ
)
&&
(
model_id
==
MODEL_GOMPERTZ
))
{
if
(
modelName
!=
"gompertz"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gompertz?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseGompertzModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
else
if
((
_model
==
MODEL_GRADIENT
)
&&
(
model_id
==
MODEL_GRADIENT
))
{
if
(
modelName
!=
"gradnav"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gradnav?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseGradientModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
else
if
((
_model
==
MODEL_VELOCITY
)
&&
(
model_id
==
MODEL_VELOCITY
))
{
if
(
modelName
!=
"Tordeux2015"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean Tordeux2015?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseVelocityModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
if
((
_model
==
MODEL_KRAUSZ
)
&&
(
model_id
==
MODEL_KRAUSZ
))
{
if
(
modelName
!=
"krausz"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean krausz?"
);
return
false
;
}
if
(
!
ParseKrauszModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
//only parsing one model
break
;
}
}
if
(
!
parsingModelSuccessful
)
{
Log
->
Write
(
"ERROR:
\t
Wrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz), 3 (Tordeux2015) or 5 (Krausz)"
,
_model
);
Log
->
Write
(
"ERROR:
\t
Please make sure that all models are specified in the operational_models section"
);
Log
->
Write
(
"ERROR:
\t
and make sure to use the same ID in the agent section"
);
return
false
;
}
//route choice strategy
TiXmlNode
*
xRouters
=
xMainNode
->
FirstChild
(
"route_choice_models"
);
TiXmlNode
*
xAgentDistri
=
xMainNode
->
FirstChild
(
"agents"
)
->
FirstChild
(
"agents_distribution"
);
if
(
!
ParseRoutingStrategies
(
xRouters
,
xAgentDistri
))
return
false
;
Log
->
Write
(
"INFO:
\t
Parsing the project file completed"
);
return
true
;
}
bool
IniFileParser
::
ParseHeader
(
TiXmlNode
*
xHeader
)
{
//logfile
if
(
xHeader
->
FirstChild
(
"logfile"
))
{
_config
->
SetErrorLogFile
(
_config
->
GetProjectRootDir
()
+
xHeader
->
FirstChild
(
"logfile"
)
->
FirstChild
()
->
Value
());
_config
->
SetLog
(
2
);
Log
->
Write
(
"INFO:
\t
logfile <%s>"
,
_config
->
GetErrorLogFile
().
c_str
());
}
Log
->
Write
(
"----
\n
JuPedSim - JPScore
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSCORE_VERSION
);
...
...
@@ -206,30 +321,30 @@ bool IniFileParser::Parse(std::string iniFile)
Log
->
Write
(
"INFO:
\t
Using num_threads <%d> threads (%d available)"
,
_config
->
GetMaxOpenMPThreads
(),
max_threads
);
//display statistics
if
(
xMainNode
->
FirstChild
(
"show_statistics"
))
{
std
::
string
value
=
xMainNode
->
FirstChild
(
"show_statistics"
)
->
FirstChild
()
->
Value
();
if
(
xHeader
->
FirstChild
(
"show_statistics"
))
{
std
::
string
value
=
xHeader
->
FirstChild
(
"show_statistics"
)
->
FirstChild
()
->
Value
();
_config
->
SetShowStatistics
(
value
==
"true"
);
Log
->
Write
(
"INFO:
\t
Show statistics: %s"
,
value
.
c_str
());
}
//trajectories
TiXmlNode
*
xTrajectories
=
xMainNode
->
FirstChild
(
"trajectories"
);
TiXmlNode
*
xTrajectories
=
xHeader
->
FirstChild
(
"trajectories"
);
if
(
xTrajectories
)
{
double
fps
;
xMainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"fps"
,
&
fps
);
xHeader
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"fps"
,
&
fps
);
_config
->
SetFps
(
fps
);
string
format
=
x
MainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
x
Header
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"format"
)
?
x
MainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
x
Header
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"format"
)
:
"xml-plain"
;
int
embedMesh
=
0
;
if
(
xMainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
if
(
xHeader
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"embed_mesh"
))
{
embedMesh
=
string
(
x
MainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"embed_mesh"
))
==
"true"
?
1
:
0
;
string
(
x
Header
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"embed_mesh"
))
==
"true"
?
1
:
0
;
}
if
(
format
==
"xml-plain"
)
_config
->
SetFileFormat
(
FORMAT_XML_PLAIN
);
...
...
@@ -244,9 +359,9 @@ bool IniFileParser::Parse(std::string iniFile)
//color mode
string
color_mode
=
x
MainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
x
Header
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"color_mode"
)
?
x
MainNode
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
x
Header
->
FirstChildElement
(
"trajectories"
)
->
Attribute
(
"color_mode"
)
:
"velocity"
;
...
...
@@ -298,112 +413,7 @@ bool IniFileParser::Parse(std::string iniFile)
}
}
// JPSfire
// -------------------------------------
// read walkingspeed
#ifdef JPSFIRE
std
::
shared_ptr
<
WalkingSpeed
>
W
(
new
WalkingSpeed
(
iniFile
)
);
_config
->
SetWalkingSpeed
(
W
);
// read ToxicityAnalysis
std
::
shared_ptr
<
ToxicityAnalysis
>
T
(
new
ToxicityAnalysis
(
iniFile
,
_config
->
GetFps
()));
_config
->
SetToxicityAnalysis
(
T
);
#endif
// -------------------------------------
//pick up which model to use
//get the wanted ped model id
_model
=
xmltoi
(
xMainNode
->
FirstChildElement
(
"agents"
)
->
Attribute
(
"operational_model_id"
),
-
1
);
if
(
_model
==-
1
)
{
Log
->
Write
(
"ERROR:
\t
missing operational_model_id attribute in the agent section."
);
Log
->
Write
(
"ERROR:
\t
please specify the model id to use"
);
return
false
;
}
bool
parsingModelSuccessful
=
false
;
for
(
TiXmlElement
*
xModel
=
xMainNode
->
FirstChild
(
"operational_models"
)
->
FirstChildElement
(
"model"
);
xModel
;
xModel
=
xModel
->
NextSiblingElement
(
"model"
))
{
if
(
!
xModel
->
Attribute
(
"description"
))
{
Log
->
Write
(
"ERROR:
\t
missing attribute description in models?"
);
return
false
;
}
string
modelName
=
string
(
xModel
->
Attribute
(
"description"
));
int
model_id
=
xmltoi
(
xModel
->
Attribute
(
"operational_model_id"
),
-
1
);
if
((
_model
==
MODEL_GCFM
)
&&
(
model_id
==
MODEL_GCFM
))
{
if
(
modelName
!=
"gcfm"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gcfm?"
);
return
false
;
}
if
(
!
ParseGCFMModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
//only parsing one model
break
;
}
else
if
((
_model
==
MODEL_GOMPERTZ
)
&&
(
model_id
==
MODEL_GOMPERTZ
))
{
if
(
modelName
!=
"gompertz"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gompertz?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseGompertzModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
else
if
((
_model
==
MODEL_GRADIENT
)
&&
(
model_id
==
MODEL_GRADIENT
))
{
if
(
modelName
!=
"gradnav"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean gradnav?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseGradientModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
else
if
((
_model
==
MODEL_VELOCITY
)
&&
(
model_id
==
MODEL_VELOCITY
))
{
if
(
modelName
!=
"Tordeux2015"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean Tordeux2015?"
);
return
false
;
}
//only parsing one model
if
(
!
ParseVelocityModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
break
;
}
if
((
_model
==
MODEL_KRAUSZ
)
&&
(
model_id
==
MODEL_KRAUSZ
))
{
if
(
modelName
!=
"krausz"
)
{
Log
->
Write
(
"ERROR:
\t
mismatch model ID and description. Did you mean krausz?"
);
return
false
;
}
if
(
!
ParseKrauszModel
(
xModel
,
xMainNode
))
return
false
;
parsingModelSuccessful
=
true
;
//only parsing one model
break
;
}
}
if
(
!
parsingModelSuccessful
)
{
Log
->
Write
(
"ERROR:
\t
Wrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz), 3 (Tordeux2015) or 5 (Krausz)"
,
_model
);
Log
->
Write
(
"ERROR:
\t
Please make sure that all models are specified in the operational_models section"
);
Log
->
Write
(
"ERROR:
\t
and make sure to use the same ID in the agent section"
);
return
false
;
}
//route choice strategy
TiXmlNode
*
xRouters
=
xMainNode
->
FirstChild
(
"route_choice_models"
);
TiXmlNode
*
xAgentDistri
=
xMainNode
->
FirstChild
(
"agents"
)
->
FirstChild
(
"agents_distribution"
);
if
(
!
ParseRoutingStrategies
(
xRouters
,
xAgentDistri
))
return
false
;
Log
->
Write
(
"INFO:
\t
Parsing the project file completed"
);
return
true
;
}
bool
IniFileParser
::
ParseGCFMModel
(
TiXmlElement
*
xGCFM
,
TiXmlElement
*
xMainNode
)
{
Log
->
Write
(
"
\n
INFO:
\t
Using the GCFM model"
);
...
...
IO/IniFileParser.h
View file @
a33375a4
...
...
@@ -44,6 +44,8 @@ public:
bool
Parse
(
std
::
string
iniFile
);
private:
bool
ParseHeader
(
TiXmlNode
*
xHeader
);
bool
ParseGCFMModel
(
TiXmlElement
*
xGCFM
,
TiXmlElement
*
xMain
);
bool
ParseKrauszModel
(
TiXmlElement
*
xKrausz
,
TiXmlElement
*
xMain
);
...
...
demos/scenario_11_sources/inifile.xml
View file @
a33375a4
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim
project=
"JPS-Project"
version=
"0.8"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://xsd.jupedsim.org/0.6/jps_ini_core.xsd"
>
<header>
<!-- seed used for initialising random generator -->
<seed>
12542
</seed>
<!-- geometry file -->
...
...
@@ -16,7 +16,7 @@
<!-- where to store the logs -->
<logfile>
log.txt
</logfile>
</header>
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- doors states are: close or open -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment