Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wizards/settings): Added Nsdoc plugin + Show LN names #516

Merged
merged 6 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,38 @@ import { ifImplemented, LitElementConstructor, Mixin } from './foundation.js';
import { Language, languages, loader } from './translations/loader.js';

import './WizardDivider.js';
import { iec6185074 } from './validators/templates/foundation.js';

function NsdocSettings() {
/**
* Get NSDoc information
* @returns
*/
async function Nsdoc() {
const nsd74 = await iec6185074;
const parsedNsdoc74 = new DOMParser().parseFromString(Settings().getSetting('IEC 61850-7-4')!, 'application/xml')

return {

/**
* Get the LNClass for a specific LN class name found in the IEC 61850-7-4 nsdoc file.
* @param name - The name of the LN class.
* @returns The LN class element.
*/
get74NsdLNClass(name: string): Element | null {
return nsd74.querySelector(`NS > LNClasses > LNClass[name="${name}"]`);
},

/**
* Get the documentation for a specific ID found in the IEC 61850-7-4 nsdoc file.
* @param id - The id to search for.
* @returns The documentation for the specific ID.
*/
get74NsdocDocumentation(id: string): Element | null {
return parsedNsdoc74.querySelector(`NSDoc > Doc[id="${id}"]`);
Flurb marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

export const nsdocSettings = NsdocSettings();
export const nsdoc = await Nsdoc();

export type SettingsRecord = {
language: Language;
Expand Down
6 changes: 4 additions & 2 deletions src/editors/ied/ldevice-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { nothing } from 'lit-html';
import { getDescriptionAttribute, getInstanceAttribute, getNameAttribute } from '../../foundation.js';
import { IconButtonToggle } from '@material/mwc-icon-button-toggle';
import { translate } from 'lit-translate';
import { nsdoc } from '../../Setting.js';

/** [[`IED`]] plugin subeditor for editing `LDevice` element. */
@customElement('ldevice-container')
Expand Down Expand Up @@ -48,8 +49,9 @@ export class LDeviceContainer extends LitElement {
></mwc-icon-button-toggle>
</abbr>` : nothing}
<div id="lnContainer">
${this.toggleButton?.on ? lnElements.map(server => html`<ln-container
.element=${server}
${this.toggleButton?.on ? lnElements.map(ln => html`<ln-container
.element=${ln}
.lnClassElement=${nsdoc.get74NsdLNClass(ln.getAttribute('lnClass')!)}
Flurb marked this conversation as resolved.
Show resolved Hide resolved
></ln-container>
`) : nothing}
</div>
Expand Down
17 changes: 13 additions & 4 deletions src/editors/ied/ln-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@ import './do-container.js';
import { getInstanceAttribute, getNameAttribute } from '../../foundation.js';
import { translate } from 'lit-translate';
import { IconButtonToggle } from '@material/mwc-icon-button-toggle';
import { nsdoc } from '../../Setting.js';
import { until } from 'lit-html/directives/until';

/** [[`IED`]] plugin subeditor for editing `LN` and `LN0` element. */
@customElement('ln-container')
export class LNContainer extends LitElement {
@property({ attribute: false })
element!: Element;

/**
* The LNClass element for this LN(0)
* found in the nsd file.
*/
@property({ attribute: false })
lnClassElement!: Element

@query('#toggleButton') toggleButton!: IconButtonToggle | undefined;

private header(): TemplateResult {
private async header(): Promise<TemplateResult> {
const prefix = this.element.getAttribute('prefix');
const lnClass = this.element.getAttribute('lnClass');
const inst = getInstanceAttribute(this.element);

return html`${prefix != null ? html`${prefix} &mdash; ` : nothing}
${lnClass}
${this.lnClassElement ?
nsdoc.get74NsdocDocumentation(this.lnClassElement.getAttribute('titleID')!)?.textContent : this.element.getAttribute('lnClass')}
${inst ? html` &mdash; ${inst}` : nothing}`;
}

Expand Down Expand Up @@ -59,7 +68,7 @@ export class LNContainer extends LitElement {
render(): TemplateResult {
const doElements = this.getDOElements();

return html`<action-pane .label="${this.header()}">
return html`<action-pane .label="${until(this.header())}">
${doElements.length > 0 ? html`<abbr slot="action" title="${translate('iededitor.toggleChildElements')}">
<mwc-icon-button-toggle
id="toggleButton"
Expand Down
2 changes: 1 addition & 1 deletion src/validators/templates/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const iec6185073 = fetch('public/xml/IEC_61850-7-3_2007B3.nsd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));

const iec6185072 = fetch('public/xml/IEC_61850-7-2_2007B3.nsd')
export const iec6185072 = fetch('public/xml/IEC_61850-7-2_2007B3.nsd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));

Expand Down