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

add side for one bus shortCircuit result #2282

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { downloadShortCircuitResultZippedCsv } from '../../../services/study/sho
import { downloadZipFile } from '../../../services/utils';
import { ShortCircuitAnalysisType } from './shortcircuit-analysis-result.type';
import { UUID } from 'crypto';
import { BranchSide } from 'components/utils/constants';

interface ShortCircuitExportButtonProps {
studyUuid: UUID;
Expand Down Expand Up @@ -47,6 +48,8 @@ export const ShortCircuitExportButton: FunctionComponent<ShortCircuitExportButto
'HIGH_VOLTAGE',
'LOW_SHORT_CIRCUIT_CURRENT',
'HIGH_SHORT_CIRCUIT_CURRENT',
BranchSide.ONE,
BranchSide.TWO,
'OTHER',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { makeAgGridCustomHeaderColumn } from '../../custom-aggrid/custom-aggrid-header-utils';
import { unitToKiloUnit } from '../../../utils/unit-converter';
import { CustomAGGrid } from '@gridsuite/commons-ui';
import { BranchSide } from 'components/utils/constants';

interface ShortCircuitAnalysisResultProps {
result: SCAFaultResult[];
Expand Down Expand Up @@ -66,6 +67,7 @@ interface ShortCircuitAnalysisResultsFeederResult {
connectableId: string;
current: number;
linkedElementId: string;
side?: string;
}

const ShortCircuitAnalysisResultTable: FunctionComponent<ShortCircuitAnalysisResultProps> = ({
Expand Down Expand Up @@ -135,6 +137,13 @@ const ShortCircuitAnalysisResultTable: FunctionComponent<ShortCircuitAnalysisRes
filterParams: numericFilterParams,
valueGetter: (params: ValueGetterParams) => unitToKiloUnit(params.data?.current),
}),
makeAgGridCustomHeaderColumn({
headerName: intl.formatMessage({ id: 'Side' }),
field: 'side',
sortProps: sortPropsCheckedForAllBusesAnalysisType,
filterProps: filterPropsCheckedForAllBusesAnalysisType,
hide: analysisType !== ShortCircuitAnalysisType.ONE_BUS,
}),
makeAgGridCustomHeaderColumn({
headerName: intl.formatMessage({ id: 'LimitType' }),
field: 'limitType',
Expand Down Expand Up @@ -281,6 +290,13 @@ const ShortCircuitAnalysisResultTable: FunctionComponent<ShortCircuitAnalysisRes

const current = getCurrent(faultResult);

const convertSide = (side: string | undefined) => {
return side === BranchSide.ONE
? intl.formatMessage({ id: 'Side1' })
: side === BranchSide.TWO
? intl.formatMessage({ id: 'Side2' })
: undefined;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function can be outside the component:
function convertSide(side?: string) {
switch (side) {
case BranchSide.ONE:
return'Side1';
case BranchSide.TWO:
return 'Side2'
default:
return undefined;
}
}; or as const const sideMap = {
[BranchSide.ONE]: 'Side1',
[BranchSide.TWO]:'Side2',
}; andthen
side: intl.formatMessage({ id: convertSide(side) })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to duplicate it I noticed that it's used by LF and SA also I just imported it

const deltaCurrentIpMax = faultResult.shortCircuitLimits.deltaCurrentIpMax;
const deltaCurrentIpMin = faultResult.shortCircuitLimits.deltaCurrentIpMin;

Expand Down Expand Up @@ -313,6 +329,7 @@ const ShortCircuitAnalysisResultTable: FunctionComponent<ShortCircuitAnalysisRes
const feederResults = faultResult.feederResults ?? [];
feederResults.forEach((feederResult) => {
const current = getCurrent(feederResult);
const side = analysisType === ShortCircuitAnalysisType.ONE_BUS ? feederResult.side : undefined;

rows.push({
connectableId: feederResult.connectableId,
Expand All @@ -321,12 +338,13 @@ const ShortCircuitAnalysisResultTable: FunctionComponent<ShortCircuitAnalysisRes
elementId: '', // we have to add this otherwise it's automatically filtered
faultType: '', // we have to add this otherwise it's automatically filtered
limitType: '', // we have to add this otherwise it's automatically filtered
side: convertSide(side),
});
});
});
return rows;
},
[getCurrent, intl]
[getCurrent, intl, analysisType]
);
const rows = useMemo(() => flattenResult(result), [flattenResult, result]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface SCAFeederResult {
connectableId: string;
current: number;
positiveMagnitude: number;
side: string;
}

interface SCAShortCircuitLimits {
Expand Down
Loading