Skip to content

Commit 3d2b063

Browse files
committed
Add DAI descriptions from d if desc is missing (part of #9)
1 parent 7f63a36 commit 3d2b063

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

oscd-supervision.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,21 @@ function getCBRefs(
304304
);
305305
}
306306

307+
function getSupervisionLnDescription(supLn: Element): string {
308+
const descriptionLn = getDescriptionAttribute(supLn);
309+
const doi = supLn.querySelector(`:scope > DOI[name="St"]`);
310+
311+
let doiDesc = doi ? getDescriptionAttribute(doi) : undefined;
312+
313+
if (!doiDesc) {
314+
doiDesc =
315+
doi?.querySelector(':scope > DAI[name="d"] > Val')?.textContent ??
316+
undefined;
317+
}
318+
319+
return [descriptionLn, doiDesc].filter(d => d !== undefined).join(' > ');
320+
}
321+
307322
/**
308323
* Editor to allow allocation of GOOSE and SMV supervision LNs
309324
* to control blocks
@@ -489,7 +504,7 @@ export default class OscdSupervision extends LitElement {
489504

490505
// eslint-disable-next-line class-methods-use-this
491506
renderUnusedSupervisionNode(lN: Element): TemplateResult {
492-
const description = getDescriptionAttribute(lN);
507+
const description = getSupervisionLnDescription(lN);
493508

494509
const controlBlockRef = getSupervisionCBRef(lN);
495510
const invalidControlBlock =
@@ -544,7 +559,7 @@ export default class OscdSupervision extends LitElement {
544559

545560
// eslint-disable-next-line class-methods-use-this
546561
renderSupervisionListItem(lN: Element, interactive: boolean): TemplateResult {
547-
const description = getDescriptionAttribute(lN);
562+
const description = getSupervisionLnDescription(lN);
548563

549564
return html`
550565
<mwc-list-item
@@ -610,14 +625,7 @@ export default class OscdSupervision extends LitElement {
610625
}
611626

612627
searchUnusedSupervisionLN(supLn: Element): boolean {
613-
const descriptionLn = getDescriptionAttribute(supLn);
614-
const cbRef = this.controlType === 'GOOSE' ? 'GoCBRef' : 'SvCBRef';
615-
const doi = supLn.querySelector(`DOI[name="${cbRef}"`);
616-
const descriptionDoi = doi ? getDescriptionAttribute(doi) : undefined;
617-
const description = [descriptionLn, descriptionDoi]
618-
.filter(d => d !== undefined)
619-
.join(' > ');
620-
628+
const description = getSupervisionLnDescription(supLn);
621629
const supervisionSearchText = `${identity(supLn)} ${description}`;
622630

623631
return (

test/fixtures/supervisions.scd

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
</IED>
413413
<IED name="GOOSE_Subscriber4" desc="GOOSE subscriber" manufacturer="Dummy">
414414
<Services>
415-
<SupSubscription maxGo="4" maxSv="3"/>
415+
<SupSubscription maxGo="5" maxSv="3"/>
416416
</Services>
417417
<AccessPoint name="AP1">
418418
<Server>
@@ -464,7 +464,21 @@
464464
</LN>
465465
<LN lnClass="LGOS" inst="2" lnType="Dummy.LGOS" desc="Important1">
466466
<Private type="OpenSCD.create"/>
467-
<DOI name="GoCBRef" desc="Important2">
467+
<DOI name="St">
468+
<DAI name="d">
469+
<Val>Important2</Val>
470+
</DAI>
471+
</DOI>
472+
<DOI name="GoCBRef">
473+
<DAI name="setSrcRef">
474+
<Val></Val>
475+
</DAI>
476+
</DOI>
477+
</LN>
478+
<LN lnClass="LGOS" inst="3" lnType="Dummy.LGOS" desc="Important1">
479+
<Private type="OpenSCD.create"/>
480+
<DOI name="St" desc="Important3"></DOI>
481+
<DOI name="GoCBRef">
468482
<DAI name="setSrcRef">
469483
<Val></Val>
470484
</DAI>

0 commit comments

Comments
 (0)