Skip to content

Commit 24a5659

Browse files
author
Dennis Labordus
authored
Merge pull request #180 from com-pas/upstream-v0.22.0
Merge version v0.22.0 from OpenSCD
2 parents 6003bde + 89376e1 commit 24a5659

File tree

56 files changed

+6703
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+6703
-509
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [0.22.0](https://github.com/openscd/open-scd/compare/v0.21.0...v0.22.0) (2022-08-22)
6+
7+
8+
### Features
9+
10+
* **editor/laterbinding:** Added first part for SMV Later Binding Editor ([#927](https://github.com/openscd/open-scd/issues/927)) ([5bfc3aa](https://github.com/openscd/open-scd/commits/5bfc3aa5f5e91c8a313875beb6b225a81f88f663))
11+
* **editor/laterbinding:** Show connected and available ExtRef Element from selected FCDA Element ([#941](https://github.com/openscd/open-scd/issues/941)) ([d06d0b4](https://github.com/openscd/open-scd/commits/d06d0b463a5cc150bfdf1d9ea24739c8f96d3f4f))
12+
* **editor/laterbinding:** Subscribe and unsubscribe from ExtRef for Later Binding (SMV) ([#944](https://github.com/openscd/open-scd/issues/944)) ([b25f9a6](https://github.com/openscd/open-scd/commits/b25f9a67d541583678a19f5a5a211cc8ef5d0d2a))
13+
* **menu/compareied:** ignore attributes/elements when comparing IED Elements ([#926](https://github.com/openscd/open-scd/issues/926)) ([7e25149](https://github.com/openscd/open-scd/commits/7e2514929d3997f598990d41a01696e567b5d6a6))
14+
* **menu/history:** move history from log to own menu plugin ([30d568f](https://github.com/openscd/open-scd/commits/30d568fd7596df307f301170b96a74b47af5053a))
15+
516
## [0.21.0](https://github.com/openscd/open-scd/compare/v0.20.0...v0.21.0) (2022-08-08)
617

718

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
"purpose": "maskable"
4141
}
4242
],
43-
"version": "0.21.0"
43+
"version": "0.22.0"
4444
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "open-scd",
3-
"version": "0.21.0",
3+
"version": "0.22.0",
44
"repository": "https://github.com/openscd/open-scd.git",
55
"description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",
66
"keywords": [

public/js/plugins.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export const officialPlugins = [
3434
default: true,
3535
kind: 'editor',
3636
},
37+
{
38+
name: 'Subscriber Later Binding (SMV)',
39+
src: '/src/editors/SMVSubscriberLaterBinding.js',
40+
icon: 'link',
41+
default: true,
42+
kind: 'editor',
43+
},
3744
{
3845
name: 'Communication',
3946
src: '/src/editors/Communication.js',
@@ -247,6 +254,15 @@ export const officialPlugins = [
247254
requireDoc: true,
248255
position: 'middle',
249256
},
257+
{
258+
name: 'Show SCL History',
259+
src: '/src/menu/SclHistory.js',
260+
icon: 'history_toggle_off',
261+
default: true,
262+
kind: 'menu',
263+
requireDoc: true,
264+
position: 'bottom',
265+
},
250266
{
251267
name: 'CoMPAS Settings',
252268
src: '/src/menu/CompasSettings.js',

src/Logging.ts

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import {
3232
LogEvent,
3333
Mixin,
3434
newActionEvent,
35-
OpenDocEvent,
36-
SclhistoryEntry,
3735
} from './foundation.js';
3836
import { getFilterIcon, iconColors } from './icons/icons.js';
3937
import { Plugin } from './Plugging.js';
@@ -43,7 +41,6 @@ const icons = {
4341
warning: 'warning',
4442
error: 'report',
4543
action: 'history',
46-
sclhistory: 'history_toggle_off',
4744
};
4845

4946
function getPluginName(src: string): string {
@@ -113,58 +110,6 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
113110
return index;
114111
}
115112

116-
private convertToDate(when: string | null): Date | null {
117-
const convertedTime = new Date(when ?? '');
118-
if (!isNaN(convertedTime.getTime())) {
119-
return convertedTime;
120-
}
121-
return null;
122-
}
123-
124-
private createMessage(
125-
who: string | null,
126-
why: string | null
127-
): string | undefined {
128-
let message = who;
129-
if (message !== null && why !== null) {
130-
message += ' : ' + why;
131-
} else if (why !== null) {
132-
message = why;
133-
}
134-
return message ?? undefined;
135-
}
136-
137-
private createSclHistoryEntry(
138-
who: string | null,
139-
what: string | null,
140-
why: string | null,
141-
when: string | null
142-
): SclhistoryEntry {
143-
return {
144-
kind: 'sclhistory',
145-
title: what ?? 'UNDEFINED',
146-
message: this.createMessage(who, why),
147-
time: this.convertToDate(when),
148-
};
149-
}
150-
151-
private onLoadHistoryFromDoc(event: OpenDocEvent) {
152-
const doc = event.detail.doc;
153-
154-
Array.from(
155-
doc.querySelectorAll(':root > Header > History > Hitem')
156-
).forEach(historyItem => {
157-
this.history.push(
158-
this.createSclHistoryEntry(
159-
historyItem.getAttribute('who'),
160-
historyItem.getAttribute('what'),
161-
historyItem.getAttribute('why'),
162-
historyItem.getAttribute('when')
163-
)
164-
);
165-
});
166-
}
167-
168113
private onIssue(de: IssueEvent): void {
169114
const issues = this.diagnoses.get(de.detail.validatorId);
170115

@@ -249,7 +194,6 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
249194

250195
this.addEventListener('log', this.onLog);
251196
this.addEventListener('issue', this.onIssue);
252-
this.addEventListener('open-doc', this.onLoadHistoryFromDoc);
253197
}
254198

255199
renderLogEntry(
@@ -330,9 +274,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
330274

331275
private renderFilterButtons() {
332276
return (<LogEntryType[]>Object.keys(icons)).map(
333-
kind => html`<mwc-icon-button-toggle
334-
id="${kind}filter"
335-
?on=${kind !== 'sclhistory'}
277+
kind => html`<mwc-icon-button-toggle id="${kind}filter" on
336278
>${getFilterIcon(kind, false)}
337279
${getFilterIcon(kind, true)}</mwc-icon-button-toggle
338280
>`
@@ -362,8 +304,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
362304
#content mwc-list-item.info,
363305
#content mwc-list-item.warning,
364306
#content mwc-list-item.error,
365-
#content mwc-list-item.action,
366-
#content mwc-list-item.sclhistory {
307+
#content mwc-list-item.action {
367308
display: none;
368309
}
369310
#infofilter[on] ~ #content mwc-list-item.info {
@@ -378,9 +319,6 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
378319
#actionfilter[on] ~ #content mwc-list-item.action {
379320
display: flex;
380321
}
381-
#sclhistoryfilter[on] ~ #content mwc-list-item.sclhistory {
382-
display: flex;
383-
}
384322
385323
#log {
386324
--mdc-dialog-min-width: 92vw;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { css, html, LitElement, property, TemplateResult } from 'lit-element';
2+
3+
import './subscription/smv-laterbinding/svc-laterbinding-list.js';
4+
import './subscription/smv-laterbinding/ext-ref-laterbinding-list.js';
5+
6+
/** An editor [[`plugin`]] for Subscribe Later Binding (SMV). */
7+
export default class SMVSubscribeLaterBindingPlugin extends LitElement {
8+
@property({ attribute: false })
9+
doc!: XMLDocument;
10+
11+
render(): TemplateResult {
12+
return html`<div>
13+
<div class="container">
14+
<svc-later-binding-list class="column" .doc=${this.doc}>
15+
</svc-later-binding-list>
16+
<extref-later-binding-list class="column" .doc=${this.doc}>
17+
</extref-later-binding-list>
18+
</div>
19+
</div>`;
20+
}
21+
22+
static styles = css`
23+
:host {
24+
width: 100vw;
25+
}
26+
27+
.container {
28+
display: flex;
29+
padding: 8px 6px 16px;
30+
height: calc(100vh - 136px);
31+
}
32+
33+
.column {
34+
flex: 50%;
35+
margin: 0px 6px 0px;
36+
min-width: 300px;
37+
height: 100%;
38+
overflow-y: auto;
39+
}
40+
`;
41+
}

src/editors/publisher/data-set-editor.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@ import '../../filtered-list.js';
2020
import { FilteredList } from '../../filtered-list.js';
2121

2222
import { compareNames, identity, selector } from '../../foundation.js';
23-
import { styles } from './foundation.js';
23+
import { styles, updateElementReference } from './foundation.js';
2424

2525
@customElement('data-set-editor')
2626
export class DataSetEditor extends LitElement {
2727
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
2828
@property({ attribute: false })
29-
set doc(newDoc: XMLDocument) {
30-
if (this._doc === newDoc) return;
31-
32-
this.selectedDataSet = undefined;
33-
if (this.selectionList && this.selectionList.selected)
34-
(this.selectionList.selected as ListItem).selected = false;
35-
36-
this._doc = newDoc;
37-
38-
this.requestUpdate();
39-
}
40-
get doc(): XMLDocument {
41-
return this._doc;
42-
}
43-
private _doc!: XMLDocument;
29+
doc!: XMLDocument;
4430

4531
@state()
4632
selectedDataSet?: Element;
4733

4834
@query('.selectionlist') selectionList!: FilteredList;
4935
@query('mwc-button') selectDataSetButton!: Button;
5036

37+
/** Resets selected GOOSE, if not existing in new doc */
38+
update(props: Map<string | number | symbol, unknown>): void {
39+
if (props.has('doc') && this.selectedDataSet) {
40+
const newDataSet = updateElementReference(this.doc, this.selectedDataSet);
41+
42+
this.selectedDataSet = newDataSet ?? undefined;
43+
44+
if (!newDataSet && this.selectionList && this.selectionList.selected)
45+
(this.selectionList.selected as ListItem).selected = false;
46+
}
47+
48+
super.update(props);
49+
}
50+
5151
private selectDataSet(evt: Event): void {
5252
const id = ((evt.target as FilteredList).selected as ListItem).value;
5353
const dataSet = this.doc.querySelector(selector('DataSet', id));

src/editors/publisher/foundation.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
import { css } from 'lit-element';
22

3+
import { identity, selector } from '../../foundation.js';
4+
5+
export function updateElementReference(
6+
newDoc: XMLDocument,
7+
oldElement: Element
8+
): Element | null {
9+
if (!oldElement || !oldElement.closest('SCL')) return null;
10+
11+
const id = identity(oldElement);
12+
const newElement = newDoc.querySelector(selector(oldElement.tagName, id));
13+
14+
return newElement;
15+
}
16+
317
export const styles = css`
418
.content {
519
display: flex;

src/editors/publisher/gse-control-editor.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,13 @@ import { FilteredList } from '../../filtered-list.js';
2222

2323
import { gooseIcon } from '../../icons/icons.js';
2424
import { compareNames, identity, selector } from '../../foundation.js';
25-
import { styles } from './foundation.js';
25+
import { styles, updateElementReference } from './foundation.js';
2626

2727
@customElement('gse-control-editor')
2828
export class GseControlEditor extends LitElement {
2929
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
3030
@property({ attribute: false })
31-
set doc(newDoc: XMLDocument) {
32-
if (this._doc === newDoc) return;
33-
34-
this.selectedDataSet = undefined;
35-
this.selectedGseControl = undefined;
36-
if (this.selectionList && this.selectionList.selected)
37-
(this.selectionList.selected as ListItem).selected = false;
38-
39-
this._doc = newDoc;
40-
41-
this.requestUpdate();
42-
}
43-
get doc(): XMLDocument {
44-
return this._doc;
45-
}
46-
private _doc!: XMLDocument;
31+
doc!: XMLDocument;
4732

4833
@state()
4934
selectedGseControl?: Element;
@@ -53,6 +38,26 @@ export class GseControlEditor extends LitElement {
5338
@query('.selectionlist') selectionList!: FilteredList;
5439
@query('mwc-button') selectGSEControlButton!: Button;
5540

41+
/** Resets selected GOOSE and its DataSet, if not existing in new doc */
42+
update(props: Map<string | number | symbol, unknown>): void {
43+
if (props.has('doc') && this.selectedGseControl) {
44+
const newGseControl = updateElementReference(
45+
this.doc,
46+
this.selectedGseControl
47+
);
48+
49+
this.selectedGseControl = newGseControl ?? undefined;
50+
this.selectedDataSet = this.selectedGseControl
51+
? updateElementReference(this.doc, this.selectedDataSet!)
52+
: undefined;
53+
54+
if (!newGseControl && this.selectionList && this.selectionList.selected)
55+
(this.selectionList.selected as ListItem).selected = false;
56+
}
57+
58+
super.update(props);
59+
}
60+
5661
private selectGSEControl(evt: Event): void {
5762
const id = ((evt.target as FilteredList).selected as ListItem).value;
5863
const gseControl = this.doc.querySelector(selector('GSEControl', id));

0 commit comments

Comments
 (0)