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
de74d8ec
Verified
Commit
de74d8ec
authored
May 17, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding train information to building
parent
9b43e882
Pipeline
#20441
failed with stages
in 1 minute and 55 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
67 deletions
+110
-67
IO/GeoFileParser.cpp
IO/GeoFileParser.cpp
+30
-41
IO/GeoFileParser.h
IO/GeoFileParser.h
+2
-2
Simulation.cpp
Simulation.cpp
+21
-2
geometry/Building.cpp
geometry/Building.cpp
+34
-6
geometry/Building.h
geometry/Building.h
+23
-16
No files found.
IO/GeoFileParser.cpp
View file @
de74d8ec
...
...
@@ -815,10 +815,8 @@ bool GeoFileParser::LoadTrainInfo(Building* building)
Log
->
Write
(
"WARNING:
\t
No train constraints were found. Continue."
);
}
bool
resTTT
=
LoadTrainTimetable
(
building
,
xRootNode
);
std
::
cout
<<
"
\n
resTTT "
<<
resTTT
<<
"
\n
"
;
bool
resType
=
LoadTrainType
(
building
,
xRootNode
);
std
::
cout
<<
"
\n
resType "
<<
resType
<<
"
\n
"
;
exit
(
1
);
return
(
resTTT
&&
resType
);
}
bool
GeoFileParser
::
LoadTrainTimetable
(
Building
*
building
,
TiXmlElement
*
xRootNode
)
...
...
@@ -853,11 +851,10 @@ bool GeoFileParser::LoadTrainTimetable(Building* building, TiXmlElement * xRootN
}
for
(
TiXmlElement
*
e
=
xTTT
->
FirstChildElement
(
"train"
);
e
;
e
=
e
->
NextSiblingElement
(
"train"
))
{
TrainTable
TTT
=
parseTrainTimeTableNode
(
e
);
std
::
shared_ptr
<
TrainTimeTable
>
TTT
=
parseTrainTimeTableNode
(
e
);
if
(
1
)
{
// todo: maybe get pointer to train
//building->AddGoal(goal);
std
::
cout
<<
"
\n
TODO: add train to building
\n
----
\n
"
;
if
(
TTT
)
{
// todo: maybe get pointer to train
building
->
AddTrainTimeTable
(
TTT
);
}
}
}
...
...
@@ -893,23 +890,16 @@ bool GeoFileParser::LoadTrainType(Building* building, TiXmlElement * xRootNode)
}
for
(
TiXmlElement
*
e
=
xTT
->
FirstChildElement
(
"train"
);
e
;
e
=
e
->
NextSiblingElement
(
"train"
))
{
TrainType
TT
=
parseTrainTypeNode
(
e
);
if
(
1
)
{
// todo: maybe get pointer to train
//building->AddGoal(goal);
std
::
cout
<<
"
\n
TODO: add train type to building
\n
----
\n
"
;
std
::
shared_ptr
<
TrainType
>
TT
=
parseTrainTypeNode
(
e
);
if
(
TT
)
{
building
->
AddTrainType
(
TT
);
}
}
return
true
;
}
// <train_time_tables>
// <train id="1" type="RE" room_id="1"
// track_start_x="0" track_start_y="0" track_x-end="300" track_y-end="0"
// train_start_x="0" train_start_y="0" train_x-end="300" train_y-end="0"
// arrival_time="5" departure_time="20>
// </train_time_tables>
TrainTable
GeoFileParser
::
parseTrainTimeTableNode
(
TiXmlElement
*
e
)
std
::
shared_ptr
<
TrainTimeTable
>
GeoFileParser
::
parseTrainTimeTableNode
(
TiXmlElement
*
e
)
{
Log
->
Write
(
"INFO:
\t
Loading train time table NODE"
);
std
::
string
caption
=
xmltoa
(
e
->
Attribute
(
"caption"
),
"-1"
);
...
...
@@ -941,25 +931,23 @@ TrainTable GeoFileParser::parseTrainTimeTableNode(TiXmlElement * e)
Point
track_end
(
track_end_x
,
track_end_y
);
Point
train_start
(
train_start_x
,
train_start_y
);
Point
train_end
(
train_end_x
,
train_end_y
);
TrainTable
trainTab
=
{
id
,
type
,
room_id
,
arrival_time
,
departure_time
,
track_start
,
track_end
,
train_start
,
train_end
,
};
return
trainTab
;
std
::
shared_ptr
<
TrainTimeTable
>
trainTimeTab
=
std
::
make_shared
<
TrainTimeTable
>
(
TrainTimeTable
{
id
,
type
,
room_id
,
arrival_time
,
departure_time
,
track_start
,
track_end
,
train_start
,
train_end
,
});
return
trainTimeTab
;
}
// <train type="RE" agents_max="600">
// <door id="1" x="3" y="5.5" frequency="2">
// <door id="2" x="13" y="15.5" frequency="3">
// <\train>
TrainType
GeoFileParser
::
parseTrainTypeNode
(
TiXmlElement
*
e
)
std
::
shared_ptr
<
TrainType
>
GeoFileParser
::
parseTrainTypeNode
(
TiXmlElement
*
e
)
{
Log
->
Write
(
"INFO:
\t
Loading train type"
);
// int T_id = xmltoi(e->Attribute("id"), -1);
...
...
@@ -992,11 +980,12 @@ TrainType GeoFileParser::parseTrainTypeNode(TiXmlElement * e)
Log
->
Write
(
"INFO:
\t
capacity: %d"
,
agents_max
);
Log
->
Write
(
"INFO:
\t
number of doors: %d"
,
doors
.
size
());
TrainType
Type
=
{
type
,
agents_max
,
doors
,
};
std
::
shared_ptr
<
TrainType
>
Type
=
std
::
make_shared
<
TrainType
>
(
TrainType
{
type
,
agents_max
,
doors
,
});
return
Type
;
}
...
...
IO/GeoFileParser.h
View file @
de74d8ec
...
...
@@ -47,8 +47,8 @@ public:
bool
LoadTrainInfo
(
Building
*
building
);
bool
LoadTrainTimetable
(
Building
*
building
,
TiXmlElement
*
xRootNode
);
bool
LoadTrainType
(
Building
*
building
,
TiXmlElement
*
xRootNode
);
TrainType
parseTrainTypeNode
(
TiXmlElement
*
e
);
TrainTable
parseTrainTimeTableNode
(
TiXmlElement
*
e
);
std
::
shared_ptr
<
TrainType
>
parseTrainTypeNode
(
TiXmlElement
*
e
);
std
::
shared_ptr
<
TrainTimeTable
>
parseTrainTimeTableNode
(
TiXmlElement
*
e
);
private:
Configuration
*
_configuration
;
...
...
Simulation.cpp
View file @
de74d8ec
...
...
@@ -246,7 +246,26 @@ bool Simulation::InitArgs()
if
(
!
_operationalModel
->
Init
(
_building
.
get
()))
return
false
;
Log
->
Write
(
"INFO:
\t
Init Operational Model done"
);
Log
->
Write
(
"Got %d Train Types"
,
_building
->
GetTrainTypes
().
size
());
for
(
auto
&&
TT
:
_building
->
GetTrainTypes
())
{
Log
->
Write
(
"INFO
\t
type : %s"
,
TT
.
second
->
type
.
c_str
());
Log
->
Write
(
"INFO
\t
Max : %d"
,
TT
.
second
->
nmax
);
Log
->
Write
(
"INFO
\t
number doors : %d
\n
"
,
TT
.
second
->
doors
.
size
());
}
Log
->
Write
(
"Got %d Train Time Tables"
,
_building
->
GetTrainTimeTables
().
size
());
for
(
auto
&&
TT
:
_building
->
GetTrainTimeTables
())
{
Log
->
Write
(
"INFO
\t
id : %d"
,
TT
.
second
->
id
);
Log
->
Write
(
"INFO
\t
type : %s"
,
TT
.
second
->
type
.
c_str
());
Log
->
Write
(
"INFO
\t
room id : %d"
,
TT
.
second
->
rid
);
Log
->
Write
(
"INFO
\t
tin : %.2f%"
,
TT
.
second
->
tin
);
Log
->
Write
(
"INFO
\t
tout : %.2f"
,
TT
.
second
->
tout
);
Log
->
Write
(
"INFO
\t
track start : (%.2f, %.2f)"
,
TT
.
second
->
pstart
.
_x
,
TT
.
second
->
pstart
.
_y
);
Log
->
Write
(
"INFO
\t
track end : (%.2f, %.2f)"
,
TT
.
second
->
pend
.
_x
,
TT
.
second
->
pend
.
_y
);
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
);
}
// 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()
...
...
@@ -636,8 +655,8 @@ double Simulation::RunBody(double maxSimTime)
Trans
->
UpdateClosingTime
(
_deltaT
);
if
(
Trans
->
GetClosingTime
()
<=
_deltaT
){
Trans
->
changeTemporaryState
();
Log
->
Write
(
"INFO:
\t
Reset state of door %d, Time=%.2f"
,
Trans
->
GetID
(),
Pedestrian
::
GetGlobalTime
());
}
Log
->
Write
(
"INFO:
\t
Reset state of door %d, Time=%.2f"
,
Trans
->
GetID
(),
Pedestrian
::
GetGlobalTime
());
}
}
}
...
...
geometry/Building.cpp
View file @
de74d8ec
...
...
@@ -915,6 +915,25 @@ bool Building::AddGoal(Goal* goal)
return
true
;
}
bool
Building
::
AddTrainType
(
std
::
shared_ptr
<
TrainType
>
TT
)
{
if
(
_trainTypes
.
count
(
TT
->
type
)
!=
0
)
{
Log
->
Write
(
"WARNING: Duplicate type for train found [%s]"
,
TT
->
type
);
}
_trainTypes
[
TT
->
type
]
=
TT
;
return
true
;
}
bool
Building
::
AddTrainTimeTable
(
std
::
shared_ptr
<
TrainTimeTable
>
TTT
)
{
if
(
_trainTimeTables
.
count
(
TTT
->
id
)
!=
0
)
{
Log
->
Write
(
"WARNING: Duplicate id for train time table found [%d]"
,
TTT
->
id
);
exit
(
EXIT_FAILURE
);
}
_trainTimeTables
[
TTT
->
id
]
=
TTT
;
return
true
;
}
const
map
<
int
,
Crossing
*>&
Building
::
GetAllCrossings
()
const
{
return
_crossings
;
...
...
@@ -930,11 +949,20 @@ const map<int, Hline*>& Building::GetAllHlines() const
return
_hLines
;
}
const
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
TrainType
>
>&
Building
::
GetTrainTypes
()
const
{
return
_trainTypes
;
}
const
std
::
map
<
int
,
std
::
shared_ptr
<
TrainTimeTable
>
>&
Building
::
GetTrainTimeTables
()
const
{
return
_trainTimeTables
;
}
const
map
<
int
,
Goal
*>&
Building
::
GetAllGoals
()
const
{
return
_goals
;
}
Transition
*
Building
::
GetTransition
(
string
caption
)
const
{
//eventually
...
...
@@ -1372,11 +1400,11 @@ Transition* Building::GetTransitionByUID(int uid) const
Crossing
*
Building
::
GetCrossingByUID
(
int
uid
)
const
{
for
(
auto
&&
cross
:
_crossings
)
{
if
(
cross
.
second
->
GetUniqueID
()
==
uid
)
return
cross
.
second
;
}
return
nullptr
;
for
(
auto
&&
cross
:
_crossings
)
{
if
(
cross
.
second
->
GetUniqueID
()
==
uid
)
return
cross
.
second
;
}
return
nullptr
;
}
bool
Building
::
SaveGeometry
(
const
std
::
string
&
filename
)
const
...
...
geometry/Building.h
View file @
de74d8ec
...
...
@@ -45,24 +45,24 @@
#include "Goal.h"
#include "../general/Configuration.h"
struct
TrainTable
struct
TrainT
imeT
able
{
int
_
id
;
std
::
string
_
type
;
int
_
rid
;
// room id
double
_
tin
;
// arrival time
double
_
tout
;
//leaving time
Point
_
pstart
;
// track start
Point
_
pend
;
// track end
Point
_
tstart
;
// train start
Point
_
tend
;
// train end
int
id
;
std
::
string
type
;
int
rid
;
// room id
double
tin
;
// arrival time
double
tout
;
//leaving time
Point
pstart
;
// track start
Point
pend
;
// track end
Point
tstart
;
// train start
Point
tend
;
// train end
};
struct
TrainType
{
std
::
string
_
type
;
int
_
nmax
;
// agents_max
std
::
vector
<
Transition
>
_
doors
;
std
::
string
type
;
int
nmax
;
// agents_max
std
::
vector
<
Transition
>
doors
;
};
...
...
@@ -95,9 +95,8 @@ private:
std
::
map
<
int
,
Transition
*>
_transitions
;
std
::
map
<
int
,
Hline
*>
_hLines
;
std
::
map
<
int
,
Goal
*>
_goals
;
std
::
map
<
int
,
std
::
vector
<
WaitingArea
*>
>
_sr2wa
;
std
::
vector
<
TrainType
>
trainTypes
;
// todo, maybe map<string, TrainType>. shared_ptr?>
std
::
vector
<
TrainType
>
trainTimeTable
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
TrainType
>
>
_trainTypes
;
std
::
map
<
int
,
std
::
shared_ptr
<
TrainTimeTable
>
>
_trainTimeTables
;
/// pedestrians pathway
bool
_savePathway
;
std
::
ofstream
_pathWayStream
;
...
...
@@ -231,6 +230,10 @@ public:
const
std
::
map
<
int
,
Goal
*>&
GetAllGoals
()
const
;
const
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
TrainType
>
>&
GetTrainTypes
()
const
;
const
std
::
map
<
int
,
std
::
shared_ptr
<
TrainTimeTable
>
>&
GetTrainTimeTables
()
const
;
bool
AddCrossing
(
Crossing
*
line
);
bool
AddTransition
(
Transition
*
line
);
...
...
@@ -239,6 +242,10 @@ public:
bool
AddGoal
(
Goal
*
goal
);
bool
AddTrainType
(
std
::
shared_ptr
<
TrainType
>
TT
);
bool
AddTrainTimeTable
(
std
::
shared_ptr
<
TrainTimeTable
>
TTT
);
const
std
::
string
&
GetProjectRootDir
()
const
;
const
std
::
string
&
GetProjectFilename
()
const
;
...
...
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