Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
994843f0
Commit
994843f0
authored
Jan 15, 2020
by
Benedikt Kleinmeier
Browse files
In "Simulation", refactored "updateCallbacks()"
parent
d7d7b097
Pipeline
#202832
passed with stages
in 151 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/control/simulation/Simulation.java
View file @
994843f0
...
...
@@ -20,14 +20,16 @@ import org.vadere.simulator.utils.cache.ScenarioCache;
import
org.vadere.state.attributes.AttributesSimulation
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
import
org.vadere.state.psychology.perception.json.StimulusInfo
;
import
org.vadere.state.psychology.perception.types.ElapsedTime
;
import
org.vadere.state.psychology.perception.types.Stimulus
;
import
org.vadere.state.psychology.perception.types.Timeframe
;
import
org.vadere.state.psychology.perception.types.WaitInArea
;
import
org.vadere.state.scenario.*
;
import
org.vadere.util.logging.Logger
;
import
java.awt.geom.Rectangle2D
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
public
class
Simulation
{
...
...
@@ -354,8 +356,18 @@ public class Simulation {
}
private
void
updateCallbacks
(
double
simTimeInSec
)
{
List
<
Stimulus
>
stimuli
=
stimulusController
.
getStimuliForTime
(
simTimeInSec
);
updateScenarioElements
(
simTimeInSec
);
updatePsychologyLayer
(
simTimeInSec
);
updateLocomotionLayer
(
simTimeInSec
);
if
(
topographyController
.
getTopography
().
hasTeleporter
())
{
teleporterController
.
update
(
simTimeInSec
);
}
}
private
void
updateScenarioElements
(
double
simTimeInSec
)
{
// "TargetControllers" are populated in each simulation loop because
// pedestrians can be declared as targets in each simulation loop.
// Therefore, create the necessary controller wrappers here for these
...
...
@@ -382,18 +394,26 @@ public class Simulation {
}
topographyController
.
update
(
simTimeInSec
);
//rebuild CellGrid
}
private
void
updatePsychologyLayer
(
double
simTimeInSec
)
{
Collection
<
Pedestrian
>
pedestrians
=
topography
.
getElements
(
Pedestrian
.
class
);
perceptionModel
.
update
(
pedestrians
,
stimuli
);
if
(
scenarioStore
.
getAttributesPsychology
().
isUsePsychologyLayer
())
{
List
<
Stimulus
>
stimuli
=
stimulusController
.
getStimuliForTime
(
simTimeInSec
);
perceptionModel
.
update
(
pedestrians
,
stimuli
);
cognitionModel
.
update
(
pedestrians
);
}
else
{
ElapsedTime
elapsedTime
=
new
ElapsedTime
(
simTimeInSec
);
pedestrians
.
stream
().
forEach
(
pedestrian
->
pedestrian
.
setMostImportantStimulus
(
elapsedTime
));
}
}
private
void
updateLocomotionLayer
(
double
simTimeInSec
)
{
for
(
Model
m
:
models
)
{
List
<
SourceController
>
stillSpawningSource
=
this
.
sourceControllers
.
stream
().
filter
(
s
->
!
s
.
isSourceFinished
(
simTimeInSec
)).
collect
(
Collectors
.
toList
());
int
pedestriansInSimulation
=
this
.
simulationState
.
getTopography
().
getPedestrianDynamicElements
().
getElements
().
size
();
// Only update until there are pedestrians in the scenario or pedestrian to spawn
if
(!
stillSpawningSource
.
isEmpty
()
||
pedestriansInSimulation
>
0
)
{
m
.
update
(
simTimeInSec
);
...
...
@@ -404,10 +424,6 @@ public class Simulation {
}
}
}
if
(
topographyController
.
getTopography
().
hasTeleporter
())
{
teleporterController
.
update
(
simTimeInSec
);
}
}
synchronized
void
pause
()
{
...
...
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