diff --git a/src/components/run-button-container.jsx b/src/components/run-button-container.jsx index eb23b761db..f1627b4e2b 100644 --- a/src/components/run-button-container.jsx +++ b/src/components/run-button-container.jsx @@ -463,14 +463,12 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU }, [ComputingType.STATE_ESTIMATION]: { messageId: 'StateEstimation', - startComputation() { + startComputation(debug) { startComputationAsync( ComputingType.STATE_ESTIMATION, null, - () => { - return startStateEstimation(studyUuid, currentNode?.id, currentRootNetworkUuid); - }, - () => {}, + () => startStateEstimation(studyUuid, currentNode?.id, currentRootNetworkUuid, debug), + () => debug && subscribeDebug(ComputingType.STATE_ESTIMATION), null, 'startStateEstimationError' ); diff --git a/src/hooks/use-computation-debug.ts b/src/hooks/use-computation-debug.ts index fb13041a68..c551cba1e7 100644 --- a/src/hooks/use-computation-debug.ts +++ b/src/hooks/use-computation-debug.ts @@ -26,6 +26,7 @@ import { useSelector } from 'react-redux'; import { AppState } from '../redux/reducer'; import { downloadDebugFileVoltageInit } from '../services/voltage-init'; import { downloadDebugFileShortCircuitAnalysis } from '../services/short-circuit-analysis'; +import { downloadDebugFileStateEstimationServer } from '../services/state-estimation'; const downloadDebugFileFetchers = { [ComputingType.DYNAMIC_SIMULATION]: downloadDebugFileDynamicSimulation, @@ -33,6 +34,7 @@ const downloadDebugFileFetchers = { [ComputingType.VOLTAGE_INITIALIZATION]: downloadDebugFileVoltageInit, [ComputingType.SHORT_CIRCUIT]: downloadDebugFileShortCircuitAnalysis, [ComputingType.SHORT_CIRCUIT_ONE_BUS]: downloadDebugFileShortCircuitAnalysis, + [ComputingType.STATE_ESTIMATION]: downloadDebugFileStateEstimationServer, } as Record Promise) | null>; export function buildDebugIdentifier({ diff --git a/src/services/state-estimation.ts b/src/services/state-estimation.ts new file mode 100644 index 0000000000..7f0794b0e2 --- /dev/null +++ b/src/services/state-estimation.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2026, 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 type { UUID } from 'node:crypto'; +import { backendFetch } from '@gridsuite/commons-ui'; + +const PREFIX_STATE_ESTIMATION_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/state-estimation'; + +function getStateEstimationServerUrl() { + return `${PREFIX_STATE_ESTIMATION_SERVER_QUERIES}/v1/`; +} + +export function downloadDebugFileStateEstimationServer(resultUuid: UUID): Promise { + console.info(`Download state estimation debug file of '${resultUuid}' ...`); + + const url = getStateEstimationServerUrl() + `results/${resultUuid}/download-debug-file`; + + console.debug(url); + return backendFetch(url, { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + }); +} diff --git a/src/services/study/state-estimation.ts b/src/services/study/state-estimation.ts index bd5db82b49..8326bf2475 100644 --- a/src/services/study/state-estimation.ts +++ b/src/services/study/state-estimation.ts @@ -13,14 +13,17 @@ import { StateEstimationParameters } from '../../components/dialogs/parameters/s export function startStateEstimation( studyUuid: UUID, currentNodeUuid: UUID, - currentRootNetworkUuid: UUID + currentRootNetworkUuid: UUID, + debug?: boolean ): Promise { console.info( `Running state estimation on ${studyUuid} on root network '${currentRootNetworkUuid}' and node ${currentNodeUuid} ...` ); - const url = - getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid) + - '/state-estimation/run'; + const urlSearchParams = new URLSearchParams(); + if (debug) { + urlSearchParams.append('debug', `${debug}`); + } + const url = `${getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid)}/state-estimation/run?${urlSearchParams}`; console.debug(url); return backendFetch(url, { method: 'post' });