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(line-editor.ts):unit_test_added #1193

Merged
merged 5 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
103 changes: 103 additions & 0 deletions src/editors/substation/line-editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import {
customElement,
html,
LitElement,
TemplateResult,
property,
state,
} from 'lit-element';

import './conducting-equipment-editor.js';
import './function-editor.js';
import './general-equipment-editor.js';
import './l-node-editor.js';
import { getChildElementsByTagName } from '../../foundation.js';

@customElement('line-editor')
export class LineEditor extends LitElement {
/** The document being edited as provided to editor by [[`Zeroline`]]. */
@property({ attribute: false })
doc!: XMLDocument;
/** SCL element Line */
@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 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()}
</action-icon>`;
}
}
25 changes: 23 additions & 2 deletions src/editors/substation/zeroline-pane.ts
marcvanraalte marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '@material/mwc-icon-button-toggle';
import { IconButton } from '@material/mwc-icon-button';
import { IconButtonToggle } from '@material/mwc-icon-button-toggle';

import './line-editor.js';
import './substation-editor.js';
import './ied-editor.js';
import { communicationMappingWizard } from '../../wizards/commmap-wizards.js';
Expand Down Expand Up @@ -113,11 +114,31 @@ export class ZerolinePane extends LitElement {

return ieds.length
? html`<div id="iedcontainer">
${ieds.map(ied => html`<ied-editor .doc=${this.doc} .element=${ied}></ied-editor>`)}
${ieds.map(
ied =>
html`<ied-editor .doc=${this.doc} .element=${ied}></ied-editor>`
)}
</div>`
: html``;
}

renderLines(): TemplateResult {
return this.doc?.querySelector(':root > Line')
? html`<section>
marcvanraalte marked this conversation as resolved.
Show resolved Hide resolved
${Array.from(this.doc.querySelectorAll('Line') ?? [])
.filter(isPublic)
.map(
line =>
html`<line-editor
.doc=${this.doc}
.element="${line}"
?showfunctions=${shouldShowFunctions()}
></line-editor>`
)}
</section>`
: html``;
marcvanraalte marked this conversation as resolved.
Show resolved Hide resolved
}

render(): TemplateResult {
return html` <h1>
<nav>
Expand Down Expand Up @@ -198,7 +219,7 @@ export class ZerolinePane extends LitElement {
<span style="color: var(--base1)"
>${translate('substation.missing')}</span
>
</h1>`}`;
</h1>`}${this.renderLines()}`;
}

