Skip to content

Commit 9a655e8

Browse files
author
Dennis Labordus
authored
feat(ied-editor/ln-node): Changed description of LN Node in IED Editor (openscd#647)
* Changed description of LN Node in IED Editor. * Fixed test.
1 parent 0210913 commit 9a655e8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/foundation/nsdoc.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ export async function initializeNsdoc(): Promise<Nsdoc> {
6666
function getLNDataDescription(element: Element): { label: string; } {
6767
const lnClassAttribute = element.getAttribute('lnClass')!;
6868
const lnClass = nsd74.querySelector(`NS > LNClasses > LNClass[name="${lnClassAttribute}"]`);
69+
const lnClassDescription = getNsdocDocumentation(nsdoc74!, lnClass?.getAttribute('titleID'));
6970

7071
return {
71-
label: getNsdocDocumentation(nsdoc74!, lnClass?.getAttribute('titleID')) ?? lnClassAttribute
72+
label: lnClassDescription ? lnClassDescription + ' (' + lnClassAttribute + ')' : lnClassAttribute
7273
};
7374
}
7475

@@ -96,7 +97,7 @@ export async function initializeNsdoc(): Promise<Nsdoc> {
9697
function getSDODataDescription(element: Element): { label: string; } {
9798
const sdoName = element.getAttribute('name')!;
9899
const subDataObject = nsd73.querySelector(`CDCs > CDC[name="${element.parentElement?.getAttribute('cdc')}"] > SubDataObject[name="${sdoName}"]`);
99-
100+
100101
return {
101102
label: getNsdocDocumentation(nsdoc73!, subDataObject?.getAttribute('descID')) ?? sdoName
102103
};
@@ -172,7 +173,7 @@ export async function initializeNsdoc(): Promise<Nsdoc> {
172173
/**
173174
* Get the potential inherited data object based on a LNClass base.
174175
* @param lnClassBase - The base of a LNClass element.
175-
* @param doName - The name of the DO(I) to search for.
176+
* @param doName - The name of the DO(I) to search for.
176177
* @returns the DataObject in case found, otherwise null.
177178
*/
178179
function getInheritedDataObject(lnClassBase: string, doName: string): Element | null {
@@ -195,7 +196,7 @@ export async function initializeNsdoc(): Promise<Nsdoc> {
195196
}
196197
>].getDataDescription(element, ancestors);
197198
}
198-
199+
199200
}
200201
}
201202

@@ -207,4 +208,4 @@ export async function initializeNsdoc(): Promise<Nsdoc> {
207208
*/
208209
function getNsdocDocumentation(nsdoc: XMLDocument, id: string | null | undefined): string | null | undefined {
209210
return nsdoc?.querySelector(`NSDoc > Doc[id="${id ?? ''}"]`)?.textContent;
210-
}
211+
}

test/unit/foundation/nsdoc.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('nsdoc', () => {
5757
const ln = validSCL.querySelector(
5858
'IED[name="IED1"] > AccessPoint[name="P1"] > Server > LDevice[inst="CircuitBreaker_CB1"] > LN0[lnClass="LLN0"]')
5959

60-
expect(nsdocsObject.getDataDescription(ln!).label).to.eql('Some LN title');
60+
expect(nsdocsObject.getDataDescription(ln!).label).to.eql('Some LN title (LLN0)');
6161
});
6262

6363
it('returns the lnClass in case no title can be found', async function () {

0 commit comments

Comments
 (0)