Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Security Analysis] Parameters and Run implementation #2499

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/components/computing-status/computing-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum ComputingType {
SHORT_CIRCUIT = 'SHORT_CIRCUIT',
SHORT_CIRCUIT_ONE_BUS = 'SHORT_CIRCUIT_ONE_BUS',
DYNAMIC_SIMULATION = 'DYNAMIC_SIMULATION',
DYNAMIC_SECURITY_ANALYSIS = 'DYNAMIC_SECURITY_ANALYSIS',
VOLTAGE_INITIALIZATION = 'VOLTAGE_INITIALIZATION',
STATE_ESTIMATION = 'STATE_ESTIMATION',
}
Expand All @@ -37,6 +38,8 @@ export const formatComputingTypeLabel = (type: ComputingType): string | undefine
return 'VoltageInit';
case ComputingType.DYNAMIC_SIMULATION:
return 'DynamicSimulation';
case ComputingType.DYNAMIC_SECURITY_ANALYSIS:
return 'DynamicSecurityAnalysis';
case ComputingType.STATE_ESTIMATION:
return 'StateEstimation';
default:
Expand Down
29 changes: 23 additions & 6 deletions src/components/computing-status/use-all-computing-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import { useComputingStatus } from './use-computing-status';
import {
getSecurityAnalysisRunningStatus,
getSensitivityAnalysisRunningStatus,
getShortCircuitAnalysisRunningStatus,
getDynamicSecurityAnalysisRunningStatus,
getDynamicSimulationRunningStatus,
getVoltageInitRunningStatus,
getLoadFlowRunningStatus,
getNonEvacuatedEnergyRunningStatus,
getSecurityAnalysisRunningStatus,
getSensitivityAnalysisRunningStatus,
getShortCircuitAnalysisRunningStatus,
getStateEstimationRunningStatus,
getVoltageInitRunningStatus,
} from '../utils/running-status';

import { UUID } from 'crypto';
Expand All @@ -32,9 +33,9 @@ import { OptionalServicesNames } from '../utils/optional-services';
import { useOptionalServiceStatus } from '../../hooks/use-optional-service-status';
import { fetchNonEvacuatedEnergyStatus } from '../../services/study/non-evacuated-energy';
import { fetchStateEstimationStatus } from '../../services/study/state-estimation';
import { fetchDynamicSecurityAnalysisStatus } from '../../services/study/dynamic-security-analysis';

const loadFlowStatusInvalidations = ['loadflow_status', 'loadflow_failed'];

const securityAnalysisStatusInvalidations = ['securityAnalysis_status', 'securityAnalysis_failed'];
const sensitivityAnalysisStatusInvalidations = ['sensitivityAnalysis_status', 'sensitivityAnalysis_failed'];
const nonEvacuatedEnergyStatusInvalidations = ['nonEvacuatedEnergy_status', 'nonEvacuatedEnergy_failed'];
Expand All @@ -44,10 +45,11 @@ const oneBusShortCircuitAnalysisStatusInvalidations = [
'oneBusShortCircuitAnalysis_failed',
];
const dynamicSimulationStatusInvalidations = ['dynamicSimulation_status', 'dynamicSimulation_failed'];
const dynamicSecurityAnalysisStatusInvalidations = ['dynamicSecurityAnalysis_status', 'dynamicSecurityAnalysis_failed'];
const voltageInitStatusInvalidations = ['voltageInit_status', 'voltageInit_failed'];
const stateEstimationStatusInvalidations = ['stateEstimation_status', 'stateEstimation_failed'];
const loadFlowStatusCompletions = ['loadflowResult', 'loadflow_failed'];

const loadFlowStatusCompletions = ['loadflowResult', 'loadflow_failed'];
const securityAnalysisStatusCompletions = ['securityAnalysisResult', 'securityAnalysis_failed'];
const sensitivityAnalysisStatusCompletions = ['sensitivityAnalysisResult', 'sensitivityAnalysis_failed'];
const nonEvacuatedEnergyStatusCompletions = ['nonEvacuatedEnergyResult', 'nonEvacuatedEnergy_failed'];
Expand All @@ -57,14 +59,17 @@ const oneBusShortCircuitAnalysisStatusCompletions = [
'oneBusShortCircuitAnalysis_failed',
];
const dynamicSimulationStatusCompletions = ['dynamicSimulationResult', 'dynamicSimulation_failed'];
const dynamicSecurityAnalysisStatusCompletions = ['dynamicSecurityAnalysisResult', 'dynamicSecurityAnalysis_failed'];
const voltageInitStatusCompletions = ['voltageInitResult', 'voltageInit_failed'];
const stateEstimationStatusCompletions = ['stateEstimationResult', 'stateEstimation_failed'];

