Skip to content

Commit d076137

Browse files
committed
wip: hash entire DataTypeTemplates element
1 parent 121aa15 commit d076137

File tree

2 files changed

+242
-81
lines changed

2 files changed

+242
-81
lines changed

hash.spec.ts

Lines changed: 178 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const baseEnumType = testScl.querySelector("#someID")!;
151151

152152
const baseDAType = testScl.querySelector("#someBaseDAType")!;
153153
const baseDOType = testScl.querySelector("#someBaseDOType")!;
154+
const baseLNodeType = testScl.querySelector("#baseLLN0")!;
154155

155156
// const baseIED = testScl.querySelector(`IED[name="IED1"]`)!;
156157
// const equalIED = testScl.querySelector(`IED[name="IED2"]`)!;
@@ -189,29 +190,202 @@ describe("hasher", () => {
189190
});
190191

191192
it("hashes DATypes by BDAs and ProtNs", () => {
193+
hash(baseDAType);
194+
/*
192195
const digest = hash(baseDAType);
193196
const description = db.DAType[digest] as Record<string, string[]>;
194197
expect(description).to.deep.equal({
195198
// FIXME(ca-d): define correct behaviour
196-
desc: "someDesc",
197-
"@BDA": ["b134bb4b87b783fa", "fcd3828e35e87aa4"],
199+
"@BDA": ["18d6c93b2cc1cc55", "dd9f5c7e69b1708c"],
198200
"@ProtNs": ["4fd2d8f99b2f756a"],
199201
});
202+
*/
200203
// TODO(ca-d): test siblingCount
201204
});
202205

203206
it("hashes DOTypes by DAs and SDOs", () => {
207+
hash(baseDOType);
208+
/*
204209
const digest = hash(baseDOType);
205210
const description = db.DOType[digest] as Record<string, string[]>;
206211
expect(description).to.deep.equal({
207212
// FIXME(ca-d): define correct behaviour
208-
"@DA": ["4af99b41c4a5737c"],
213+
"@DA": ["74871b9108bd5768"],
214+
cdc: "SPS",
209215
});
216+
*/
217+
});
218+
219+
it("hashes LNodeTypes by DOs", () => {
220+
hash(baseLNodeType);
221+
/*
222+
const digest = hash(baseLNodeType);
223+
const description = db.LNodeType[digest] as Record<string, string[]>;
224+
expect(description).to.deep.equal({
225+
// FIXME(ca-d): define correct behaviour
226+
"@DO": ["4c6e42c7c8b0797f"],
227+
lnClass: "LLN0",
228+
});
229+
*/
230+
});
231+
232+
it("hashes LNodeTypes by DOs", () => {
233+
hash(testScl.querySelector("DataTypeTemplates")!);
210234
});
211235

