Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/run-button-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,19 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
},
[ComputingType.SHORT_CIRCUIT]: {
messageId: 'ShortCircuitAnalysis',
startComputation() {
startComputation(debug) {
startComputationAsync(
ComputingType.SHORT_CIRCUIT,
null,
() => startShortCircuitAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid),
() => {},
() =>
startShortCircuitAnalysis(
studyUuid,
currentNode?.id,
currentRootNetworkUuid,
undefined,
debug
),
() => debug && subscribeDebug(ComputingType.SHORT_CIRCUIT),
null,
'startShortCircuitError'
);
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/use-computation-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import { NotificationType } from '../types/notification-types';
import { useSelector } from 'react-redux';
import { AppState } from '../redux/reducer';
import { downloadDebugFileVoltageInit } from '../services/voltage-init';
import { downloadDebugFileShortCircuitAnalysis } from '../services/short-circuit-analysis';

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

export function buildDebugIdentifier({
Expand Down
27 changes: 27 additions & 0 deletions src/services/short-circuit-analysis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { UUID } from 'crypto';
import { backendFetch } from './utils';

const PREFIX_SHORT_CIRCUIT_ANALYSIS_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/shortcircuit';

function getShotCircuitAnalysisUrl() {
return `${PREFIX_SHORT_CIRCUIT_ANALYSIS_SERVER_QUERIES}/v1/`;
}

export function downloadDebugFileShortCircuitAnalysis(resultUuid: UUID): Promise<Response> {
console.info(`Download short circuit analysis debug file of '${resultUuid}' ...`);

const url = getShotCircuitAnalysisUrl() + `results/${resultUuid}/download-debug-file`;

console.debug(url);
return backendFetch(url, {
method: 'get',
headers: { 'Content-Type': 'application/json' },
});
}
12 changes: 7 additions & 5 deletions src/services/study/short-circuit-analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ export function startShortCircuitAnalysis(
studyUuid: string,
currentNodeUuid: UUID | undefined,
currentRootNetworkUuid: UUID | null,
busId: string
busId: string,
debug?: boolean
): Promise<void> {
console.info(
`Running short circuit analysis on '${studyUuid}' on root network '${currentRootNetworkUuid}' and node '${currentNodeUuid}' ...`
);
const urlSearchParams = new URLSearchParams();
busId && urlSearchParams.append('busId', busId);

const startShortCircuitAnalysisUrl =
getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid) +
'/shortcircuit/run?' +
urlSearchParams.toString();
if (debug) {
urlSearchParams.append('debug', `${debug}`);
}

const startShortCircuitAnalysisUrl = `${getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid)}/shortcircuit/run?${urlSearchParams}`;
console.debug(startShortCircuitAnalysisUrl);
return backendFetch(startShortCircuitAnalysisUrl, { method: 'put' });
}
Expand Down
Loading