// this hook loads all current computation status into redux then keeps them up to date according to notifications
export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID, currentRootNetworkUuid: UUID): void => {
const securityAnalysisAvailability = useOptionalServiceStatus(OptionalServicesNames.SecurityAnalysis);
const sensitivityAnalysisAvailability = useOptionalServiceStatus(OptionalServicesNames.SensitivityAnalysis);
const nonEvacuatedEnergyAvailability = useOptionalServiceStatus(OptionalServicesNames.SensitivityAnalysis);
const dynamicSimulationAvailability = useOptionalServiceStatus(OptionalServicesNames.DynamicSimulation);
const dynamicSecurityAnalysisAvailability = useOptionalServiceStatus(OptionalServicesNames.DynamicSecurityAnalysis);
const voltageInitAvailability = useOptionalServiceStatus(OptionalServicesNames.VoltageInit);
const shortCircuitAvailability = useOptionalServiceStatus(OptionalServicesNames.ShortCircuit);
const stateEstimationAvailability = useOptionalServiceStatus(OptionalServicesNames.StateEstimation);
Expand Down Expand Up @@ -152,6 +157,18 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID, cu
dynamicSimulationAvailability
);

useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchDynamicSecurityAnalysisStatus,
dynamicSecurityAnalysisStatusInvalidations,
dynamicSecurityAnalysisStatusCompletions,
getDynamicSecurityAnalysisRunningStatus,
ComputingType.DYNAMIC_SECURITY_ANALYSIS,
dynamicSecurityAnalysisAvailability
);

useComputingStatus(
studyUuid,
currentNodeUuid,
Expand Down
39 changes: 39 additions & 0 deletions src/components/dialogs/parameters/common/provider-parameter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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 { Grid, SelectChangeEvent } from '@mui/material';
import { DropDown } from '../parameters';
import { useCallback } from 'react';

export interface ProviderParameterProps {
providers: Record<string, string>;
provider: string | undefined;
onChangeProvider: (provider: string) => void;
}

export default function ProviderParameter({ providers, provider, onChangeProvider }: Readonly<ProviderParameterProps>) {
const handleUpdateProvider = useCallback(
(evt: SelectChangeEvent) => {
onChangeProvider(evt.target.value);
},
[onChangeProvider]
);

return (
<Grid
xl={8}
container
sx={{
height: 'fit-content',
justifyContent: 'space-between',
}}
>
{providers && provider && (
<DropDown value={provider} label="Provider" values={providers} callback={handleUpdateProvider} />
)}
</Grid>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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 yup from '../../../utils/yup-config';
import { Grid } from '@mui/material';
import { makeComponents, TYPES } from '../util/make-component-utils';
import ParameterLineDirectoryItemsInput from '../widget/parameter-line-directory-items-input';
import { ElementType } from '@gridsuite/commons-ui';
import { ID, NAME } from '../../../utils/field-constants';

export const CONTINGENCIES_START_TIME = 'contingenciesStartTime';
export const CONTINGENCIES_LIST_INFOS = 'contingencyListInfos';

export const formSchema = yup.object().shape({
[CONTINGENCIES_START_TIME]: yup.number().required(),
[CONTINGENCIES_LIST_INFOS]: yup
.array()
.of(
yup.object().shape({
[ID]: yup.string().required(),
[NAME]: yup.string().required(),
})
)
.required(),
});

export const emptyFormData = {
[CONTINGENCIES_START_TIME]: 0,
[CONTINGENCIES_LIST_INFOS]: [],
};

const defParams = {
[CONTINGENCIES_START_TIME]: {
type: TYPES.FLOAT,
label: 'DynamicSecurityAnalysisContingenciesStartTime',
},
};

function ContingencyParameters({ path }: Readonly<{ path: string }>) {
return (
<Grid xl={8} container>
{makeComponents(defParams, path)}
<ParameterLineDirectoryItemsInput
name={`${path}.${CONTINGENCIES_LIST_INFOS}`}
elementType={ElementType.CONTINGENCY_LIST}
label={'ContingencyListsSelection'}
hideErrorMessage={true}
/>
</Grid>
);
}

export default ContingencyParameters;
Loading
Loading