Skip to content

Commit 0da74ae

Browse files
authored
One bus short circuit debug mode (#3113)
Signed-off-by: Thang PHAM <[email protected]>
1 parent e82da9c commit 0da74ae

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/components/grid-layout/cards/diagrams/singleLineDiagram/single-line-diagram-content.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { useParameterState } from 'components/dialogs/parameters/use-parameters-
4141
import { DiagramType } from '../diagram.type';
4242
import { useEquipmentMenu } from '../../../../../hooks/use-equipment-menu';
4343
import useEquipmentDialogs from 'hooks/use-equipment-dialogs';
44+
import useComputationDebug from '../../../../../hooks/use-computation-debug';
4445

4546
interface SingleLineDiagramContentProps {
4647
readonly showInSpreadsheet: (menu: { equipmentId: string | null; equipmentType: EquipmentType | null }) => void;
@@ -160,12 +161,22 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
160161
});
161162
}, []);
162163

164+
// --- for running in debug mode --- //
165+
const subscribeDebug = useComputationDebug({
166+
studyUuid: studyUuid,
167+
nodeUuid: currentNode?.id!,
168+
rootNetworkUuid: currentRootNetworkUuid!,
169+
});
170+
163171
const handleRunShortcircuitAnalysis = useCallback(
164-
(busId: string) => {
172+
(busId: string, debug: boolean) => {
165173
dispatch(setComputingStatus(ComputingType.SHORT_CIRCUIT_ONE_BUS, RunningStatus.RUNNING));
166174
displayOneBusShortcircuitAnalysisLoader();
167175
dispatch(setComputationStarting(true));
168-
startShortCircuitAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid, busId)
176+
startShortCircuitAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid, busId, debug)
177+
.then(() => {
178+
debug && subscribeDebug(ComputingType.SHORT_CIRCUIT_ONE_BUS);
179+
})
169180
.catch((error) => {
170181
snackError({
171182
messageTxt: error.message,
@@ -188,6 +199,7 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
188199
currentRootNetworkUuid,
189200
snackError,
190201
resetOneBusShortcircuitAnalysisLoader,
202+
subscribeDebug,
191203
]
192204
);
193205

src/components/menus/bus-menu.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { ListItemIcon, ListItemText, Menu, Typography } from '@mui/material';
99
import BoltIcon from '@mui/icons-material/Bolt';
1010
import { FormattedMessage } from 'react-intl';
11-
import { FunctionComponent, useCallback, useEffect, useMemo, useState } from 'react';
11+
import { FunctionComponent, MouseEvent as ReactMouseEvent, useCallback, useEffect, useMemo, useState } from 'react';
1212
import { isNodeBuilt, isNodeReadOnly } from 'components/graph/util/model-functions';
1313
import { useSelector } from 'react-redux';
1414
import { AppState } from 'redux/reducer';
@@ -22,13 +22,13 @@ import { useOptionalServiceStatus } from '../../hooks/use-optional-service-statu
2222
import { OptionalServicesNames, OptionalServicesStatus } from '../utils/optional-services';
2323
import OfflineBoltOutlinedIcon from '@mui/icons-material/OfflineBoltOutlined';
2424
import { tripEquipment } from '../../services/study/network-modifications';
25-
import { EquipmentType, useSnackMessage, CustomMenuItem, ComputingType } from '@gridsuite/commons-ui';
25+
import { ComputingType, CustomMenuItem, EquipmentType, useSnackMessage } from '@gridsuite/commons-ui';
2626
import { fetchNetworkElementInfos } from '../../services/study/network';
2727
import { useParameterState } from 'components/dialogs/parameters/use-parameters-state';
2828

2929
interface BusMenuProps {
3030
busId: string;
31-
handleRunShortcircuitAnalysis: (busId: string) => void;
31+
handleRunShortcircuitAnalysis: (busId: string, debug: boolean) => void;
3232
onOpenDynamicSimulationEventDialog: (
3333
equipmentId: string,
3434
equipmentType: EquipmentType,
@@ -105,10 +105,13 @@ export const BusMenu: FunctionComponent<BusMenuProps> = ({
105105
(state: AppState) => state.computingStatus[ComputingType.SHORT_CIRCUIT_ONE_BUS]
106106
);
107107

108-
const handleClickRunShortcircuitAnalysis = useCallback(() => {
109-
onClose();
110-
handleRunShortcircuitAnalysis(busId);
111-
}, [busId, onClose, handleRunShortcircuitAnalysis]);
108+
const handleClickRunShortcircuitAnalysis = useCallback(
109+
(event: ReactMouseEvent<HTMLLIElement>) => {
110+
onClose();
111+
handleRunShortcircuitAnalysis(busId, event.ctrlKey);
112+
},
113+
[busId, onClose, handleRunShortcircuitAnalysis]
114+
);
112115

113116
const handleOpenDynamicSimulationEventDialog = useCallback(
114117
(equipmentId: string, equipmentType: EquipmentType, dialogTitle: string) => {

src/hooks/use-computation-debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const downloadDebugFileFetchers = {
3131
[ComputingType.DYNAMIC_SECURITY_ANALYSIS]: downloadDebugFileDynamicSecurityAnalysis,
3232
[ComputingType.VOLTAGE_INITIALIZATION]: downloadDebugFileVoltageInit,
3333
[ComputingType.SHORT_CIRCUIT]: downloadDebugFileShortCircuitAnalysis,
34+
[ComputingType.SHORT_CIRCUIT_ONE_BUS]: downloadDebugFileShortCircuitAnalysis,
3435
} as Record<ComputingType, ((resultUuid: UUID) => Promise<Response>) | null>;
3536

3637
export function buildDebugIdentifier({

0 commit comments

Comments
 (0)