Skip to content

Commit 51f0449

Browse files
JakobVogelsangJakob Vogelsang
authored andcommitted
feat: lNodeTypeToSelection
1 parent 453a273 commit 51f0449

File tree

4 files changed

+608
-0
lines changed

4 files changed

+608
-0
lines changed

index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export { sourceControlBlock } from "./tExtRef/sourceControlBlock.js";
6969
export { isSubscribed } from "./tExtRef/isSubscribed.js";
7070

7171
export { importLNodeType } from "./tDataTypeTemplates/importLNodeType.js";
72+
export {
73+
lNodeTypeToSelection,
74+
TreeSelection,
75+
} from "./tDataTypeTemplates/lNodeTypeToSelection.js";
7276

7377
export {
7478
Supervision,
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import { expect } from "chai";
2+
3+
import {
4+
baseDataTypes,
5+
invalidDataTypeTemplates,
6+
} from "./lNodeTypeToSelection.testfiles.js";
7+
8+
import { lNodeTypeToSelection } from "./lNodeTypeToSelection.js";
9+
10+
const mmxu = new DOMParser()
11+
.parseFromString(baseDataTypes, "text/xml")
12+
.querySelector("LNodeType[lnClass='MMXU']")!;
13+
14+
const tctr = new DOMParser()
15+
.parseFromString(invalidDataTypeTemplates, "text/xml")
16+
.querySelector("LNodeType[lnClass='TCTR']")!;
17+
18+
const mmxuSelection = {
19+
A: {
20+
phsA: {
21+
cVal: {
22+
ang: { f: {} },
23+
mag: { f: {} },
24+
},
25+
},
26+
},
27+
Beh: {
28+
stVal: {
29+
blocked: {},
30+
off: {},
31+
on: {},
32+
test: {},
33+
"test/blocked": {},
34+
},
35+
q: {},
36+
t: {},
37+
},
38+
Health: {
39+
stVal: {
40+
Alarm: {},
41+
Ok: {},
42+
Warning: {},
43+
},
44+
q: {},
45+
t: {},
46+
},
47+
Mod: {
48+
Cancel: {
49+
ctlVal: {
50+
blocked: {},
51+
off: {},
52+
on: {},
53+
test: {},
54+
"test/blocked": {},
55+
},
56+
origin: {
57+
orCat: {
58+
"automatic-bay": {},
59+
"automatic-remote": {},
60+
"automatic-station": {},
61+
"bay-control": {},
62+
maintenance: {},
63+
"not-supported": {},
64+
process: {},
65+
"remote-control": {},
66+
"station-control": {},
67+
},
68+
orIdent: {},
69+
},
70+
ctlNum: {},
71+
T: {},
72+
Test: {},
73+
},
74+
Oper: {
75+
ctlVal: {
76+
blocked: {},
77+
off: {},
78+
on: {},
79+
test: {},
80+
"test/blocked": {},
81+
},
82+
origin: {
83+
orCat: {
84+
"automatic-bay": {},
85+
"automatic-remote": {},
86+
"automatic-station": {},
87+
"bay-control": {},
88+
maintenance: {},
89+
"not-supported": {},
90+
process: {},
91+
"remote-control": {},
92+
"station-control": {},
93+
},
94+
orIdent: {},
95+
},
96+
ctlNum: {},
97+
T: {},
98+
Test: {},
99+
Check: {},
100+
},
101+
SBOw: {
102+
ctlVal: {
103+
blocked: {},
104+
off: {},
105+
on: {},
106+
test: {},
107+
"test/blocked": {},
108+
},
109+
origin: {
110+
orCat: {
111+
"automatic-bay": {},
112+
"automatic-remote": {},
113+
"automatic-station": {},
114+
"bay-control": {},
115+
maintenance: {},
116+
"not-supported": {},
117+
process: {},
118+
"remote-control": {},
119+
"station-control": {},
120+
},
121+
orIdent: {},
122+
},
123+
ctlNum: {},
124+
T: {},
125+
Test: {},
126+
Check: {},
127+
},
128+
ctlModel: {
129+
"direct-with-enhanced-security": {},
130+
"direct-with-normal-security": {},
131+
"sbo-with-enhanced-security": {},
132+
"sbo-with-normal-security": {},
133+
"status-only": {},
134+
},
135+
origin: {
136+
orCat: {
137+
"automatic-bay": {},
138+
"automatic-remote": {},
139+
"automatic-station": {},
140+
"bay-control": {},
141+
maintenance: {},
142+
"not-supported": {},
143+
process: {},
144+
"remote-control": {},
145+
"station-control": {},
146+
},
147+
orIdent: {},
148+
},
149+
stVal: {
150+
blocked: {},
151+
off: {},
152+
on: {},
153+
test: {},
154+
"test/blocked": {},
155+
},
156+
q: {},
157+
t: {},
158+
sboTimeout: {},
159+
operTimeout: {},
160+
},
161+
NamPlt: { vendor: {}, swRev: {}, d: {}, configRev: {}, ldNs: {} },
162+
};
163+
164+
const invalidTctrSelection = {
165+
AmpSv: {
166+
instMag: {},
167+
q: {},
168+
},
169+
Beh: {
170+
some: {},
171+
stVal: {},
172+
t: {},
173+
},
174+
Mode: {},
175+
};
176+
177+
describe("lNodeTypeToSelection", () => {
178+
it("returns correct selection for MMXU lNodeType", () =>
179+
expect(lNodeTypeToSelection(mmxu)).to.deep.equal(mmxuSelection));
180+
181+
it("does not return any invalid data type structure", () =>
182+
expect(lNodeTypeToSelection(tctr)).to.deep.equal(invalidTctrSelection));
183+
});

0 commit comments

Comments
 (0)