212236
after(() => {
237+
/* // primivite snapshot test - uncomment to update
213238
Object.keys(db).forEach((key) => {
214-
console.log(key, db[key]);
239+
console.log('expect(db["' + key + '"]).to.deep.equal(', db[key], ")");
240+
});
241+
*/
242+
expect(db["SomeNonSCLElement@http://somevalidURI"]).to.deep.equal({
243+
b6712fb57eb0e24b: {
244+
xml: '<ens:SomeNonSCLElement xmlns:ens="http://somevalidURI"/>',
245+
},
246+
});
247+
expect(db.Private).to.deep.equal({
248+
"082c018bb12fb5e5": {
249+
xml:
250+
'<Private xmlns="http://www.iec.ch/61850/2003/SCL" type="someType" desc="someDesc" xmlns:sxy="http://www.iec.ch/61850/2003/SCLcoordinates" sxy:x="10" xmlns:ens="http://somevalidURI" ens:some="someOtherNameSpace">\n' +
251+
" <![CDATA[some comment]]>\n" +
252+
' <IED name="somePrivateIED"/>\n' +
253+
" </Private>",
254+
},
255+
"878b5b8db7dc9340": {
256+
xml:
257+
'<Private xmlns="http://www.iec.ch/61850/2003/SCL" type="someType" desc="someDesc" xmlns:ens="http://somevalidURI" ens:some="someOtherNameSpace" xmlns:sxy="http://www.iec.ch/61850/2003/SCLcoordinates" sxy:x="10">\n' +
258+
" <![CDATA[some comment]]>\n" +
259+
' <IED name="somePrivateIED"/>\n' +
260+
" </Private>",
261+
},
262+
});
263+
expect(db.Text).to.deep.equal({
264+
"6e995d62cc5f8f1a": {
265+
xml: '<Text xmlns="http://www.iec.ch/61850/2003/SCL">Some detailed description</Text>',
266+
},
267+
});
268+
expect(db.EnumVal).to.deep.equal({
269+
"8f561e2a03513559": { ord: 1, val: "A" },
270+
"25599d957ef37857": { ord: -1, val: "SomeContent" },
271+
ef0565086e00a6e5: { ord: 13, val: "SomeOtherContent" },
272+
"7332c15a44952cce": { ord: -23, val: "" },
273+
"728b4a0f4332e9c5": { ord: 1, val: "" },
274+
});
275+
expect(db.EnumType).to.deep.equal({
276+
c2541301f8126d77: {
277+
"@Private": ["082c018bb12fb5e5"],
278+
"@Text": ["6e995d62cc5f8f1a"],
279+
"@ens:SomeNonSCLElement": ["b6712fb57eb0e24b"],
280+
"@EnumVal": ["8f561e2a03513559"],
281+
},
282+
"52e71c8529bf548f": {
283+
"@EnumVal": [
284+
"25599d957ef37857",
285+
"7332c15a44952cce",
286+
"ef0565086e00a6e5",
287+
],
288+
},
289+
"01bfdeb82adbbab3": {
290+
"@Private": ["878b5b8db7dc9340"],
291+
"@Text": ["6e995d62cc5f8f1a"],
292+
"@ens:SomeNonSCLElement": ["b6712fb57eb0e24b"],
293+
"@EnumVal": ["728b4a0f4332e9c5"],
294+
},
295+
});
296+
expect(db.Val).to.deep.equal({
297+
"4841a3d87b04aa9b": { val: "45.00", sGroup: 1 },
298+
"0fc915000247dd52": { val: "65.00", sGroup: 2 },
299+
});
300+
expect(db.BDA).to.deep.equal({
301+
a99636321898296f: {
302+
"@Val": ["0fc915000247dd52", "4841a3d87b04aa9b"],
303+
bType: "FLOAT32",
304+
valImport: true,
305+
valKind: "RO",
306+
count: 0,
307+
},
308+
"017e02f18557b8a3": {
309+
bType: "Struct",
310+
sAddr: "someSAddr",
311+
valKind: "Set",
312+
valImport: false,
313+
count: 0,
314+
"@DAType": ["c579130da5263aca"],
315+
},
316+
"0ad0aa080b280458": {
317+
bType: "Enum",
318+
sAddr: "someSAddr",
319+
valKind: "Set",
320+
valImport: false,
321+
count: 0,
322+
"@EnumType": ["52e71c8529bf548f"],
323+
},
324+
});
325+
expect(db.DAType).to.deep.equal({
326+
c579130da5263aca: {
327+
"@BDA": ["a99636321898296f"],
328+
iedType: "someIedType",
329+
},
330+
d322e88e06132d1b: {
331+
"@BDA": ["017e02f18557b8a3", "0ad0aa080b280458"],
332+
"@ProtNs": ["4fd2d8f99b2f756a"],
333+
},
334+
});
335+
expect(db.ProtNs).to.deep.equal({
336+
"4fd2d8f99b2f756a": { type: "8-MMS", val: "IEC 61850-8-1:2007" },
337+
});
338+
expect(db.DA).to.deep.equal({
339+
d567af79f866336f: {
340+
bType: "Struct",
341+
fc: "ST",
342+
valKind: "Set",
343+
valImport: false,
344+
count: 0,
345+
"@DAType": ["d322e88e06132d1b"],
346+
},
347+
"745036cf3aa59119": {
348+
bType: "Enum",
349+
fc: "ST",
350+
valKind: "Set",
351+
valImport: false,
352+
count: 0,
353+
"@EnumType": ["c2541301f8126d77"],
354+
},
355+
});
356+
expect(db.DOType).to.deep.equal({
357+
"8eaab6c78d2cf143": { cdc: "SPS", "@DA": ["d567af79f866336f"] },
358+
d359de8b7fddee2c: { cdc: "SPS", "@DA": ["745036cf3aa59119"] },
359+
});
360+
expect(db.DO).to.deep.equal({
361+
"2b5d2e745d7551b4": { "@DOType": ["8eaab6c78d2cf143"] },
362+
"80c83ba21492936c": { "@DOType": ["d359de8b7fddee2c"] },
363+
});
364+
expect(db.LNodeType).to.deep.equal({
365+
"4e0619031232ec6e": { "@DO": ["2b5d2e745d7551b4"], lnClass: "LLN0" },
366+
ef46e239e70ddbc9: { "@DO": ["80c83ba21492936c"], lnClass: "LLN0" },
367+
aeb05f6e8affc23a: { "@DO": ["2b5d2e745d7551b4"], lnClass: "XCBR" },
368+
"99a26557bf1bb276": { "@DO": ["80c83ba21492936c"], lnClass: "XCBR" },
369+
});
370+
expect(db.DataTypeTemplates).to.deep.equal({
371+
bc00e9afa5b7022e: {
372+
"@LNodeType": [
373+
"4e0619031232ec6e",
374+
"4e0619031232ec6e",
375+
"99a26557bf1bb276",
376+
"aeb05f6e8affc23a",
377+
"aeb05f6e8affc23a",
378+
"ef46e239e70ddbc9",
379+
],
380+
"@DOType": ["8eaab6c78d2cf143", "8eaab6c78d2cf143", "d359de8b7fddee2c"],
381+
"@DAType": ["c579130da5263aca", "d322e88e06132d1b", "d322e88e06132d1b"],
382+
"@EnumType": [
383+
"01bfdeb82adbbab3",
384+
"52e71c8529bf548f",
385+
"c2541301f8126d77",
386+
"c2541301f8126d77",
387+
],
388+
},
215389
});
216390
});
217391
});

0 commit comments

Comments
 (0)