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
47b8067e
Verified
Commit
47b8067e
authored
May 18, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
open/close doors according to train time table
parent
8c7c3618
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
8 deletions
+59
-8
Simulation.cpp
Simulation.cpp
+59
-8
No files found.
Simulation.cpp
View file @
47b8067e
...
...
@@ -51,7 +51,10 @@ using namespace std;
OutputHandler
*
Log
;
Trajectories
*
outputTXT
;
// todo: add these variables to class simulation
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
TrainType
>
>
TrainTypes
;
std
::
map
<
int
,
std
::
shared_ptr
<
TrainTimeTable
>
>
TrainTimeTables
;
//--------
Simulation
::
Simulation
(
Configuration
*
args
)
:
_config
(
args
)
{
...
...
@@ -266,6 +269,11 @@ bool Simulation::InitArgs()
Log
->
Write
(
"INFO
\t
train start : (%.2f, %.2f)"
,
TT
.
second
->
tstart
.
_x
,
TT
.
second
->
tstart
.
_y
);
Log
->
Write
(
"INFO
\t
train end : (%.2f, %.2f)
\n
"
,
TT
.
second
->
tend
.
_x
,
TT
.
second
->
tend
.
_y
);
}
//@todo: these variables are global
TrainTypes
=
_building
->
GetTrainTypes
();
TrainTimeTables
=
_building
->
GetTrainTimeTables
();
//-----
// Give the DirectionStrategy the chance to perform some initialization.
// This should be done after the initialization of the operationalModel
// because then, invalid pedestrians have been deleted and FindExit()
...
...
@@ -644,6 +652,18 @@ double Simulation::RunBody(double maxSimTime)
// here open transition that should be closed
// TODO fix, opens door everytime...
bool
trainHere
=
false
;
std
::
string
train
=
""
;
auto
now
=
Pedestrian
::
GetGlobalTime
();
for
(
auto
&&
tab
:
TrainTimeTables
)
{
if
(
(
now
>=
tab
.
second
->
tin
)
&&
(
now
<=
tab
.
second
->
tout
)
)
{
trainHere
=
true
;
train
=
tab
.
second
->
type
;
continue
;
}
}
for
(
auto
&
itr
:
_building
->
GetAllTransitions
())
{
Transition
*
Trans
=
itr
.
second
;
...
...
@@ -652,21 +672,52 @@ double Simulation::RunBody(double maxSimTime)
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
){
Trans
->
UpdateClosingTime
(
_deltaT
);
if
(
Trans
->
GetClosingTime
()
<=
_deltaT
){
Trans
->
changeTemporaryState
();
Log
->
Write
(
"INFO:
\t
Reset state of door %d, Time=%.2f"
,
Trans
->
GetID
(),
Pedestrian
::
GetGlobalTime
());
}
}
}
// normal transition
}
// ------ train
if
(
trainHere
)
// track?
{
auto
doors
=
TrainTypes
[
train
]
->
doors
;
for
(
auto
door
:
doors
)
{
auto
tp1
=
door
.
GetPoint1
();
auto
tp2
=
door
.
GetPoint2
();
if
(
Trans
->
IsInLineSegment
(
tp1
)
&&
Trans
->
IsInLineSegment
(
tp2
))
{
Trans
->
SetMaxDoorUsage
(
TrainTypes
[
train
]
->
nmax
);
// SetOutflowRate() in initialisation phase
Trans
->
Open
();
}
}
}
else
{
for
(
auto
tt
:
TrainTypes
)
{
auto
doors
=
tt
.
second
->
doors
;
for
(
auto
door
:
doors
)
{
auto
tp1
=
door
.
GetPoint1
();
auto
tp2
=
door
.
GetPoint2
();
if
(
Trans
->
IsInLineSegment
(
tp1
)
&&
Trans
->
IsInLineSegment
(
tp2
))
//todo: If only we knew that Trans is a track
{
Trans
->
TempClose
();
}
}
}
}
}
if
(
frameNr
%
1000
==
0
)
{
Log
->
Write
(
"INFO:
\t
Update door statistics at t=%.2f"
,
t
);
PrintStatistics
(
t
);
Log
->
Write
(
"INFO:
\t
Update door statistics at t=%.2f"
,
t
);
PrintStatistics
(
t
);
}
}
// while time
return
t
;
}
...
...
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