28
28
import fr .sncf .osrd .stdcm .BacktrackingEnvelopeAttr ;
29
29
import fr .sncf .osrd .train .RollingStock ;
30
30
import fr .sncf .osrd .utils .units .Distance ;
31
+ import java .util .HashMap ;
31
32
import java .util .List ;
32
33
import java .util .Map ;
33
34
34
35
/** This class contains all the methods used to simulate the train behavior. */
35
36
public class STDCMSimulations {
37
+
38
+ HashMap <BlockSimulationParameters , Envelope > simulatedEnvelopes ;
39
+
40
+ public STDCMSimulations () {
41
+ this .simulatedEnvelopes = new HashMap <>();
42
+ }
43
+
36
44
/** Create an EnvelopeSimContext instance from the blocks and extra parameters.
37
45
* offsetFirstBlock is in millimeters. */
38
46
static EnvelopeSimContext makeSimContext (
@@ -49,6 +57,37 @@ static EnvelopeSimContext makeSimContext(
49
57
return EnvelopeSimContextBuilder .build (rollingStock , envelopePath , timeStep , comfort );
50
58
}
51
59
60
+ /** Returns the corresponding envelope if the block's envelope has already been computed in simulatedEnvelopes,
61
+ * otherwise computes the matching envelope and adds it to the STDCMGraph. **/
62
+ public Envelope simulateBlock (
63
+ RawSignalingInfra rawInfra ,
64
+ BlockInfra blockInfra ,
65
+ RollingStock rollingStock ,
66
+ RollingStock .Comfort comfort ,
67
+ double timeStep ,
68
+ String trainTag ,
69
+ BlockSimulationParameters blockParams
70
+ ) {
71
+ if (simulatedEnvelopes .containsKey (blockParams )) {
72
+ return simulatedEnvelopes .get (blockParams );
73
+ } else {
74
+ var simulatedEnvelope = simulateBlock (
75
+ rawInfra ,
76
+ blockInfra ,
77
+ blockParams .blockId (),
78
+ blockParams .initialSpeed (),
79
+ blockParams .start (),
80
+ rollingStock ,
81
+ comfort ,
82
+ timeStep ,
83
+ blockParams .stop (),
84
+ trainTag
85
+ );
86
+ simulatedEnvelopes .put (blockParams , simulatedEnvelope );
87
+ return simulatedEnvelope ;
88
+ }
89
+ }
90
+
52
91
/**
53
92
* Returns an envelope matching the given block. The envelope time starts when the train enters the block.
54
93
* stopPosition specifies the position at which the train should stop, may be null (no stop)
0 commit comments