Skip to content

Commit e5ca4d4

Browse files
feat: allow to tag non IEC61850-7-4 namespaces
1 parent 82a7b99 commit e5ca4d4

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

tDataTypeTemplates/insertSelecetdLNodeType.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
mhaiSelection,
1010
mmxuSelection,
1111
ptocSelection,
12+
lln0Selection
1213
} from "./insertSelectedLNodeType.testdata.js";
1314

1415
import {
@@ -19,7 +20,7 @@ import {
1920
} from "./insertSelectedDataType.testfiles.js";
2021

2122
import { insertSelectedLNodeType } from "./insertSelectedLNodeType.js";
22-
import { LNodeDescription, nsdToJson } from "./nsdToJson.js";
23+
import { CdcChildren, DaDescription, LNodeDescription, nsdToJson } from "./nsdToJson.js";
2324

2425
const incompleteMmxu = findElement(missingMmxuTypes) as XMLDocument;
2526
const imcompleteLtrk = findElement(incompleteLtrkTypes) as XMLDocument;
@@ -215,4 +216,28 @@ describe("insertLNodeTypeSelection", () => {
215216
const doTypeEdit = edits[4].node as Element;
216217
expect(doTypeEdit.querySelector('SDO[name="phsAHar"]')?.getAttribute('count')).to.equal("maxPts");
217218
});
219+
220+
it('add user defined data object', () => {
221+
const lnData = nsdToJson("LLN0") as LNodeDescription;
222+
const userData = nsdToJson("SPS") as CdcChildren;
223+
(userData["dataNs"] as DaDescription).mandatory = true;
224+
(userData["dataNs"] as DaDescription).val = "TestNameSpace-1-d-1234567890";
225+
226+
const cdcDescription = {
227+
tagName: 'DataObject',
228+
type: 'SPS',
229+
descID: '',
230+
presCond: 'O',
231+
children: userData,
232+
};
233+
234+
Object.assign(lnData, {
235+
['TestDo']: cdcDescription,
236+
});
237+
238+
const edits = insertSelectedLNodeType(missingDataTypes, lln0Selection, { class: "LLN0", data: lnData });
239+
240+
expect(edits.length).to.equal(5);
241+
expect((edits[3].node as Element).querySelector('DA[name="dataNs"] > Val')?.textContent).to.equal("TestNameSpace-1-d-1234567890");
242+
})
218243
});

tDataTypeTemplates/insertSelectedLNodeType.testdata.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,23 @@ export const mhaiSelection = {
513513
}
514514
}
515515
}
516+
517+
export const lln0Selection = {
518+
"Beh": {
519+
"q": {},
520+
"stVal": {
521+
"blocked": {},
522+
"off": {},
523+
"on": {},
524+
"test": {},
525+
"test/blocked": {}
526+
},
527+
"t": {}
528+
},
529+
"TestDo": {
530+
"stVal": {},
531+
"q": {},
532+
"t": {},
533+
"dataNs": {}
534+
},
535+
}

tDataTypeTemplates/insertSelectedLNodeType.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ export function insertSelectedLNodeType(
332332
type?: string;
333333
isArray?: string;
334334
sizeAttribute?: string;
335+
val?: string;
335336
},
336337
][] = Object.entries(dO.children);
337338

@@ -360,6 +361,15 @@ export function insertSelectedLNodeType(
360361

361362
if (dep.typeKind === "BASIC" || !dep.typeKind) {
362363
da.setAttribute("bType", dep.type!);
364+
365+
366+
// One can include a value for any data attribute
367+
if (dep.val) {
368+
const value = createElement(doc, "Val", {});
369+
value.textContent = dep.val;
370+
(da as Node).insertBefore(value, null);
371+
}
372+
363373
}
364374

365375
if (dep.typeKind === "ENUMERATED") {

tDataTypeTemplates/nsdToJson.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type ServiceDaDescription = {
5858
children?: DaChildren;
5959
};
6060

61-
type DaDescription = {
61+
export type DaDescription = {
6262
tagName: string;
6363
name: string;
6464
type?: string;
@@ -75,9 +75,10 @@ type DaDescription = {
7575
defaultValue?: string;
7676
presCondArgs?: string;
7777
children?: DaChildren;
78+
val?: string
7879
};
7980

80-
type CdcChildren = Record<
81+
export type CdcChildren = Record<
8182
string,
8283
DaDescription | ServiceDaDescription | CdcDescription
8384
>;

0 commit comments

Comments
 (0)