node-opcua-data-model 2.54.0 → 2.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.mocharc.yml +10 -10
  2. package/LICENSE +20 -20
  3. package/dist/_make_flag.d.ts +1 -1
  4. package/dist/_make_flag.js.map +1 -1
  5. package/dist/access_level.js.map +1 -1
  6. package/dist/access_level_ex.d.ts +2 -0
  7. package/dist/access_level_ex.js +5 -2
  8. package/dist/access_level_ex.js.map +1 -1
  9. package/dist/access_restrictions.js.map +1 -1
  10. package/dist/attributeIds.js.map +1 -1
  11. package/dist/data_encoding.d.ts +1 -1
  12. package/dist/data_encoding.js +2 -2
  13. package/dist/data_encoding.js.map +1 -1
  14. package/dist/diagnostic_info.d.ts +2 -2
  15. package/dist/diagnostic_info.js.map +1 -1
  16. package/dist/localized_text.d.ts +3 -3
  17. package/dist/localized_text.js.map +1 -1
  18. package/dist/node_class_mask.js.map +1 -1
  19. package/dist/nodeclass.js.map +1 -1
  20. package/dist/permission_flag.js.map +1 -1
  21. package/dist/qualified_name.js +2 -2
  22. package/dist/qualified_name.js.map +1 -1
  23. package/dist/result_mask.js.map +1 -1
  24. package/dist/write_mask.js +1 -1
  25. package/dist/write_mask.js.map +1 -1
  26. package/package.json +14 -12
  27. package/source/BrowseDirection.ts +41 -41
  28. package/source/_make_flag.ts +2 -3
  29. package/source/access_level.ts +18 -13
  30. package/source/access_level_ex.ts +26 -25
  31. package/source/access_restrictions.ts +1 -3
  32. package/source/attributeIds.ts +1 -5
  33. package/source/data_encoding.ts +23 -23
  34. package/source/diagnostic_info.ts +362 -361
  35. package/source/localized_text.ts +189 -188
  36. package/source/node_class_mask.ts +47 -47
  37. package/source/nodeclass.ts +23 -23
  38. package/source/permission_flag.ts +8 -8
  39. package/source/qualified_name.ts +3 -3
  40. package/source/result_mask.ts +35 -35
  41. package/source/time_zone.ts +18 -18
  42. package/source/write_mask.ts +37 -37
  43. package/.nyc_output/13d15b6c-23cf-479c-919f-4cd69586f383.json +0 -1
  44. package/.nyc_output/processinfo/13d15b6c-23cf-479c-919f-4cd69586f383.json +0 -1
  45. package/.nyc_output/processinfo/index.json +0 -1
