Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion tDataTypeTemplates/insertSelecetdLNodeType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
mhaiSelection,
mmxuSelection,
ptocSelection,
lln0Selection
} from "./insertSelectedLNodeType.testdata.js";

import {
Expand All @@ -19,7 +20,7 @@ import {
} from "./insertSelectedDataType.testfiles.js";

import { insertSelectedLNodeType } from "./insertSelectedLNodeType.js";
import { LNodeDescription, nsdToJson } from "./nsdToJson.js";
import { CdcChildren, DaDescription, LNodeDescription, nsdToJson } from "./nsdToJson.js";

const incompleteMmxu = findElement(missingMmxuTypes) as XMLDocument;
const imcompleteLtrk = findElement(incompleteLtrkTypes) as XMLDocument;
Expand Down Expand Up @@ -215,4 +216,28 @@ describe("insertLNodeTypeSelection", () => {
const doTypeEdit = edits[4].node as Element;
expect(doTypeEdit.querySelector('SDO[name="phsAHar"]')?.getAttribute('count')).to.equal("maxPts");
});

it('add user defined data object', () => {
const lnData = nsdToJson("LLN0") as LNodeDescription;
const userData = nsdToJson("SPS") as CdcChildren;
(userData["dataNs"] as DaDescription).mandatory = true;
(userData["dataNs"] as DaDescription).val = "TestNameSpace-1-d-1234567890";

const cdcDescription = {
tagName: 'DataObject',
type: 'SPS',
descID: '',
presCond: 'O',
children: userData,
};

Object.assign(lnData, {
['TestDo']: cdcDescription,
});

const edits = insertSelectedLNodeType(missingDataTypes, lln0Selection, { class: "LLN0", data: lnData });

expect(edits.length).to.equal(5);
expect((edits[3].node as Element).querySelector('DA[name="dataNs"] > Val')?.textContent).to.equal("TestNameSpace-1-d-1234567890");
})
});
20 changes: 20 additions & 0 deletions tDataTypeTemplates/insertSelectedLNodeType.testdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,23 @@ export const mhaiSelection = {
}
}
}

export const lln0Selection = {
"Beh": {
"q": {},
"stVal": {
"blocked": {},
"off": {},
"on": {},
"test": {},
"test/blocked": {}
},
"t": {}
},
"TestDo": {
"stVal": {},
"q": {},
"t": {},
"dataNs": {}
},
}
10 changes: 10 additions & 0 deletions tDataTypeTemplates/insertSelectedLNodeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export function insertSelectedLNodeType(
type?: string;
isArray?: string;
sizeAttribute?: string;
val?: string;
},
][] = Object.entries(dO.children);

Expand Down Expand Up @@ -360,6 +361,15 @@ export function insertSelectedLNodeType(

if (dep.typeKind === "BASIC" || !dep.typeKind) {
da.setAttribute("bType", dep.type!);


// One can include a value for any data attribute
if (dep.val) {
const value = createElement(doc, "Val", {});
value.textContent = dep.val;
(da as Node).insertBefore(value, null);
}

}

if (dep.typeKind === "ENUMERATED") {
Expand Down
5 changes: 3 additions & 2 deletions tDataTypeTemplates/nsdToJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type ServiceDaDescription = {
children?: DaChildren;
};

type DaDescription = {
export type DaDescription = {
tagName: string;
name: string;
type?: string;
Expand All @@ -75,9 +75,10 @@ type DaDescription = {
defaultValue?: string;
presCondArgs?: string;
children?: DaChildren;
val?: string
};

type CdcChildren = Record<
export type CdcChildren = Record<
string,
DaDescription | ServiceDaDescription | CdcDescription
>;
Expand Down