Skip to content

Commit 2f0bad9

Browse files
fix(menu/subscriberinfo): fix lnInst attribute for lnClass LLN0 (openscd#749)
1 parent b4eed22 commit 2f0bad9

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

src/menu/SubscriberInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function addIEDName(extRef: Element, gseControl: Element): Element | null {
5050
ldInst: lDevice.getAttribute('inst') ?? '',
5151
prefix: anyln.getAttribute('prefix') ?? '',
5252
lnClass: anyln.getAttribute('lnClass') ?? '',
53-
lnInst: anyln.getAttribute('inst') ?? '',
53+
lnInst: anyln.getAttribute('inst') || null,
5454
}
5555
);
5656
iedName.innerHTML = ied.getAttribute('name')!;

test/testfiles/subscriberinfo2007.scd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@
252252
</DataSet>
253253
<GSEControl type="GOOSE" appID="0002" fixedOffs="false" confRev="1" name="GCB" datSet="GooseDataSet1">
254254
</GSEControl>
255+
<Inputs>
256+
<ExtRef iedName="IED1" ldInst="Disconnectors" prefix="DC" lnClass="XSWI" lnInst="1" doName="Pos" daName="stVal"/>
257+
<ExtRef iedName="IED1" ldInst="Disconnectors" prefix="DC" lnClass="XSWI" lnInst="1" doName="Pos" daName="q"/>
258+
</Inputs>
255259
</LN0>
256260
<LN lnClass="LPHD" inst="1" lnType="Dummy.LPHD1"/>
257261
<LN lnClass="XCBR" inst="1" lnType="Dummy.XCBR1">
@@ -654,4 +658,4 @@
654658
<EnumVal ord="8">process</EnumVal>
655659
</EnumType>
656660
</DataTypeTemplates>
657-
</SCL>
661+
</SCL>

test/unit/editors/subscriberinfo.test.ts

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from '@open-wc/testing';
33
import { createMissingIEDNameSubscriberInfo } from '../../../src/menu/SubscriberInfo.js';
44
import { Create, isCreate, SimpleAction } from '../../../src/foundation.js';
55

