Skip to content

Commit

Permalink
985 process editor (#1212)
Browse files Browse the repository at this point in the history
* feat(line-editor.ts):unit_test_added

* feat(line-editor):add_edit_wizard

* feat(line-editor-wizard-editing.test):part-of-test

* feat(line-editor_wizard_editing)_continue

* feat(line.test,etc):editing_and_testing

* feat(line.ts):createLineWizard_added

* feat(zeroline-pane):create_Line_added

* feat(line.test.ts):create_tests_added

* feat(line-editor.ts):remove_line_and_test

* feat(line-editor):add_add_button_and_test

* feat(process-editor.ts):editor_added

* fix(Process.scd):GeneralEquipment_added

* fix(Process.scd):GeneralEquipment_added

---------

Co-authored-by: Steffen van den Driest <35229971+Stef3st@users.noreply.github.com>
  • Loading branch information
marcvanraalte and Stef3st authored Apr 20, 2023
1 parent fc6af77 commit 1ec77e1
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/editors/substation/line-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class LineEditor extends LitElement {
const wizard = wizards['Line'].edit(this.element);
if (wizard) this.dispatchEvent(newWizardEvent(wizard));
}

private openCreateWizard(tagName: string): void {
const wizard = wizards[<SCLTag>tagName].create(this.element!);

Expand Down
162 changes: 162 additions & 0 deletions src/editors/substation/process-editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {
css,
customElement,
html,
LitElement,
TemplateResult,
property,
state,
} from 'lit-element';

import '@material/mwc-icon';
import '@material/mwc-icon-button';
import '@material/mwc-menu';

import './conducting-equipment-editor.js';
import './function-editor.js';
import './general-equipment-editor.js';
import './l-node-editor.js';
import './line-editor.js';
import './process-editor.js';
import './substation-editor.js';
import './process-editor.js';

import { styles } from './foundation.js';
import { getChildElementsByTagName } from '../../foundation.js';

@customElement('process-editor')
export class ProcessEditor extends LitElement {
/** The document being edited as provided to editor by [[`Zeroline`]]. */
@property({ attribute: false })
doc!: XMLDocument;
/** SCL element Process */
@property({ attribute: false })
element!: Element;
/** Whether `Function` and `LNode` are rendered */
@property({ type: Boolean })
showfunctions = false;

@state()
get header(): string {
const name = this.element.getAttribute('name') ?? '';
const desc = this.element.getAttribute('desc');

return `${name} ${desc ? `—${desc}` : ''}`;
}

private renderConductingEquipments(): TemplateResult {
const ConductingEquipments = getChildElementsByTagName(
this.element,
'ConductingEquipment'
);
return html` ${ConductingEquipments.map(
ConductingEquipment =>
html`<conducting-equipment-editor
.doc=${this.doc}
.element=${ConductingEquipment}
?showfunctions=${this.showfunctions}
></conducting-equipment-editor>`
)}`;
}

private renderGeneralEquipments(): TemplateResult {
const GeneralEquipments = getChildElementsByTagName(
this.element,
'GeneralEquipment'
);
return html` ${GeneralEquipments.map(
GeneralEquipment =>
html`<general-equipment-editor
.doc=${this.doc}
.element=${GeneralEquipment}
?showfunctions=${this.showfunctions}
></general-equipment-editor>`
)}`;
}

private renderLines(): TemplateResult {
const Lines = getChildElementsByTagName(this.element, 'Line');
return html` ${Lines.map(
Line =>
html`<line-editor
.doc=${this.doc}
.element=${Line}
?showfunctions=${this.showfunctions}
></line-editor>`
)}`;
}

private renderSubstations(): TemplateResult {
const Substations = getChildElementsByTagName(this.element, 'Substation');
return html` ${Substations.map(
Substation =>
html`<substation-editor
.doc=${this.doc}
.element=${Substation}
?showfunctions=${this.showfunctions}
></substation-editor>`
)}`;
}

private renderProcesses(): TemplateResult {
const Processes = getChildElementsByTagName(this.element, 'Process');
return html` ${Processes.map(
Process =>
html`<process-editor
.doc=${this.doc}
.element=${Process}
?showfunctions=${this.showfunctions}
></process-editor>`
)}`;
}

private renderFunctions(): TemplateResult {
if (!this.showfunctions) return html``;

const Functions = getChildElementsByTagName(this.element, 'Function');
return html` ${Functions.map(
Function =>
html`<function-editor
.doc=${this.doc}
.element=${Function}
?showfunctions=${this.showfunctions}
></function-editor>`
)}`;
}

private renderLNodes(): TemplateResult {
if (!this.showfunctions) return html``;

const lNodes = getChildElementsByTagName(this.element, 'LNode');
return lNodes.length
? html`<div class="container lnode">
${lNodes.map(
lNode =>
html`<l-node-editor
.doc=${this.doc}
.element=${lNode}
></l-node-editor>`
)}
</div>`
: html``;
}

render(): TemplateResult {
return html`<action-pane label=${this.header}>
${this.renderConductingEquipments()}${this.renderGeneralEquipments()}${this.renderFunctions()}${this.renderLNodes()}
${this.renderLines()} ${this.renderSubstations()}${this.renderProcesses()}
</action-pane>`;
}
static styles = css`
${styles}
:host(.moving) {
opacity: 0.3;
}
abbr {
text-decoration: none;
border-bottom: none;
}
`;
}
22 changes: 21 additions & 1 deletion src/editors/substation/zeroline-pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IconButtonToggle } from '@material/mwc-icon-button-toggle';
import { Menu } from '@material/mwc-menu';

import './line-editor.js';
import './process-editor.js';
import './substation-editor.js';
import './ied-editor.js';
import { communicationMappingWizard } from '../../wizards/commmap-wizards.js';
Expand Down Expand Up @@ -173,6 +174,25 @@ export class ZerolinePane extends LitElement {
: html``;
}

renderProcesses(): TemplateResult {
return this.doc?.querySelector(':root > Process')
? html`<section>
${Array.from(this.doc.querySelectorAll(':root > Process') ?? [])
.filter(isPublic)
.map(
process =>
html`<process-editor
.doc=${this.doc}
.element=${process}
.getAttachedIeds=${this.getAttachedIeds}
?readonly=${this.readonly}
?showfunctions=${shouldShowFunctions()}
></process-editor>`
)}
</section>`
: html``;
}

private openCreateWizard(tagName: string): void {
const wizard = wizards[<SCLTag>tagName].create(this.doc.documentElement);

Expand Down Expand Up @@ -261,7 +281,7 @@ export class ZerolinePane extends LitElement {
</nav>
</h1>
${this.renderIedContainer()}
${this.renderSubstation()}${this.renderLines()}`;
${this.renderSubstation()}${this.renderLines()}${this.renderProcesses()}`;
}

static styles = css`
Expand Down
2 changes: 2 additions & 0 deletions test/integration/editors/substation/zeroline-pane.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MockWizardEditor } from '../../../mock-wizard-editor.js';
import '../../../../src/editors/substation/zeroline-pane.js';
import { FilteredList } from '../../../../src/filtered-list.js';
import { ZerolinePane } from '../../../../src/editors/substation/zeroline-pane.js';

import { WizardTextField } from '../../../../src/wizard-textfield.js';
import { IconButton } from '@material/mwc-icon-button';
import { ListItem } from '@material/mwc-list/mwc-list-item';
Expand Down Expand Up @@ -70,6 +71,7 @@ describe('zeroline-pane wizarding editing integration', () => {
doc.querySelectorAll('ReportControl').length
);
});

it('add Substation element with add button', async () => {
expect(doc.querySelector('Substation[name="newSubstation"]')).to.not.exist;
zeroline.addButton.click();
Expand Down
69 changes: 69 additions & 0 deletions test/testfiles/editors/substation/Process.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" version="2007" revision="B" release="4">
<Header id="general_equipment"/>
<Process name="ProcessGenConduct">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
<GeneralEquipment name="genSub" desc="someDesc" type="AXN"/>
<Function name="someFunction">
<SubFunction name="someSubFunc"/>
</Function>
<ConductingEquipment name="someCondEq" type="CBR">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
</ConductingEquipment>
</Process>
<Process name="ProcProcSubAA1">
<Substation name="AA1" desc="">
<GeneralEquipment name="genSub" desc="someDesc" type="AXN"/>
<GeneralEquipment name="genSub2" desc="someDesc" type="AXN"/>
<VoltageLevel name="E1" desc="" nomFreq="50" numPhases="3">
<GeneralEquipment name="genVolt1" type="BAT">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI"/>
<EqFunction name="Eq1"/>
</GeneralEquipment>
<Bay name="Q01" desc="">
<Function name="F1">
<SubFunction name="Sub1">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI"/>
<GeneralEquipment name="someGenCon1" desc="someDesc" type="MOT"/>
</SubFunction>
</Function>
</Bay>
</VoltageLevel>
</Substation>
<Process name="ProcessSubAA2">
<Substation name="AA2" desc="">
<GeneralEquipment name="genSub" desc="someDesc" type="AXN"/>
<GeneralEquipment name="genSub2" desc="someDesc" type="AXN"/>
<VoltageLevel name="E1" desc="" nomFreq="50" numPhases="3">
<GeneralEquipment name="genVolt1" type="BAT">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI"/>
<EqFunction name="Eq1"/>
</GeneralEquipment>
<Bay name="Q01" desc="">
<Function name="F1">
<SubFunction name="Sub1">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI"/>
<GeneralEquipment name="someGenCon1" desc="someDesc" type="MOT"/>
</SubFunction>
</Function>
</Bay>
</VoltageLevel>
</Substation>
</Process>
</Process>
<Process name="ProcessLine">
<Line name="Berlin" desc="" type="test" nomFreq="50" numPhases="3">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
<GeneralEquipment name="someGenEq" type="BAT">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
</GeneralEquipment>
<Function name="someFunctionToMunich">
<SubFunction name="someSubFunc">
</SubFunction>
</Function>
<Voltage multiplier="k" unit="V">380.0</Voltage>
<ConductingEquipment name="someCondEq" type="DIS">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
</ConductingEquipment>
</Line>
</Process>
</SCL>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["web component rendering Process element rendering LNode, GeneralEquipment,Function and ConductingEquipment children looks like the latest snapshot"] =
`<action-pane
label="ProcessGenConduct "
tabindex="0"
>
<conducting-equipment-editor showfunctions="">
</conducting-equipment-editor>
<general-equipment-editor showfunctions="">
</general-equipment-editor>
<function-editor showfunctions="">
</function-editor>
<div class="container lnode">
<l-node-editor>
</l-node-editor>
</div>
</action-pane>
`;
/* end snapshot web component rendering Process element rendering LNode, GeneralEquipment,Function and ConductingEquipment children looks like the latest snapshot */

snapshots["web component rendering Process element hides LNode and Function children looks like the latest snapshot"] =
`<action-pane
label="ProcessGenConduct "
tabindex="0"
>
<conducting-equipment-editor>
</conducting-equipment-editor>
<general-equipment-editor>
</general-equipment-editor>
</action-pane>
`;
/* end snapshot web component rendering Process element hides LNode and Function children looks like the latest snapshot */

snapshots["web component rendering Process element rendering Substation and Process children looks like the latest snapshot"] =
`<action-pane
label="ProcProcSubAA1 "
tabindex="0"
>
<substation-editor showfunctions="">
</substation-editor>
<process-editor showfunctions="">
</process-editor>
</action-pane>
`;
/* end snapshot web component rendering Process element rendering Substation and Process children looks like the latest snapshot */

snapshots["web component rendering Process element rendering a Line child looks like the latest snapshot"] =
`<action-pane
label="ProcessLine "
tabindex="0"
>
<line-editor showfunctions="">
</line-editor>
</action-pane>
`;
/* end snapshot web component rendering Process element rendering a Line child looks like the latest snapshot */

12 changes: 6 additions & 6 deletions test/unit/editors/substation/line-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('web component rendering Line element', () => {
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
element = <LineEditor>(
await fixture(
html`<Line-editor
html`<line-editor
.element=${doc.querySelector('Line[name="Berlin"]')}
></Line-editor>`
></line-editor>`
)
);
element.showfunctions = true;
Expand All @@ -34,9 +34,9 @@ describe('web component rendering Line element', () => {
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
element = <LineEditor>(
await fixture(
html`<Line-editor
html`<line-editor
.element=${doc.querySelector('Line[name="Berlin"]')}
></Line-editor>`
></line-editor>`
)
);
element.showfunctions = true;
Expand All @@ -53,9 +53,9 @@ describe('web component rendering Line element', () => {
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
element = <LineEditor>(
await fixture(
html`<Line-editor
html`<line-editor
.element=${doc.querySelector('Line[name="Munich"]')}
></Line-editor>`
></line-editor>`
)
);
element.showfunctions = true;
Expand Down
Loading

0 comments on commit 1ec77e1

Please sign in to comment.