static styles = css`
Expand Down
235 changes: 235 additions & 0 deletions test/testfiles/editors/substation/Line.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" version="2007" revision="B" release="4">
<Header id="general_equipment"/>
<DataTypeTemplates>
<LNodeType lnClass="CSWI" id="OpenSCD_CSWI" desc="Switch control: single phase">
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="Health" type="OpenSCD_ENS_Health"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
<DO name="LocKey" type="OpenSCD_SPS_simple"/>
<DO name="Loc" type="OpenSCD_SPS_simple"/>
<DO name="LocSta" type="OpenSCD_SPC_LocSta"/>
<DO name="Pos" type="OpenSCD_DPC"/>
<DO name="OpOpn" transient="true" type="OpenSCD_ACT_threephase_control"/>
<DO name="OpCls" transient="true" type="OpenSCD_ACT_threephase_control"/>
<DO name="SelOpn" type="OpenSCD_SPS_simple"/>
<DO name="SelCls" type="OpenSCD_SPS_simple"/>
<DO name="PosA" type="OpenSCD_DPC_statusonly"/>
<DO name="PosB" type="OpenSCD_DPC_statusonly"/>
<DO name="PosC" type="OpenSCD_DPC_statusonly"/>
</LNodeType>
<DOType cdc="DPC" id="OpenSCD_DPC_statusonly">
<DA name="stVal" bType="Dbpos" dchg="true" fc="ST"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="ctlModel" bType="Enum" fc="CF" type="OpenSCD_StatusOnly">
<Val>status-only</Val>
</DA>
</DOType>
<DOType cdc="ACT" id="OpenSCD_ACT_threephase_control">
<DA name="general" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="phsA" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="phsB" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="phsC" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="originSrc" bType="Struct" type="OpenSCD_Originator" fc="ST"/>
</DOType>
<DOType cdc="DPC" id="OpenSCD_DPC">
<DA name="origin" bType="Struct" dchg="true" fc="ST" type="OpenSCD_Originator"/>
<DA name="stVal" bType="Enum" dchg="true" fc="ST" type="BehaviourModeKind"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="ctlModel" bType="Enum" fc="CF" type="CtlModelKind">
<Val>sbo-with-enhanced-security</Val>
</DA>
<DA name="sboTimeout" bType="INT32U" fc="CF">
<Val>30000</Val>
</DA>
<DA name="operTimeout" bType="INT32U" fc="CF">
<Val>600</Val>
</DA>
<DA name="pulseConfig" bType="Struct" fc="CO" type="OpenSCD_PulseConfig"/>
<DA name="SBOw" bType="Struct" fc="CO" type="OpenSCD_OperSBOw_Dbpos"/>
<DA name="Oper" bType="Struct" fc="CO" type="OpenSCD_OperSBOw_Dbpos"/>
<DA name="Cancel" bType="Struct" fc="CO" type="OpenSCD_Cancel_Dbpos"/>
</DOType>
<DOType cdc="SPC" id="OpenSCD_SPC_LocSta">
<DA name="stVal" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="Oper" bType="Struct" type="OpenSCD_OperSBOw_SPC" fc="CO"/>
<DA name="Cancel" bType="Struct" type="OpenSCD_Cancel_SPC" fc="CO"/>
<DA name="operTimeout" bType="INT32U" fc="CF">
<Val>1000</Val>
</DA>
<DA name="ctlModel" bType="Enum" dchg="true" type="CtlModelKind" fc="CF">
<Val>direct-with-enhanced-security</Val>
</DA>
</DOType>
<DOType cdc="SPS" id="OpenSCD_SPS_simple">
<DA name="stVal" bType="BOOLEAN" dchg="true" fc="ST"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="d" bType="VisString255" fc="DC"/>
</DOType>
<DOType cdc="LPL" id="OpenSCD_LPL_noLD">
<DA name="vendor" bType="VisString255" fc="DC"/>
<DA name="swRev" bType="VisString255" fc="DC"/>
<DA name="d" bType="VisString255" fc="DC"/>
<DA name="configRev" bType="VisString255" fc="DC"/>
</DOType>
<DOType cdc="ENS" id="OpenSCD_ENS_Health">
<DA name="stVal" bType="Enum" dchg="true" fc="ST" type="HealthKind"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
</DOType>
<DOType cdc="ENS" id="OpenSCD_ENS_Beh">
<DA name="stVal" bType="Enum" dchg="true" fc="ST" type="BehaviourModeKind"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
</DOType>
<DOType cdc="ENC" id="OpenSCD_ENC_Mod">
<DA name="origin" bType="Struct" dchg="true" fc="ST" type="OpenSCD_Originator"/>
<DA name="stVal" bType="Enum" dchg="true" fc="ST" type="BehaviourModeKind"/>
<DA name="q" bType="Quality" qchg="true" fc="ST"/>
<DA name="t" bType="Timestamp" fc="ST"/>
<DA name="ctlModel" bType="Enum" fc="CF" type="CtlModelKind">
<Val>sbo-with-enhanced-security</Val>
</DA>
<DA name="sboTimeout" bType="INT32U" fc="CF">
<Val>30000</Val>
</DA>
<DA name="operTimeout" bType="INT32U" fc="CF">
<Val>600</Val>
</DA>
<DA name="SBOw" bType="Struct" fc="CO" type="OpenSCD_OperSBOw_BehaviourModeKind"/>
<DA name="Oper" bType="Struct" fc="CO" type="OpenSCD_OperSBOw_BehaviourModeKind"/>
<DA name="Cancel" bType="Struct" fc="CO" type="OpenSCD_Cancel_BehaviourModeKind"/>
</DOType>
<DAType id="OpenSCD_Cancel_Dbpos">
<BDA name="ctlVal" bType="Dbpos"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_OperSBOw_Dbpos">
<BDA name="ctlVal" bType="Dbpos"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<BDA name="Check" bType="Check"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_PulseConfig">
<BDA name="cmdQual" bType="Enum" type="OutputSignalKind"/>
<BDA name="onDur" bType="INT32U"/>
<BDA name="offDur" bType="INT32U"/>
<BDA name="numPls" bType="INT32U"/>
</DAType>
<DAType id="OpenSCD_Cancel_SPC">
<BDA name="ctlVal" bType="BOOLEAN"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_OperSBOw_SPC">
<BDA name="ctlVal" bType="BOOLEAN"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<BDA name="Check" bType="Check"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_Cancel_BehaviourModeKind">
<BDA name="ctlVal" bType="Enum" type="BehaviourModeKind"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_OperSBOw_BehaviourModeKind">
<BDA name="ctlVal" bType="Enum" type="BehaviourModeKind"/>
<BDA name="origin" bType="Struct" type="OpenSCD_Originator"/>
<BDA name="ctlNum" bType="INT8U"/>
<BDA name="T" bType="Timestamp"/>
<BDA name="Test" bType="BOOLEAN"/>
<BDA name="Check" bType="Check"/>
<ProtNs type="8-MMS">IEC 61850-8-1:2003</ProtNs>
</DAType>
<DAType id="OpenSCD_Originator">
<BDA name="orCat" bType="Enum" type="OriginatorCategoryKind"/>
<BDA name="orIdent" bType="Octet64"/>
</DAType>
<EnumType id="OpenSCD_StatusOnly">
<EnumVal ord="0">status-only</EnumVal>
</EnumType>
<EnumType id="OutputSignalKind">
<EnumVal ord="0">pulse</EnumVal>
<EnumVal ord="1">persistent</EnumVal>
<EnumVal ord="2">persistent-feedback</EnumVal>
</EnumType>
<EnumType id="HealthKind">
<EnumVal ord="1">Ok</EnumVal>
<EnumVal ord="2">Warning</EnumVal>
<EnumVal ord="3">Alarm</EnumVal>
</EnumType>
<EnumType id="CtlModelKind">
<EnumVal ord="0">status-only</EnumVal>
<EnumVal ord="1">direct-with-normal-security</EnumVal>
<EnumVal ord="2">sbo-with-normal-security</EnumVal>
<EnumVal ord="3">direct-with-enhanced-security</EnumVal>
<EnumVal ord="4">sbo-with-enhanced-security</EnumVal>
</EnumType>
<EnumType id="BehaviourModeKind">
<EnumVal ord="1">on</EnumVal>
<EnumVal ord="2">blocked</EnumVal>
<EnumVal ord="3">test</EnumVal>
<EnumVal ord="4">test/blocked</EnumVal>
<EnumVal ord="5">off</EnumVal>
</EnumType>
<EnumType id="OriginatorCategoryKind">
<EnumVal ord="0">not-supported</EnumVal>
<EnumVal ord="1">bay-control</EnumVal>
<EnumVal ord="2">station-control</EnumVal>
<EnumVal ord="3">remote-control</EnumVal>
<EnumVal ord="4">automatic-bay</EnumVal>
<EnumVal ord="5">automatic-station</EnumVal>
<EnumVal ord="6">automatic-remote</EnumVal>
<EnumVal ord="7">maintenance</EnumVal>
<EnumVal ord="8">process</EnumVal>
</EnumType>
</DataTypeTemplates>
<Line name="Berlin">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
<Function name="someFunctionToBerlin">
<SubFunction name="someSubFunc">
</SubFunction>
</Function>
<Voltage multiplier="k" unit="V">110.0</Voltage>
<ConductingEquipment name="someCondEq" type="CBR">
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="OpenSCD_CSWI" />
</ConductingEquipment>
</Line>
<Line name="Munich">
<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>
</SCL>
Loading