Skip to content

Commit

Permalink
bugfix: render prefix logic rework
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-solovei-s1 committed Nov 18, 2024
1 parent 4547145 commit 1ea9832
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/plugins/src/menu/VirtualTemplateIED.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,25 @@ function getLDeviceDescriptions(
)!;
const lnType = lLN0?.split(": ")[1];

// Map to ensure unique prefixes based on node attributes
const anyLNs = [
{ prefix: null, lnClass: "LLN0", inst: "", lnType },
...selectedLNodes.map((lNode, index) => ({
prefix: `CSWI-${index + 1}`, // Assigns a unique prefix based on the index
lnClass: lNode.getAttribute("lnClass")!,
inst: lNode.getAttribute("lnInst")!,
lnType: lNode.getAttribute("lnType")!,
})),
...selectedLNodes.map((lNode, index) => {
const lnClass = lNode.getAttribute("lnClass")!;
const inst = lNode.getAttribute("lnInst")!;
const lnType = lNode.getAttribute("lnType")!;
const existingPrefix = lNode.getAttribute("prefix") || "";

// Generate unique prefix if not already provided
const uniquePrefix = existingPrefix || `${lnClass}-${index + 1}`; // Prefix includes class and unique index

return {
prefix: uniquePrefix,
lnClass,
inst,
lnType,
};
}),
];

lDeviceDescriptions.push({
Expand Down

0 comments on commit 1ea9832

Please sign in to comment.