6-
describe('SubscriberInfo', () => {
6+
describe('menu plugin adding subscriber info', () => {
77
describe('for Edition2 and higher files', () => {
88
let doc: Document;
99
let actions: SimpleAction[];
@@ -15,11 +15,11 @@ describe('SubscriberInfo', () => {
1515
actions = createMissingIEDNameSubscriberInfo(doc);
1616
});
1717

18-
it('creates two SimpleActions', () => {
19-
expect(actions.length).to.equal(3);
18+
it('does create one action per necessary IEDName creation', () => {
19+
expect(actions.length).to.equal(4);
2020
});
2121

22-
it('the first writes the correct IEDName element', () => {
22+
it('creates correct IEDName element referencing LN0 element', () => {
2323
expect(actions[0]).to.satisfy(isCreate);
2424
expect(
2525
(<Element>(<Create>actions[0]).new.element).getAttribute('apRef')
@@ -32,32 +32,34 @@ describe('SubscriberInfo', () => {
3232
).to.equal('');
3333
expect(
3434
(<Element>(<Create>actions[0]).new.element).getAttribute('lnClass')
35-
).to.equal('XSWI');
35+
).to.equal('LLN0');
3636
expect(
3737
(<Element>(<Create>actions[0]).new.element).getAttribute('lnInst')
38-
).to.equal('1');
38+
).to.equal(null);
3939
expect((<Create>actions[0]).new.element.textContent).to.equal('IED2');
4040
});
41-
it('the second writes the correct IEDName element', () => {
41+
42+
it('creates correct IEDName element referencing LN element', () => {
4243
expect(actions[1]).to.satisfy(isCreate);
4344
expect(
4445
(<Element>(<Create>actions[1]).new.element).getAttribute('apRef')
4546
).to.equal('P1');
4647
expect(
4748
(<Element>(<Create>actions[1]).new.element).getAttribute('ldInst')
48-
).to.equal('Disconnectors');
49+
).to.equal('CBSW');
4950
expect(
5051
(<Element>(<Create>actions[1]).new.element).getAttribute('prefix')
51-
).to.equal('DC');
52+
).to.equal('');
5253
expect(
5354
(<Element>(<Create>actions[1]).new.element).getAttribute('lnClass')
54-
).to.equal('CSWI');
55+
).to.equal('XSWI');
5556
expect(
5657
(<Element>(<Create>actions[1]).new.element).getAttribute('lnInst')
5758
).to.equal('1');
58-
expect((<Create>actions[1]).new.element.textContent).to.equal('IED1');
59+
expect((<Create>actions[1]).new.element.textContent).to.equal('IED2');
5960
});
60-
it('the third writes the correct IEDName element', () => {
61+
62+
it('creates correct IEDName element referencing LN element', () => {
6163
expect(actions[2]).to.satisfy(isCreate);
6264
expect(
6365
(<Element>(<Create>actions[2]).new.element).getAttribute('apRef')
@@ -67,15 +69,35 @@ describe('SubscriberInfo', () => {
6769
).to.equal('Disconnectors');
6870
expect(
6971
(<Element>(<Create>actions[2]).new.element).getAttribute('prefix')
70-
).to.equal('');
72+
).to.equal('DC');
7173
expect(
7274
(<Element>(<Create>actions[2]).new.element).getAttribute('lnClass')
7375
).to.equal('CSWI');
7476
expect(
7577
(<Element>(<Create>actions[2]).new.element).getAttribute('lnInst')
76-
).to.equal('2');
78+
).to.equal('1');
7779
expect((<Create>actions[2]).new.element.textContent).to.equal('IED1');
7880
});
81+
82+
it('creates correct IEDName element referencing LN element', () => {
83+
expect(actions[3]).to.satisfy(isCreate);
84+
expect(
85+
(<Element>(<Create>actions[3]).new.element).getAttribute('apRef')
86+
).to.equal('P1');
87+
expect(
88+
(<Element>(<Create>actions[3]).new.element).getAttribute('ldInst')
89+
).to.equal('Disconnectors');
90+
expect(
91+
(<Element>(<Create>actions[3]).new.element).getAttribute('prefix')
92+
).to.equal('');
93+
expect(
94+
(<Element>(<Create>actions[3]).new.element).getAttribute('lnClass')
95+
).to.equal('CSWI');
96+
expect(
97+
(<Element>(<Create>actions[3]).new.element).getAttribute('lnInst')
98+
).to.equal('2');
99+
expect((<Create>actions[3]).new.element.textContent).to.equal('IED1');
100+
});
79101
});
80102

81103
describe('for Edition1 files', () => {
@@ -89,21 +111,21 @@ describe('SubscriberInfo', () => {
89111
actions = createMissingIEDNameSubscriberInfo(doc);
90112
});
91113

92-
it('creates two SimpleActions', () => {
114+
it('does create one action per necessary IEDName creation', () => {
93115
expect(actions.length).to.equal(2);
94116
});
95117

96-
it('the first writing correct IEDName element', () => {
118+
it('creates correct IEDName element', () => {
97119
expect(actions[0]).to.satisfy(isCreate);
98120
expect((<Create>actions[0]).new.element.textContent).to.equal('IED1');
99121
});
100122

101-
it('the second writing correct IEDName element', () => {
123+
it('creates correct IEDName element', () => {
102124
expect(actions[1]).to.satisfy(isCreate);
103125
expect((<Create>actions[1]).new.element.textContent).to.equal('IED1');
104126
});
105127

106-
it('not writing Edition2 attributes into the IEDName element', () => {
128+
it('does not add Edition2 attributes into the IEDName element', () => {
107129
actions.forEach(action => {
108130
expect((<Element>(<Create>action).new.element).getAttribute('apRef')).to
109131
.be.null;

0 commit comments

Comments
 (0)