@@ -59,7 +59,8 @@ const overloadSteps = (
59
59
trainRegime : ReportTrain ,
60
60
operationalPoints : OperationalPointWithTimeAndSpeed [ ] ,
61
61
speedLimits : SpeedRanges ,
62
- electrificationRanges : ElectrificationRange [ ]
62
+ electrificationRanges : ElectrificationRange [ ] ,
63
+ electricalProfiles : SimulationResponseSuccess [ 'electrical_profiles' ]
63
64
) : PositionSpeedTimeOP [ ] => {
64
65
const speedsAtOps = operationalPoints . map ( ( op ) => ( {
65
66
position : op . position ,
@@ -81,24 +82,16 @@ const overloadSteps = (
81
82
const speedsAtElectrificationRanges : PositionSpeedTimeOP [ ] = [ ] ;
82
83
electrificationRanges . forEach ( ( electrification , idx ) => {
83
84
const electrificationType = electrification . electrificationUsage . type ;
84
- const electricalProfileType = electrification . electrificationUsage . electrical_profile_type ;
85
85
86
86
const electrificationMode =
87
87
electrificationType === 'electrification' ? electrification . electrificationUsage . voltage : '' ;
88
- const electrificationProfile =
89
- electrificationType === 'electrification' &&
90
- electricalProfileType === 'profile' &&
91
- electrification . electrificationUsage . profile
92
- ? electrification . electrificationUsage . profile
93
- : '' ;
94
88
const electrificationStart = electrification . start ;
95
89
96
90
speedsAtElectrificationRanges . push ( {
97
91
position : mmToM ( electrificationStart ) ,
98
92
speed : interpolateValue ( trainRegime , electrificationStart , 'speeds' ) ,
99
93
electrificationType,
100
94
electrificationMode,
101
- electrificationProfile,
102
95
time : interpolateValue ( trainRegime , electrificationStart , 'times' ) ,
103
96
} ) ;
104
97
@@ -114,7 +107,6 @@ const overloadSteps = (
114
107
speed : interpolateValue ( trainRegime , electrification . stop + 1 , 'speeds' ) ,
115
108
electrificationType : '' ,
116
109
electrificationMode : '' ,
117
- electrificationProfile : '' ,
118
110
time : interpolateValue ( trainRegime , electrification . stop + 1 , 'times' ) ,
119
111
} ) ;
120
112
}
@@ -126,10 +118,35 @@ const overloadSteps = (
126
118
time : trainRegime . times [ index ] ,
127
119
} ) ) ;
128
120
121
+ const formattedElectricalProfiles = electricalProfiles . values . map ( ( value , index ) => {
122
+ const currentTrainRegime = {
123
+ speed : interpolateValue (
124
+ trainRegime ,
125
+ mmToM ( electricalProfiles . boundaries [ index - 1 ] ) || 0 ,
126
+ 'speeds'
127
+ ) ,
128
+ position : mmToM ( electricalProfiles . boundaries [ index - 1 ] ) || 0 ,
129
+ time :
130
+ interpolateValue ( trainRegime , mmToM ( electricalProfiles . boundaries [ index - 1 ] ) , 'times' ) ||
131
+ 0 ,
132
+ } ;
133
+ if ( value . electrical_profile_type === 'profile' ) {
134
+ return {
135
+ electrificationProfile : value . profile || '' ,
136
+ ...currentTrainRegime ,
137
+ } ;
138
+ }
139
+ return {
140
+ electrificationProfile : '' ,
141
+ ...currentTrainRegime ,
142
+ } ;
143
+ } ) ;
144
+
129
145
const speedsWithOPsAndSpeedLimits = formattedTrainRegime . concat (
130
146
speedsAtOps ,
131
147
speedsAtSpeedLimitChange ,
132
- speedsAtElectrificationRanges
148
+ speedsAtElectrificationRanges ,
149
+ formattedElectricalProfiles
133
150
) ;
134
151
135
152
return speedsWithOPsAndSpeedLimits . sort ( ( stepA , stepB ) => stepA . position - stepB . position ) ;
@@ -211,7 +228,8 @@ export default function exportTrainCSV(
211
228
trainRegimeWithAccurateTime ,
212
229
operationalPoints ,
213
230
formattedMrsp ,
214
- electrificationRanges
231
+ electrificationRanges ,
232
+ simulatedTrain . electrical_profiles
215
233
) ;
216
234
217
235
const steps = speedsWithOPsAndSpeedLimits . map ( ( speed ) => ( {
@@ -228,5 +246,6 @@ export default function exportTrainCSV(
228
246
electrificationMode : speed . electrificationMode ,
229
247
electrificationProfile : speed . electrificationProfile ,
230
248
} ) ) ;
249
+
231
250
if ( steps ) createFakeLinkWithData ( train . train_name , spreadDataBetweenSteps ( steps ) ) ;
232
251
}
0 commit comments