|
| 1 | +import { expect } from "chai"; |
| 2 | + |
| 3 | +import { describeGSEControl } from "./GSEControl.js"; |
| 4 | + |
| 5 | +const scl = new DOMParser().parseFromString( |
| 6 | + `<SCL xmlns="http://www.iec.ch/61850/2003/SCL" > |
| 7 | + <IED name="IED1"> |
| 8 | + <AccessPoint name="AP1"> |
| 9 | + <Server> |
| 10 | + <LDevice inst="lDevice"> |
| 11 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0"> |
| 12 | + <DataSet name="baseDataSet" > |
| 13 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 14 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 15 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" daName="stVal" fc="ST" /> |
| 16 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" fc="ST" /> |
| 17 | + </DataSet> |
| 18 | + <DataSet name="equalDataSet" > |
| 19 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 20 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 21 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" /> |
| 22 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" /> |
| 23 | + </DataSet> |
| 24 | + <DataSet name="diffDataSet" > |
| 25 | + <Private type="private" /> |
| 26 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 27 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" /> |
| 28 | + <FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" /> |
| 29 | + <FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" /> |
| 30 | + </DataSet> |
| 31 | + <DataSet name="invalidDataSet" > |
| 32 | + <FCDA ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" /> |
| 33 | + </DataSet> |
| 34 | + <GSEControl name="gseControl1" datSet="baseDataSet" confRev="1" appID="appID" fixedOffs="false" securityEnable="Signature" > |
| 35 | + <IEDName apRef="AP1" ldInst="ldInst" prefix="CB" lnClass="CSWI" lnInst="1">IED3</IEDName> |
| 36 | + <IEDName >IED1</IEDName> |
| 37 | + <IEDName apRef="AP1" ldInst="ldInst" lnClass="LLN0">IED2</IEDName> |
| 38 | + <IEDName >IED1</IEDName> |
| 39 | + <Protocol mustUnderstand="true">R-GOOSE</Protocol> |
| 40 | + </GSEControl> |
| 41 | + <GSEControl name="gseControl2" datSet="equalDataSet" confRev="1" appID="appID" securityEnable="Signature" > |
| 42 | + <IEDName >IED1</IEDName> |
| 43 | + <IEDName apRef="AP1" ldInst="ldInst" prefix="" lnClass="LLN0" lnInst="" >IED2</IEDName> |
| 44 | + <IEDName apRef="AP1" ldInst="ldInst" prefix="CB" lnClass="CSWI" lnInst="1" >IED3</IEDName> |
| 45 | + <IEDName >IED1</IEDName> |
| 46 | + <Protocol mustUnderstand="true">R-GOOSE</Protocol> |
| 47 | + </GSEControl> |
| 48 | + <GSEControl name="gseControl5" datSet="diffDataSet" type="GSSE" fixedOffs="true" /> |
| 49 | + <GSEControl name="gseControl3" datSet="invalidDataSet" /> |
| 50 | + <GSEControl name="gseControl4" datSet="invalidReference" /> |
| 51 | + </LN0> |
| 52 | + </LDevice> |
| 53 | + </Server> |
| 54 | + </AccessPoint> |
| 55 | + </IED> |
| 56 | + </SCL>`, |
| 57 | + "application/xml" |
| 58 | +); |
| 59 | + |
| 60 | +const baseGSEControl = scl.querySelector(`*[datSet="baseDataSet"]`)!; |
| 61 | +const equalGSEControl = scl.querySelector('*[datSet="equalDataSet"]')!; |
| 62 | +const diffGSEControl = scl.querySelector('*[datSet="diffDataSet"]')!; |
| 63 | +const invalidDataSet = scl.querySelector('*[datSet="invalidDataSet"]')!; |
| 64 | +const invalidReference = scl.querySelector('*[datSet="invalidReference"]')!; |
| 65 | + |
| 66 | +describe("Description for SCL schema type tControlWithIEDName", () => { |
| 67 | + it("returns undefined when referenced DataSet is undefined", () => |
| 68 | + expect(describeGSEControl(invalidDataSet)).to.be.undefined); |
| 69 | + |
| 70 | + it("returns undefined with missing referenced DataSet", () => |
| 71 | + expect(describeGSEControl(invalidReference)).to.be.undefined); |
| 72 | + |
| 73 | + it("returns same description with semantically equal GSEControl's", () => |
| 74 | + expect(JSON.stringify(describeGSEControl(baseGSEControl))).to.equal( |
| 75 | + JSON.stringify(describeGSEControl(equalGSEControl)) |
| 76 | + )); |
| 77 | + |
| 78 | + it("returns different description with unequal GSEControl elements", () => |
| 79 | + expect(JSON.stringify(describeGSEControl(baseGSEControl))).to.not.equal( |
| 80 | + JSON.stringify(describeGSEControl(diffGSEControl)) |
| 81 | + )); |
| 82 | +}); |
0 commit comments