@@ -1,361 +1,362 @@
1
- /**
2
- * @module node-opcua-data-model
3
- */
4
- import { assert } from "node-opcua-assert";
5
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
6
- import {
7
- BaseUAObject,
8
- buildStructuredType,
9
- parameters,
10
- registerSpecialVariantEncoder,
11
- StructuredTypeSchema
12
- } from "node-opcua-factory";
13
- import { StatusCode, StatusCodes } from "node-opcua-status-code";
14
-
15
- import {
16
- decodeByte,
17
- decodeInt32,
18
- decodeStatusCode,
19
- decodeString,
20
- encodeByte,
21
- encodeInt32,
22
- encodeStatusCode,
23
- encodeString,
24
- Int32,
25
- UAString
26
- } from "node-opcua-basic-types";
27
- import { check_options_correctness_against_schema, initialize_field } from "node-opcua-factory";
28
-
29
- // --------------------------------------------------------------------------------------------
30
- export const schemaDiagnosticInfo: StructuredTypeSchema = buildStructuredType({
31
- name: "DiagnosticInfo",
32
-
33
- baseType: "BaseUAObject",
34
-
35
- fields: [
36
- {
37
- name: "namespaceUri",
38
-
39
- fieldType: "Int32",
40
-
41
- defaultValue: -1,
42
- documentation: "The symbolicId is defined within the context of a namespace."
43
- },
44
- {
45
- name: "symbolicId",
46
-
47
- fieldType: "Int32",
48
-
49
- defaultValue: -1,
50
- documentation: "The symbolicId shall be used to identify a vendor-specific error or condition"
51
- },
52
- {
53
- name: "locale",
54
-
55
- fieldType: "Int32",
56
-
57
- defaultValue: -1,
58
- documentation: "The locale part of the vendor-specific localized text describing the symbolic id."
59
- },
60
- { name: "localizedText", fieldType: "Int32", defaultValue: -1 },
61
- {
62
- name: "additionalInfo",
63
-
64
- fieldType: "String",
65
-
66
- defaultValue: null,
67
- documentation: "Vendor-specific diagnostic information."
68
- },
69
- {
70
- name: "innerStatusCode",
71
-
72
- fieldType: "StatusCode",
73
-
74
- defaultValue: StatusCodes.Good,
75
- documentation: "The StatusCode from the inner operation."
76
- },
77
- {
78
- name: "innerDiagnosticInfo",
79
-
80
- fieldType: "DiagnosticInfo",
81
-
82
- defaultValue: null,
83
- documentation: "The diagnostic info associated with the inner StatusCode."
84
- }
85
- ]
86
- });
87
-
88
- export class DiagnosticInfo extends BaseUAObject {
89
- public static schema = schemaDiagnosticInfo;
90
- public static possibleFields = [
91
- "symbolicId",
92
- "namespaceURI",
93
- "locale",
94
- "localizedText",
95
- "additionalInfo",
96
- "innerStatusCode",
97
- "innerDiagnosticInfo"
98
- ];
99
-
100
- public symbolicId: Int32;
101
- public namespaceURI: Int32;
102
- public locale: Int32;
103
- public localizedText: Int32;
104
- public additionalInfo: UAString;
105
- public innerStatusCode: StatusCode;
106
- public innerDiagnosticInfo: DiagnosticInfo;
107
-
108
- /**
109
- *
110
- * @class DiagnosticInfo
111
- * @constructor
112
- * @extends BaseUAObject
113
- * @param options {Object}
114
- */
115
- constructor(options: DiagnosticInfoOptions = {}) {
116
- super();
117
- const schema = schemaDiagnosticInfo;
118
- /* istanbul ignore next */
119
- if (parameters.debugSchemaHelper) {
120
- check_options_correctness_against_schema(this, schema, options);
121
- }
122
- this.symbolicId = initialize_field(schema.fields[0], options.symbolicId);
123
- this.namespaceURI = initialize_field(schema.fields[1], options.namespaceURI);
124
- this.locale = initialize_field(schema.fields[2], options.locale);
125
- this.localizedText = initialize_field(schema.fields[3], options.localizedText);
126
- this.additionalInfo = initialize_field(schema.fields[4], options.additionalInfo);
127
- this.innerStatusCode = initialize_field(schema.fields[5], options.innerStatusCode);
128
- this.innerDiagnosticInfo = initialize_field(schema.fields[6], options.innerDiagnosticInfo);
129
- }
130
-
131
- public encode(stream: OutputBinaryStream): void {
132
- encode_DiagnosticInfo(this, stream);
133
- }
134
-
135
- public decode(stream: BinaryStream): void {
136
- decode_DiagnosticInfo(this, stream);
137
- }
138
-
139
- public decodeDebug(stream: BinaryStream, options: any): void {
140
- decodeDebug_DiagnosticInfo(this, stream, options);
141
- }
142
- }
143
-
144
- DiagnosticInfo.prototype.schema = DiagnosticInfo.schema;
145
- DiagnosticInfo.schema.fields[6].schema = DiagnosticInfo.schema;
146
-
147
- export interface DiagnosticInfoOptions {
148
- symbolicId?: Int32;
149
- namespaceURI?: Int32;
150
- locale?: Int32;
151
- localizedText?: Int32;
152
- additionalInfo?: UAString;
153
- innerStatusCode?: StatusCode;
154
- innerDiagnosticInfo?: DiagnosticInfo;
155
- }
156
-
157
- export enum DiagnosticInfo_EncodingByte {
158
- SymbolicId = 0x01,
159
- NamespaceURI = 0x02,
160
- LocalizedText = 0x04,
161
- Locale = 0x08,
162
- AdditionalInfo = 0x10,
163
- InnerStatusCode = 0x20,
164
- InnerDiagnosticInfo = 0x40
165
- }
166
-
167
- // tslint:disable:no-bitwise
168
- function getDiagnosticInfoEncodingByte(diagnosticInfo: DiagnosticInfo): DiagnosticInfo_EncodingByte {
169
- assert(diagnosticInfo);
170
-
171
- let encodingMask = 0;
172
-
173
- if (diagnosticInfo.symbolicId >= 0) {
174
- encodingMask |= DiagnosticInfo_EncodingByte.SymbolicId;
175
- }
176
- if (diagnosticInfo.namespaceURI >= 0) {
177
- encodingMask |= DiagnosticInfo_EncodingByte.NamespaceURI;
178
- }
179
- if (diagnosticInfo.localizedText >= 0) {
180
- encodingMask |= DiagnosticInfo_EncodingByte.LocalizedText;
181
- }
182
- if (diagnosticInfo.locale >= 0) {
183
- encodingMask |= DiagnosticInfo_EncodingByte.Locale;
184
- }
185
- if (diagnosticInfo.additionalInfo) {
186
- encodingMask |= DiagnosticInfo_EncodingByte.AdditionalInfo;
187
- }
188
- if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
189
- encodingMask |= DiagnosticInfo_EncodingByte.InnerStatusCode;
190
- }
191
- if (diagnosticInfo.innerDiagnosticInfo) {
192
- encodingMask |= DiagnosticInfo_EncodingByte.InnerDiagnosticInfo;
193
- }
194
- return encodingMask;
195
- }
196
-
197
- function encode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: OutputBinaryStream): void {
198
- const encodingMask = getDiagnosticInfoEncodingByte(diagnosticInfo);
199
-
200
- // write encoding byte
201
- encodeByte(encodingMask, stream);
202
-
203
- // write symbolic id
204
- if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
205
- encodeInt32(diagnosticInfo.symbolicId, stream);
206
- }
207
- // write namespace uri
208
- if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
209
- encodeInt32(diagnosticInfo.namespaceURI, stream);
210
- }
211
- // write locale
212
- if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
213
- encodeInt32(diagnosticInfo.locale, stream);
214
- }
215
- // write localized text
216
- if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
217
- encodeInt32(diagnosticInfo.localizedText, stream);
218
- }
219
- // write additional info
220
- if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
221
- encodeString(diagnosticInfo.additionalInfo, stream);
222
- }
223
- // write inner status code
224
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
225
- encodeStatusCode(diagnosticInfo.innerStatusCode, stream);
226
- }
227
- // write innerDiagnosticInfo
228
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
229
- assert(diagnosticInfo.innerDiagnosticInfo !== null, "missing innerDiagnosticInfo");
230
- if (diagnosticInfo.innerDiagnosticInfo) {
231
- encode_DiagnosticInfo(diagnosticInfo.innerDiagnosticInfo, stream);
232
- }
233
- }
234
- }
235
-
236
- function decodeDebug_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream, options: any): void {
237
- const tracer = options.tracer;
238
-
239
- tracer.trace("start", options.name + "(" + "DiagnosticInfo" + ")", stream.length, stream.length);
240
-
241
- let cursorBefore = stream.length;
242
- const encodingMask = decodeByte(stream);
243
-
244
- tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cursorBefore, stream.length, "Mask");
245
- tracer.encoding_byte(encodingMask, DiagnosticInfo_EncodingByte, cursorBefore, stream.length);
246
-
247
- cursorBefore = stream.length;
248
-
249
- // read symbolic id
250
- if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
251
- diagnosticInfo.symbolicId = decodeInt32(stream);
252
- tracer.trace("member", "symbolicId", diagnosticInfo.symbolicId, cursorBefore, stream.length, "Int32");
253
- cursorBefore = stream.length;
254
- }
255
- // read namespace uri
256
- if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
257
- diagnosticInfo.namespaceURI = decodeInt32(stream);
258
- tracer.trace("member", "symbolicId", diagnosticInfo.namespaceURI, cursorBefore, stream.length, "Int32");
259
- cursorBefore = stream.length;
260
- }
261
- // read locale
262
- if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
263
- diagnosticInfo.locale = decodeInt32(stream);
264
- tracer.trace("member", "locale", diagnosticInfo.locale, cursorBefore, stream.length, "Int32");
265
- cursorBefore = stream.length;
266
- }
267
- // read localized text
268
- if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
269
- diagnosticInfo.localizedText = decodeInt32(stream);
270
- tracer.trace("member", "localizedText", diagnosticInfo.localizedText, cursorBefore, stream.length, "Int32");
271
- cursorBefore = stream.length;
272
- }
273
- // read additional info
274
- if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
275
- diagnosticInfo.additionalInfo = decodeString(stream);
276
- tracer.trace("member", "additionalInfo", diagnosticInfo.additionalInfo, cursorBefore, stream.length, "String");
277
- cursorBefore = stream.length;
278
- }
279
- // read inner status code
280
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
281
- diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
282
- tracer.trace("member", "innerStatusCode", diagnosticInfo.innerStatusCode, cursorBefore, stream.length, "StatusCode");
283
- cursorBefore = stream.length;
284
- }
285
- // read inner status code
286
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
287
- diagnosticInfo.innerDiagnosticInfo = new DiagnosticInfo({});
288
- if (diagnosticInfo.innerDiagnosticInfo) {
289
- diagnosticInfo.innerDiagnosticInfo.decodeDebug(stream, options);
290
- }
291
- tracer.trace(
292
- "member",
293
- "innerDiagnosticInfo",
294
- diagnosticInfo.innerDiagnosticInfo,
295
- cursorBefore,
296
- stream.length,
297
- "DiagnosticInfo"
298
- );
299
- }
300
-
301
- tracer.trace("end", options.name, stream.length, stream.length);
302
- }
303
-
304
- function decode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream): void {
305
- const encodingMask = decodeByte(stream);
306
-
307
- // read symbolic id
308
- if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
309
- diagnosticInfo.symbolicId = decodeInt32(stream);
310
- }
311
- // read namespace uri
312
- if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
313
- diagnosticInfo.namespaceURI = decodeInt32(stream);
314
- }
315
- // read locale
316
- if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
317
- diagnosticInfo.locale = decodeInt32(stream);
318
- }
319
- // read localized text
320
- if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
321
- diagnosticInfo.localizedText = decodeInt32(stream);
322
- }
323
- // read additional info
324
- if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
325
- diagnosticInfo.additionalInfo = decodeString(stream);
326
- }
327
- // read inner status code
328
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
329
- diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
330
- }
331
- // read inner status code
332
- if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
333
- diagnosticInfo.innerDiagnosticInfo = new DiagnosticInfo({});
334
- if (diagnosticInfo.innerDiagnosticInfo) {
335
- diagnosticInfo.innerDiagnosticInfo.decode(stream);
336
- }
337
- }
338
- }
339
-
340
- const emptyDiagnosticInfo = new DiagnosticInfo({});
341
-
342
- export function encodeDiagnosticInfo(value: DiagnosticInfo | null, stream: OutputBinaryStream): void {
343
- if (value === null) {
344
- emptyDiagnosticInfo.encode(stream);
345
- } else {
346
- value.encode(stream);
347
- }
348
- }
349
-
350
- export function decodeDiagnosticInfo(stream: BinaryStream, _value?: DiagnosticInfo | null): DiagnosticInfo {
351
- const value = _value || new DiagnosticInfo();
352
- value.decode(stream);
353
- return value;
354
- }
355
-
356
- // Note:
357
- // the SymbolicId, NamespaceURI, LocalizedText and Locale fields are indexes in a string table which is returned
358
- // in the response header. Only the index of the corresponding string in the string table is encoded. An index
359
- // of −1 indicates that there is no value for the string.
360
- //
361
- registerSpecialVariantEncoder(DiagnosticInfo);
1
+ /**
2
+ * @module node-opcua-data-model
3
+ */
4
+ import { assert } from "node-opcua-assert";
5
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
6
+ import {
7
+ BaseUAObject,
8
+ buildStructuredType,
9
+ DecodeDebugOptions,
10
+ parameters,
11
+ registerSpecialVariantEncoder,
12
+ StructuredTypeSchema
13
+ } from "node-opcua-factory";
14
+ import { StatusCode, StatusCodes } from "node-opcua-status-code";
15
+
16
+ import {
17
+ decodeByte,
18
+ decodeInt32,
19
+ decodeStatusCode,
20
+ decodeString,
21
+ encodeByte,
22
+ encodeInt32,
23
+ encodeStatusCode,
24
+ encodeString,
25
+ Int32,
26
+ UAString
27
+ } from "node-opcua-basic-types";
28
+ import { check_options_correctness_against_schema, initialize_field } from "node-opcua-factory";
29
+
30
+ // --------------------------------------------------------------------------------------------
31
+ export const schemaDiagnosticInfo: StructuredTypeSchema = buildStructuredType({
32
+ name: "DiagnosticInfo",
33
+
34
+ baseType: "BaseUAObject",
35
+
36
+ fields: [
37
+ {
38
+ name: "namespaceUri",
39
+
40
+ fieldType: "Int32",
41
+
42
+ defaultValue: -1,
43
+ documentation: "The symbolicId is defined within the context of a namespace."
44
+ },
45
+ {
46
+ name: "symbolicId",
47
+
48
+ fieldType: "Int32",
49
+
50
+ defaultValue: -1,
51
+ documentation: "The symbolicId shall be used to identify a vendor-specific error or condition"
52
+ },
53
+ {
54
+ name: "locale",
55
+
56
+ fieldType: "Int32",
57
+
58
+ defaultValue: -1,
59
+ documentation: "The locale part of the vendor-specific localized text describing the symbolic id."
60
+ },
61
+ { name: "localizedText", fieldType: "Int32", defaultValue: -1 },
62
+ {
63
+ name: "additionalInfo",
64
+
65
+ fieldType: "String",
66
+
67
+ defaultValue: null,
68
+ documentation: "Vendor-specific diagnostic information."
69
+ },
70
+ {
71
+ name: "innerStatusCode",
72
+
73
+ fieldType: "StatusCode",
74
+
75
+ defaultValue: StatusCodes.Good,
76
+ documentation: "The StatusCode from the inner operation."
77
+ },
78
+ {
79
+ name: "innerDiagnosticInfo",
80
+
81
+ fieldType: "DiagnosticInfo",
82
+
83
+ defaultValue: null,
84
+ documentation: "The diagnostic info associated with the inner StatusCode."
85
+ }
86
+ ]
87
+ });
88
+
89
+ export class DiagnosticInfo extends BaseUAObject {
90
+ public static schema = schemaDiagnosticInfo;
91
+ public static possibleFields = [
92
+ "symbolicId",
93
+ "namespaceURI",
94
+ "locale",
95
+ "localizedText",
96
+ "additionalInfo",
97
+ "innerStatusCode",
98
+ "innerDiagnosticInfo"
99
+ ];
100
+
101
+ public symbolicId: Int32;
102
+ public namespaceURI: Int32;
103
+ public locale: Int32;
104
+ public localizedText: Int32;
105
+ public additionalInfo: UAString;
106
+ public innerStatusCode: StatusCode;
107
+ public innerDiagnosticInfo: DiagnosticInfo;
108
+
109
+ /**
110
+ *
111
+ * @class DiagnosticInfo
112
+ * @constructor
113
+ * @extends BaseUAObject
114
+ * @param options {Object}
115
+ */
116
+ constructor(options: DiagnosticInfoOptions = {}) {
117
+ super();
118
+ const schema = schemaDiagnosticInfo;
119
+ /* istanbul ignore next */
120
+ if (parameters.debugSchemaHelper) {
121
+ check_options_correctness_against_schema(this, schema, options);
122
+ }
123
+ this.symbolicId = initialize_field(schema.fields[0], options.symbolicId) as Int32;
124
+ this.namespaceURI = initialize_field(schema.fields[1], options.namespaceURI) as Int32;
125
+ this.locale = initialize_field(schema.fields[2], options.locale) as Int32;
126
+ this.localizedText = initialize_field(schema.fields[3], options.localizedText) as Int32;
127
+ this.additionalInfo = initialize_field(schema.fields[4], options.additionalInfo) as UAString;
128
+ this.innerStatusCode = initialize_field(schema.fields[5], options.innerStatusCode) as StatusCode;
129
+ this.innerDiagnosticInfo = initialize_field(schema.fields[6], options.innerDiagnosticInfo) as DiagnosticInfo;
130
+ }
131
+
132
+ public encode(stream: OutputBinaryStream): void {
133
+ encode_DiagnosticInfo(this, stream);
134
+ }
135
+
136
+ public decode(stream: BinaryStream): void {
137
+ decode_DiagnosticInfo(this, stream);
138
+ }
139
+
140
+ public decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void {
141
+ decodeDebug_DiagnosticInfo(this, stream, options);
142
+ }
143
+ }
144
+
145
+ DiagnosticInfo.prototype.schema = DiagnosticInfo.schema;
146
+ DiagnosticInfo.schema.fields[6].schema = DiagnosticInfo.schema;
147
+
148
+ export interface DiagnosticInfoOptions {
149
+ symbolicId?: Int32;
150
+ namespaceURI?: Int32;
151
+ locale?: Int32;
152
+ localizedText?: Int32;
153
+ additionalInfo?: UAString;
154
+ innerStatusCode?: StatusCode;
155
+ innerDiagnosticInfo?: DiagnosticInfo;
156
+ }
157
+
158
+ export enum DiagnosticInfo_EncodingByte {
159
+ SymbolicId = 0x01,
160
+ NamespaceURI = 0x02,
161
+ LocalizedText = 0x04,
162
+ Locale = 0x08,
163
+ AdditionalInfo = 0x10,
164
+ InnerStatusCode = 0x20,
165
+ InnerDiagnosticInfo = 0x40
166
+ }
167
+
168
+ // tslint:disable:no-bitwise
169
+ function getDiagnosticInfoEncodingByte(diagnosticInfo: DiagnosticInfo): DiagnosticInfo_EncodingByte {
170
+ assert(diagnosticInfo);
171
+
172
+ let encodingMask = 0;
173
+
174
+ if (diagnosticInfo.symbolicId >= 0) {
175
+ encodingMask |= DiagnosticInfo_EncodingByte.SymbolicId;
176
+ }
177
+ if (diagnosticInfo.namespaceURI >= 0) {
178
+ encodingMask |= DiagnosticInfo_EncodingByte.NamespaceURI;
179
+ }
180
+ if (diagnosticInfo.localizedText >= 0) {
181
+ encodingMask |= DiagnosticInfo_EncodingByte.LocalizedText;
182
+ }
183
+ if (diagnosticInfo.locale >= 0) {
184
+ encodingMask |= DiagnosticInfo_EncodingByte.Locale;
185
+ }
186
+ if (diagnosticInfo.additionalInfo) {
187
+ encodingMask |= DiagnosticInfo_EncodingByte.AdditionalInfo;
188
+ }
189
+ if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
190
+ encodingMask |= DiagnosticInfo_EncodingByte.InnerStatusCode;
191
+ }
192
+ if (diagnosticInfo.innerDiagnosticInfo) {
193
+ encodingMask |= DiagnosticInfo_EncodingByte.InnerDiagnosticInfo;
194
+ }
195
+ return encodingMask;
196
+ }
197
+
198
+ function encode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: OutputBinaryStream): void {
199
+ const encodingMask = getDiagnosticInfoEncodingByte(diagnosticInfo);
200
+
201
+ // write encoding byte
202
+ encodeByte(encodingMask, stream);
203
+
204
+ // write symbolic id
205
+ if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
206
+ encodeInt32(diagnosticInfo.symbolicId, stream);
207
+ }
208
+ // write namespace uri
209
+ if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
210
+ encodeInt32(diagnosticInfo.namespaceURI, stream);
211
+ }
212
+ // write locale
213
+ if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
214
+ encodeInt32(diagnosticInfo.locale, stream);
215
+ }
216
+ // write localized text
217
+ if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
218
+ encodeInt32(diagnosticInfo.localizedText, stream);
219
+ }
220
+ // write additional info
221
+ if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
222
+ encodeString(diagnosticInfo.additionalInfo, stream);
223
+ }
224
+ // write inner status code
225
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
226
+ encodeStatusCode(diagnosticInfo.innerStatusCode, stream);
227
+ }
228
+ // write innerDiagnosticInfo
229
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
230
+ assert(diagnosticInfo.innerDiagnosticInfo !== null, "missing innerDiagnosticInfo");
231
+ if (diagnosticInfo.innerDiagnosticInfo) {
232
+ encode_DiagnosticInfo(diagnosticInfo.innerDiagnosticInfo, stream);
233
+ }
234
+ }
235
+ }
236
+
237
+ function decodeDebug_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream, options: DecodeDebugOptions): void {
238
+ const tracer = options.tracer;
239
+
240
+ tracer.trace("start", options.name + "(" + "DiagnosticInfo" + ")", stream.length, stream.length);
241
+
242
+ let cursorBefore = stream.length;
243
+ const encodingMask = decodeByte(stream);
244
+
245
+ tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cursorBefore, stream.length, "Mask");
246
+ tracer.encoding_byte(encodingMask, DiagnosticInfo_EncodingByte, cursorBefore, stream.length);
247
+
248
+ cursorBefore = stream.length;
249
+
250
+ // read symbolic id
251
+ if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
252
+ diagnosticInfo.symbolicId = decodeInt32(stream);
253
+ tracer.trace("member", "symbolicId", diagnosticInfo.symbolicId, cursorBefore, stream.length, "Int32");
254
+ cursorBefore = stream.length;
255
+ }
256
+ // read namespace uri
257
+ if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
258
+ diagnosticInfo.namespaceURI = decodeInt32(stream);
259
+ tracer.trace("member", "symbolicId", diagnosticInfo.namespaceURI, cursorBefore, stream.length, "Int32");
260
+ cursorBefore = stream.length;
261
+ }
262
+ // read locale
263
+ if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
264
+ diagnosticInfo.locale = decodeInt32(stream);
265
+ tracer.trace("member", "locale", diagnosticInfo.locale, cursorBefore, stream.length, "Int32");
266
+ cursorBefore = stream.length;
267
+ }
268
+ // read localized text
269
+ if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
270
+ diagnosticInfo.localizedText = decodeInt32(stream);
271
+ tracer.trace("member", "localizedText", diagnosticInfo.localizedText, cursorBefore, stream.length, "Int32");
272
+ cursorBefore = stream.length;
273
+ }
274
+ // read additional info
275
+ if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
276
+ diagnosticInfo.additionalInfo = decodeString(stream);
277
+ tracer.trace("member", "additionalInfo", diagnosticInfo.additionalInfo, cursorBefore, stream.length, "String");
278
+ cursorBefore = stream.length;
279
+ }
280
+ // read inner status code
281
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
282
+ diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
283
+ tracer.trace("member", "innerStatusCode", diagnosticInfo.innerStatusCode, cursorBefore, stream.length, "StatusCode");
284
+ cursorBefore = stream.length;
285
+ }
286
+ // read inner status code
287
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
288
+ diagnosticInfo.innerDiagnosticInfo = new DiagnosticInfo({});
289
+ if (diagnosticInfo.innerDiagnosticInfo) {
290
+ diagnosticInfo.innerDiagnosticInfo.decodeDebug(stream, options);
291
+ }
292
+ tracer.trace(
293
+ "member",
294
+ "innerDiagnosticInfo",
295
+ diagnosticInfo.innerDiagnosticInfo,
296
+ cursorBefore,
297
+ stream.length,
298
+ "DiagnosticInfo"
299
+ );
300
+ }
301
+
302
+ tracer.trace("end", options.name, stream.length, stream.length);
303
+ }
304
+
305
+ function decode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream): void {
306
+ const encodingMask = decodeByte(stream);
307
+
308
+ // read symbolic id
309
+ if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
310
+ diagnosticInfo.symbolicId = decodeInt32(stream);
311
+ }
312
+ // read namespace uri
313
+ if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
314
+ diagnosticInfo.namespaceURI = decodeInt32(stream);
315
+ }
316
+ // read locale
317
+ if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
318
+ diagnosticInfo.locale = decodeInt32(stream);
319
+ }
320
+ // read localized text
321
+ if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
322
+ diagnosticInfo.localizedText = decodeInt32(stream);
323
+ }
324
+ // read additional info
325
+ if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
326
+ diagnosticInfo.additionalInfo = decodeString(stream);
327
+ }
328
+ // read inner status code
329
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
330
+ diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
331
+ }
332
+ // read inner status code
333
+ if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
334
+ diagnosticInfo.innerDiagnosticInfo = new DiagnosticInfo({});
335
+ if (diagnosticInfo.innerDiagnosticInfo) {
336
+ diagnosticInfo.innerDiagnosticInfo.decode(stream);
337
+ }
338
+ }
339
+ }
340
+
341
+ const emptyDiagnosticInfo = new DiagnosticInfo({});
342
+
343
+ export function encodeDiagnosticInfo(value: DiagnosticInfo | null, stream: OutputBinaryStream): void {
344
+ if (value === null) {
345
+ emptyDiagnosticInfo.encode(stream);
346
+ } else {
347
+ value.encode(stream);
348
+ }
349
+ }
350
+
351
+ export function decodeDiagnosticInfo(stream: BinaryStream, _value?: DiagnosticInfo | null): DiagnosticInfo {
352
+ const value = _value || new DiagnosticInfo();
353
+ value.decode(stream);
354
+ return value;
355
+ }
356
+
357
+ // Note:
358
+ // the SymbolicId, NamespaceURI, LocalizedText and Locale fields are indexes in a string table which is returned
359
+ // in the response header. Only the index of the corresponding string in the string table is encoded. An index
360
+ // of −1 indicates that there is no value for the string.
361
+ //
362
+ registerSpecialVariantEncoder(DiagnosticInfo);