Skip to content

Commit d5591b6

Browse files
danyillStef3st
andauthored
fix(editors/subscriber-message) Filter controls with datSet attribute presence, closes openscd#1262 (openscd#1263)
* fix: goose subscription reflects state incorrectly Signed-off-by: Stef3st <[email protected]> * Filter controls with datSet attribute presence, closes openscd#1262 * Update tests * Update snapshots --------- Signed-off-by: Stef3st <[email protected]> Co-authored-by: Stef3st <[email protected]> Co-authored-by: Steffen van den Driest <[email protected]>
1 parent 548f63b commit d5591b6

File tree

7 files changed

+86
-135
lines changed

7 files changed

+86
-135
lines changed

src/editors/subscription/goose/goose-list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class GooseList extends LitElement {
105105
noninteractive
106106
graphic="icon"
107107
value="${Array.from(ied.querySelectorAll('GSEControl'))
108+
.filter(cb => cb.hasAttribute('datSet'))
108109
.map(element => {
109110
const id = identity(element) as string;
110111
return typeof id === 'string' ? id : '';
@@ -119,7 +120,9 @@ export class GooseList extends LitElement {
119120
ied.querySelectorAll(
120121
':scope > AccessPoint > Server > LDevice > LN0 > GSEControl'
121122
)
122-
).map(control => this.renderGoose(control))}
123+
)
124+
.filter(cb => cb.hasAttribute('datSet'))
125+
.map(control => this.renderGoose(control))}
123126
`
124127
)}
125128
</filtered-list>

src/editors/subscription/goose/subscriber-list.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,47 +92,49 @@ export class SubscriberList extends SubscriberListContainer {
9292
`LN0 > Inputs, LN > Inputs`
9393
);
9494

95-
this.doc.querySelectorAll('GSEControl').forEach(control => {
96-
const ied = control.closest('IED')!;
95+
Array.from(this.doc.querySelectorAll('GSEControl'))
96+
.filter(cb => cb.hasAttribute('datSet'))
97+
.forEach(control => {
98+
const ied = control.closest('IED')!;
9799

98-
if (
99-
ied.getAttribute('name') ==
100-
this.currentSelectedIed?.getAttribute('name')
101-
)
102-
return;
103-
104-
/** If no Inputs is available, it's automatically available. */
105-
if (subscribedInputs.length == 0) {
106-
this.availableElements.push({ element: control });
107-
return;
108-
}
100+
if (
101+
ied.getAttribute('name') ==
102+
this.currentSelectedIed?.getAttribute('name')
103+
)
104+
return;
109105

110-
let numberOfLinkedExtRefs = 0;
111-
const dataSet = ied.querySelector(
112-
`DataSet[name="${control.getAttribute('datSet')}"]`
113-
);
106+
/** If no Inputs is available, it's automatically available. */
107+
if (subscribedInputs.length == 0) {
108+
this.availableElements.push({ element: control });
109+
return;
110+
}
111+
112+
let numberOfLinkedExtRefs = 0;
113+
const dataSet = ied.querySelector(
114+
`DataSet[name="${control.getAttribute('datSet')}"]`
115+
);
114116

115-
if (!dataSet) return;
117+
if (!dataSet) return;
116118

117-
dataSet!.querySelectorAll('FCDA').forEach(fcda => {
118-
subscribedInputs.forEach(inputs => {
119-
if (getExtRef(inputs, fcda, control)) {
120-
numberOfLinkedExtRefs++;
121-
}
119+
dataSet!.querySelectorAll('FCDA').forEach(fcda => {
120+
subscribedInputs.forEach(inputs => {
121+
if (getExtRef(inputs, fcda, control)) {
122+
numberOfLinkedExtRefs++;
123+
}
124+
});
122125
});
123-
});
124126

125-
if (numberOfLinkedExtRefs == 0) {
126-
this.availableElements.push({ element: control });
127-
return;
128-
}
127+
if (numberOfLinkedExtRefs == 0) {
128+
this.availableElements.push({ element: control });
129+
return;
130+
}
129131

130-
if (numberOfLinkedExtRefs >= dataSet!.querySelectorAll('FCDA').length) {
131-
this.subscribedElements.push({ element: control });
132-
} else {
133-
this.availableElements.push({ element: control, partial: true });
134-
}
135-
});
132+
if (numberOfLinkedExtRefs >= dataSet!.querySelectorAll('FCDA').length) {
133+
this.subscribedElements.push({ element: control });
134+
} else {
135+
this.availableElements.push({ element: control, partial: true });
136+
}
137+
});
136138

137139
this.requestUpdate();
138140
}

src/editors/subscription/sampledvalues/smv-list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export class SmvPublisherList extends LitElement {
101101
noninteractive
102102
graphic="icon"
103103
value="${Array.from(ied.querySelectorAll('SampledValueControl'))
104+
.filter(cb => cb.hasAttribute('datSet'))
104105
.map(element => {
105106
const id = identity(element) as string;
106107
return typeof id === 'string' ? id : '';
@@ -115,7 +116,9 @@ export class SmvPublisherList extends LitElement {
115116
ied.querySelectorAll(
116117
':scope > AccessPoint > Server > LDevice > LN0 > SampledValueControl'
117118
)
118-
).map(control => this.renderSmv(control))}
119+
)
120+
.filter(cb => cb.hasAttribute('datSet'))
121+
.map(control => this.renderSmv(control))}
119122
`
120123
)}
121124
</filtered-list>

