Skip to content

Commit 3e9297a

Browse files
authored
Feat shortcircuit ENR params part 1 (#958)
* feat(): Add specific parameters management for shortcircuit Signed-off-by: sBouzols <[email protected]>
1 parent 9097007 commit 3e9297a

11 files changed

+443
-29
lines changed

src/components/parameters/short-circuit/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const SHORT_CIRCUIT_VOLTAGE_RANGES = 'voltageRanges';
2929

3030
// specific parameters
3131
export const SHORT_CIRCUIT_ONLY_STARTED_GENERATORS = 'onlyStartedGenerators';
32+
export const SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS = 'modelPowerElectronics';
33+
export const SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS = 'powerElectronicsMaterials';
3234

3335
export const intlPredefinedParametersOptions = () => [
3436
{

src/components/parameters/short-circuit/short-circuit-fields.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Grid } from '@mui/material';
1010
import { green, red } from '@mui/material/colors';
1111
import { Lens } from '@mui/icons-material';
1212
import { useFormContext, useWatch } from 'react-hook-form';
13+
import { FormattedMessage } from 'react-intl';
1314
import {
1415
InitialVoltage,
1516
intlInitialVoltageProfileMode,
@@ -18,6 +19,8 @@ import {
1819
PredefinedParameters,
1920
SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE,
2021
SHORT_CIRCUIT_ONLY_STARTED_GENERATORS,
22+
SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS,
23+
SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS,
2124
SHORT_CIRCUIT_PREDEFINED_PARAMS,
2225
SHORT_CIRCUIT_WITH_FEEDER_RESULT,
2326
SHORT_CIRCUIT_WITH_LOADS,
@@ -31,6 +34,8 @@ import GridSection from '../../grid/grid-section';
3134
import { CheckboxInput, FieldLabel, MuiSelectInput, RadioInput, SwitchInput } from '../../inputs';
3235
import type { SxStyle } from '../../../utils/styles';
3336
import { COMMON_PARAMETERS, SPECIFIC_PARAMETERS } from '../common';
37+
import { ShortCircuitIccMaterialTable } from './short-circuit-icc-material-table';
38+
import { COLUMNS_DEFINITIONS_ICC_MATERIALS } from './short-circuit-icc-material-table-columns-definition';
3439

3540
export interface ShortCircuitFieldsProps {
3641
resetAll: (predefinedParams: PredefinedParameters) => void;
@@ -42,6 +47,12 @@ export enum Status {
4247
ERROR = 'ERROR',
4348
}
4449

50+
const columnsDef = COLUMNS_DEFINITIONS_ICC_MATERIALS.map((col) => ({
51+
...col,
52+
label: <FormattedMessage id={col.label as string} />,
53+
tooltip: <FormattedMessage id={col.tooltip as string} />,
54+
}));
55+
4556
export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonly<ShortCircuitFieldsProps>) {
4657
const [status, setStatus] = useState(Status.SUCCESS);
4758
const watchInitialVoltageProfileMode = useWatch({
@@ -188,6 +199,13 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl
188199
/>
189200
);
190201

202+
const modelPowerElectronics = (
203+
<CheckboxInput
204+
name={`${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS}`}
205+
label="ShortCircuitModelPowerElectronics"
206+
/>
207+
);
208+
191209
useEffect(() => {
192210
// To show the right status, we need to check the predefinedParams and initial voltage profile mode values.
193211
// Show success only if ICC_MAX_WITH_NOMINAL_VOLTAGE_MAP is associated with NOMINAL, or ICC_MAX_WITH_CEI909 with CEI909, or ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP with NOMINAL
@@ -251,6 +269,15 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl
251269
<Grid container>
252270
<GridItem size={12}>{onlyStartedGenerators}</GridItem>
253271
</Grid>
272+
<GridSection title="ShortCircuitPowerElectronicsSection" heading={4} />
273+
<Grid container>
274+
<GridItem size={12}>{modelPowerElectronics}</GridItem>
275+
</Grid>
276+
<ShortCircuitIccMaterialTable
277+
formName={`${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS}`}
278+
tableHeight={300}
279+
columnsDefinition={columnsDef}
280+
/>
254281
</>
255282
)}
256283
</Grid>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
import { TableCell } from '@mui/material';
8+
import { FloatInput, RawReadOnlyInput, SwitchInput } from '../../inputs';
9+
import {
10+
IccMaterialIColumnsDef,
11+
SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE,
12+
SHORT_CIRCUIT_ICC_MATERIAL_TYPE,
13+
} from './short-circuit-icc-material-table-columns-definition';
14+
15+
export function ShortCircuitIccMaterialTableCell({
16+
formName,
17+
rowIndex,
18+
column,
19+
inputsDisabled,
20+
}: Readonly<{
21+
formName: string;
22+
rowIndex: number;
23+
column: IccMaterialIColumnsDef;
24+
inputsDisabled?: boolean;
25+
}>) {
26+
return (
27+
<TableCell sx={{ fontWeight: 'bold' }}>
28+
{column.dataKey === SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE && (
29+
<SwitchInput name={`${formName}[${rowIndex}].${column.dataKey}`} />
30+
)}
31+
{column.dataKey === SHORT_CIRCUIT_ICC_MATERIAL_TYPE && (
32+
<RawReadOnlyInput name={`${formName}[${rowIndex}].${column.dataKey}`} />
33+
)}
34+
{column.dataKey !== SHORT_CIRCUIT_ICC_MATERIAL_TYPE &&
35+
column.dataKey !== SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE && (
36+
<FloatInput disabled={inputsDisabled} name={`${formName}[${rowIndex}].${column.dataKey}`} />
37+
)}
38+
</TableCell>
39+
);
40+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
export const SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE = 'active';
9+
export const SHORT_CIRCUIT_ICC_MATERIAL_TYPE = 'type';
10+
export const SHORT_CIRCUIT_ICC_MATERIAL_ALPHA = 'alpha';
11+
export const SHORT_CIRCUIT_ICC_MATERIAL_USMIN = 'usMin';
12+
export const SHORT_CIRCUIT_ICC_MATERIAL_USMAX = 'usMax';
13+
export const SHORT_CIRCUIT_ICC_MATERIAL_U0 = 'u0';
14+
15+
export interface IccMaterialIColumnsDef {
16+
label: React.ReactNode;
17+
dataKey: string;
18+
tooltip: React.ReactNode;
19+
}
20+
21+
export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [
22+
{
23+
label: 'ShortCircuitIccMaterialActivate',
24+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE,
25+
tooltip: 'ShortCircuitIccMaterialActivateTooltip',
26+
},
27+
{
28+
label: 'ShortCircuitIccMaterialType',
29+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_TYPE,
30+
tooltip: 'ShortCircuitIccMaterialTypeTooltip',
31+
},
32+
{
33+
label: 'ShortCircuitIccMaterialAlpha',
34+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ALPHA,
35+
tooltip: 'ShortCircuitIccMaterialAlphaTooltip',
36+
},
37+
{
38+
label: 'ShortCircuitIccMaterialUsmin',
39+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMIN,
40+
tooltip: 'ShortCircuitIccMaterialUsminTooltip',
41+
},
42+
{
43+
label: 'ShortCircuitIccMaterialUsmax',
44+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMAX,
45+
tooltip: 'ShortCircuitIccMaterialUsmaxTooltip',
46+
},
47+
{
48+
label: 'ShortCircuitIccMaterialU0',
49+
dataKey: SHORT_CIRCUIT_ICC_MATERIAL_U0,
50+
tooltip: 'ShortCircuitIccMaterialU0Tooltip',
51+
},
52+
];
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import { TableRow } from '@mui/material';
8+
import { useWatch } from 'react-hook-form';
9+
import {
10+
IccMaterialIColumnsDef,
11+
SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE,
12+
} from './short-circuit-icc-material-table-columns-definition';
13+
import { ShortCircuitIccMaterialTableCell } from './short-circuit-icc-material-table-cell';
14+
15+
interface ShortCircuitIccMaterialTableRowProps {
16+
formName: string;
17+
columnsDefinition: IccMaterialIColumnsDef[];
18+
index: number;
19+
}
20+
21+
export function ShortCircuitIccMaterialTableRow({
22+
formName,
23+
columnsDefinition,
24+
index,
25+
}: Readonly<ShortCircuitIccMaterialTableRowProps>) {
26+
const watchRowActive = useWatch({
27+
name: `${formName}[${index}].${SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE}`,
28+
});
29+
30+
return (
31+
<TableRow>
32+
{columnsDefinition.map((column: IccMaterialIColumnsDef) => (
33+
<ShortCircuitIccMaterialTableCell
34+
key={`${column.dataKey}`}
35+
formName={formName}
36+
rowIndex={index}
37+
column={column}
38+
inputsDisabled={!watchRowActive}
39+
/>
40+
))}
41+
</TableRow>
42+
);
43+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material';
9+
import { useFieldArray } from 'react-hook-form';
10+
import { IccMaterialIColumnsDef } from './short-circuit-icc-material-table-columns-definition';
11+
import { ShortCircuitIccMaterialTableRow } from './short-circuit-icc-material-table-row';
12+
13+
interface ShortCircuitIccMaterialTableProps {
14+
columnsDefinition: IccMaterialIColumnsDef[];
15+
tableHeight: number;
16+
formName: string;
17+
}
18+
19+
export function ShortCircuitIccMaterialTable({
20+
formName,
21+
columnsDefinition,
22+
tableHeight,
23+
}: Readonly<ShortCircuitIccMaterialTableProps>) {
24+
const { fields: rows } = useFieldArray({
25+
name: formName,
26+
});
27+
28+
return (
29+
<TableContainer
30+
sx={{
31+
height: tableHeight,
32+
width: 'inherit',
33+
border: 'solid 0px rgba(0,0,0,0.1)',
34+
}}
35+
>
36+
<Table stickyHeader size="small" sx={{ tableLayout: 'fixed' }}>
37+
<TableHead>
38+
<TableRow>
39+
{columnsDefinition.map((column) => (
40+
<Tooltip key={column.dataKey} title={column.tooltip}>
41+
<TableCell
42+
sx={{
43+
textAlign: 'center',
44+
}}
45+
>
46+
{column.label}
47+
</TableCell>
48+
</Tooltip>
49+
))}
50+
</TableRow>
51+
</TableHead>
52+
<TableBody>
53+
{rows.map((row, index) => (
54+
<ShortCircuitIccMaterialTableRow
55+
key={`${row.id}`}
56+
columnsDefinition={columnsDefinition}
57+
index={index}
58+
formName={formName}
59+
/>
60+
))}
61+
</TableBody>
62+
</Table>
63+
</TableContainer>
64+
);
65+
}

0 commit comments

Comments
 (0)