Skip to content

Feat remove ied duplicates issue#146

Open
stee-re wants to merge 4 commits intoOpenEnergyTools:mainfrom
stee-re:feat_removeIED-duplicates-issue
Open

Feat remove ied duplicates issue#146
stee-re wants to merge 4 commits intoOpenEnergyTools:mainfrom
stee-re:feat_removeIED-duplicates-issue

Conversation

@stee-re
Copy link
Copy Markdown
Collaborator

@stee-re stee-re commented Apr 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 adds an option to detect and remove such duplicates instead of
creating redundant entries, by default. Callers can use the options to prevent this happening:

remove(myIEDElement, {removeLNodes: false});

Changes

  • tIED/removeIED.ts:
    • Added RemoveIedOptions interface with a removeLNodes flag (defaults to true)
    • Introduced a lNodeKey() helper to compute a unique key per LNode
    • When removeLNodes is true (default), duplicate LNodes already set to "None" are removed rather
      than duplicated
    • When removeLNodes is false, LNodes are only updated to "None" (previous behaviour)
  • index.ts: Exported RemoveIedOptions type
  • tIED/removeIED.spec.ts: Added tests for duplicate removal and opt-out behaviour
  • tIED/removeIED.testfile.ts: Added test fixture with duplicate LNode scenario
  • .gitignore: Added IDE and build artifact patterns

Copy link
Copy Markdown
Collaborator

@danyill danyill left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution. It looks good to me but I wonder if it would be better if we didn't have an option to make the file schema invalid following ca-d comments in #121 (comment)

Comment thread tIED/removeIED.ts
)}`;
}

function updateIedNameToNone(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we call this something else? e.g. virtualiseIedOrRemoveLNode (too long) or ensureUniqueLNodes (doesn't quite capture it) or just updateLNodes (even if it can also remove them!).

Eek it's a bit of a mouthful but I think it's a bit misleading as is.

Comment thread tIED/removeIED.ts
Comment on lines +55 to +57
return `${attr("lnInst")}|${attr("lnClass")}|${attr("ldInst")}|${attr(
"prefix",
)}`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is nit-picking but I suppose I'd prefer something a little more semantic:

return `${attr("ldInst")}|${attr("prefix")}|${attr("lnClass")}|${attr("lnInst")}`;

Comment thread tIED/removeIED.ts
if (hasDuplicate) return { node: element } as Remove;
}
}
return { element, attributes: { iedName: "None" } } as SetAttributes;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I suppose I don't like that we have an API that can needlessly result in a schema invalid file. I think if we agree we should have only two options, "virtualise" or "remove LNodes" from the recent issue discussions then we should change this API.

How do you feel about making this small modification such that if we're not virtualising we just Remove the LNode rather than doing a SettAttributes?

Suggested change
return { element, attributes: { iedName: "None" } } as SetAttributes;
return { node: element } as Remove;

I think then our options should reflect this terminology.

Comment thread tIED/removeIED.ts
* KDC, Association, ConnectedAP and IEDName
* 2. Remove subscriptions and supervisions
* 2. Update LNodes to an iedName of None
* 3. Update LNodes to an iedName of None (or remove duplicates)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps

Suggested change
* 3. Update LNodes to an iedName of None (or remove duplicates)
* 3. Update LNodes to an iedName of None (and remove any duplicates by default)

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

3 participants