Skip to content

Commit 003161f

Browse files
authored
fix: Require lnInst only for regular lns (openscd#1713)
1 parent cf45fe9 commit 003161f

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

packages/plugins/src/editors/subscription/foundation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,11 @@ export function canCreateValidExtRef(
690690
'lnInst',
691691
'doName',
692692
].map(attr => fcda.getAttribute(attr));
693-
if (!iedName || !ldInst || !lnClass || !lnInst || !doName) {
693+
694+
// lnInst is only required for ln that are not ln0
695+
const hasValidLnInst = lnClass === 'LLN0' || !!lnInst;
696+
697+
if (!iedName || !ldInst || !lnClass || !hasValidLnInst || !doName) {
694698
return false;
695699
}
696700

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" version="2007" revision="B" release="4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.nrec.com">
3+
<IED name="IED1" type="PCS-221S" originalSclVersion="2007" originalSclRevision="B">
4+
<AccessPoint name="S1">
5+
<Server>
6+
<Authentication />
7+
<LDevice inst="LD0">
8+
<LN0 desc="LLN0" lnType="LLN0_type" lnClass="LLN0" inst="">
9+
<DataSet name="ds1">
10+
<FCDA ldInst="LD0" prefix="" lnClass="LLN0" doName="AnIn1"/>
11+
</DataSet>
12+
<GSEControl name="gseControl" datSet="ds1" confRev="10001" appID="gse1" />
13+
</LN0>
14+
</LDevice>
15+
</Server>
16+
</AccessPoint>
17+
</IED>
18+
</SCL>

packages/plugins/test/unit/editors/subscription/foundation.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect } from '@open-wc/testing';
22

33
import {
4+
canCreateValidExtRef,
45
createExtRefElement,
56
getExistingSupervision,
67
getExtRef,
@@ -334,4 +335,21 @@ describe('foundation', () => {
334335
expect(extRef).to.equal(expectedExtRef)
335336
});
336337
});
338+
339+
describe('regression test for bugfix 1711', () => {
340+
beforeEach(async () => {
341+
doc = await fetch('/test/testfiles/editors/bugfix1711-can-create-extref.scd')
342+
.then(response => response.text())
343+
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
344+
});
345+
346+
it('should return true for canCreateValidExtRef on FCDA without lnInst for LN0', () => {
347+
const fcda = doc.querySelector('FCDA')!;
348+
const controlBlock = doc.querySelector('IED[name="IED1"] GSEControl[name="gseControl"]')!;
349+
350+
const canCreateExtRef = canCreateValidExtRef(fcda, controlBlock);
351+
352+
expect(canCreateExtRef).to.be.true;
353+
});
354+
});
337355
});

0 commit comments

Comments
 (0)