node-opcua-address-space 2.178.0 → 2.179.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.
- package/dist/source/address_space_ts.d.ts +16 -6
- package/dist/source/address_space_ts.js +1 -1
- package/dist/source/address_space_ts.js.map +1 -1
- package/dist/source/helpers/argument_list.js +2 -2
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +3 -0
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +6 -2
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +3 -1
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/interfaces/extension_object_constructor.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +0 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -1
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +2 -1
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +12 -8
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.js +26 -7
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +6 -4
- package/dist/source/loader/parsers/extension_object_parser.js +12 -6
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -1
- package/dist/source/loader/parsers/localized_text_parser.d.ts +1 -1
- package/dist/source/loader/parsers/nodeid_parser.d.ts +10 -2
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -1
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +1 -2
- package/dist/source/loader/parsers/variant_parser.d.ts +8 -2
- package/dist/source/loader/parsers/variant_parser.js +11 -8
- package/dist/source/loader/parsers/variant_parser.js.map +1 -1
- package/dist/source/pseudo_session.js +70 -24
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/xml_writer.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +0 -3
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +0 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +7 -2
- package/dist/src/address_space.js +36 -28
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +6 -9
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +6 -6
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +8 -4
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +6 -5
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +3 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +17 -8
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +0 -6
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/extension_object_array_node.d.ts +9 -1
- package/dist/src/extension_object_array_node.js +20 -3
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +3 -1
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +2 -4
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/namespace_impl.js +6 -5
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +4 -5
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +10 -11
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +2 -4
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +71 -43
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.d.ts +2 -2
- package/dist/src/reference_impl.js +5 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +1 -1
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +9 -7
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +4 -4
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +21 -11
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +5 -2
- package/dist/src/ua_object_type_impl.js +4 -3
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +1 -2
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +9 -11
- package/dist/src/ua_variable_impl.js +103 -65
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.d.ts +6 -6
- package/dist/src/ua_variable_impl_ext_obj.js +33 -22
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +6 -2
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +3 -0
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/boiler_system.js +27 -6
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +3 -3
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/dump_statemachine.js +1 -1
- package/distHelpers/dump_statemachine.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +0 -1
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/package.json +41 -41
- package/source/address_space_ts.ts +19 -9
- package/source/helpers/argument_list.ts +2 -2
- package/source/helpers/call_helpers.ts +4 -1
- package/source/helpers/dump_tools.ts +7 -3
- package/source/helpers/make_optionals_map.ts +4 -2
- package/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.ts +4 -3
- package/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.ts +10 -11
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +6 -7
- package/source/interfaces/extension_object_constructor.ts +1 -1
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +0 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +0 -1
- package/source/loader/decode_xml_extension_object.ts +3 -3
- package/source/loader/ensure_datatype_extracted.ts +6 -2
- package/source/loader/generateAddressSpaceRaw.ts +5 -4
- package/source/loader/load_nodeset2.ts +12 -8
- package/source/loader/make_xml_extension_object_parser.ts +78 -45
- package/source/loader/namespace_post_step.ts +1 -1
- package/source/loader/parsers/extension_object_parser.ts +36 -27
- package/source/loader/parsers/localized_text_parser.ts +1 -1
- package/source/loader/parsers/nodeid_parser.ts +10 -2
- package/source/loader/parsers/qualified_name_parser.ts +1 -1
- package/source/loader/parsers/variant_parser.ts +53 -40
- package/source/pseudo_session.ts +81 -28
- package/source/session_context.ts +1 -0
- package/source/xml_writer.ts +1 -1
- package/src/_instantiate_helpers.ts +0 -3
- package/src/_mandatory_child_or_requested_optional_filter.ts +3 -4
- package/src/address_space.ts +58 -42
- package/src/address_space_private.ts +2 -0
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +6 -10
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +5 -7
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +20 -13
- package/src/alarms_and_conditions/ua_base_event_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +12 -10
- package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +8 -5
- package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +0 -1
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +0 -1
- package/src/apply_condition_refresh.ts +1 -1
- package/src/base_node_impl.ts +30 -35
- package/src/base_node_private.ts +0 -6
- package/src/extension_object_array_node.ts +44 -15
- package/src/get_basic_datatype.ts +4 -1
- package/src/historical_access/address_space_historical_data_node.ts +2 -5
- package/src/namespace_impl.ts +24 -17
- package/src/nodeid_manager.ts +8 -11
- package/src/nodeset_tools/construct_namespace_dependency.ts +18 -15
- package/src/nodeset_tools/dump_to_bsd.ts +6 -8
- package/src/nodeset_tools/nodeset_to_xml.ts +105 -75
- package/src/private_namespace.ts +7 -2
- package/src/reference_impl.ts +11 -10
- package/src/state_machine/finite_state_machine.ts +12 -10
- package/src/state_machine/ua_shelving_state_machine_ex.ts +4 -4
- package/src/state_machine/ua_two_state_variable.ts +12 -9
- package/src/tool_isSubtypeOf.ts +2 -9
- package/src/ua_data_type_impl.ts +4 -4
- package/src/ua_method_impl.ts +24 -14
- package/src/ua_object_type_impl.ts +12 -6
- package/src/ua_reference_type_impl.ts +2 -3
- package/src/ua_variable_impl.ts +142 -96
- package/src/ua_variable_impl_ext_obj.ts +110 -82
- package/src/ua_variable_type_impl.ts +17 -5
|
@@ -2,24 +2,27 @@ import assert from "node:assert";
|
|
|
2
2
|
import type { IAddressSpace } from "node-opcua-address-space-base";
|
|
3
3
|
import { coerceInt64 } from "node-opcua-basic-types";
|
|
4
4
|
import { Range } from "node-opcua-data-access";
|
|
5
|
-
import { coerceLocalizedText, LocalizedText, type LocalizedTextOptions } from "node-opcua-data-model";
|
|
5
|
+
import { coerceLocalizedText, coerceLocalizedTextStrict, LocalizedText, type LocalizedTextOptions } from "node-opcua-data-model";
|
|
6
6
|
import { make_debugLog } from "node-opcua-debug";
|
|
7
7
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
8
8
|
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
9
9
|
import { Argument, EnumValueType, EUInformation, type EUInformationOptions } from "node-opcua-types";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
InternalFragmentClonerReaderState,
|
|
12
|
+
type IReaderState,
|
|
13
|
+
type ParserLike,
|
|
14
|
+
type ReaderStateParserLike,
|
|
15
|
+
type Xml2Json,
|
|
16
|
+
type XmlAttributes
|
|
17
|
+
} from "node-opcua-xml2json";
|
|
11
18
|
import { decodeXmlExtensionObject } from "../decode_xml_extension_object";
|
|
12
19
|
import { localizedText_parser } from "./localized_text_parser";
|
|
13
20
|
|
|
14
21
|
const debugLog = make_debugLog("ExtensionObjectParser");
|
|
15
22
|
const errorLog = make_debugLog("ExtensionObjectParser");
|
|
16
|
-
const
|
|
23
|
+
const doDebug = false;
|
|
17
24
|
export type Task = (addressSpace: IAddressSpace) => Promise<void>;
|
|
18
25
|
|
|
19
|
-
interface PostExtensionObjectData {
|
|
20
|
-
postponedExtensionObject: ExtensionObject | null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
26
|
// #region Argument parser
|
|
24
27
|
type ArgumentParser = ParserLike & { argument: Argument };
|
|
25
28
|
type ArgumentParserL2 = { parent: ArgumentParser } & { text: string };
|
|
@@ -61,11 +64,11 @@ const makeArgumentParser = (_translateNodeId: (nodeId: string) => NodeId) => ({
|
|
|
61
64
|
Description: {
|
|
62
65
|
...localizedText_parser.LocalizedText,
|
|
63
66
|
finish(this: ArgumentParserL2L) {
|
|
64
|
-
this.parent.argument.description =
|
|
67
|
+
this.parent.argument.description = coerceLocalizedTextStrict({ ...this.localizedText });
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
},
|
|
68
|
-
finish(this:
|
|
71
|
+
finish(this: ArgumentParser) {
|
|
69
72
|
// xx this.argument = new Argument(this.argument);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
@@ -102,14 +105,14 @@ const Range_parser = {
|
|
|
102
105
|
|
|
103
106
|
type EUInformationParser = ReaderStateParserLike & {
|
|
104
107
|
euInformation: EUInformationOptions;
|
|
105
|
-
parser:
|
|
108
|
+
parser: ParserLike;
|
|
106
109
|
};
|
|
107
110
|
type EUInformationParserLevel2 = { parent: EUInformationParser } & { text: string };
|
|
108
111
|
type EUInformationParserLevel2L = { parent: EUInformationParser } & { localizedText: LocalizedTextOptions };
|
|
109
112
|
|
|
110
113
|
const EUInformation_parser: ParserLike = {
|
|
111
|
-
EUInformation: <EUInformationParser>{
|
|
112
|
-
init(this: EUInformationParser, _name, _attrs, _parent, _engine) {
|
|
114
|
+
EUInformation: <EUInformationParser>(<unknown>{
|
|
115
|
+
init(this: EUInformationParser, _name: string, _attrs: XmlAttributes, _parent: IReaderState, _engine: Xml2Json) {
|
|
113
116
|
this.euInformation = new EUInformation({});
|
|
114
117
|
},
|
|
115
118
|
parser: {
|
|
@@ -141,7 +144,7 @@ const EUInformation_parser: ParserLike = {
|
|
|
141
144
|
finish(this: EUInformationParser) {
|
|
142
145
|
this.euInformation = new EUInformation(this.euInformation);
|
|
143
146
|
}
|
|
144
|
-
}
|
|
147
|
+
})
|
|
145
148
|
};
|
|
146
149
|
// #endregion
|
|
147
150
|
|
|
@@ -208,11 +211,11 @@ export interface ExtensionObjectTypeIdIdentifierParser {
|
|
|
208
211
|
export interface ExtensionObjectParserInner {
|
|
209
212
|
typeDefinitionId: NodeId;
|
|
210
213
|
}
|
|
211
|
-
type ExtensionObjectParser = ExtensionObjectParserInner &
|
|
214
|
+
type ExtensionObjectParser = ExtensionObjectParserInner & ReaderStateParserLike & { parent?: unknown };
|
|
212
215
|
export interface ExtensionObjectBodyParser {
|
|
213
216
|
parent: ExtensionObjectParser;
|
|
214
217
|
_cloneFragment: InternalFragmentClonerReaderState;
|
|
215
|
-
engine:
|
|
218
|
+
engine: Xml2Json;
|
|
216
219
|
parser: {
|
|
217
220
|
Argument: ArgumentParser;
|
|
218
221
|
EUInformation: EUInformationParser;
|
|
@@ -236,7 +239,7 @@ export function makeExtensionObjectParser<T>(
|
|
|
236
239
|
setExtensionObjectPojo: (typeDefinition: NodeId, xmlData: string, data: T) => void
|
|
237
240
|
): ParserLike {
|
|
238
241
|
return {
|
|
239
|
-
ExtensionObject: <ExtensionObjectParser>{
|
|
242
|
+
ExtensionObject: <ExtensionObjectParser>(<unknown>{
|
|
240
243
|
init(this: ExtensionObjectParser) {
|
|
241
244
|
this.typeDefinitionId = NodeId.nullNodeId;
|
|
242
245
|
},
|
|
@@ -261,7 +264,7 @@ export function makeExtensionObjectParser<T>(
|
|
|
261
264
|
EnumValueType: enumValueType_parser.EnumValueType,
|
|
262
265
|
Range: Range_parser.Range
|
|
263
266
|
},
|
|
264
|
-
startElement(this: ExtensionObjectBodyParser, elementName: string, attrs:
|
|
267
|
+
startElement(this: ExtensionObjectBodyParser, elementName: string, attrs: XmlAttributes) {
|
|
265
268
|
if (!Object.hasOwn(this.parser, elementName)) {
|
|
266
269
|
// treat it as a opaque XML bloc for the time being
|
|
267
270
|
// until we find the definition of this object, so we know how to interpret the fields
|
|
@@ -315,22 +318,25 @@ export function makeExtensionObjectParser<T>(
|
|
|
315
318
|
// the XML file is probably not exposing standard UA extension object correctly.
|
|
316
319
|
// this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
|
|
317
320
|
// nodeid
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
// c8 ignore next
|
|
322
|
+
doDebug &&
|
|
323
|
+
errorLog(
|
|
324
|
+
"[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId",
|
|
325
|
+
typeDefinitionId.toString()
|
|
326
|
+
);
|
|
322
327
|
break;
|
|
323
328
|
}
|
|
324
|
-
const bodyXML = this._cloneFragment
|
|
325
|
-
this._cloneFragment
|
|
329
|
+
const bodyXML = this._cloneFragment.value;
|
|
330
|
+
this._cloneFragment.value = null;
|
|
326
331
|
|
|
327
332
|
// the "Default Xml" encoding nodeId
|
|
328
333
|
const xmlEncodingNodeId = typeDefinitionId;
|
|
329
334
|
if (typeDefinitionId.isEmpty()) {
|
|
330
|
-
|
|
335
|
+
// c8 ignore next
|
|
336
|
+
doDebug && debugLog(`xmlEncodingNodeId is empty for ${typeDefinitionId.toString()}`);
|
|
331
337
|
break;
|
|
332
338
|
}
|
|
333
|
-
setExtensionObjectPojo(xmlEncodingNodeId, bodyXML, data);
|
|
339
|
+
setExtensionObjectPojo(xmlEncodingNodeId, bodyXML ?? "", data);
|
|
334
340
|
break;
|
|
335
341
|
}
|
|
336
342
|
}
|
|
@@ -340,7 +346,7 @@ export function makeExtensionObjectParser<T>(
|
|
|
340
346
|
finish(this: ExtensionObjectParser) {
|
|
341
347
|
/* empty */
|
|
342
348
|
}
|
|
343
|
-
}
|
|
349
|
+
})
|
|
344
350
|
};
|
|
345
351
|
}
|
|
346
352
|
|
|
@@ -359,7 +365,10 @@ export function createXMLExtensionObjectDecodingTask(
|
|
|
359
365
|
capturedXmlBody,
|
|
360
366
|
translateNodeId
|
|
361
367
|
);
|
|
362
|
-
|
|
368
|
+
if (!extensionObject) {
|
|
369
|
+
throw new Error("decodeXmlExtensionObject returned null");
|
|
370
|
+
}
|
|
371
|
+
withDecoded(extensionObject);
|
|
363
372
|
};
|
|
364
373
|
return task;
|
|
365
374
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { coerceLocalizedText, type LocalizedText, type LocalizedTextOptions } from "node-opcua-data-model";
|
|
2
2
|
import type { ReaderStateParserLike } from "node-opcua-xml2json";
|
|
3
3
|
|
|
4
|
-
type LocalizedTextParserLikeL1 = ReaderStateParserLike & {
|
|
4
|
+
export type LocalizedTextParserLikeL1 = ReaderStateParserLike & {
|
|
5
5
|
localizedText: LocalizedTextOptions;
|
|
6
6
|
value: LocalizedText | null;
|
|
7
7
|
};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { type NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
2
2
|
|
|
3
|
+
interface NodeIdParserState {
|
|
4
|
+
nodeId: string | NodeId;
|
|
5
|
+
}
|
|
6
|
+
interface IdentifierParserState {
|
|
7
|
+
text: string;
|
|
8
|
+
parent: NodeIdParserState;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
export const makeNodeIdParser = (_translateNodeId: (nodeId: string) => NodeId) => ({
|
|
4
12
|
NodeId: {
|
|
5
|
-
init(this:
|
|
13
|
+
init(this: NodeIdParserState) {
|
|
6
14
|
this.nodeId = "";
|
|
7
15
|
},
|
|
8
16
|
parser: {
|
|
9
17
|
Identifier: {
|
|
10
|
-
finish(this:
|
|
18
|
+
finish(this: IdentifierParserState) {
|
|
11
19
|
this.parent.nodeId = _translateNodeId(resolveNodeId(this.text.trim()).toString());
|
|
12
20
|
}
|
|
13
21
|
}
|
|
@@ -2,7 +2,7 @@ import { coerceQualifiedName, type QualifiedName, type QualifiedNameOptions } fr
|
|
|
2
2
|
import { type NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
3
3
|
import type { ReaderStateParserLike } from "node-opcua-xml2json";
|
|
4
4
|
|
|
5
|
-
interface QualifiedNameParserL1 extends ReaderStateParserLike {
|
|
5
|
+
export interface QualifiedNameParserL1 extends ReaderStateParserLike {
|
|
6
6
|
value: QualifiedName | null;
|
|
7
7
|
qualifiedName: QualifiedNameOptions;
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAddressSpace, UAVariable
|
|
1
|
+
import type { IAddressSpace, UAVariable } from "node-opcua-address-space-base";
|
|
2
2
|
import { assert } from "node-opcua-assert";
|
|
3
3
|
import { coerceBoolean, coerceInt64, coerceUInt64, DataType, type Int64, isValidGuid, type UInt64 } from "node-opcua-basic-types";
|
|
4
4
|
import {
|
|
@@ -8,21 +8,22 @@ import {
|
|
|
8
8
|
NodeClass,
|
|
9
9
|
type QualifiedNameOptions
|
|
10
10
|
} from "node-opcua-data-model";
|
|
11
|
-
import { make_debugLog } from "node-opcua-debug";
|
|
11
|
+
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
12
12
|
import type { ExtensionObject } from "node-opcua-extension-object";
|
|
13
13
|
import { type NodeId, type NodeIdLike, resolveNodeId } from "node-opcua-nodeid";
|
|
14
14
|
import { VariantArrayType, type VariantOptions } from "node-opcua-variant";
|
|
15
|
-
import type { ParserLike, ReaderStateParserLike, XmlAttributes } from "node-opcua-xml2json";
|
|
15
|
+
import type { IReaderState, ParserLike, ReaderStateParserLike, Xml2Json, XmlAttributes } from "node-opcua-xml2json";
|
|
16
16
|
import {
|
|
17
17
|
createXMLExtensionObjectDecodingTask,
|
|
18
18
|
makeExtensionObjectInnerParser,
|
|
19
19
|
makeExtensionObjectParser
|
|
20
20
|
} from "./extension_object_parser";
|
|
21
|
-
import { localizedText_parser } from "./localized_text_parser";
|
|
21
|
+
import { type LocalizedTextParserLikeL1, localizedText_parser } from "./localized_text_parser";
|
|
22
22
|
import { makeNodeIdParser } from "./nodeid_parser";
|
|
23
|
-
import { makeQualifiedNameParser } from "./qualified_name_parser";
|
|
23
|
+
import { makeQualifiedNameParser, type QualifiedNameParserL1 } from "./qualified_name_parser";
|
|
24
24
|
|
|
25
25
|
const debugLog = make_debugLog(__dirname);
|
|
26
|
+
const doDebug = checkDebugFlag(__dirname);
|
|
26
27
|
|
|
27
28
|
export type Task = (addressSpace2: IAddressSpace) => Promise<void>;
|
|
28
29
|
|
|
@@ -30,10 +31,11 @@ type IBasicReaderStateParserLike<T> = ReaderStateParserLike & {
|
|
|
30
31
|
value: T | undefined;
|
|
31
32
|
text: string;
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
function BasicType_parser<T>(dataType: string, parseFunc: (this: { value: T | undefined }, text: string) => T): ParserLike {
|
|
34
36
|
const _parser: Record<string, ReaderStateParserLike> = {};
|
|
35
37
|
const a = {
|
|
36
|
-
init(this: IBasicReaderStateParserLike<T>, _name: string, _attrs: XmlAttributes, _parent:
|
|
38
|
+
init(this: IBasicReaderStateParserLike<T>, _name: string, _attrs: XmlAttributes, _parent: IReaderState, _engine: Xml2Json) {
|
|
37
39
|
this.value = undefined;
|
|
38
40
|
},
|
|
39
41
|
finish(this: IBasicReaderStateParserLike<T>) {
|
|
@@ -44,7 +46,11 @@ function BasicType_parser<T>(dataType: string, parseFunc: (this: { value: T | un
|
|
|
44
46
|
return _parser as ParserLike;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
function ListOf<T>(
|
|
49
|
+
function ListOf<T>(
|
|
50
|
+
_setValue: (data: VariantOptions) => void,
|
|
51
|
+
dataType: string,
|
|
52
|
+
parseFunc: (this: { value: T | undefined }, text: string) => T
|
|
53
|
+
) {
|
|
48
54
|
return {
|
|
49
55
|
init(this: ListOfTParser<T>) {
|
|
50
56
|
this.listData = [];
|
|
@@ -55,43 +61,50 @@ function ListOf<T>(_setValue: (data: VariantOptions) => void, dataType: string,
|
|
|
55
61
|
finish(this: ListOfTParser<T>) {
|
|
56
62
|
_setValue({
|
|
57
63
|
arrayType: VariantArrayType.Array,
|
|
58
|
-
dataType: (DataType as
|
|
64
|
+
dataType: (DataType as unknown as Record<string, number>)[dataType] as DataType,
|
|
59
65
|
value: this.listData
|
|
60
66
|
});
|
|
61
67
|
},
|
|
62
68
|
endElement(this: ListOfTParser<T>, _element: string) {
|
|
63
|
-
this.listData.push(this.parser[dataType].value);
|
|
69
|
+
this.listData.push(this.parser[dataType].value as T);
|
|
64
70
|
}
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
interface Parser {
|
|
69
|
-
parent
|
|
75
|
+
parent?: Parser;
|
|
76
|
+
obj?: { nodeId: NodeId };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface UAVariableTypeWithVariantValue {
|
|
80
|
+
value: { value: unknown };
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
function _installExtensionObjectListInitializationPostTask(
|
|
73
84
|
postTasks2_AssignedExtensionObjectToDataValue: Task[],
|
|
74
85
|
element: ListOfExtensionObjectParser
|
|
75
86
|
) {
|
|
76
|
-
let listExtensionObject = element.listExtensionObject;
|
|
77
|
-
let nodeId = element.parent.parent
|
|
78
|
-
|
|
87
|
+
let listExtensionObject: (ExtensionObject | null)[] | undefined = element.listExtensionObject;
|
|
88
|
+
let nodeId: NodeId | undefined = element.parent.parent?.obj?.nodeId;
|
|
89
|
+
if (!nodeId) {
|
|
90
|
+
throw new Error("expecting a nodeid");
|
|
91
|
+
}
|
|
79
92
|
const task = async (addressSpace2: IAddressSpace) => {
|
|
80
|
-
const node = addressSpace2.findNode(nodeId)
|
|
93
|
+
const node = nodeId ? addressSpace2.findNode(nodeId) : null;
|
|
81
94
|
if (!node) {
|
|
82
|
-
|
|
95
|
+
// c8 ignore next
|
|
96
|
+
doDebug && debugLog(`Cannot find node with nodeId ${nodeId}. may be the node was marked as deprecated`);
|
|
83
97
|
} else if (node.nodeClass === NodeClass.Variable) {
|
|
84
98
|
const v = node as UAVariable;
|
|
85
99
|
assert(v.getBasicDataType() === DataType.ExtensionObject, "expecting an extension object");
|
|
86
100
|
v.bindExtensionObject(listExtensionObject as ExtensionObject[], { createMissingProp: false });
|
|
87
101
|
} else if (node.nodeClass === NodeClass.VariableType) {
|
|
88
102
|
// no need to bind a variable type
|
|
89
|
-
|
|
90
|
-
(v as any) /*fix me*/.value.value = listExtensionObject;
|
|
103
|
+
(node as unknown as UAVariableTypeWithVariantValue) /*fix me*/.value.value = listExtensionObject;
|
|
91
104
|
}
|
|
92
|
-
listExtensionObject
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
listExtensionObject?.slice(0);
|
|
106
|
+
listExtensionObject = undefined;
|
|
107
|
+
nodeId = undefined;
|
|
95
108
|
};
|
|
96
109
|
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
97
110
|
}
|
|
@@ -100,15 +113,15 @@ export interface ListOfTParser<T> extends Parser {
|
|
|
100
113
|
listData: T[];
|
|
101
114
|
parent: Parser;
|
|
102
115
|
parser: {
|
|
103
|
-
[key: string]:
|
|
116
|
+
[key: string]: ReaderStateParserLike & { value?: T; nodeId?: NodeId | string };
|
|
104
117
|
};
|
|
105
118
|
}
|
|
106
|
-
function parser2
|
|
119
|
+
function parser2(_setValue: (data: VariantOptions) => void, type: string, p: (text: string) => unknown): ReaderStateParserLike {
|
|
107
120
|
return {
|
|
108
|
-
finish(this:
|
|
121
|
+
finish(this: { text: string }) {
|
|
109
122
|
_setValue({
|
|
110
123
|
arrayType: VariantArrayType.Scalar,
|
|
111
|
-
dataType: (DataType as
|
|
124
|
+
dataType: (DataType as unknown as Record<string, number>)[type] as DataType,
|
|
112
125
|
value: p(this.text)
|
|
113
126
|
});
|
|
114
127
|
}
|
|
@@ -144,7 +157,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
144
157
|
parser: {
|
|
145
158
|
QualifiedName: {
|
|
146
159
|
...makeQualifiedNameParser(translateNodeId).QualifiedName,
|
|
147
|
-
finish(this:
|
|
160
|
+
finish(this: QualifiedNameParserL1) {
|
|
148
161
|
setValue2({
|
|
149
162
|
dataType: DataType.QualifiedName,
|
|
150
163
|
value: coerceQualifiedName({ ...this.qualifiedName })
|
|
@@ -153,7 +166,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
153
166
|
},
|
|
154
167
|
LocalizedText: {
|
|
155
168
|
...localizedText_parser.LocalizedText,
|
|
156
|
-
finish(this:
|
|
169
|
+
finish(this: LocalizedTextParserLikeL1) {
|
|
157
170
|
setValue2({
|
|
158
171
|
dataType: DataType.LocalizedText,
|
|
159
172
|
value: coerceLocalizedText({ ...this.localizedText })
|
|
@@ -161,7 +174,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
161
174
|
}
|
|
162
175
|
},
|
|
163
176
|
XmlElement: {
|
|
164
|
-
finish(this:
|
|
177
|
+
finish(this: { text: string }) {
|
|
165
178
|
setValue2({
|
|
166
179
|
dataType: DataType.XmlElement,
|
|
167
180
|
value: this.text
|
|
@@ -169,7 +182,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
169
182
|
}
|
|
170
183
|
},
|
|
171
184
|
String: {
|
|
172
|
-
finish(this:
|
|
185
|
+
finish(this: { text: string }) {
|
|
173
186
|
setValue2({
|
|
174
187
|
dataType: DataType.String,
|
|
175
188
|
value: this.text
|
|
@@ -179,7 +192,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
179
192
|
Guid: {
|
|
180
193
|
parser: {
|
|
181
194
|
String: {
|
|
182
|
-
finish(this:
|
|
195
|
+
finish(this: { text: string }) {
|
|
183
196
|
const guid = this.text;
|
|
184
197
|
if (!isValidGuid(guid)) {
|
|
185
198
|
/* ?*/
|
|
@@ -196,7 +209,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
196
209
|
NodeId: {
|
|
197
210
|
parser: {
|
|
198
211
|
Identifier: {
|
|
199
|
-
finish(this:
|
|
212
|
+
finish(this: { text: string }) {
|
|
200
213
|
const nodeId = this.text;
|
|
201
214
|
setValue2({
|
|
202
215
|
dataType: DataType.NodeId,
|
|
@@ -221,10 +234,10 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
221
234
|
Int64: parser2(setValue2, "Int64", parseInt64),
|
|
222
235
|
|
|
223
236
|
ByteString: {
|
|
224
|
-
init(this:
|
|
237
|
+
init(this: { value: Buffer | null; text: string }) {
|
|
225
238
|
this.value = null;
|
|
226
239
|
},
|
|
227
|
-
finish(this:
|
|
240
|
+
finish(this: { value: Buffer | null; text: string }) {
|
|
228
241
|
const base64text = this.text;
|
|
229
242
|
const byteString = Buffer.from(base64text, "base64");
|
|
230
243
|
setValue2({
|
|
@@ -235,7 +248,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
235
248
|
}
|
|
236
249
|
},
|
|
237
250
|
Float: {
|
|
238
|
-
finish(this:
|
|
251
|
+
finish(this: { text: string }) {
|
|
239
252
|
setValue2({
|
|
240
253
|
dataType: DataType.Float,
|
|
241
254
|
value: parseFloat(this.text)
|
|
@@ -244,7 +257,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
244
257
|
},
|
|
245
258
|
|
|
246
259
|
Double: {
|
|
247
|
-
finish(this:
|
|
260
|
+
finish(this: { text: string }) {
|
|
248
261
|
setValue2({
|
|
249
262
|
dataType: DataType.Double,
|
|
250
263
|
value: parseFloat(this.text)
|
|
@@ -325,7 +338,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
325
338
|
});
|
|
326
339
|
} else {
|
|
327
340
|
// postpone the creation of the extension object
|
|
328
|
-
const listExtensionObject: ExtensionObject[] = this.listExtensionObject as
|
|
341
|
+
const listExtensionObject: ExtensionObject[] = this.listExtensionObject as ExtensionObject[];
|
|
329
342
|
setDeferredValue(
|
|
330
343
|
self,
|
|
331
344
|
{
|
|
@@ -348,7 +361,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
348
361
|
...localizedText_parser
|
|
349
362
|
},
|
|
350
363
|
endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
|
|
351
|
-
this.listData.push(this.parser.LocalizedText.value);
|
|
364
|
+
this.listData.push(this.parser.LocalizedText.value as QualifiedNameOptions);
|
|
352
365
|
},
|
|
353
366
|
finish(this: ListOfTParser<QualifiedNameOptions>) {
|
|
354
367
|
setValue2({
|
|
@@ -364,7 +377,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
364
377
|
},
|
|
365
378
|
parser: makeQualifiedNameParser(translateNodeId),
|
|
366
379
|
endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
|
|
367
|
-
this.listData.push(this.parser.QualifiedName.value);
|
|
380
|
+
this.listData.push(this.parser.QualifiedName.value as QualifiedNameOptions);
|
|
368
381
|
},
|
|
369
382
|
finish(this: ListOfTParser<QualifiedNameOptions>) {
|
|
370
383
|
setValue2({
|
|
@@ -380,7 +393,7 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
380
393
|
},
|
|
381
394
|
parser: makeNodeIdParser(translateNodeId),
|
|
382
395
|
endElement(this: ListOfTParser<NodeIdLike>, _elementName: string) {
|
|
383
|
-
this.listData.push(this.parser.NodeId.nodeId);
|
|
396
|
+
this.listData.push(this.parser.NodeId.nodeId as NodeIdLike);
|
|
384
397
|
},
|
|
385
398
|
finish(this: ListOfTParser<NodeIdLike>) {
|
|
386
399
|
setValue2({
|
|
@@ -416,5 +429,5 @@ export function makeVariantReader<T extends ReaderStateParserLike>(
|
|
|
416
429
|
ListOfXmlElement: ListOf<string>(setValue2, "XmlElement", (value: string) => value)
|
|
417
430
|
}
|
|
418
431
|
};
|
|
419
|
-
return reader as
|
|
432
|
+
return reader as unknown as ReaderStateParserLike;
|
|
420
433
|
}
|