Skip to content

Commit 61357e1

Browse files
author
Dennis Labordus
committed
Fixed review comments and fixed configuration/example files.
Signed-off-by: Dennis Labordus <dennis.labordus@alliander.com>
1 parent fb41c54 commit 61357e1

File tree

5 files changed

+74
-54
lines changed

5 files changed

+74
-54
lines changed

public/conf/export-ied-params.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{
4646
"header": "IL1 Secondary rated current",
4747
"selector": "AccessPoint > Server > LDevice > LN[prefix=\"IL1\"][lnClass=\"TCTR\"]",
48-
"dataAttributePath": ["ARtgSec", "stVal"]
48+
"dataAttributePath": ["ARtgSec", "setVal"]
4949
},
5050
{
5151
"header": "RES Primary rated current",
@@ -60,7 +60,7 @@
6060
{
6161
"header": "RES Secondary rated current",
6262
"selector": "AccessPoint > Server > LDevice > LN[prefix=\"RES\"][lnClass=\"TCTR\"]",
63-
"dataAttributePath": ["ARtgSec", "stVal"]
63+
"dataAttributePath": ["ARtgSec", "setVal"]
6464
},
6565
{
6666
"header": "UL1 Primary rated voltage",
@@ -70,7 +70,7 @@
7070
{
7171
"header": "UL1 Secondary rated voltage",
7272
"selector": "AccessPoint > Server > LDevice > LN[prefix=\"UL1\"][lnClass=\"TVTR\"]",
73-
"dataAttributePath": ["VRtgSec", "stVal"]
73+
"dataAttributePath": ["VRtgSec", "setVal"]
7474
},
7575
{
7676
"header": "UL1 Devision ratio",
@@ -85,7 +85,7 @@
8585
{
8686
"header": "RES Secondary rated voltage",
8787
"selector": "AccessPoint > Server > LDevice > LN[prefix=\"RES\"][lnClass=\"TVTR\"]",
88-
"dataAttributePath": ["VRtgSec", "stVal"]
88+
"dataAttributePath": ["VRtgSec", "setVal"]
8989
},
9090
{
9191
"header": "RES Devision ratio",

src/menu/ExportIEDParams.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,21 @@ export default class ExportIEDParamsPlugin extends LitElement {
4040
* Find the DO/DA/BDA element with the passed name defined below the type element passed.
4141
* Depending on the type of Type element the query will search for the DO/DA/BDA element.
4242
*
43-
* @param typeElement - The type element, this can be a LNodeType, DOType or DAType element.
44-
* @param name - The name of the element to search for below the type element.
43+
* @param dataTypeTemplate - The type element, this can be a LNodeType, DOType or DAType element.
44+
* @param name - The name of the element to search for below the type element.
4545
*/
46-
private getDataElement(typeElement: Element, name: string): Element | null {
47-
if (typeElement.tagName === 'LNodeType') {
48-
return typeElement.querySelector(`:scope > DO[name="${name}"]`);
49-
} else if (typeElement.tagName === 'DOType') {
50-
return typeElement.querySelector(
46+
private getDataTypeChildElement(
47+
dataTypeTemplate: Element,
48+
name: string
49+
): Element | null {
50+
if (dataTypeTemplate.tagName === 'LNodeType') {
51+
return dataTypeTemplate.querySelector(`:scope > DO[name="${name}"]`);
52+
} else if (dataTypeTemplate.tagName === 'DOType') {
53+
return dataTypeTemplate.querySelector(
5154
`:scope > SDO[name="${name}"], :scope > DA[name="${name}"]`
5255
);
5356
} else {
54-
return typeElement.querySelector(`:scope > BDA[name="${name}"]`);
57+
return dataTypeTemplate.querySelector(`:scope > BDA[name="${name}"]`);
5558
}
5659
}
5760

@@ -75,17 +78,19 @@ export default class ExportIEDParamsPlugin extends LitElement {
7578
* Use the DO/SDO/DA/BDA data element to search for the type element. In case of the DO/SDO a DOType is search
7679
* for and otherwise a DAType is searched for if the data element is a struct type.
7780
*
78-
* @param lastElement - The data element to retrieve its type definition.
81+
* @param leafElement - The data element to retrieve its type definition.
7982
*/
80-
private getTypeElement(lastElement: Element | null): Element | null {
81-
if (lastElement) {
82-
if (['DO', 'SDO'].includes(lastElement.tagName)) {
83-
const type = lastElement.getAttribute('type') ?? '';
83+
private getDataTypeTemplateElement(
84+
leafElement: Element | null
85+
): Element | null {
86+
if (leafElement) {
87+
if (['DO', 'SDO'].includes(leafElement.tagName)) {
88+
const type = leafElement.getAttribute('type') ?? '';
8489
return this.doc.querySelector(`DOType[id="${type}"]`);
8590
} else {
86-
const bType = lastElement.getAttribute('bType') ?? '';
91+
const bType = leafElement.getAttribute('bType') ?? '';
8792
if (bType === 'Struct') {
88-
const type = lastElement.getAttribute('type') ?? '';
93+
const type = leafElement.getAttribute('type') ?? '';
8994
return this.doc.querySelector(`DAType[id="${type}"]`);
9095
}
9196
}
@@ -111,20 +116,20 @@ export default class ExportIEDParamsPlugin extends LitElement {
111116
) {
112117
// Search LNodeType Element that is linked to the LN(0) Element.
113118
const type = lnElement.getAttribute('lnType');
114-
let typeElement = this.doc.querySelector(`LNodeType[id="${type}"]`);
115-
let lastElement: Element | null = null;
119+
let dataTypeTemplate = this.doc.querySelector(`LNodeType[id="${type}"]`);
120+
let leafElement: Element | null = null;
116121

117122
// Now start search through the Template section jumping between the type elements.
118123
dataAttributePath.forEach(name => {
119-
if (typeElement) {
120-
lastElement = this.getDataElement(typeElement, name);
121-
typeElement = this.getTypeElement(lastElement);
124+
if (dataTypeTemplate) {
125+
leafElement = this.getDataTypeChildElement(dataTypeTemplate, name);
126+
dataTypeTemplate = this.getDataTypeTemplateElement(leafElement);
122127
}
123128
});
124129

125-
if (lastElement) {
126-
const valElement = (<Element>lastElement).querySelector('Val');
127-
return valElement?.textContent ?? null;
130+
if (leafElement) {
131+
const valElement = (<Element>leafElement).querySelector('Val');
132+
return valElement?.textContent?.trim() ?? null;
128133
}
129134
}
130135
return null;
@@ -160,7 +165,7 @@ export default class ExportIEDParamsPlugin extends LitElement {
160165
.join(' > ');
161166

162167
const daiValueElement = lnElement.querySelector(daiSelector + ' Val');
163-
return daiValueElement?.textContent ?? null;
168+
return daiValueElement?.textContent?.trim() ?? null;
164169
}
165170
return null;
166171
}

src/translations/de.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ export const de: Translations = {
866866
useWebsockets: '???',
867867
},
868868
exportIEDParams: {
869-
noIEDs: '???',
869+
noIEDs: 'Keine IEDs in Projekt',
870870
},
871871
session: {
872872
headingExpiring: '???',

test/testfiles/menu/export-ied-params.scd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</SDI>
7474
</DOI>
7575
<DOI name="ARtgSec">
76-
<DAI name="stVal">
76+
<DAI name="setVal">
7777
<Val>5</Val>
7878
</DAI>
7979
</DOI>
@@ -131,7 +131,7 @@
131131
</SDI>
132132
</DOI>
133133
<DOI name="ARtgSec">
134-
<DAI name="stVal">
134+
<DAI name="setVal">
135135
<Val>5</Val>
136136
</DAI>
137137
</DOI>
@@ -162,7 +162,7 @@
162162
</SDI>
163163
</DOI>
164164
<DOI name="VRtgSec">
165-
<DAI name="stVal">
165+
<DAI name="setVal">
166166
<Val>200</Val>
167167
</DAI>
168168
</DOI>
@@ -193,7 +193,7 @@
193193
</SDI>
194194
</DOI>
195195
<DOI name="VRtgSec">
196-
<DAI name="stVal">
196+
<DAI name="setVal">
197197
<Val>200</Val>
198198
</DAI>
199199
</DOI>
@@ -236,7 +236,7 @@
236236
</SDI>
237237
</DOI>
238238
<DOI name="ARtgSec">
239-
<DAI name="stVal">
239+
<DAI name="setVal">
240240
<Val>5</Val>
241241
</DAI>
242242
</DOI>
@@ -294,7 +294,7 @@
294294
</SDI>
295295
</DOI>
296296
<DOI name="ARtgSec">
297-
<DAI name="stVal">
297+
<DAI name="setVal">
298298
<Val>10</Val>
299299
</DAI>
300300
</DOI>
@@ -325,7 +325,7 @@
325325
</SDI>
326326
</DOI>
327327
<DOI name="VRtgSec">
328-
<DAI name="stVal">
328+
<DAI name="setVal">
329329
<Val>200</Val>
330330
</DAI>
331331
</DOI>
@@ -356,7 +356,7 @@
356356
</SDI>
357357
</DOI>
358358
<DOI name="VRtgSec">
359-
<DAI name="stVal">
359+
<DAI name="setVal">
360360
<Val>250</Val>
361361
</DAI>
362362
</DOI>
@@ -410,7 +410,7 @@
410410
<DA name="t" bType="Timestamp" fc="SP"/>
411411
</DOType>
412412
<DOType cdc="INS" id="Dummy.ING">
413-
<DA name="stVal" bType="INT32" dchg="true" fc="ST"/>
413+
<DA name="setVal" bType="INT32" dchg="true" fc="SP"/>
414414
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
415415
<DA name="t" bType="Timestamp" fc="ST"/>
416416
<DA name="d" bType="VisString255" fc="DC"/>

test/unit/menu/ExportIEDParams.test.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ describe('Export IED Params Plugin -', () => {
4848
});
4949
});
5050

51-
describe('retrieve the data template element from a type element (getDataElement) -', () => {
51+
describe('retrieve the data template element from a type element (getDataTypeChildElement) -', () => {
5252
it('when called with a LNodeType element and a known name is passed then correct DO Element returned', () => {
5353
const typeElement = doc.querySelector('LNodeType[id="Dummy.TVTR"]');
5454

55-
const dataElement = plugin['getDataElement'](typeElement!, 'Beh');
55+
const dataElement = plugin['getDataTypeChildElement'](
56+
typeElement!,
57+
'Beh'
58+
);
5659
expect(dataElement).to.be.not.null;
5760
expect(dataElement?.tagName).to.be.equal('DO');
5861
expect(dataElement).to.have.attribute('type', 'OpenSCD_ENS_Beh');
@@ -61,14 +64,17 @@ describe('Export IED Params Plugin -', () => {
6164
it('when called with a LNodeType element and a unknown name is passed then null returned', () => {
6265
const typeElement = doc.querySelector('LNodeType[id="Dummy.TVTR"]');
6366

64-
const dataElement = plugin['getDataElement'](typeElement!, 'Unknown');
67+
const dataElement = plugin['getDataTypeChildElement'](
68+
typeElement!,
69+
'Unknown'
70+
);
6571
expect(dataElement).to.be.null;
6672
});
6773

6874
it('when called with a DOType element and a known name is passed then correct DO Element returned', () => {
6975
const typeElement = doc.querySelector('DOType[id="Dummy.ASG"]');
7076

71-
const dataElement = plugin['getDataElement'](typeElement!, 'q');
77+
const dataElement = plugin['getDataTypeChildElement'](typeElement!, 'q');
7278
expect(dataElement).to.be.not.null;
7379
expect(dataElement?.tagName).to.be.equal('DA');
7480
expect(dataElement).to.have.attribute('bType', 'Quality');
@@ -77,16 +83,22 @@ describe('Export IED Params Plugin -', () => {
7783
it('when called with a DOType element and a unknown name is passed then null returned', () => {
7884
const typeElement = doc.querySelector('DOType[id="Dummy.ASG"]');
7985

80-
const dataElement = plugin['getDataElement'](typeElement!, 'Unknown');
86+
const dataElement = plugin['getDataTypeChildElement'](
87+
typeElement!,
88+
'Unknown'
89+
);
8190
expect(dataElement).to.be.null;
8291
});
8392

84-
it('when called with a DAType element and a known name is passed then correct DO Element returned', () => {
93+
it('when called with a DAType element and a known name is passed then correct BDA Element returned', () => {
8594
const typeElement = doc.querySelector(
8695
'DAType[id="OpenSCD_Cancel_BehaviourModeKind"]'
8796
);
8897

89-
const dataElement = plugin['getDataElement'](typeElement!, 'ctlNum');
98+
const dataElement = plugin['getDataTypeChildElement'](
99+
typeElement!,
100+
'ctlNum'
101+
);
90102
expect(dataElement).to.be.not.null;
91103
expect(dataElement?.tagName).to.be.equal('BDA');
92104
expect(dataElement).to.have.attribute('bType', 'INT8U');
@@ -97,29 +109,32 @@ describe('Export IED Params Plugin -', () => {
97109
'DAType[id="OpenSCD_Cancel_BehaviourModeKind"]'
98110
);
99111

100-
const dataElement = plugin['getDataElement'](typeElement!, 'Unknown');
112+
const dataElement = plugin['getDataTypeChildElement'](
113+
typeElement!,
114+
'Unknown'
115+
);
101116
expect(dataElement).to.be.null;
102117
});
103118
});
104119

105-
describe('retrieve the type element from a data element (getTypeElement) -', () => {
120+
describe('retrieve the type element from a data element (getDataTypeTemplateElement) -', () => {
106121
it('when passing a DO Element then the DOType Element is returned', () => {
107122
const doElement = doc.querySelector(
108123
'LNodeType[id="Dummy.TCTR"] > DO[name="Rat"]'
109124
);
110125

111-
const typeElement = plugin['getTypeElement'](doElement);
126+
const typeElement = plugin['getDataTypeTemplateElement'](doElement);
112127
expect(typeElement).to.be.not.null;
113128
expect(typeElement?.tagName).to.be.equal('DOType');
114129
expect(typeElement).to.have.attribute('cdc', 'ASG');
115130
});
116131

117-
it('when passing a DA Element then the DOType Element is returned', () => {
132+
it('when passing a DA Element then the DAType Element is returned', () => {
118133
const daElement = doc.querySelector(
119134
'DOType[id="OpenSCD_ENC_Mod"] > DA[name="Oper"]'
120135
);
121136

122-
const typeElement = plugin['getTypeElement'](daElement);
137+
const typeElement = plugin['getDataTypeTemplateElement'](daElement);
123138
expect(typeElement).to.be.not.null;
124139
expect(typeElement?.tagName).to.be.equal('DAType');
125140
expect(typeElement).to.have.attribute(
@@ -193,7 +208,7 @@ describe('Export IED Params Plugin -', () => {
193208
it('when something else as a LN element is passed then null is returned', () => {
194209
const value = plugin['getDataAttributeTemplateValue'](iedElement, [
195210
'ARtgSec',
196-
'stVal',
211+
'setVal',
197212
]);
198213

199214
expect(value).to.be.null;
@@ -214,7 +229,7 @@ describe('Export IED Params Plugin -', () => {
214229
it('when a instance value is defined then that value is returned', () => {
215230
const value = plugin['getDataAttributeInstanceValue'](lnElement, [
216231
'ARtgSec',
217-
'stVal',
232+
'setVal',
218233
]);
219234

220235
expect(value).to.be.equal('5');
@@ -238,7 +253,7 @@ describe('Export IED Params Plugin -', () => {
238253
it('when something else as a LN element is passed then null is returned', () => {
239254
const value = plugin['getDataAttributeInstanceValue'](iedElement, [
240255
'ARtgSec',
241-
'stVal',
256+
'setVal',
242257
]);
243258

244259
expect(value).to.be.null;
@@ -257,7 +272,7 @@ describe('Export IED Params Plugin -', () => {
257272
it('when a instance value is defined then that value is returned', () => {
258273
const value = plugin['getDataAttributeValue'](lnElement, [
259274
'ARtgSec',
260-
'stVal',
275+
'setVal',
261276
]);
262277

263278
expect(value).to.be.equal('5');

0 commit comments

Comments
 (0)