Repository navigation
Expand file tree
/
Copy pathLN.spec.ts
More file actions
289 lines (280 loc) · 12 KB
/
Copy pathLN.spec.ts
File metadata and controls
289 lines (280 loc) · 12 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
import { expect } from "chai";
import { LN } from "./LN.js";
import { LNodeType, isLNodeTypeDescription } from "./LNodeType.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">
<DOI name="Beh" >
<DAI name="stVal">
<Val>on</Val>
</DAI>
</DOI>
<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 desc="missingLnType" prefix="" lnClass="PTOC" inst="1" />
<LN desc="invalidLnType" prefix="" lnClass="PTOC" inst="1" lnType="invalidPointer"/>
<LN desc="invalidLnTypeDescription" prefix="" lnClass="PTOC" inst="1" lnType="invalidPTOC"/>
</LDevice>
<LDevice inst="lDevice2">
<LN0 lnClass="LLN0" inst="" lnType="LLN02" >
<Log name="someOtherLog" />
<Log name="someLog" />
<Inputs>
<ExtRef intAddr="Beh.t" pLN="LLN0" pDO="Beh" pDA="t" pServT="GOOSE" />
</Inputs>
</LN0>
<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">
<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>
<DOI name="B" >
<SDI name="phsA" >
<Val sGroup="1">10.10</Val>
<Val sGroup="3">30.30</Val>
<Val sGroup="2">20.20</Val>
</SDI>
</DOI>
</LN>
</LDevice>
<LDevice inst="lDevice4" >
<LN0 lnClass="LLN0" inst="" lnType="diffLLN0" />
<LN lnClass="MMXU" inst="1" lnType="diffMMXU" >
<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>
</LN>
</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 baseLLN0 = scl.querySelector(
`LDevice[inst="lDevice1"] > *[lnClass="LLN0"][inst=""]`,
)!;
const equalLLN0 = scl.querySelector(
'LDevice[inst="lDevice2"] > *[lnClass="LLN0"][inst=""]',
)!;
const diffLLN0 = scl.querySelector(
'LDevice[inst="lDevice3"] > *[lnClass="LLN0"][inst=""]',
)!;
const diffEnumType = scl.querySelector(
'LDevice[inst="lDevice4"] > *[lnClass="LLN0"][inst=""]',
)!;
const baseMMXU = scl.querySelector(
`LDevice[inst="lDevice1"] > *[lnClass="MMXU"][inst="1"]`,
)!;
const equalMMXU = scl.querySelector(
`LDevice[inst="lDevice2"] > *[lnClass="MMXU"][inst="1"]`,
)!;
const diffMMXU = scl.querySelector(
`LDevice[inst="lDevice3"] > *[lnClass="MMXU"][inst="1"]`,
)!;
const diffSDO = scl.querySelector(
`LDevice[inst="lDevice4"] > *[lnClass="MMXU"][inst="1"]`,
)!;
describe("Description for SCL schema type LN", () => {
it("returns undefined with missing lnType attribute", () =>
expect(LN(missingLnType)).to.be.undefined);
it("returns undefined with invalid lnType attribute", () =>
expect(LN(invalidLnType)).to.be.undefined);
it("returns undefined with invalid LNodeType description", () =>
expect(LN(invalidLnTypeDescription)).to.be.undefined);
it("return logical node structure in lnType key", () =>
expect(LN(baseLLN0)?.lnType).to.satisfy(isLNodeTypeDescription));
it("returns same description with semantically equal LN's", () => {
expect(JSON.stringify(LN(baseLLN0))).to.equal(
JSON.stringify(LN(equalLLN0)),
);
expect(JSON.stringify(LN(baseMMXU))).to.equal(
JSON.stringify(LN(equalMMXU)),
);
});
it("returns different description with unequal LN elements", () => {
expect(JSON.stringify(LN(baseLLN0))).to.not.equal(
JSON.stringify(LN(diffLLN0)),
);
expect(JSON.stringify(LN(baseLLN0))).to.not.equal(
JSON.stringify(LN(diffEnumType)),
);
expect(JSON.stringify(LN(baseMMXU))).to.not.equal(
JSON.stringify(LN(diffMMXU)),
);
expect(JSON.stringify(LN(baseMMXU))).to.not.equal(
JSON.stringify(LN(diffSDO)),
);
});
});