src/editors/subscription/sampledvalues/subscriber-list.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,47 +92,49 @@ export class SubscriberList extends SubscriberListContainer {
9292
`LN0 > Inputs, LN > Inputs`
9393
);
9494

95-
this.doc.querySelectorAll('SampledValueControl').forEach(control => {
96-
const ied = control.closest('IED')!;
95+
Array.from(this.doc.querySelectorAll('SampledValueControl'))
96+
.filter(cb => cb.hasAttribute('datSet'))
97+
.forEach(control => {
98+
const ied = control.closest('IED')!;
9799

98-
if (
99-
ied.getAttribute('name') ==
100-
this.currentSelectedIed?.getAttribute('name')
101-
)
102-
return;
103-
104-
/** If no Inputs is available, it's automatically available. */
105-
if (subscribedInputs.length == 0) {
106-
this.availableElements.push({ element: control });
107-
return;
108-
}
100+
if (
101+
ied.getAttribute('name') ==
102+
this.currentSelectedIed?.getAttribute('name')
103+
)
104+
return;
109105

110-
let numberOfLinkedExtRefs = 0;
111-
const dataSet = ied.querySelector(
112-
`DataSet[name="${control.getAttribute('datSet')}"]`
113-
);
106+
/** If no Inputs is available, it's automatically available. */
107+
if (subscribedInputs.length == 0) {
108+
this.availableElements.push({ element: control });
109+
return;
110+
}
114111

115-
if (!dataSet) return;
112+
let numberOfLinkedExtRefs = 0;
113+
const dataSet = ied.querySelector(
114+
`DataSet[name="${control.getAttribute('datSet')}"]`
115+
);
116+
117+
if (!dataSet) return;
116118

117-
dataSet!.querySelectorAll('FCDA').forEach(fcda => {
118-
subscribedInputs.forEach(inputs => {
119-
if (getExtRef(inputs, fcda, this.currentSelectedSmvControl)) {
120-
numberOfLinkedExtRefs++;
121-
}
119+
dataSet!.querySelectorAll('FCDA').forEach(fcda => {
120+
subscribedInputs.forEach(inputs => {
121+
if (getExtRef(inputs, fcda, this.currentSelectedSmvControl)) {
122+
numberOfLinkedExtRefs++;
123+
}
124+
});
122125
});
123-
});
124126

125-
if (numberOfLinkedExtRefs == 0) {
126-
this.availableElements.push({ element: control });
127-
return;
128-
}
127+
if (numberOfLinkedExtRefs == 0) {
128+
this.availableElements.push({ element: control });
129+
return;
130+
}
129131

130-
if (numberOfLinkedExtRefs >= dataSet!.querySelectorAll('FCDA').length) {
131-
this.subscribedElements.push({ element: control });
132-
} else {
133-
this.availableElements.push({ element: control, partial: true });
134-
}
135-
});
132+
if (numberOfLinkedExtRefs >= dataSet!.querySelectorAll('FCDA').length) {
133+
this.subscribedElements.push({ element: control });
134+
} else {
135+
this.availableElements.push({ element: control, partial: true });
136+
}
137+
});
136138

137139
this.requestUpdate();
138140
}

test/integration/editors/GooseSubscriberMessageBinding.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ describe('GOOSE subscriber plugin', () => {
5151
});
5252

5353
describe('with a selected GOOSE message', () => {
54-
const nthGSEControl = 2;
54+
const nthGSEControl = 1;
5555
let fCDAs: Element[];
5656
let gseControlBlock: Element;
5757

5858
let goose: HTMLElement;
5959

6060
beforeEach(async () => {
61-
gseControlBlock = doc.querySelectorAll('GSEControl')[nthGSEControl];
61+
gseControlBlock =
62+
doc.querySelectorAll('GSEControl[datSet]')[nthGSEControl];
6263
fCDAs = Array.from(
6364
gseControlBlock.parentElement?.querySelectorAll(
6465
`DataSet[name="${gseControlBlock.getAttribute('datSet')}"] > FCDA`

test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the right hand
199199
graphic="icon"
200200
noninteractive=""
201201
tabindex="-1"
202-
value="IED1>>CircuitBreaker_CB1>GCB IED1>>CircuitBreaker_CB1>GCB2"
202+
value="IED1>>CircuitBreaker_CB1>GCB"
203203
>
204204
<span>
205205
IED1
@@ -233,26 +233,6 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the right hand
233233
>
234234
</mwc-icon-button>
235235
</mwc-list-item>
236-
<mwc-list-item
237-
aria-disabled="false"
238-
graphic="large"
239-
hasmeta=""
240-
mwc-list-item=""
241-
tabindex="-1"
242-
value="IED1>>CircuitBreaker_CB1>GCB2"
243-
>
244-
<mwc-icon slot="graphic">
245-
</mwc-icon>
246-
<span>
247-
GCB2
248-
</span>
249-
<mwc-icon-button
250-
class="hidden"
251-
icon="edit"
252-
slot="meta"
253-
>
254-
</mwc-icon-button>
255-
</mwc-list-item>
256236
<mwc-list-item
257237
aria-disabled="false"
258238
graphic="icon"
@@ -316,7 +296,7 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the right hand
316296
graphic="icon"
317297
noninteractive=""
318298
tabindex="-1"
319-
value="IED4>>CircuitBreaker_CB1>GCB IED4>>CircuitBreaker_CB1>GCB2"
299+
value="IED4>>CircuitBreaker_CB1>GCB"
320300
>
321301
<span>
322302
IED4
@@ -350,26 +330,6 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the right hand
350330
>
351331
</mwc-icon-button>
352332
</mwc-list-item>
353-
<mwc-list-item
354-
aria-disabled="false"
355-
graphic="large"
356-
hasmeta=""
357-
mwc-list-item=""
358-
tabindex="-1"
359-
value="IED4>>CircuitBreaker_CB1>GCB2"
360-
>
361-
<mwc-icon slot="graphic">
362-
</mwc-icon>
363-
<span>
364-
GCB2
365-
</span>
366-
<mwc-icon-button
367-
class="hidden"
368-
icon="edit"
369-
slot="meta"
370-
>
371-
</mwc-icon-button>
372-
</mwc-list-item>
373333
</filtered-list>
374334
</section>
375335
`;

test/unit/editors/subscription/goose/__snapshots__/goose-list.test.snap.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ snapshots["goose-list looks like the latest snapshot with a document loaded"] =
1212
graphic="icon"
1313
noninteractive=""
1414
tabindex="-1"
15-
value="IED1>>CircuitBreaker_CB1>GCB IED1>>CircuitBreaker_CB1>GCB2"
15+
value="IED1>>CircuitBreaker_CB1>GCB"
1616
>
1717
<span>
1818
IED1
@@ -46,26 +46,6 @@ snapshots["goose-list looks like the latest snapshot with a document loaded"] =
4646
>
4747
</mwc-icon-button>
4848
</mwc-list-item>
49-
<mwc-list-item
50-
aria-disabled="false"
51-
graphic="large"
52-
hasmeta=""
53-
mwc-list-item=""
54-
tabindex="-1"
55-
value="IED1>>CircuitBreaker_CB1>GCB2"
56-
>
57-
<mwc-icon slot="graphic">
58-
</mwc-icon>
59-
<span>
60-
GCB2
61-
</span>
62-
<mwc-icon-button
63-
class="hidden"
64-
icon="edit"
65-
slot="meta"
66-
>
67-
</mwc-icon-button>
68-
</mwc-list-item>
6949
<mwc-list-item
7050
aria-disabled="false"
7151
graphic="icon"

0 commit comments

Comments
 (0)