-
Notifications
You must be signed in to change notification settings - Fork 1
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
nad-viewer: update bus connections #163
base: main
Are you sure you want to change the base?
nad-viewer: update bus connections #163
Conversation
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
Signed-off-by: Leclerc Clement <[email protected]>
@@ -160,8 +159,8 @@ export const addNadToDemo = () => { | |||
?.getElementsByTagName('svg')[0] | |||
.setAttribute('style', 'border:2px; border-style:solid;'); | |||
|
|||
// add button to update branch labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you update the comment rather than removing it?
src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts
Show resolved
Hide resolved
return; | ||
} | ||
|
||
const edge = this.diagramMetadata?.edges.find((e) => e.svgId === edgeId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the edge is already known by the caller, as edgesMap.get(branchState.branchId)
is called. So you could have the edge instead of the edgeId in setBranchBusConnection
const currentBusNode = this.diagramMetadata?.busNodes.find((busNode) => busNode.svgId === currentBusNodeId); | ||
|
||
if (currentBusNode && currentBusNode.vlNode !== targetBusNode.vlNode) { | ||
console.warn('Skipping updating branch ' + branchId + ' side ' + side + ' status: Cannot connect to bus from different voltage level'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can! the only thing we can't so far is to connect two buses from the same voltage level (we didn't draw loops in network-viewer so far, we only translate them). It's just a bit more complex, as it has some side effects for parallel edges. Should we do this in current PR?
this.moveStraightEdge(edge, vlElement, currentPosition); | ||
const vlBusNodes = this.diagramMetadata?.busNodes.filter( | ||
(busNode) => busNode.vlNode === targetBusNode.vlNode | ||
); | ||
const busNodeEdges = new Map<string, EdgeMetadata[]>(); | ||
vlBusNodes?.forEach((busNode) => { | ||
const busEdges = this.diagramMetadata?.edges.filter( | ||
(e) => e.busNode1 === busNode.svgId || e.busNode2 === busNode.svgId | ||
); | ||
if (busEdges?.length) { | ||
busNodeEdges.set(busNode.svgId, busEdges); | ||
} | ||
}); | ||
this.redrawVoltageLevelNode(vlElement, busNodeEdges, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only working for straight edges, not for parallel fork edges. To avoid that I think you can call directly moveEdges(vlNode, position)
instead of all that, can't you? One drawback, it's doing more than needed
value2: -611 + value * 20, | ||
connected1: true, | ||
connected2: true, | ||
connectedBus1: value < 10 ? '4' : '5', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to add this new slider, you should do this in the first one
@@ -1201,20 +1203,17 @@ export class NetworkAreaDiagramViewer { | |||
if (typeof edgeAngle !== 'undefined') { | |||
traversingBusEdgesAngles.push(edgeAngle); | |||
} | |||
// redraw only if there is an edge going to another voltage level | |||
if (edge.node1 != edge.node2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand why you did remove this? EDIT: just got it, it was to avoid redrawing a bus node which contained only loops. If you remove it, you lose this tiny optimization
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
What kind of change does this PR introduce?
Adding bus connection capability to branches in the Network Area Diagram viewer
Does this PR introduce a new Powsybl Action implying to be implemented in simulators or pypowsybl?
What is the current behavior?
Currently, the NetworkAreaDiagramViewer allows moving branches and updating their states, but doesn't support dynamically changing which bus a branch is connected to within a voltage level.
What is the new behavior (if this is a feature change)?
Automatically redraw the voltage level node and affected edges when bus connections change
Maintain proper branch positioning and visual representation after bus connection changes
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
Other information: