Skip to content

Commit d88b7d2

Browse files
juancho0202Dennis Labordus
andauthored
feat(editors/subscriber-later-binding): Show connected and available ExtRef on FCDA selection (GOOSE) (openscd#995)
* refactor: making ext-ref-laterbinding-list reusable for both GSEControl and SVC elements * translate: updating translation files * feat: Adding extref-later-binding-list for GSEControl elements * test(GooseSubscriberLaterBinding): updating tests after refactor and new tests for GOOSE extref list as well * fix: using getSclSchemaVersion, removing get version() * refactor: checking extRefElement[serviceType] for GOOSE and SMV * chore: update fn name in check ext-ref requirements Co-authored-by: Dennis Labordus <[email protected]>
1 parent 6e610e2 commit d88b7d2

15 files changed

+966
-40
lines changed

src/editors/GooseSubscriberLaterBinding.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LitElement, property, html, TemplateResult, css } from 'lit-element';
22

33
import './subscription/later-binding/fcda-later-binding-list.js';
4+
import './subscription/later-binding/ext-ref-laterbinding-list.js';
45

56
export default class GooseSubscribeLaterBindingPlugin extends LitElement {
67
@property({ attribute: false })
@@ -9,8 +10,18 @@ export default class GooseSubscribeLaterBindingPlugin extends LitElement {
910
render(): TemplateResult {
1011
return html`<div>
1112
<div class="container">
12-
<fcda-later-binding-list .doc=${this.doc} controlTag="GSEControl">
13+
<fcda-later-binding-list
14+
class="column"
15+
.doc=${this.doc}
16+
controlTag="GSEControl"
17+
>
1318
</fcda-later-binding-list>
19+
<extref-later-binding-list
20+
class="column"
21+
controlTag="GSEControl"
22+
.doc=${this.doc}
23+
>
24+
</extref-later-binding-list>
1425
</div>
1526
</div>`;
1627
}
@@ -21,7 +32,17 @@ export default class GooseSubscribeLaterBindingPlugin extends LitElement {
2132
}
2233
2334
.container {
35+
display: flex;
2436
padding: 8px 6px 16px;
37+
height: calc(100vh - 136px);
38+
}
39+
40+
.column {
41+
flex: 50%;
42+
margin: 0px 6px 0px;
43+
min-width: 300px;
44+
height: 100%;
45+
overflow-y: auto;
2546
}
2647
`;
2748
}

src/editors/SMVSubscriberLaterBinding.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { css, html, LitElement, property, TemplateResult } from 'lit-element';
22

33
import './subscription/later-binding/fcda-later-binding-list.js';
4-
import './subscription/smv-laterbinding/ext-ref-laterbinding-list.js';
4+
import './subscription/later-binding/ext-ref-laterbinding-list.js';
55

66
/** An editor [[`plugin`]] for Subscribe Later Binding (SMV). */
77
export default class SMVSubscribeLaterBindingPlugin extends LitElement {
@@ -17,7 +17,11 @@ export default class SMVSubscribeLaterBindingPlugin extends LitElement {
1717
controlTag="SampledValueControl"
1818
>
1919
</fcda-later-binding-list>
20-
<extref-later-binding-list class="column" .doc=${this.doc}>
20+
<extref-later-binding-list
21+
class="column"
22+
.doc=${this.doc}
23+
controlTag="SampledValueControl"
24+
>
2125
</extref-later-binding-list>
2226
</div>
2327
</div>`;

src/editors/subscription/foundation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function canCreateValidExtRef(
9494
return true;
9595
}
9696

97-
const serviceTypes: Partial<Record<string, string>> = {
97+
export const serviceTypes: Partial<Record<string, string>> = {
9898
ReportControl: 'Report',
9999
GSEControl: 'GOOSE',
100100
SampledValueControl: 'SMV',

src/editors/subscription/smv-laterbinding/ext-ref-laterbinding-list.ts renamed to src/editors/subscription/later-binding/ext-ref-laterbinding-list.ts

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import {
1818
identity,
1919
newActionEvent,
2020
Replace,
21+
getSclSchemaVersion,
2122
} from '../../../foundation.js';
2223

23-
import { styles, updateExtRefElement } from '../foundation.js';
24+
import { styles, updateExtRefElement, serviceTypes } from '../foundation.js';
2425
import { FcdaSelectEvent, getFcdaTitleValue } from './foundation.js';
2526

2627
/**
@@ -31,9 +32,11 @@ import { FcdaSelectEvent, getFcdaTitleValue } from './foundation.js';
3132
export class ExtRefLaterBindingList extends LitElement {
3233
@property({ attribute: false })
3334
doc!: XMLDocument;
35+
@property()
36+
controlTag!: 'SampledValueControl' | 'GSEControl';
3437

3538
@state()
36-
currentSelectedSvcElement: Element | undefined;
39+
currentSelectedControlElement: Element | undefined;
3740
@state()
3841
currentSelectedFcdaElement: Element | undefined;
3942
@state()
@@ -77,7 +80,7 @@ export class ExtRefLaterBindingList extends LitElement {
7780
}
7881

7982
private async onFcdaSelectEvent(event: FcdaSelectEvent) {
80-
this.currentSelectedSvcElement = event.detail.svc;
83+
this.currentSelectedControlElement = event.detail.controlElement;
8184
this.currentSelectedFcdaElement = event.detail.fcda;
8285

8386
// Retrieve the IED Element to which the FCDA belongs.
@@ -97,6 +100,33 @@ export class ExtRefLaterBindingList extends LitElement {
97100
);
98101
}
99102

103+
private checkEditionSpecificRequirements(extRefElement: Element): boolean {
104+
if (getSclSchemaVersion(extRefElement.ownerDocument) === '2003')
105+
return true;
106+
return (
107+
extRefElement.getAttribute('serviceType') ===
108+
serviceTypes[this.controlTag] &&
109+
extRefElement.getAttribute('srcLDInst') ===
110+
this.currentSelectedControlElement
111+
?.closest('LDevice')
112+
?.getAttribute('inst') &&
113+
(extRefElement.getAttribute('scrPrefix') || '') ===
114+
(this.currentSelectedControlElement
115+
?.closest('LN0')
116+
?.getAttribute('prefix') || '') &&
117+
extRefElement.getAttribute('srcLNClass') ===
118+
this.currentSelectedControlElement
119+
?.closest('LN0')
120+
?.getAttribute('lnClass') &&
121+
(extRefElement.getAttribute('srcLNInst') || '') ===
122+
this.currentSelectedControlElement
123+
?.closest('LN0')
124+
?.getAttribute('inst') &&
125+
extRefElement.getAttribute('srcCBName') ===
126+
this.currentSelectedControlElement?.getAttribute('name')
127+
);
128+
}
129+
100130
/**
101131
* Check if specific attributes from the ExtRef Element are the same as the ones from the FCDA Element
102132
* and also if the IED Name is the same. If that is the case this ExtRef subscribes to the selected FCDA
@@ -113,7 +143,8 @@ export class ExtRefLaterBindingList extends LitElement {
113143
this.sameAttributeValue(extRefElement, 'lnClass') &&
114144
this.sameAttributeValue(extRefElement, 'lnInst') &&
115145
this.sameAttributeValue(extRefElement, 'doName') &&
116-
this.sameAttributeValue(extRefElement, 'daName')
146+
this.sameAttributeValue(extRefElement, 'daName') &&
147+
this.checkEditionSpecificRequirements(extRefElement)
117148
);
118149
}
119150

@@ -187,7 +218,7 @@ export class ExtRefLaterBindingList extends LitElement {
187218
if (
188219
!this.currentIedElement ||
189220
!this.currentSelectedFcdaElement ||
190-
!this.currentSelectedSvcElement!
221+
!this.currentSelectedControlElement!
191222
) {
192223
return null;
193224
}
@@ -197,16 +228,16 @@ export class ExtRefLaterBindingList extends LitElement {
197228
new: {
198229
element: updateExtRefElement(
199230
extRefElement,
200-
this.currentSelectedSvcElement,
231+
this.currentSelectedControlElement,
201232
this.currentSelectedFcdaElement
202233
),
203234
},
204235
};
205236
}
206237

207238
private renderTitle(): TemplateResult {
208-
const svcName = this.currentSelectedSvcElement
209-
? getNameAttribute(this.currentSelectedSvcElement)
239+
const controlElementName = this.currentSelectedControlElement
240+
? getNameAttribute(this.currentSelectedControlElement)
210241
: undefined;
211242
const fcdaName = this.currentSelectedFcdaElement
212243
? getFcdaTitleValue(this.currentSelectedFcdaElement)
@@ -216,7 +247,8 @@ export class ExtRefLaterBindingList extends LitElement {
216247
${translate(
217248
'subscription.laterBinding.extRefList.SampledValueControl.title',
218249
{
219-
svcName: svcName ?? '-',
250+
controlTag: this.controlTag,
251+
controlElementName: controlElementName ?? '-',
220252
fcdaName: fcdaName ?? '-',
221253
}
222254
)}
@@ -323,7 +355,7 @@ export class ExtRefLaterBindingList extends LitElement {
323355

324356
render(): TemplateResult {
325357
return html` <section tabindex="0">
326-
${this.currentSelectedSvcElement && this.currentSelectedFcdaElement
358+
${this.currentSelectedControlElement && this.currentSelectedFcdaElement
327359
? html`
328360
${this.renderTitle()}
329361
<filtered-list>

src/editors/subscription/later-binding/fcda-later-binding-list.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ import { wizards } from '../../../wizards/wizard-library.js';
2727

2828
import { styles } from '../foundation.js';
2929

30-
import {
31-
getFcdaTitleValue,
32-
newFcdaSelectEvent,
33-
} from '../smv-laterbinding/foundation.js';
30+
import { getFcdaTitleValue, newFcdaSelectEvent } from './foundation.js';
3431

3532
/**
3633
* A sub element for showing all Goose/Sampled Value Controls.

src/editors/subscription/smv-laterbinding/foundation.ts renamed to src/editors/subscription/later-binding/foundation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ export function getFcdaTitleValue(fcdaElement: Element): string {
77
}
88

99
export interface FcdaSelectDetail {
10-
svc: Element | undefined;
10+
controlElement: Element | undefined;
1111
fcda: Element | undefined;
1212
}
1313
export type FcdaSelectEvent = CustomEvent<FcdaSelectDetail>;
1414
export function newFcdaSelectEvent(
15-
svc: Element | undefined,
15+
controlElement: Element | undefined,
1616
fcda: Element | undefined,
1717
eventInitDict?: CustomEventInit<FcdaSelectDetail>
1818
): FcdaSelectEvent {
1919
return new CustomEvent<FcdaSelectDetail>('fcda-select', {
2020
bubbles: true,
2121
composed: true,
2222
...eventInitDict,
23-
detail: { svc, fcda, ...eventInitDict?.detail },
23+
detail: { controlElement, fcda, ...eventInitDict?.detail },
2424
});
2525
}
2626

src/translations/de.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const de: Translations = {
155155
compareButton: 'Starte Vergleich',
156156
attributes: 'Attribute von {{ elementName }}',
157157
children: 'Kindelemente von {{ elementName }}',
158-
filterMutables: 'Projektspzifische Unterschiede ausblenden'
158+
filterMutables: 'Projektspzifische Unterschiede ausblenden',
159159
},
160160
log: {
161161
name: 'Protokoll',
@@ -385,10 +385,8 @@ export const de: Translations = {
385385
},
386386
},
387387
extRefList: {
388-
SampledValueControl: {
389-
title:
390-
'Ausgewählter Sampled Value Datenpunkt "{{ svcName }}" / "{{ fcdaName }}"',
391-
},
388+
title:
389+
'Ausgewählter {{ controlTag }} Datenpunkt "{{ svcName }}" / "{{ fcdaName }}"',
392390
noSelection: 'Kein Daten-Attribut ausgewählt',
393391
noSubscribedExtRefs: 'Keine verknüpften externen Referenzen',
394392
noAvailableExtRefs:

src/translations/en.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const en = {
133133
compareButton: 'Compare',
134134
attributes: 'Attributes from {{ elementName }}',
135135
children: 'Child elements from {{ elementName }}',
136-
filterMutables: 'Filter project specific settings'
136+
filterMutables: 'Filter project specific settings',
137137
},
138138
log: {
139139
name: 'Log',
@@ -382,10 +382,8 @@ export const en = {
382382
},
383383
},
384384
extRefList: {
385-
SampledValueControl: {
386-
title:
387-
'Selected Sampled Value data "{{ svcName }}" / FCDA "{{ fcdaName }}"',
388-
},
385+
title:
386+
'Selected {{ controlTag }} data "{{ controlElementName }}" / FCDA "{{ fcdaName }}"',
389387
noSelection: 'No data attribute selected',
390388
noSubscribedExtRefs: 'No subscribed ExtRefs',
391389
noAvailableExtRefs: 'No available ExtRefs to subscribe',

test/integration/editors/SMVSubscriberLaterBinding.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Wizarding } from '../../../src/Wizarding.js';
44
import { Editing } from '../../../src/Editing.js';
55

66
import SMVSubscribeLaterBindingPlugin from '../../../src/editors/SMVSubscriberLaterBinding.js';
7-
import { ExtRefLaterBindingList } from '../../../src/editors/subscription/smv-laterbinding/ext-ref-laterbinding-list.js';
7+
import { ExtRefLaterBindingList } from '../../../src/editors/subscription/later-binding/ext-ref-laterbinding-list.js';
88
import { FCDALaterBindingList } from '../../../src/editors/subscription/later-binding/fcda-later-binding-list.js';
99

1010
describe('SMV Subscribe Later Binding plugin', () => {

0 commit comments

Comments
 (0)