@@ -18,7 +18,7 @@ import { useDispatch, useSelector } from 'react-redux';
18
18
19
19
import RunningStatus from './utils/running-status' ;
20
20
21
- import { PARAM_DEVELOPER_MODE } from '../utils/config-params' ;
21
+ import { PARAM_DEVELOPER_MODE , PARAM_PROVIDER_DYNAFLOW } from '../utils/config-params' ;
22
22
23
23
import { useSnackMessage , ComputingType } from '@gridsuite/commons-ui' ;
24
24
import RunButton from './run-button' ;
@@ -32,7 +32,7 @@ import {
32
32
startDynamicSimulation ,
33
33
stopDynamicSimulation ,
34
34
} from '../services/study/dynamic-simulation' ;
35
- import { startLoadFlow , stopLoadFlow } from '../services/study/loadflow' ;
35
+ import { getLoadFlowProvider , startLoadFlow , stopLoadFlow } from '../services/study/loadflow' ;
36
36
import { startSecurityAnalysis , stopSecurityAnalysis } from '../services/study/security-analysis' ;
37
37
import { startShortCircuitAnalysis , stopShortCircuitAnalysis } from '../services/study/short-circuit-analysis' ;
38
38
import { startVoltageInit , stopVoltageInit } from '../services/study/voltage-init' ;
@@ -41,6 +41,7 @@ import { OptionalServicesNames, OptionalServicesStatus } from './utils/optional-
41
41
import { useOptionalServiceStatus } from '../hooks/use-optional-service-status' ;
42
42
import { startDynamicSecurityAnalysis , stopDynamicSecurityAnalysis } from '../services/study/dynamic-security-analysis' ;
43
43
import { useParameterState } from './dialogs/parameters/use-parameters-state' ;
44
+ import { isSecurityModificationNode } from './graph/tree-node.type.js' ;
44
45
45
46
const checkDynamicSimulationParameters = ( studyUuid ) => {
46
47
return fetchDynamicSimulationParameters ( studyUuid ) . then ( ( params ) => {
@@ -137,7 +138,25 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
137
138
} ,
138
139
[ dispatch , snackError ]
139
140
) ;
140
-
141
+ //In DynaFlow, we need to verify that the current node is a security node before starting the computation.
142
+ const checkLoadFlowProvider = useCallback (
143
+ ( studyUuid , handleComputation ) => {
144
+ if ( isSecurityModificationNode ( currentNode ) ) {
145
+ handleComputation ( ) ;
146
+ return ;
147
+ }
148
+ getLoadFlowProvider ( studyUuid ) . then ( ( provider ) => {
149
+ if ( provider === PARAM_PROVIDER_DYNAFLOW ) {
150
+ snackError ( {
151
+ headerId : 'LoadFlowDynaFlowError' ,
152
+ } ) ;
153
+ } else {
154
+ handleComputation ( ) ;
155
+ }
156
+ } ) ;
157
+ } ,
158
+ [ currentNode , snackError ]
159
+ ) ;
141
160
const handleStartSecurityAnalysis = ( contingencyListNames ) => {
142
161
startComputationAsync (
143
162
ComputingType . SECURITY_ANALYSIS ,
@@ -171,6 +190,26 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
171
190
'DynamicSimulationRunError'
172
191
) ;
173
192
} ;
193
+ const handleStartLoadFlow = useCallback (
194
+ ( withRatioTapChangers ) => {
195
+ startComputationAsync (
196
+ ComputingType . LOAD_FLOW ,
197
+ ( ) => {
198
+ dispatch (
199
+ setComputingStatusParameters ( ComputingType . LOAD_FLOW , {
200
+ withRatioTapChangers : withRatioTapChangers ,
201
+ } )
202
+ ) ;
203
+ } ,
204
+ ( ) => startLoadFlow ( studyUuid , currentNode ?. id , currentRootNetworkUuid , withRatioTapChangers ) ,
205
+ ( ) => { } ,
206
+ null ,
207
+ 'startLoadFlowError' ,
208
+ ( ) => { }
209
+ ) ;
210
+ } ,
211
+ [ currentNode ?. id , currentRootNetworkUuid , dispatch , startComputationAsync , studyUuid ]
212
+ ) ;
174
213
175
214
const runnables = useMemo ( ( ) => {
176
215
function actionOnRunnables ( type , fnStop ) {
@@ -184,17 +223,7 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
184
223
LOAD_FLOW_WITHOUT_RATIO_TAP_CHANGERS : {
185
224
messageId : 'LoadFlow' ,
186
225
startComputation ( ) {
187
- startComputationAsync (
188
- ComputingType . LOAD_FLOW ,
189
- ( ) =>
190
- dispatch (
191
- setComputingStatusParameters ( ComputingType . LOAD_FLOW , { withRatioTapChangers : false } )
192
- ) ,
193
- ( ) => startLoadFlow ( studyUuid , currentNode ?. id , currentRootNetworkUuid , false ) ,
194
- ( ) => { } ,
195
- null ,
196
- 'startLoadFlowError'
197
- ) ;
226
+ checkLoadFlowProvider ( studyUuid , ( ) => handleStartLoadFlow ( false ) ) ;
198
227
} ,
199
228
actionOnRunnable ( ) {
200
229
actionOnRunnables ( ComputingType . LOAD_FLOW , ( ) => stopLoadFlow ( studyUuid , currentNode ?. id , false ) ) ;
@@ -203,17 +232,7 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
203
232
LOAD_FLOW_WITH_RATIO_TAP_CHANGERS : {
204
233
messageId : 'LoadFlowWithRatioTapChangers' ,
205
234
startComputation ( ) {
206
- startComputationAsync (
207
- ComputingType . LOAD_FLOW ,
208
- ( ) =>
209
- dispatch (
210
- setComputingStatusParameters ( ComputingType . LOAD_FLOW , { withRatioTapChangers : true } )
211
- ) ,
212
- ( ) => startLoadFlow ( studyUuid , currentNode ?. id , currentRootNetworkUuid , true ) ,
213
- ( ) => { } ,
214
- null ,
215
- 'startLoadFlowError'
216
- ) ;
235
+ checkLoadFlowProvider ( studyUuid , ( ) => handleStartLoadFlow ( true ) ) ;
217
236
} ,
218
237
actionOnRunnable ( ) {
219
238
actionOnRunnables ( ComputingType . LOAD_FLOW , ( ) => stopLoadFlow ( studyUuid , currentNode ?. id , true ) ) ;
@@ -370,7 +389,16 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
370
389
} ,
371
390
} ,
372
391
} ;
373
- } , [ dispatch , snackError , startComputationAsync , studyUuid , currentNode ?. id , currentRootNetworkUuid ] ) ;
392
+ } , [
393
+ dispatch ,
394
+ checkLoadFlowProvider ,
395
+ studyUuid ,
396
+ handleStartLoadFlow ,
397
+ currentNode ?. id ,
398
+ currentRootNetworkUuid ,
399
+ startComputationAsync ,
400
+ snackError ,
401
+ ] ) ;
374
402
375
403
// running status is refreshed more often, so we memoize it apart
376
404
const getRunningStatus = useCallback (
0 commit comments