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

Handle tie lines equipment #53

Merged
merged 5 commits into from
Mar 26, 2024
Merged
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
37 changes: 37 additions & 0 deletions src/components/network-map-viewer/network/map-equipments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class MapEquipments {

linesById = new Map();

tieLines = [];

tieLinesById = new Map();

hvdcLines = [];

hvdcLinesById = new Map();
Expand Down Expand Up @@ -152,6 +156,19 @@ export class MapEquipments {
}
}

completeTieLinesInfos(equipementsToIndex) {
if (equipementsToIndex?.length > 0) {
equipementsToIndex.forEach((tieLine) => {
this.tieLinesById?.set(tieLine.id, tieLine);
});
} else {
this.tieLinesById = this.tieLines.reduce(
elementIdIndexer,
new Map()
);
}
}

updateLines(lines, fullReload) {
if (fullReload) {
this.lines = [];
Expand All @@ -164,6 +181,18 @@ export class MapEquipments {
this.completeLinesInfos(fullReload ? [] : lines);
}

updateTieLines(tieLines, fullReload) {
if (fullReload) {
this.tieLines = [];
}
this.tieLines = this.updateEquipments(
this.tieLines,
tieLines,
EQUIPMENT_TYPES.TIE_LINE
);
this.completeTieLinesInfos(fullReload ? [] : tieLines);
}

updateHvdcLines(hvdcLines, fullReload) {
if (fullReload) {
this.hvdcLines = [];
Expand Down Expand Up @@ -276,4 +305,12 @@ export class MapEquipments {
getHvdcLine(id) {
return this.hvdcLinesById.get(id);
}

getTieLines() {
return this.tieLines;
}

getTieLine(id) {
return this.tieLinesById.get(id);
}
}
44 changes: 29 additions & 15 deletions src/components/network-map-viewer/network/network-map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ const NetworkMap = (props) => {

const readyToDisplayLines =
readyToDisplay &&
(props.mapEquipments?.lines || props.mapEquipments?.hvdcLines) &&
(props.mapEquipments?.lines ||
props.mapEquipments?.hvdcLines ||
props.mapEquipments?.tieLines) &&
props.mapEquipments.voltageLevels &&
props.geoData.substationPositionsById.size > 0;

Expand All @@ -129,12 +131,20 @@ const NetworkMap = (props) => {
...line,
equipmentType: EQUIPMENT_TYPES.LINE,
})) ?? []),
...(props.mapEquipments?.tieLines.map((tieLine) => ({
...tieLine,
equipmentType: EQUIPMENT_TYPES.TIE_LINE,
})) ?? []),
...(props.mapEquipments?.hvdcLines.map((hvdcLine) => ({
...hvdcLine,
equipmentType: EQUIPMENT_TYPES.HVDC_LINE,
})) ?? []),
];
}, [props.mapEquipments?.hvdcLines, props.mapEquipments?.lines]);
}, [
props.mapEquipments?.hvdcLines,
props.mapEquipments?.tieLines,
props.mapEquipments?.lines,
]);

const divRef = useRef();

Expand Down Expand Up @@ -338,22 +348,24 @@ const NetworkMap = (props) => {
) {
// picked line properties are retrieved from network data and not from pickable object infos,
// because pickable object infos might not be up to date
let line = network.getLine(info.object.id);
if (line) {
props.onLineMenuClick(
line,
const line = network.getLine(info.object.id);
const tieLine = network.getTieLine(info.object.id);
const hvdcLine = network.getHvdcLine(info.object.id);

const equipment = line || tieLine || hvdcLine;
if (equipment) {
const menuClickFunction =
equipment === line
? props.onLineMenuClick
: equipment === tieLine
? props.onTieLineMenuClick
: props.onHvdcLineMenuClick;

menuClickFunction(
equipment,
event.originalEvent.x,
event.originalEvent.y
);
} else {
let hvdcLine = network.getHvdcLine(info.object.id);
if (hvdcLine) {
props.onHvdcLineMenuClick(
hvdcLine,
event.originalEvent.x,
event.originalEvent.y
);
}
}
}
}
Expand Down Expand Up @@ -594,6 +606,7 @@ NetworkMap.defaultProps = {
onSubstationMenuClick: () => {},
onVoltageLevelMenuClick: () => {},
onLineMenuClick: () => {},
onTieLineMenuClick: () => {},
onHvdcLineMenuClick: () => {},
onManualRefreshClick: () => {},
renderPopover: (eId) => {
Expand Down Expand Up @@ -639,6 +652,7 @@ NetworkMap.propTypes = {

onHvdcLineMenuClick: PropTypes.func,
onLineMenuClick: PropTypes.func,
onTieLineMenuClick: PropTypes.func,
onManualRefreshClick: PropTypes.func,
onSubstationClick: PropTypes.func,
onSubstationClickChooseVoltageLevel: PropTypes.func,
Expand Down
1 change: 1 addition & 0 deletions src/components/network-map-viewer/utils/equipment-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const EQUIPMENT_TYPES = {
BATTERY: 'BATTERY',
LOAD: 'LOAD',
SHUNT_COMPENSATOR: 'SHUNT_COMPENSATOR',
TIE_LINE: 'TIE_LINE',
DANGLING_LINE: 'DANGLING_LINE',
STATIC_VAR_COMPENSATOR: 'STATIC_VAR_COMPENSATOR',
HVDC_CONVERTER_STATION: 'HVDC_CONVERTER_STATION',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const FEEDER_COMPONENT_TYPES = new Set([
'LOAD',
'BATTERY',
'DANGLING_LINE',
'TIE_LINE',
'GENERATOR',
'VSC_CONVERTER_STATION',
'LCC_CONVERTER_STATION',
Expand Down
Loading