Skip to content

fix: removeIED - prevent duplicate LNode's#147

Open
stee-re wants to merge 1 commit into
openscd:mainfrom
stee-re:feat_removeIED-duplicates-issue
Open

fix: removeIED - prevent duplicate LNode's#147
stee-re wants to merge 1 commit into
openscd:mainfrom
stee-re:feat_removeIED-duplicates-issue

Conversation

@stee-re
Copy link
Copy Markdown
Collaborator

@stee-re stee-re commented May 27, 2026

resolves #121

Summary

When multiple IEDs reference the same LNode, removing those IEDs sequentially can result in duplicate LNode
entries with iedName="None". This PR modifies the default behaviour for removeIED() to delete all LNodes bound to that IED by default, but exposes a new optional flag preserveLNodes which will instead, set the LNodes ideName="None". In cases where setting the iedName="None" would lead to a duplicate LNode, then it is removed instead.
E.g.

remove(myIEDElement, {preserveLNodes: true});

Changes

  • tIED/removeIED.ts:
    • Added RemoveIedOptions interface with an optional preserveLNodes flag (defaults to false)
    • Added the following LNode related functions:
    • removeBoundLNodes() - Default handling for LNodes - find any (public) matching LNodes and create a Remove edit for them.
    • detachLNodeBindings() - if "preserveLNodes flag set, this function is called instead, to instead set the LNodes iedName to "None", taking care to avoid duplicates. Any LNodes encountered which would cause a duplicate, are removed instead.

Helper functions

  • lNodeKey - creates a key for the LNode based on all the other attributes (except iedName) which combined, must be unique.
  • removeLNode() & setLNodeToNone() - oneliner functions, there only to make the code more readable.
  • getLNodeByIedName() used to find the bound LNodes (and the specification LNodes (set ot None))

Other Changed files

  • index.ts: Exported RemoveIedOptions type
  • tIED/removeIED.spec.ts: Added tests for LNode removal and opt-in LNode updating behaviour
  • tIED/removeIED.testfile.ts: Added test fixture with duplicate LNode scenario
  • .gitignore: Added IDE and build artifact patterns

Code coverage 99.52%

@stee-re stee-re force-pushed the feat_removeIED-duplicates-issue branch 2 times, most recently from ec48b77 to 4ef2497 Compare May 27, 2026 13:32
@stee-re stee-re requested review from JakobVogelsang and danyill and removed request for danyill May 27, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tIED: removeIeds behaviours with LNodes

1 participant