@@ -11,7 +11,12 @@ export const supportedCdcTypes =
11
11
'SEC' , 'SPC' , 'SPG' , 'SPS' ] as const ;
12
12
export type SupportedCdcType = typeof supportedCdcTypes [ number ] ;
13
13
14
- export type CreateFunction = ( daiElement : Element , selectedTi : string ) => Create [ ] ;
14
+ export type CreateFunction = ( daiElement : Element , selectedTi : string , inverted : boolean ) => Create [ ] ;
15
+ export interface TiInformation {
16
+ filter : string ;
17
+ create : CreateFunction ;
18
+ inverted ?: boolean ;
19
+ }
15
20
16
21
/**
17
22
* Record with configuration information on how to create Address elements for the 104 protocol.
@@ -25,14 +30,8 @@ export type CreateFunction = (daiElement: Element, selectedTi: string) => Create
25
30
export const cdcProcessings : Record <
26
31
SupportedCdcType ,
27
32
{
28
- monitor : Record < string , {
29
- filter : string ;
30
- create : CreateFunction ;
31
- } > ,
32
- control : Record < string , {
33
- filter : string ;
34
- create : CreateFunction ;
35
- } > ,
33
+ monitor : Record < string , TiInformation > ,
34
+ control : Record < string , TiInformation > ,
36
35
}
37
36
> = {
38
37
ACT : {
@@ -43,11 +42,12 @@ export const cdcProcessings: Record<
43
42
':scope > DAI[name="phsB"], ' +
44
43
':scope > DAI[name="phsC"], ' +
45
44
':scope > DAI[name="neut"]' ,
46
- create : createSingleAddressAction
45
+ create : createAddressAction ,
46
+ inverted : true
47
47
} ,
48
48
'39' : {
49
49
filter : ':scope > DAI[name="general"]' ,
50
- create : createSingleAddressAction
50
+ create : createAddressAction
51
51
}
52
52
} ,
53
53
control : { }
@@ -56,21 +56,21 @@ export const cdcProcessings: Record<
56
56
monitor : {
57
57
'36' : {
58
58
filter : ':scope > SDI[name="mxVal"] > DAI[name="f"]' ,
59
- create : createSingleAddressAction
59
+ create : createAddressAction
60
60
} ,
61
61
} ,
62
62
control : {
63
63
'63' : {
64
64
filter : ':scope > SDI[name="Oper"] > SDI[name="ctlVal"] > DAI[name="f"]' ,
65
- create : createSingleAddressAction
65
+ create : createAddressAction
66
66
} ,
67
67
}
68
68
} ,
69
69
ASG : {
70
70
monitor : {
71
71
'63' : {
72
72
filter : ':scope > SDI[name="setMag"] > DAI[name="f"]' ,
73
- create : createSingleAddressAction
73
+ create : createAddressAction
74
74
}
75
75
} ,
76
76
control : { }
@@ -79,13 +79,13 @@ export const cdcProcessings: Record<
79
79
monitor : {
80
80
'36' : {
81
81
filter : ':scope > SDI[name="mxVal"] > DAI[name="f"]' ,
82
- create : createSingleAddressAction
82
+ create : createAddressAction
83
83
} ,
84
84
} ,
85
85
control : {
86
86
'60' : {
87
87
filter : ':scope > SDI[name="Oper"] > DAI[name="ctlVal"]' ,
88
- create : createSingleAddressAction
88
+ create : createAddressAction
89
89
} ,
90
90
}
91
91
} ,
@@ -94,7 +94,7 @@ export const cdcProcessings: Record<
94
94
'37' : {
95
95
filter : ':scope > DAI[name="actVal"], ' +
96
96
':scope > DAI[name="frVal"]' ,
97
- create : createSingleAddressAction
97
+ create : createAddressAction
98
98
} ,
99
99
} ,
100
100
control : { }
@@ -103,13 +103,13 @@ export const cdcProcessings: Record<
103
103
monitor : {
104
104
'32' : {
105
105
filter : ':scope > SDI[name="valWTr"] > DAI[name="posVal"]' ,
106
- create : createSingleAddressAction
106
+ create : createAddressAction
107
107
} ,
108
108
} ,
109
109
control : {
110
110
'60' : {
111
111
filter : ':scope > SDI[name="Oper"] > DAI[name=“ctlVal”]' ,
112
- create : createSingleAddressAction
112
+ create : createAddressAction
113
113
} ,
114
114
}
115
115
} ,
@@ -118,12 +118,12 @@ export const cdcProcessings: Record<
118
118
'35' : {
119
119
filter : ':scope > SDI[name="mag"] > DAI[name="i"], ' +
120
120
':scope > SDI[name="ang"] > DAI[name="i"]' ,
121
- create : createSingleAddressAction
121
+ create : createAddressAction
122
122
} ,
123
123
'36' : {
124
124
filter : ':scope > SDI[name="mag"] > DAI[name="f"], ' +
125
125
':scope > SDI[name="ang"] > DAI[name="f"]' ,
126
- create : createSingleAddressAction
126
+ create : createAddressAction
127
127
}
128
128
} ,
129
129
control : { }
@@ -132,21 +132,21 @@ export const cdcProcessings: Record<
132
132
monitor : {
133
133
'31' : {
134
134
filter : ':scope > DAI[name="stVal"]' ,
135
- create : createSingleAddressAction
135
+ create : createAddressAction
136
136
} ,
137
137
} ,
138
138
control : {
139
139
'59' : {
140
140
filter : ':scope > SDI[name="Oper"] > DAI[name="ctlVal"]' ,
141
- create : createSingleAddressAction
141
+ create : createAddressAction
142
142
} ,
143
143
}
144
144
} ,
145
145
DPS : {
146
146
monitor : {
147
147
'31' : {
148
148
filter : ':scope > DAI[name="stVal"]' ,
149
- create : createSingleAddressAction
149
+ create : createAddressAction
150
150
}
151
151
} ,
152
152
control : { }
@@ -155,21 +155,21 @@ export const cdcProcessings: Record<
155
155
monitor : {
156
156
'35' : {
157
157
filter : ':scope > DAI[name="stVal"]' ,
158
- create : createSingleAddressAction
158
+ create : createAddressAction
159
159
} ,
160
160
} ,
161
161
control : {
162
162
'62' : {
163
163
filter : ':scope > SDI[name="Oper"] > DAI[name="ctlVal"]' ,
164
- create : createSingleAddressAction
164
+ create : createAddressAction
165
165
} ,
166
166
}
167
167
} ,
168
168
ING : {
169
169
monitor : {
170
170
'62' : {
171
171
filter : ':scope > DAI[name="setVal"]' ,
172
- create : createSingleAddressAction
172
+ create : createAddressAction
173
173
}
174
174
} ,
175
175
control : { }
@@ -178,15 +178,16 @@ export const cdcProcessings: Record<
178
178
monitor : {
179
179
'30' : {
180
180
filter : ':scope > DAI[name="stVal"]' ,
181
- create : createInvertedAddressAction
181
+ create : createAddressAction ,
182
+ inverted : true
182
183
} ,
183
184
'33' : {
184
185
filter : ':scope > DAI[name="stVal"]' ,
185
- create : createSingleAddressAction
186
+ create : createAddressAction
186
187
} ,
187
188
'35' : {
188
189
filter : ':scope > DAI[name="stVal"]' ,
189
- create : createSingleAddressAction
190
+ create : createAddressAction
190
191
}
191
192
} ,
192
193
control : { }
@@ -195,25 +196,25 @@ export const cdcProcessings: Record<
195
196
monitor : {
196
197
'32' : {
197
198
filter : ':scope > SDI[name="valWTr"] > DAI[name="posVal"]' ,
198
- create : createSingleAddressAction
199
+ create : createAddressAction
199
200
} ,
200
201
} ,
201
202
control : {
202
203
'62' : {
203
204
filter : ':scope > SDI[name="Oper"] > DAI[name="ctlVal"]' ,
204
- create : createSingleAddressAction
205
+ create : createAddressAction
205
206
} ,
206
207
}
207
208
} ,
208
209
MV : {
209
210
monitor : {
210
211
'35' : {
211
212
filter : ':scope > SDI[name="mag"] > DAI[name="i"]' ,
212
- create : createSingleAddressAction
213
+ create : createAddressAction
213
214
} ,
214
215
'36' : {
215
216
filter : ':scope > SDI[name="mag"] > DAI[name="f"]' ,
216
- create : createSingleAddressAction
217
+ create : createAddressAction
217
218
}
218
219
} ,
219
220
control : { }
@@ -222,7 +223,7 @@ export const cdcProcessings: Record<
222
223
monitor : {
223
224
'37' : {
224
225
filter : ':scope > DAI[name="cnt"]' ,
225
- create : createSingleAddressAction
226
+ create : createAddressAction
226
227
}
227
228
} ,
228
229
control : { }
@@ -231,21 +232,22 @@ export const cdcProcessings: Record<
231
232
monitor : {
232
233
'30' : {
233
234
filter : ':scope > DAI[name="stVal"]' ,
234
- create : createSingleAddressAction
235
+ create : createAddressAction ,
236
+ inverted : true
235
237
} ,
236
238
} ,
237
239
control : {
238
240
'58' : {
239
241
filter : ':scope > SDI[name="Oper"] > DAI[name="ctlVal"]' ,
240
- create : createSingleAddressAction
242
+ create : createAddressAction
241
243
} ,
242
244
}
243
245
} ,
244
246
SPG : {
245
247
monitor : {
246
248
'58' : {
247
249
filter : ':scope > DAI[name="setVal"]' ,
248
- create : createSingleAddressAction
250
+ create : createAddressAction
249
251
}
250
252
} ,
251
253
control : { }
@@ -254,42 +256,30 @@ export const cdcProcessings: Record<
254
256
monitor : {
255
257
'30' : {
256
258
filter : ':scope > DAI[name="stVal"]' ,
257
- create : createSingleAddressAction
259
+ create : createAddressAction ,
260
+ inverted : true
258
261
}
259
262
} ,
260
263
control : { }
261
264
} ,
262
265
} ;
263
266
264
267
/**
265
- * Create a new SCL Private element and add one 104 Address element below this.
268
+ * Create a new SCL Private element and add 104 Address element(s) below this.
266
269
* Set the attribute value of 'ti' to the passed ti value.
267
270
*
268
271
* @param daiElement - The DAI Element to use to set namespace on the root element and create new elements.
269
272
* @param ti - The value to be set on the attribute 'ti'.
273
+ * @param inverted - Indicates if extra Address Elements should be created with 'inverted=true'.
270
274
*/
271
- function createSingleAddressAction ( daiElement : Element , ti : string ) : Create [ ] {
272
- addPrefixAndNamespaceToDocument ( daiElement ) ;
273
-
274
- const privateElement = createPrivateElement ( daiElement ) ;
275
- createPrivateAddress ( daiElement , privateElement , ti ) ;
276
- return [ { new : { parent : daiElement , element : privateElement } } ] ;
277
- }
278
-
279
- /**
280
- * Create a new SCL Private element and add two 104 Address elements, one without the attribute 'inverted' meaning
281
- * 'false' and the other element with the attribute 'inverted' to 'true'.
282
- * Also set the attribute value of 'ti' to the passed ti value.
283
- *
284
- * @param daiElement - The DAI Element to use to set namespace on the root element and create new elements.
285
- * @param ti - The value to be set on the attribute 'ti'.
286
- */
287
- function createInvertedAddressAction ( daiElement : Element , ti : string ) : Create [ ] {
275
+ function createAddressAction ( daiElement : Element , ti : string , inverted : boolean ) : Create [ ] {
288
276
addPrefixAndNamespaceToDocument ( daiElement ) ;
289
277
290
278
const privateElement = createPrivateElement ( daiElement ) ;
291
279
createPrivateAddress ( daiElement , privateElement , ti ) ;
292
- const invertedAddressElement = createPrivateAddress ( daiElement , privateElement , ti ) ;
293
- invertedAddressElement . setAttribute ( 'inverted' , 'true' ) ;
280
+ if ( inverted ) {
281
+ const invertedAddressElement = createPrivateAddress ( daiElement , privateElement , ti ) ;
282
+ invertedAddressElement . setAttribute ( 'inverted' , 'true' ) ;
283
+ }
294
284
return [ { new : { parent : daiElement , element : privateElement } } ] ;
295
285
}
0 commit comments