Skip to content

Commit d469497

Browse files
authored
Short Circuit debug mode (#3108)
1 parent 3b1413b commit d469497

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

src/components/run-button-container.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,19 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
329329
},
330330
[ComputingType.SHORT_CIRCUIT]: {
331331
messageId: 'ShortCircuitAnalysis',
332-
startComputation() {
332+
startComputation(debug) {
333333
startComputationAsync(
334334
ComputingType.SHORT_CIRCUIT,
335335
null,
336-
() => startShortCircuitAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid),
337-
() => {},
336+
() =>
337+
startShortCircuitAnalysis(
338+
studyUuid,
339+
currentNode?.id,
340+
currentRootNetworkUuid,
341+
undefined,
342+
debug
343+
),
344+
() => debug && subscribeDebug(ComputingType.SHORT_CIRCUIT),
338345
null,
339346
'startShortCircuitError'
340347
);

src/hooks/use-computation-debug.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import { NotificationType } from '../types/notification-types';
2424
import { useSelector } from 'react-redux';
2525
import { AppState } from '../redux/reducer';
2626
import { downloadDebugFileVoltageInit } from '../services/voltage-init';
27+
import { downloadDebugFileShortCircuitAnalysis } from '../services/short-circuit-analysis';
2728

2829
const downloadDebugFileFetchers = {
2930
[ComputingType.DYNAMIC_SIMULATION]: downloadDebugFileDynamicSimulation,
3031
[ComputingType.DYNAMIC_SECURITY_ANALYSIS]: downloadDebugFileDynamicSecurityAnalysis,
3132
[ComputingType.VOLTAGE_INITIALIZATION]: downloadDebugFileVoltageInit,
33+
[ComputingType.SHORT_CIRCUIT]: downloadDebugFileShortCircuitAnalysis,
3234
} as Record<ComputingType, ((resultUuid: UUID) => Promise<Response>) | null>;
3335

3436
export function buildDebugIdentifier({
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { UUID } from 'crypto';
9+
import { backendFetch } from './utils';
10+
11+
const PREFIX_SHORT_CIRCUIT_ANALYSIS_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/shortcircuit';
12+
13+
function getShotCircuitAnalysisUrl() {
14+
return `${PREFIX_SHORT_CIRCUIT_ANALYSIS_SERVER_QUERIES}/v1/`;
15+
}
16+
17+
export function downloadDebugFileShortCircuitAnalysis(resultUuid: UUID): Promise<Response> {
18+
console.info(`Download short circuit analysis debug file of '${resultUuid}' ...`);
19+
20+
const url = getShotCircuitAnalysisUrl() + `results/${resultUuid}/download-debug-file`;
21+
22+
console.debug(url);
23+
return backendFetch(url, {
24+
method: 'get',
25+
headers: { 'Content-Type': 'application/json' },
26+
});
27+
}

src/services/study/short-circuit-analysis.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,20 @@ export function startShortCircuitAnalysis(
3535
studyUuid: string,
3636
currentNodeUuid: UUID | undefined,
3737
currentRootNetworkUuid: UUID | null,
38-
busId: string
38+
busId: string,
39+
debug?: boolean
3940
): Promise<void> {
4041
console.info(
4142
`Running short circuit analysis on '${studyUuid}' on root network '${currentRootNetworkUuid}' and node '${currentNodeUuid}' ...`
4243
);
4344
const urlSearchParams = new URLSearchParams();
4445
busId && urlSearchParams.append('busId', busId);
4546

46-
const startShortCircuitAnalysisUrl =
47-
getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid) +
48-
'/shortcircuit/run?' +
49-
urlSearchParams.toString();
47+
if (debug) {
48+
urlSearchParams.append('debug', `${debug}`);
49+
}
50+
51+
const startShortCircuitAnalysisUrl = `${getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid)}/shortcircuit/run?${urlSearchParams}`;
5052
console.debug(startShortCircuitAnalysisUrl);
5153
return backendFetch(startShortCircuitAnalysisUrl, { method: 'put' });
5254
}

0 commit comments

Comments
 (0)