Skip to content

Commit 0253adc

Browse files
feat(zeroline): show SampledValueControl for IED and whole project (openscd#477)
* feat(wizards/sampledvaluecontrol): add select wizard * feat(zeroline-pane): add button to trigger SMV select wizard * feat(zeroline/ied-editor): access SampledValueControl elements
1 parent 12c9123 commit 0253adc

File tree

12 files changed

+779
-7
lines changed

12 files changed

+779
-7
lines changed

src/translations/de.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const de: Translations = {
6666
iedsloading: 'IEDs werden geladen...',
6767
commmap: 'Kommunikationszuordnung',
6868
gsecontrol: 'GOOSEs anzeigen',
69+
smvcontrol: 'Sampled Values anzeigen',
6970
},
7071
editing: {
7172
created: '{{ name }} hinzugefügt',
@@ -162,7 +163,7 @@ export const de: Translations = {
162163
searchHelper: 'IED auswählen',
163164
searchHelperDesc: '({{description}})',
164165
missing: 'Kein IED vorhanden',
165-
toggleChildElements: "???"
166+
toggleChildElements: '???',
166167
},
167168
powertransformer: {
168169
wizard: {

src/translations/en.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const en = {
6464
iedsloading: 'Loading IEDs...',
6565
commmap: 'Communication mapping',
6666
gsecontrol: 'Show all GOOSEs',
67+
smvcontrol: 'Show all Sampled Values',
6768
},
6869
editing: {
6970
created: 'Added {{ name }}',
@@ -156,10 +157,10 @@ export const en = {
156157
},
157158
},
158159
iededitor: {
159-
searchHelper: "Select IED",
160-
searchHelperDesc: "({{description}})",
160+
searchHelper: 'Select IED',
161+
searchHelperDesc: '({{description}})',
161162
missing: 'No IED',
162-
toggleChildElements: "Toggle child elements"
163+
toggleChildElements: 'Toggle child elements',
163164
},
164165
powertransformer: {
165166
wizard: {
@@ -168,7 +169,7 @@ export const en = {
168169
title: {
169170
edit: 'Edit power transformer',
170171
},
171-
}
172+
},
172173
},
173174
voltagelevel: {
174175
name: 'Voltage level',

src/wizards/sampledvaluecontrol.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { html } from 'lit-element';
2+
import { get } from 'lit-translate';
3+
4+
import { identity, isPublic, Wizard } from '../foundation.js';
5+
6+
export function selectSampledValueControlWizard(element: Element): Wizard {
7+
const smvControls = Array.from(
8+
element.querySelectorAll('SampledValueControl')
9+
).filter(isPublic);
10+
11+
return [
12+
{
13+
title: get('wizard.title.select', { tagName: 'SampledValueControl' }),
14+
content: [
15+
html`<filtered-list
16+
>${smvControls.map(
17+
smvControl =>
18+
html`<mwc-list-item twoline value="${identity(smvControl)}"
19+
><span>${smvControl.getAttribute('name')}</span
20+
><span slot="secondary"
21+
>${identity(smvControl)}</span
22+
></mwc-list-item
23+
>`
24+
)}</filtered-list
25+
>`,
26+
],
27+
},
28+
];
29+
}

src/zeroline-pane.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import './zeroline/substation-editor.js';
1818
import './zeroline/ied-editor.js';
1919
import { Settings } from './Setting.js';
2020
import { communicationMappingWizard } from './wizards/commmap-wizards.js';
21-
import { gooseIcon } from './icons.js';
21+
import { gooseIcon, smvIcon } from './icons.js';
2222
import { isPublic, newWizardEvent } from './foundation.js';
2323
import { selectGseControlWizard } from './wizards/gsecontrol.js';
2424
import { wizards } from './wizards/wizard-library.js';
2525
import { getAttachedIeds } from './zeroline/foundation.js';
26+
import { selectSampledValueControlWizard } from './wizards/sampledvaluecontrol.js';
2627

2728
function shouldShowIEDs(): boolean {
2829
return localStorage.getItem('showieds') === 'on';
@@ -47,6 +48,7 @@ export class ZerolinePane extends LitElement {
4748
@query('#commmap') commmap!: IconButton;
4849
@query('#showieds') showieds!: IconButtonToggle;
4950
@query('#gsecontrol') gsecontrol!: IconButton;
51+
@query('#smvcontrol') smvcontrol!: IconButton;
5052
@query('#createsubstation') createsubstation!: IconButton;
5153

5254
openCommunicationMapping(): void {
@@ -65,6 +67,11 @@ export class ZerolinePane extends LitElement {
6567
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
6668
}
6769

70+
openSampledValueControlSelection(): void {
71+
const wizard = selectSampledValueControlWizard(this.doc.documentElement);
72+
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
73+
}
74+
6875
toggleShowIEDs(): void {
6976
if (shouldShowIEDs()) setShowIEDs('off');
7077
else setShowIEDs('on');
@@ -119,6 +126,13 @@ export class ZerolinePane extends LitElement {
119126
>${gooseIcon}</mwc-icon-button
120127
></abbr
121128
>
129+
<abbr title="${translate('zeroline.smvcontrol')}"
130+
><mwc-icon-button
131+
id="smvcontrol"
132+
@click="${() => this.openSampledValueControlSelection()}"
133+
>${smvIcon}</mwc-icon-button
134+
></abbr
135+
>
122136
</nav>
123137
</h1>
124138
${this.renderIedContainer()}

src/zeroline/ied-editor.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import { Fab } from '@material/mwc-fab';
1313

1414
import '../action-icon.js';
1515
import { createClientLnWizard } from '../wizards/clientln.js';
16-
import { gooseIcon } from '../icons.js';
16+
import { gooseIcon, smvIcon } from '../icons.js';
1717
import { newWizardEvent } from '../foundation.js';
1818
import { selectGseControlWizard } from '../wizards/gsecontrol.js';
19+
import { selectSampledValueControlWizard } from '../wizards/sampledvaluecontrol.js';
1920

2021
/** [[`SubstationEditor`]] subeditor for a child-less `IED` element. */
2122
@customElement('ied-editor')
@@ -44,6 +45,11 @@ export class IedEditor extends LitElement {
4445
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
4546
}
4647

48+
private openSmvControlSelection(): void {
49+
const wizard = selectSampledValueControlWizard(this.element);
50+
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
51+
}
52+
4753
render(): TemplateResult {
4854
return html`<action-icon label="${this.name}" icon="developer_board"
4955
><mwc-fab
@@ -59,6 +65,12 @@ export class IedEditor extends LitElement {
5965
mini
6066
@click="${() => this.openGseControlSelection()}"
6167
><mwc-icon slot="icon">${gooseIcon}</mwc-icon></mwc-fab
68+
><mwc-fab
69+
slot="action"
70+
class="selectsmv"
71+
mini
72+
@click="${() => this.openSmvControlSelection()}"
73+
><mwc-icon slot="icon">${smvIcon}</mwc-icon></mwc-fab
6274
></action-icon
6375
> `;
6476
}

test/integration/zeroline-pane.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ describe('zeroline-pane wizarding editing integration', () => {
4444
);
4545
});
4646

47+
it('opens selectSampledValueControlWizard for the complete SCL file', async () => {
48+
zeroline.smvcontrol.click();
49+
await parent.updateComplete;
50+
51+
expect(parent.wizardUI.dialog).to.exist;
52+
const smvControlList = <FilteredList>(
53+
parent.wizardUI.dialog?.querySelector('filtered-list')
54+
);
55+
await smvControlList.updateComplete;
56+
expect(smvControlList.items.length).to.equal(
57+
doc.querySelectorAll('SampledValueControl').length
58+
);
59+
});
60+
4761
it('add Substation element with createSubstationWizard', async () => {
4862
expect(doc.querySelector('Substation[name="newSubstation"]')).to.not.exist;
4963
zeroline.createsubstation.click();

0 commit comments

Comments
 (0)