Skip to content

Commit e3e906d

Browse files
authored
Fix spreadsheet update equipments (#3197)
Signed-off-by: achour94 <[email protected]>
1 parent 45d69c1 commit e3e906d

File tree

1 file changed

+71
-3
lines changed

1 file changed

+71
-3
lines changed

src/redux/reducer.ts

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,70 @@ export type StudyUpdated = {
313313
force: number; //IntRange<0, 1>;
314314
} & StudyUpdateNotification;
315315

316+
export enum EquipmentUpdateType {
317+
LINES = 'lines',
318+
TIE_LINES = 'tieLines',
319+
TWO_WINDINGS_TRANSFORMERS = 'twoWindingsTransformers',
320+
THREE_WINDINGS_TRANSFORMERS = 'threeWindingsTransformers',
321+
GENERATORS = 'generators',
322+
LOADS = 'loads',
323+
BATTERIES = 'batteries',
324+
DANGLING_LINES = 'danglingLines',
325+
HVDC_LINES = 'hvdcLines',
326+
LCC_CONVERTER_STATIONS = 'lccConverterStations',
327+
VSC_CONVERTER_STATIONS = 'vscConverterStations',
328+
SHUNT_COMPENSATORS = 'shuntCompensators',
329+
STATIC_VAR_COMPENSATORS = 'staticVarCompensators',
330+
VOLTAGE_LEVELS = 'voltageLevels',
331+
SUBSTATIONS = 'substations',
332+
BUSES = 'buses',
333+
BUSBAR_SECTIONS = 'busbarSections',
334+
BRANCHES = 'branches', // LINE + TWO_WINDINGS_TRANSFORMER
335+
}
336+
337+
function getEquipmentTypeFromUpdateType(updateType: EquipmentUpdateType): SpreadsheetEquipmentType | undefined {
338+
switch (updateType) {
339+
case EquipmentUpdateType.LINES:
340+
return SpreadsheetEquipmentType.LINE;
341+
case EquipmentUpdateType.TIE_LINES:
342+
return SpreadsheetEquipmentType.TIE_LINE;
343+
case EquipmentUpdateType.TWO_WINDINGS_TRANSFORMERS:
344+
return SpreadsheetEquipmentType.TWO_WINDINGS_TRANSFORMER;
345+
case EquipmentUpdateType.THREE_WINDINGS_TRANSFORMERS:
346+
return SpreadsheetEquipmentType.THREE_WINDINGS_TRANSFORMER;
347+
case EquipmentUpdateType.GENERATORS:
348+
return SpreadsheetEquipmentType.GENERATOR;
349+
case EquipmentUpdateType.LOADS:
350+
return SpreadsheetEquipmentType.LOAD;
351+
case EquipmentUpdateType.BATTERIES:
352+
return SpreadsheetEquipmentType.BATTERY;
353+
case EquipmentUpdateType.DANGLING_LINES:
354+
return SpreadsheetEquipmentType.DANGLING_LINE;
355+
case EquipmentUpdateType.HVDC_LINES:
356+
return SpreadsheetEquipmentType.HVDC_LINE;
357+
case EquipmentUpdateType.LCC_CONVERTER_STATIONS:
358+
return SpreadsheetEquipmentType.LCC_CONVERTER_STATION;
359+
case EquipmentUpdateType.VSC_CONVERTER_STATIONS:
360+
return SpreadsheetEquipmentType.VSC_CONVERTER_STATION;
361+
case EquipmentUpdateType.SHUNT_COMPENSATORS:
362+
return SpreadsheetEquipmentType.SHUNT_COMPENSATOR;
363+
case EquipmentUpdateType.STATIC_VAR_COMPENSATORS:
364+
return SpreadsheetEquipmentType.STATIC_VAR_COMPENSATOR;
365+
case EquipmentUpdateType.VOLTAGE_LEVELS:
366+
return SpreadsheetEquipmentType.VOLTAGE_LEVEL;
367+
case EquipmentUpdateType.SUBSTATIONS:
368+
return SpreadsheetEquipmentType.SUBSTATION;
369+
case EquipmentUpdateType.BUSES:
370+
return SpreadsheetEquipmentType.BUS;
371+
case EquipmentUpdateType.BUSBAR_SECTIONS:
372+
return SpreadsheetEquipmentType.BUSBAR_SECTION;
373+
case EquipmentUpdateType.BRANCHES:
374+
return SpreadsheetEquipmentType.BRANCH;
375+
default:
376+
return;
377+
}
378+
}
379+
316380
export interface OneBusShortCircuitAnalysisDiagram {
317381
diagramId: string;
318382
nodeId: UUID;
@@ -1373,10 +1437,10 @@ export const reducer = createReducer(initialState, (builder) => {
13731437
builder.addCase(UPDATE_EQUIPMENTS, (state, action: UpdateEquipmentsAction) => {
13741438
// for now, this action receives an object containing all equipments from a substation
13751439
// it will be modified when the notifications received after a network modification are more precise
1376-
// equipmentType: type of equipment updated
1440+
// updatedEquipmentType: type of equipment updated
13771441
// equipments: list of updated equipments of type <equipmentType>
1378-
for (const [equipmentType, equipments] of Object.entries(action.equipments) as [
1379-
SpreadsheetEquipmentType,
1442+
for (const [updatedEquipmentType, equipments] of Object.entries(action.equipments) as [
1443+
EquipmentUpdateType,
13801444
Identifiable[],
13811445
][]) {
13821446
let updatedEquipments;
@@ -1386,6 +1450,10 @@ export const reducer = createReducer(initialState, (builder) => {
13861450
updatedEquipments = [equipments];
13871451
}
13881452

1453+
const equipmentType = getEquipmentTypeFromUpdateType(updatedEquipmentType);
1454+
if (!equipmentType) {
1455+
continue;
1456+
}
13891457
const currentEquipment: Identifiable[] | undefined =
13901458
state.spreadsheetNetwork[equipmentType]?.equipmentsByNodeId[action.nodeId];
13911459

0 commit comments

Comments
 (0)