Repository navigation
Expand file tree
/
Copy pathLDevice.spec.ts
More file actions
294 lines (282 loc) · 13.7 KB
/
Copy pathLDevice.spec.ts
File metadata and controls
294 lines (282 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
import { expect } from "chai";
import { LDevice } from "./LDevice.js";
const scl = new DOMParser().parseFromString(
`<SCL xmlns="http://www.iec.ch/61850/2003/SCL" >
<IED name="IED1">
<AccessPoint name="AP1">
<Server>
<LDevice inst="lDevice1">
<LN0 lnClass="LLN0" inst="" lnType="LLN0">
<DataSet name="baseDataSet" >
<FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" fc="ST" />
</DataSet>
<DOI name="Beh" >
<DAI name="stVal">
<Val>on</Val>
</DAI>
</DOI>
<GSEControl name="gse1" datSet="baseDataSet" />
<GSEControl name="gse2" />
<SampledValueControl name="smv1" datSet="baseDataSet" smpRate="80" nofASDU="1" >
<SmvOpts />
</SampledValueControl>
<SampledValueControl name="smv2" smpRate="80" nofASDU="1" >
<SmvOpts />
</SampledValueControl>
<Log name="someLog" />
<Log name="someOtherLog" />
<Inputs>
<ExtRef intAddr="Beh.t" pLN="LLN0" pDO="Beh" pDA="t" pServT="GOOSE" />
</Inputs>
</LN0>
<LN prefix="Meas" lnClass="MMXU" inst="1" lnType="MMXU" >
<DataSet name="baseDataSet" >
<FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" fc="ST" />
</DataSet>
<DOI name="A" >
<SDI name="phsA" >
<SDI name="cVal" >
<SDI name="mag" >
<DAI name="f" >
<Val sGroup="1">10.10</Val>
<Val sGroup="3">30.30</Val>
<Val sGroup="2">20.20</Val>
</DAI>
</SDI>
</SDI>
</SDI>
</DOI>
<LogControl name="anotherLog" logName="logName" />
<LogControl name="log" dataSet="baseDataSet" logName="logName" reasonCode="true" logEna="true" intgPd="0" bufTime="0" >
<TrgOps dchg="false" qchg="false" dupd="false" period="false" gi="false" />
</LogControl>
<ReportControl name="report" datSet="baseDataSet" intgPd="0" indexed="true" buffered="true" bufTime="0" confRev="0" >
<TrgOps dchg="false" qchg="false" dupd="false" period="false" gi="false" />
<OptFields seqNum="false" timeStamp="false" dataSet="false" reasonCode="false" dataRef="false" entryID="false" configRef="false" bufOvfl="false"/>
<RptEnabled max="0" />
</ReportControl>
<ReportControl name="anotherReport" />
</LN>
<LN lnClass="MMXU" inst="2" lnType="MMXU" />
</LDevice>
<LDevice inst="lDevice2">
<LN0 lnClass="LLN0" inst="" lnType="LLN02" >
<DataSet name="equalDataSet" >
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" />
</DataSet>
<GSEControl name="gse2" />
<GSEControl name="gse1" datSet="equalDataSet" />
<SampledValueControl name="smv2" smpRate="80" nofASDU="1" >
<SmvOpts />
</SampledValueControl>
<SampledValueControl name="smv1" datSet="equalDataSet" smpRate="80" nofASDU="1" >
<SmvOpts />
</SampledValueControl>
<Log name="someOtherLog" />
<Log name="someLog" />
<Inputs>
<ExtRef intAddr="Beh.t" pLN="LLN0" pDO="Beh" pDA="t" pServT="GOOSE" />
</Inputs>
</LN0>
<LN lnClass="MMXU" inst="2" lnType="MMXU" />
<LN prefix="Meas" lnClass="MMXU" inst="1" lnType="MMXU2" >
<DataSet name="equalDataSet" >
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="XCBR" lnInst="1" doName="Pos" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="XCBR" lnInst="1" doName="Pos" daName="q" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" prefix="" lnClass="LLN0" lnInst="" doName="Beh" daName="stVal" fc="ST" />
<FCDA iedName="IED1" ldInst="lDevice" lnClass="LLN0" doName="Beh" fc="ST" />
</DataSet>
<LogControl name="log" dataSet="equalDataSet" logName="logName" />
<LogControl name="anotherLog" logName="logName" />
<ReportControl name="anotherReport" />
<ReportControl name="report" datSet="equalDataSet" />
</LN>
</LDevice>
<LDevice inst="lDevice3" ldName="ldName" >
<LN0 lnClass="LLN0" inst="" lnType="LLN0" >
<DOI name="Beh" >
<DAI name="stVal">
<Val>test</Val>
</DAI>
</DOI>
<Inputs>
<ExtRef intAddr="A.phsA" pLN="MMXU" pDO="A.phsA" pDA="cVal.mag.f" pServT="SMV" />
</Inputs>
</LN0>
<LN prefix="Meas" lnClass="MMXU" inst="1" lnType="MMXU" >
<DOI name="A" >
<SDI >
<Val sGroup="1">10.10</Val>
<Val sGroup="3">30.30</Val>
<Val sGroup="2">20.20</Val>
</SDI>
</DOI>
</LN>
<AccessControl>Some AccessControl Own Namespace thingy!</AccessControl>
</LDevice>
<LDevice inst="lDevice4" >
</LDevice>
<LDevice inst="lDevice5" >
<LN0 lnClass="LLN0" inst="" />
</LDevice>
<LDevice inst="lDevice6" >
<LN0 lnClass="LLN0" inst="LLN0" />
<LN lnClass="PTOC" inst="1" lnType="invalidPTOC" />
</LDevice>
<LDevice inst="lDevice7" >
<LN0 lnClass="LLN0" inst="" lnType="LLN0" />
<LN lnClass="MMXU" inst="1" lnType="MMXU" />
<LN lnClass="MMXU" inst="2" lnType="MMXU" />
<LN lnType="MMXU" />
</LDevice>
<LDevice inst="lDevice8" >
<LN0 lnClass="LLN0" inst="" lnType="LLN0" />
<LN lnClass="MMXU" inst="1" lnType="MMXU" />
<LN lnClass="MMXU" inst="2" lnType="MMXU3" />
<LN lnType="MMXU" />
</LDevice>
</Server>
</AccessPoint>
</IED>
<DataTypeTemplates>
<LNodeType id="invalidPTOC" desc="desc" lnType="lnType" />
<LNodeType id="LLN0" desc="desc" lnClass="LLN0">
<DO name="Beh" type="BehENS"/>
</LNodeType>
<LNodeType id="LLN02" desc="desc" lnClass="LLN0">
<DO name="Beh" type="BehENS2"/>
</LNodeType>
<LNodeType id="diffLLN0" desc="desc" lnClass="LLN0">
<DO name="Beh" type="diffBehENS"/>
</LNodeType>
<LNodeType id="MMXU" desc="desc" lnClass="MMXU">
<DO name="A" type="WYE"/>
</LNodeType>
<LNodeType id="MMXU2" desc="desc" lnClass="MMXU">
<DO name="A" type="WYE2"/>
</LNodeType>
<LNodeType id="diffMMXU" desc="desc" lnClass="MMXU">
<DO name="A" type="diffWYE"/>
</LNodeType>
<DOType cdc="ENS" id="BehENS" >
<DA name="stVal" bType="Enum" type="BehModKind" fc="ST" >
<Val>off</Val>
</DA>
</DOType>
<DOType cdc="ENS" id="BehENS2" >
<DA name="stVal" bType="Enum" type="BehModKind" fc="ST" >
<Val>on</Val>
</DA>
</DOType>
<DOType id="diffBehENS" cdc="ENS" >
<DA name="stVal" bType="Enum" type="BehModKind" fc="ST" >
<Val>on</Val>
</DA>
<DA name="q" bType="Quality" fc="ST" />
</DOType>
<DOType id="WYE" cdc="WYE">
<SDO name="phsA" type="CMV" />
</DOType>
<DOType id="WYE2" cdc="WYE">
<SDO name="phsA" type="CMV2" />
</DOType>
<DOType id="diffWYE" cdc="WYE">
<SDO name="phsA" type="diffCMV" />
<SDO name="phsB" type="CMV" />
</DOType>
<DOType id="CMV" cdc="CMV" >
<DA name="cVal" bType="Struct" fc="MX" type="Vector"/>
</DOType>
<DOType id="CMV2" cdc="CMV" >
<DA name="cVal" bType="Struct" fc="MX" type="Vector2"/>
</DOType>
<DOType id="diffCMV" cdc="CMV" >
<DA name="cVal" bType="Struct" fc="MX" type="diffVector"/>
<DA name="q" bType="Quality" fc="MX" />
</DOType>
<DAType id="Vector" >
<BDA name="mag" bType="Struct" type="AnalogueValue" />
</DAType>
<DAType id="Vector2" >
<BDA name="mag" bType="Struct" type="AnalogueValue2" />
</DAType>
<DAType id="diffVector" >
<BDA name="mag" bType="Struct" type="AnalogueValue" />
<BDA name="ang" bType="Struct" type="AnalogueValue" />
</DAType>
<DAType id="AnalogueValue" >
<BDA name="f" bType="FLOAT32" >
<Val sGroup="3">60.60</Val>
<Val sGroup="1">10.10</Val>
<Val sGroup="2">40.10</Val>
</BDA>
</DAType>
<DAType id="AnalogueValue2" >
<BDA name="f" bType="FLOAT32" >
<Val sGroup="3">30.30</Val>
<Val sGroup="1">10.10</Val>
<Val sGroup="2">20.20</Val>
</BDA>
</DAType>
<EnumType id="BehModKind" >
<EnumVal ord="1">on</EnumVal>
<EnumVal ord="3">test</EnumVal>
<EnumVal ord="5">off</EnumVal>
</EnumType>
<EnumType id="diffBehModKind" >
<EnumVal ord="1">on</EnumVal>
<EnumVal ord="3">test</EnumVal>
</EnumType>
</DataTypeTemplates>
</SCL>`,
"application/xml",
);
/*
const missingLnType = scl.querySelector('*[desc="missingLnType"]')!;
const invalidLnType = scl.querySelector('*[desc="invalidLnType"]')!;
const invalidLnTypeDescription = scl.querySelector(
'*[desc="invalidLnTypeDescription"]'
)!; */
const baseLDevice = scl.querySelector(`LDevice[inst="lDevice1"]`)!;
const equalLDevice = scl.querySelector('LDevice[inst="lDevice2"]')!;
const diffLDevice = scl.querySelector('LDevice[inst="lDevice3"]')!;
const missingLLN0 = scl.querySelector('LDevice[inst="lDevice4"]')!;
const missingLnType = scl.querySelector('LDevice[inst="lDevice5"]')!;
const invalidLnType = scl.querySelector('LDevice[inst="lDevice6"]')!;
const missingInst = scl.querySelector('LDevice[inst="lDevice7"]')!;
const undefinedLN = scl.querySelector('LDevice[inst="lDevice8"]')!;
describe("Description for SCL schema type LDevice", () => {
it("returns undefined with missing lnType attribute", () =>
expect(LDevice(missingLLN0)).to.be.undefined);
it("returns undefined with missing lnType attribute", () =>
expect(LDevice(missingLnType)).to.be.undefined);
it("returns undefined with invalid lnType attribute", () =>
expect(LDevice(invalidLnType)).to.be.undefined);
it("returns undefined with missing lnType attribute", () =>
expect(LDevice(missingInst)).to.be.undefined);
it("returns undefined with at least one undefined LNDescription", () =>
expect(LDevice(undefinedLN)).to.be.undefined);
it("return ldName attribute if present", () =>
expect(LDevice(diffLDevice)?.ldName).to.equal("ldName"));
it("return AccessControl child as a string if present", () =>
expect(LDevice(diffLDevice)?.accessControl).to.equal(
`<AccessControl xmlns="http://www.iec.ch/61850/2003/SCL">Some AccessControl Own Namespace thingy!</AccessControl>`,
));
it("returns same description with semantically equal LDevice's", () =>
expect(JSON.stringify(LDevice(baseLDevice))).to.equal(
JSON.stringify(LDevice(equalLDevice)),
));
it("returns different description with unequal LDevice elements", () =>
expect(JSON.stringify(LDevice(baseLDevice))).to.not.equal(
JSON.stringify(LDevice(diffLDevice)),
));
});