Skip to content

Commit

Permalink
Add DAI descriptions from d if desc is missing (part of #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
danyill committed Jun 17, 2024
1 parent 7f63a36 commit 3d2b063
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
28 changes: 18 additions & 10 deletions oscd-supervision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ function getCBRefs(
);
}

function getSupervisionLnDescription(supLn: Element): string {
const descriptionLn = getDescriptionAttribute(supLn);
const doi = supLn.querySelector(`:scope > DOI[name="St"]`);

let doiDesc = doi ? getDescriptionAttribute(doi) : undefined;

if (!doiDesc) {
doiDesc =
doi?.querySelector(':scope > DAI[name="d"] > Val')?.textContent ??
undefined;
}

return [descriptionLn, doiDesc].filter(d => d !== undefined).join(' > ');
}

/**
* Editor to allow allocation of GOOSE and SMV supervision LNs
* to control blocks
Expand Down Expand Up @@ -489,7 +504,7 @@ export default class OscdSupervision extends LitElement {

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

const controlBlockRef = getSupervisionCBRef(lN);
const invalidControlBlock =
Expand Down Expand Up @@ -544,7 +559,7 @@ export default class OscdSupervision extends LitElement {

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

return html`
<mwc-list-item
Expand Down Expand Up @@ -610,14 +625,7 @@ export default class OscdSupervision extends LitElement {
}

searchUnusedSupervisionLN(supLn: Element): boolean {
const descriptionLn = getDescriptionAttribute(supLn);
const cbRef = this.controlType === 'GOOSE' ? 'GoCBRef' : 'SvCBRef';
const doi = supLn.querySelector(`DOI[name="${cbRef}"`);
const descriptionDoi = doi ? getDescriptionAttribute(doi) : undefined;
const description = [descriptionLn, descriptionDoi]
.filter(d => d !== undefined)
.join(' > ');

const description = getSupervisionLnDescription(supLn);
const supervisionSearchText = `${identity(supLn)} ${description}`;

return (
Expand Down
18 changes: 16 additions & 2 deletions test/fixtures/supervisions.scd
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
</IED>
<IED name="GOOSE_Subscriber4" desc="GOOSE subscriber" manufacturer="Dummy">
<Services>
<SupSubscription maxGo="4" maxSv="3"/>
<SupSubscription maxGo="5" maxSv="3"/>
</Services>
<AccessPoint name="AP1">
<Server>
Expand Down Expand Up @@ -464,7 +464,21 @@
</LN>
<LN lnClass="LGOS" inst="2" lnType="Dummy.LGOS" desc="Important1">
<Private type="OpenSCD.create"/>
<DOI name="GoCBRef" desc="Important2">
<DOI name="St">
<DAI name="d">
<Val>Important2</Val>
</DAI>
</DOI>
<DOI name="GoCBRef">
<DAI name="setSrcRef">
<Val></Val>
</DAI>
</DOI>
</LN>
<LN lnClass="LGOS" inst="3" lnType="Dummy.LGOS" desc="Important1">
<Private type="OpenSCD.create"/>
<DOI name="St" desc="Important3"></DOI>
<DOI name="GoCBRef">
<DAI name="setSrcRef">
<Val></Val>
</DAI>
Expand Down

0 comments on commit 3d2b063

Please sign in to comment.