Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
JPScore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JuPedSim
JPScore
Commits
d64e8535
Commit
d64e8535
authored
Apr 12, 2019
by
Tobias Schrödter
Browse files
Options
Downloads
Plain Diff
Merge branch '306-schedule-for-was' into develop
parents
277817e3
75f11914
No related branches found
No related tags found
No related merge requests found
Pipeline
#19379
passed
Apr 12, 2019
Stage: configure
Stage: compile
Stage: unit_test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Simulation.cpp
+5
-1
5 additions, 1 deletion
Simulation.cpp
events/EventManager.cpp
+102
-0
102 additions, 0 deletions
events/EventManager.cpp
events/EventManager.h
+5
-0
5 additions, 0 deletions
events/EventManager.h
with
112 additions
and
1 deletion
Simulation.cpp
+
5
−
1
View file @
d64e8535
...
@@ -275,6 +275,10 @@ bool Simulation::InitArgs()
...
@@ -275,6 +275,10 @@ bool Simulation::InitArgs()
if
(
!
_em
->
ReadEventsXml
())
{
if
(
!
_em
->
ReadEventsXml
())
{
Log
->
Write
(
"ERROR:
\t
Could not initialize events handling"
);
Log
->
Write
(
"ERROR:
\t
Could not initialize events handling"
);
}
}
if
(
!
_em
->
ReadSchedule
())
{
Log
->
Write
(
"ERROR:
\t
Could not initialize schedule handling"
);
}
_em
->
ListEvents
();
_em
->
ListEvents
();
//_building->SaveGeometry("test.sav.xml");
//_building->SaveGeometry("test.sav.xml");
...
...
This diff is collapsed.
Click to expand it.
events/EventManager.cpp
+
102
−
0
View file @
d64e8535
...
@@ -794,3 +794,105 @@ void EventManager::CreateSomeEngines()
...
@@ -794,3 +794,105 @@ void EventManager::CreateSomeEngines()
exit
(
0
);
exit
(
0
);
}
}
bool
EventManager
::
ReadSchedule
()
{
Log
->
Write
(
"INFO:
\t
Reading schedule"
);
//get the geometry filename from the project file
TiXmlDocument
doc
(
_projectFilename
);
if
(
!
doc
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
doc
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
could not parse the project file."
);
return
false
;
}
TiXmlElement
*
xMainNode
=
doc
.
RootElement
();
string
scheduleFile
=
""
;
if
(
xMainNode
->
FirstChild
(
"schedule_file"
))
{
scheduleFile
=
_projectRootDir
+
xMainNode
->
FirstChild
(
"schedule_file"
)
->
FirstChild
()
->
Value
();
Log
->
Write
(
"INFO:
\t
events <"
+
scheduleFile
+
">"
);
}
else
{
Log
->
Write
(
"INFO:
\t
No events found"
);
return
true
;
}
Log
->
Write
(
"INFO:
\t
Parsing the schedule file"
);
TiXmlDocument
docSchedule
(
scheduleFile
);
if
(
!
docSchedule
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
docSchedule
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
could not parse the schedule file."
);
return
false
;
}
TiXmlElement
*
xRootNode
=
docSchedule
.
RootElement
();
if
(
!
xRootNode
)
{
Log
->
Write
(
"ERROR:
\t
Root element does not exist."
);
return
false
;
}
if
(
xRootNode
->
ValueStr
()
!=
"JPScore"
)
{
Log
->
Write
(
"ERROR:
\t
Root element value is not 'JPScore'."
);
return
false
;
}
// Read groups
TiXmlNode
*
xGroups
=
xRootNode
->
FirstChild
(
"groups"
);
if
(
!
xGroups
)
{
Log
->
Write
(
"ERROR:
\t
No groups found."
);
return
false
;
}
for
(
TiXmlElement
*
e
=
xGroups
->
FirstChildElement
(
"group"
);
e
;
e
=
e
->
NextSiblingElement
(
"group"
)){
int
id
=
atoi
(
e
->
Attribute
(
"id"
));
std
::
vector
<
int
>
member
;
for
(
TiXmlElement
*
xmember
=
e
->
FirstChildElement
(
"member"
);
xmember
;
xmember
=
xmember
->
NextSiblingElement
(
"member"
)){
int
tId
=
atoi
(
xmember
->
Attribute
(
"t_id"
));
member
.
push_back
(
tId
);
}
groupDoor
[
id
]
=
member
;
}
// Read times
TiXmlNode
*
xTimes
=
xRootNode
->
FirstChild
(
"times"
);
if
(
!
xTimes
)
{
Log
->
Write
(
"ERROR:
\t
No times found."
);
return
false
;
}
for
(
TiXmlElement
*
e
=
xTimes
->
FirstChildElement
(
"time"
);
e
;
e
=
e
->
NextSiblingElement
(
"time"
))
{
int
id
=
atoi
(
e
->
Attribute
(
"group_id"
));
int
closing_time
=
atoi
(
e
->
Attribute
(
"closing_time"
));
std
::
vector
<
int
>
timeOpen
;
std
::
vector
<
int
>
timeClose
;
for
(
TiXmlElement
*
time
=
e
->
FirstChildElement
(
"t"
);
time
;
time
=
time
->
NextSiblingElement
(
"t"
))
{
int
t
=
atoi
(
time
->
Attribute
(
"t"
));
timeOpen
.
push_back
(
t
);
timeClose
.
push_back
(
t
+
closing_time
);
}
for
(
auto
door
:
groupDoor
[
id
]){
for
(
auto
open
:
timeOpen
){
Event
event
(
door
,
open
,
"door"
,
"open"
);
_events
.
push_back
(
event
);
}
for
(
auto
close
:
timeClose
){
Event
event
(
door
,
close
,
"door"
,
"temp_close"
);
_events
.
push_back
(
event
);
}
}
}
Log
->
Write
(
"INFO:
\t
Schedule initialized"
);
return
true
;
}
This diff is collapsed.
Click to expand it.
events/EventManager.h
+
5
−
0
View file @
d64e8535
...
@@ -67,6 +67,10 @@ public:
...
@@ -67,6 +67,10 @@ public:
*/
*/
void
ReadEventsTxt
(
double
time
);
void
ReadEventsTxt
(
double
time
);
/**
* Reads the schedule file
*/
bool
ReadSchedule
();
//process the event using the current time stamp
//process the event using the current time stamp
//from the pedestrian class
//from the pedestrian class
...
@@ -163,4 +167,5 @@ private:
...
@@ -163,4 +167,5 @@ private:
std
::
mt19937
_rdGenerator
;
std
::
mt19937
_rdGenerator
;
std
::
uniform_real_distribution
<
double
>
_rdDistribution
;
std
::
uniform_real_distribution
<
double
>
_rdDistribution
;
// std::uniform_real_distribution<double> d(0, 1);
// std::uniform_real_distribution<double> d(0, 1);
std
::
map
<
int
,
std
::
vector
<
int
>>
groupDoor
;
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment