Skip to content

Commit 4e0d862

Browse files
feat(tBay): update 90-30 SourceRef element as well
1 parent eb3c657 commit 4e0d862

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

tBay/updateBay.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const aa2d1q01 = findElement(
1818
substation,
1919
'Substation[name="AA2"]>VoltageLevel[name="D1"]>Bay[name="Q01"]',
2020
) as Element;
21+
const aa3j1q01 = findElement(
22+
substation,
23+
'Substation[name="AA3"]>VoltageLevel[name="J1"]>Bay[name="Q01"]',
24+
) as Element;
2125

2226
const orphanBay = new DOMParser()
2327
.parseFromString('<Bay name="Q01" />', "application/xml")
@@ -40,7 +44,7 @@ describe("update Bay element", () => {
4044
});
4145

4246
describe("when no name attribute is changed", () => {
43-
it("updates ReportControl attributes", () => {
47+
it("updates desc attributes", () => {
4448
const edits = updateBay({
4549
element: aa1e1q01,
4650
attributes: { desc: "newDesc" },
@@ -144,5 +148,26 @@ describe("update Bay element", () => {
144148
).to.exist;
145149
expect(edits.length).to.equal(6);
146150
});
151+
152+
it("updates SourceRef source attribute", () => {
153+
const edits = updateBay({
154+
element: aa3j1q01,
155+
attributes: { name: "Q02" },
156+
});
157+
158+
expect(edits.length).to.equal(5);
159+
expect(edits[1].attributes.source).to.equal(
160+
"AA3/J1/Q02/QA2/CBR/CSWI1/OpCls.general",
161+
);
162+
expect(edits[2].attributes.source).to.equal(
163+
"AA3/J1/Q02/QA2/CBR/CSWI1/OpCls.q",
164+
);
165+
expect(edits[3].attributes.source).to.equal(
166+
"AA3/J1/Q02/QA2/CBR/CSWI1/OpOpn.general",
167+
);
168+
expect(edits[4].attributes.source).to.equal(
169+
"AA3/J1/Q02/QA2/CBR/CSWI1/OpOpn.q",
170+
);
171+
});
147172
});
148173
});

tBay/updateBay.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
import { Update } from "../foundation/utils.js";
22

3+
function updateSourceRef(
4+
element: Element,
5+
{
6+
oldSubstation,
7+
oldVoltageLevel,
8+
oldBay,
9+
newBay,
10+
}: {
11+
oldSubstation: string;
12+
oldVoltageLevel: string;
13+
oldBay: string;
14+
newBay: string;
15+
},
16+
): Update[] {
17+
const sourceRefs = Array.from(
18+
element.ownerDocument.querySelectorAll(
19+
'Private[type="eIEC61850-6-100"]>LNodeInputs>SourceRef',
20+
),
21+
);
22+
23+
const updates: Update[] = [];
24+
25+
sourceRefs.forEach((srcRef) => {
26+
const source = srcRef.getAttribute("source");
27+
if (!source) return;
28+
29+
const oldPath = `${oldSubstation}/${oldVoltageLevel}/${oldBay}`;
30+
31+
if (!source.startsWith(oldPath)) return;
32+
33+
const newPath = `${oldSubstation}/${oldVoltageLevel}/${newBay}`;
34+
updates.push({
35+
element: srcRef,
36+
attributes: { source: source.replace(oldPath, newPath) },
37+
});
38+
});
39+
40+
return updates.filter((update) => update) as Update[];
41+
}
42+
343
function updateConnectivityNodes(
444
element: Element,
545
{
@@ -96,5 +136,11 @@ export function updateBay(update: Update): Update[] {
96136
voltageLevel: voltageLevelName,
97137
bayName: newName,
98138
}),
139+
...updateSourceRef(bay, {
140+
oldSubstation: substationName,
141+
oldVoltageLevel: voltageLevelName,
142+
oldBay: oldName,
143+
newBay: newName,
144+
}),
99145
);
100146
}

tSubstation/substation.testfiles.ts

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const substation = `<SCL
22
xmlns="http://www.iec.ch/61850/2003/SCL"
3+
xmlns:eTr_6-100="http://www.iec.ch/61850/2019/SCL/6-100"
34
version="2007"
45
revision="B"
56
release="4"
@@ -58,6 +59,9 @@ export const substation = `<SCL
5859
bayName="Q01"
5960
cNodeName="L1"
6061
></Terminal>
62+
<EqFunction name="CBR">
63+
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="someCSWI" />
64+
</EqFunction>
6165
</ConductingEquipment>
6266
<ConductingEquipment name="QB1" type="DIS">
6367
<Terminal
@@ -171,12 +175,69 @@ export const substation = `<SCL
171175
<VoltageLevel name="D1">
172176
<Bay name="Q01">
173177
<ConductingEquipment name="QA1" >
174-
<Terminal name="T1" connectivityNode="" substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
175-
<Terminal substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
178+
<Terminal name="T1" connectivityNode="" substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
179+
<Terminal substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
180+
<EqFunction name="CBR">
181+
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="someCSWI" />
182+
</EqFunction>
176183
</ConductingEquipment>
177184
<ConnectivityNode name="L1" />
178185
<ConnectivityNode />
179186
</Bay>
180187
</VoltageLevel>
181188
</Substation>
189+
<Substation name="AA3">
190+
<VoltageLevel name="J1">
191+
<Bay name="Q01">
192+
<ConductingEquipment name="QA1" >
193+
<Terminal name="T1" connectivityNode="" substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
194+
<Terminal substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
195+
<EqFunction name="CBR">
196+
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="someCSWI" />
197+
</EqFunction>
198+
</ConductingEquipment>
199+
</Bay>
200+
</VoltageLevel>
201+
</Substation>
202+
<Substation name="AA4">
203+
<VoltageLevel name="D1">
204+
<Bay name="Q01">
205+
<ConductingEquipment name="QA1" >
206+
<Terminal name="T1" connectivityNode="" substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
207+
<Terminal substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
208+
<EqFunction name="CBR">
209+
<LNode iedName="None" lnClass="CSWI" lnInst="1" lnType="someCSWI" />
210+
</EqFunction>
211+
</ConductingEquipment>
212+
</Bay>
213+
</VoltageLevel>
214+
</Substation>
215+
<Substation name="AA5">
216+
<VoltageLevel name="D1">
217+
<Bay name="Q01">
218+
<ConductingEquipment name="QA1" >
219+
<Terminal name="T1" connectivityNode="" substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
220+
<Terminal substationName="AA2" voltageLevelName="D1" bayName="Q01" cNodeName="L1" />
221+
<EqFunction name="CBR">
222+
<LNode iedName="None" lnClass="XCBR" lnInst="1" lnType="someXCBR" >
223+
<Private type="eIEC61850-6-100">
224+
<eTr_6-100:LNodeSpecNaming sIedName="None" sLnClass="XCBR" sLnInst="1"/>
225+
<eTr_6-100:LNodeInputs>
226+
<eTr_6-100:SourceRef source="AA3/J1/Q01/QA2/CBR/CSWI1/OpCls.general" input="CSWI1" inputInst="1" service="GOOSE"/>
227+
<eTr_6-100:SourceRef source="AA3/J1/Q01/QA2/CBR/CSWI1/OpCls.q" input="CSWI1" inputInst="2" service="GOOSE"/>
228+
<eTr_6-100:SourceRef source="AA3/J1/Q01/QA2/CBR/CSWI1/OpOpn.general" input="CSWI1" inputInst="3" service="GOOSE"/>
229+
<eTr_6-100:SourceRef source="AA3/J1/Q01/QA2/CBR/CSWI1/OpOpn.q" input="CSWI1" inputInst="4" service="GOOSE"/>
230+
<eTr_6-100:SourceRef source="AA4/D1/Q01/QA1/CBR/CSWI1/OpCls.general" input="CSWI1" inputInst="5" service="GOOSE"/>
231+
<eTr_6-100:SourceRef source="AA4/D1/Q01/QA1/CBR/CSWI1/OpCls.q" input="CSWI1" inputInst="6" service="GOOSE"/>
232+
<eTr_6-100:SourceRef source="AA4/D1/Q01/QA1/CBR/CSWI1/OpOpn.general" input="CSWI1" inputInst="7" service="GOOSE"/>
233+
<eTr_6-100:SourceRef source="AA4/D1/Q01/QA1/CBR/CSWI1/OpOpn.q" input="CSWI1" inputInst="8" service="GOOSE"/>
234+
<eTr_6-100:SourceRef input="CSWI1" inputInst="9" service="GOOSE" resourceName="outsideThisFile"/>
235+
</eTr_6-100:LNodeInputs>
236+
</Private>
237+
<LNode>
238+
</EqFunction>
239+
</ConductingEquipment>
240+
</Bay>
241+
</VoltageLevel>
242+
</Substation>
182243
</SCL>`;

0 commit comments

Comments
 (0)