node-opcua-address-space 2.136.0 → 2.137.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/helpers/adjust_browse_direction.js +1 -2
- package/dist/source/helpers/adjust_browse_direction.js.map +1 -1
- package/dist/source/helpers/argument_list.js +6 -7
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +1 -2
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/coerce_enum_value.js +1 -2
- package/dist/source/helpers/coerce_enum_value.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +5 -6
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/ensure_secure_access.js +1 -2
- package/dist/source/helpers/ensure_secure_access.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +1 -3
- package/dist/source/helpers/make_optionals_map.js +7 -4
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/helpers/multiform_func.js +2 -3
- package/dist/source/helpers/multiform_func.js.map +1 -1
- package/dist/source/helpers/resolve_opaque_on_address_space.js +1 -2
- package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -1
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +2 -0
- package/dist/source/index.js.map +1 -1
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +0 -3
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +0 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +0 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js.map +1 -1
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +1 -2
- package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +1 -0
- package/dist/source/loader/decode_xml_extension_object.d.ts +1 -1
- package/dist/source/loader/decode_xml_extension_object.js +4 -5
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js +32 -4
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +3 -4
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +145 -737
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_semver_compatible.js +1 -2
- package/dist/source/loader/make_semver_compatible.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.d.ts +1 -6
- package/dist/source/loader/make_xml_extension_object_parser.js +52 -73
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.d.ts +4 -6
- package/dist/source/loader/namespace_post_step.js +5 -5
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +51 -0
- package/dist/source/loader/parsers/extension_object_parser.js +269 -0
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -0
- package/dist/source/loader/parsers/localized_text_parser.d.ts +25 -0
- package/dist/source/loader/parsers/localized_text_parser.js +30 -0
- package/dist/source/loader/parsers/localized_text_parser.js.map +1 -0
- package/dist/source/loader/parsers/nodeid_parser.d.ts +11 -0
- package/dist/source/loader/parsers/nodeid_parser.js +20 -0
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -0
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +26 -0
- package/dist/source/loader/parsers/qualified_name_parser.js +35 -0
- package/dist/source/loader/parsers/qualified_name_parser.js.map +1 -0
- package/dist/source/loader/parsers/variant_parser.d.ts +29 -0
- package/dist/source/loader/parsers/variant_parser.js +328 -0
- package/dist/source/loader/parsers/variant_parser.js.map +1 -0
- package/dist/source/loader/register_node_promoter.js +2 -3
- package/dist/source/loader/register_node_promoter.js.map +1 -1
- package/dist/source/pseudo_session.d.ts +0 -2
- package/dist/source/pseudo_session.js +3 -3
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.d.ts +1 -1
- package/dist/source/session_context.js +3 -3
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.js +1 -2
- package/dist/source/set_namespace_meta_data.js.map +1 -1
- package/dist/source/ua_addin.d.ts +11 -0
- package/dist/source/ua_addin.js +42 -0
- package/dist/source/ua_addin.js.map +1 -0
- package/dist/source/ua_interface.d.ts +2 -0
- package/dist/source/ua_interface.js +35 -0
- package/dist/source/ua_interface.js.map +1 -0
- package/dist/source/xml_writer.d.ts +3 -5
- package/dist/src/_instantiate_helpers.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +6 -7
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +6 -5
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +1 -5
- package/dist/src/address_space.js +1 -1
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_change_event_tools.js +3 -4
- package/dist/src/address_space_change_event_tools.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition.d.ts +4 -7
- package/dist/src/alarms_and_conditions/condition.js +1 -25
- package/dist/src/alarms_and_conditions/condition.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +2 -20
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +211 -234
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +4 -5
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +0 -2
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +1 -2
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +0 -2
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +3 -3
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +0 -2
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +10 -12
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -1
- package/dist/src/apply_condition_refresh.d.ts +1 -3
- package/dist/src/apply_condition_refresh.js +4 -5
- package/dist/src/apply_condition_refresh.js.map +1 -1
- package/dist/src/base_node_impl.d.ts +0 -1
- package/dist/src/base_node_impl.js +11 -11
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +4 -7
- package/dist/src/base_node_private.js +23 -25
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/check_value_rank_compatibility.js +1 -2
- package/dist/src/check_value_rank_compatibility.js.map +1 -1
- package/dist/src/data_access/add_dataItem_stuff.js +1 -2
- package/dist/src/data_access/add_dataItem_stuff.js.map +1 -1
- package/dist/src/data_access/adjust_datavalue_status_code.js +1 -2
- package/dist/src/data_access/adjust_datavalue_status_code.js.map +1 -1
- package/dist/src/data_access/ua_multistate_discrete_impl.js +3 -3
- package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js +5 -5
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
- package/dist/src/data_access/ua_two_state_discrete_impl.js +3 -3
- package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -1
- package/dist/src/extension_object_array_node.js +4 -5
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +2 -3
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +5 -5
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/index_current.d.ts +3 -1
- package/dist/src/index_current.js +3 -1
- package/dist/src/index_current.js.map +1 -1
- package/dist/src/namespace_impl.js +3 -3
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/namespace_private.js +1 -2
- package/dist/src/namespace_private.js.map +1 -1
- package/dist/src/nodeset_tools/adjust_namespace_array.js +1 -2
- package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -2
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +12 -12
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +5 -6
- 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 +53 -46
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js +3 -4
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.js +4 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/role_permissions.js +1 -2
- package/dist/src/role_permissions.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +6 -6
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +0 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +2 -2
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +4 -4
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.d.ts +1 -1
- package/dist/src/tool_isSubtypeOf.js +18 -16
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_addin.d.ts +11 -0
- package/dist/src/ua_addin.js +43 -0
- package/dist/src/ua_addin.js.map +1 -0
- package/dist/src/ua_data_type_impl.js +7 -6
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +2 -1
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.d.ts +1 -1
- package/dist/src/ua_reference_type_impl.js +3 -3
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +6 -3
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js +15 -15
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +2 -0
- package/dist/src/ua_variable_type_impl.js +8 -4
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/validate_data_type_correctness.js +1 -2
- package/dist/src/validate_data_type_correctness.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +1 -2
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/alarms_and_conditions_demo.js +1 -2
- package/distHelpers/alarms_and_conditions_demo.js.map +1 -1
- package/distHelpers/assertHasMatchingReference.js +1 -2
- package/distHelpers/assertHasMatchingReference.js.map +1 -1
- package/distHelpers/boiler_system.js +2 -3
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +1 -2
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js +1 -2
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +1 -2
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/distHelpers/get_mini_address_space.js +2 -2
- package/distHelpers/get_mini_address_space.js.map +1 -1
- package/distNodeJS/generate_address_space.js +2 -3
- package/distNodeJS/generate_address_space.js.map +1 -1
- package/package.json +24 -24
- package/source/helpers/make_optionals_map.ts +9 -6
- package/source/index.ts +3 -0
- package/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.ts +3 -1
- package/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.ts +18 -16
- package/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.ts +5 -3
- package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +4 -2
- package/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.ts +4 -2
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +3 -1
- package/source/interfaces/state_machine/ua_shelved_state_machine_ex.ts +1 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +14 -7
- package/source/loader/decode_xml_extension_object.ts +4 -3
- package/source/loader/ensure_datatype_extracted.ts +38 -2
- package/source/loader/generateAddressSpaceRaw.ts +4 -4
- package/source/loader/load_nodeset2.ts +212 -901
- package/source/loader/make_xml_extension_object_parser.ts +87 -123
- package/source/loader/namespace_post_step.ts +6 -5
- package/source/loader/parsers/extension_object_parser.ts +364 -0
- package/source/loader/parsers/localized_text_parser.ts +34 -0
- package/source/loader/parsers/nodeid_parser.ts +17 -0
- package/source/loader/parsers/qualified_name_parser.ts +43 -0
- package/source/loader/parsers/variant_parser.ts +427 -0
- package/source/loader/register_node_promoter.ts +2 -5
- package/source/session_context.ts +1 -1
- package/source/ua_addin.ts +52 -0
- package/source/ua_interface.ts +38 -0
- package/source/xml_writer.ts +4 -5
- package/src/_instantiate_helpers.ts +8 -2
- package/src/_mandatory_child_or_requested_optional_filter.ts +9 -7
- package/src/address_space.ts +1 -1
- package/src/alarms_and_conditions/condition.ts +0 -32
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +176 -189
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +1 -3
- package/src/alarms_and_conditions/ua_base_event_impl.ts +6 -2
- package/src/alarms_and_conditions/ua_condition_impl.ts +11 -13
- package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +3 -1
- package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +3 -1
- package/src/apply_condition_refresh.ts +4 -4
- package/src/base_node_impl.ts +13 -13
- package/src/base_node_private.ts +6 -11
- package/src/data_access/ua_multistate_value_discrete_impl.ts +1 -1
- package/src/historical_access/address_space_historical_data_node.ts +3 -3
- package/src/index_current.ts +4 -1
- package/src/nodeset_tools/construct_namespace_dependency.ts +9 -8
- package/src/nodeset_tools/dump_to_bsd.ts +7 -7
- package/src/nodeset_tools/nodeset_to_xml.ts +70 -44
- package/src/tool_isSubtypeOf.ts +20 -16
- package/src/ua_data_type_impl.ts +5 -4
- package/src/ua_object_type_impl.ts +4 -1
- package/src/ua_reference_type_impl.ts +6 -6
- package/src/ua_variable_impl.ts +4 -0
- package/src/ua_variable_impl_ext_obj.ts +2 -1
- package/src/ua_variable_type_impl.ts +11 -1
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { IAddressSpace } from "node-opcua-address-space-base";
|
|
3
|
+
import { ExtensionObject } from "node-opcua-extension-object";
|
|
4
|
+
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
5
|
+
import { InternalFragmentClonerReaderState, ParserLike, ReaderStateParser, ReaderStateParserLike } from "node-opcua-xml2json";
|
|
6
|
+
import { decodeXmlExtensionObject } from "../decode_xml_extension_object";
|
|
7
|
+
import { coerceLocalizedText, LocalizedText, LocalizedTextOptions } from "node-opcua-data-model";
|
|
8
|
+
import { Argument, EnumValueType, EUInformation, EUInformationOptions } from "node-opcua-types";
|
|
9
|
+
import { localizedText_parser } from "./localized_text_parser";
|
|
10
|
+
import { coerceInt64 } from "node-opcua-basic-types";
|
|
11
|
+
import { make_debugLog } from "node-opcua-debug";
|
|
12
|
+
import { Range } from "node-opcua-data-access";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const debugLog = make_debugLog("ExtensionObjectParser");
|
|
16
|
+
const errorLog = make_debugLog("ExtensionObjectParser");
|
|
17
|
+
const doDebug = false;
|
|
18
|
+
export type Task = (addressSpace: IAddressSpace) => Promise<void>;
|
|
19
|
+
|
|
20
|
+
interface PostExtensionObjectData {
|
|
21
|
+
postponedExtensionObject: ExtensionObject | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// #region Argument parser
|
|
25
|
+
type ArgumentParser = ParserLike & { argument: Argument };
|
|
26
|
+
type ArgumentParserL2 = { parent: ArgumentParser } & { text: string };
|
|
27
|
+
type ArgumentParserL2L = { parent: ArgumentParser } & { localizedText: LocalizedTextOptions };
|
|
28
|
+
type ArgumentParserL3 = { parent: ArgumentParserL2 } & { text: string };
|
|
29
|
+
|
|
30
|
+
const makeArgumentParser = (_translateNodeId: (nodeId: string) => NodeId) => ({
|
|
31
|
+
Argument: {
|
|
32
|
+
init(this: ArgumentParser) {
|
|
33
|
+
this.argument = new Argument({});
|
|
34
|
+
},
|
|
35
|
+
parser: {
|
|
36
|
+
Name: {
|
|
37
|
+
finish(this: ArgumentParserL2) {
|
|
38
|
+
this.parent.argument.name = this.text.trim();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
DataType: {
|
|
43
|
+
parser: {
|
|
44
|
+
Identifier: {
|
|
45
|
+
finish(this: ArgumentParserL3) {
|
|
46
|
+
this.parent.parent.argument.dataType = _translateNodeId(resolveNodeId(this.text.trim()).toString());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
ValueRank: {
|
|
52
|
+
finish(this: ArgumentParserL2) {
|
|
53
|
+
this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
ArrayDimensions: {
|
|
58
|
+
finish(this: ArgumentParserL2) {
|
|
59
|
+
// xx this.parent.argument.arrayDimensions =[];
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
Description: {
|
|
63
|
+
...localizedText_parser.LocalizedText,
|
|
64
|
+
finish(this: ArgumentParserL2L) {
|
|
65
|
+
this.parent.argument.description = coerceLocalizedText({ ...this.localizedText })!;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
finish(this: any) {
|
|
70
|
+
// xx this.argument = new Argument(this.argument);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// #endregion
|
|
75
|
+
|
|
76
|
+
// #region Range parser
|
|
77
|
+
type RangeParser = ParserLike & { range: Range };
|
|
78
|
+
type RangeParserL2 = ParserLike & { parent: RangeParser, text: string };
|
|
79
|
+
|
|
80
|
+
const Range_parser = {
|
|
81
|
+
Range: {
|
|
82
|
+
init(this: RangeParser) {
|
|
83
|
+
this.range = new Range({});
|
|
84
|
+
},
|
|
85
|
+
parser: {
|
|
86
|
+
Low: {
|
|
87
|
+
finish(this: RangeParserL2) {
|
|
88
|
+
this.parent.range.low = parseFloat(this.text);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
High: {
|
|
93
|
+
finish(this: RangeParserL2) {
|
|
94
|
+
this.parent.range.high = parseFloat(this.text);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
|
|
102
|
+
// #region EUInformation parser
|
|
103
|
+
|
|
104
|
+
type EUInformationParser = ReaderStateParserLike & {
|
|
105
|
+
euInformation: EUInformationOptions;
|
|
106
|
+
parser: any
|
|
107
|
+
};
|
|
108
|
+
type EUInformationParserLevel2 = { parent: EUInformationParser } & { text: string };
|
|
109
|
+
type EUInformationParserLevel2L = { parent: EUInformationParser } & { localizedText: LocalizedTextOptions };
|
|
110
|
+
|
|
111
|
+
const EUInformation_parser: ParserLike = {
|
|
112
|
+
EUInformation: <EUInformationParser>{
|
|
113
|
+
init(this: EUInformationParser, name, attrs, parent, engine) {
|
|
114
|
+
this.euInformation = new EUInformation({});
|
|
115
|
+
},
|
|
116
|
+
parser: {
|
|
117
|
+
NamespaceUri: {
|
|
118
|
+
finish(this: EUInformationParserLevel2) {
|
|
119
|
+
this.parent.euInformation.namespaceUri = this.text;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
UnitId: {
|
|
123
|
+
finish(this: EUInformationParserLevel2) {
|
|
124
|
+
this.parent.euInformation.unitId = parseInt(this.text, 10);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
DisplayName: {
|
|
129
|
+
...localizedText_parser.LocalizedText,
|
|
130
|
+
finish(this: EUInformationParserLevel2L) {
|
|
131
|
+
this.parent.euInformation.displayName = coerceLocalizedText({ ...this.localizedText });
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
Description: {
|
|
136
|
+
...localizedText_parser.LocalizedText,
|
|
137
|
+
finish(this: EUInformationParserLevel2L) {
|
|
138
|
+
this.parent.euInformation.description = coerceLocalizedText({ ...this.localizedText });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
finish(this: EUInformationParser) {
|
|
143
|
+
this.euInformation = new EUInformation(this.euInformation);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
// #endregion
|
|
148
|
+
|
|
149
|
+
// #region EnumValueType parser
|
|
150
|
+
type EnumValueParser = ReaderStateParserLike & {
|
|
151
|
+
enumValueType: EnumValueType;
|
|
152
|
+
parser: {
|
|
153
|
+
Value: ReaderStateParserLike,
|
|
154
|
+
DisplayName: ReaderStateParserLike,
|
|
155
|
+
Description: ReaderStateParserLike
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
type EnumValueParserL2 = ReaderStateParserLike & { parent: EnumValueParser } & { text: string };
|
|
159
|
+
type EnumValueParserL2L = { parent: EnumValueParser } & { localizedText: LocalizedTextOptions };
|
|
160
|
+
|
|
161
|
+
const enumValueType_parser = {
|
|
162
|
+
EnumValueType: {
|
|
163
|
+
init(this: EnumValueParser) {
|
|
164
|
+
this.enumValueType = new EnumValueType({
|
|
165
|
+
description: undefined,
|
|
166
|
+
displayName: undefined,
|
|
167
|
+
value: coerceInt64(-1)
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
parser: {
|
|
171
|
+
Value: {
|
|
172
|
+
// note: Value may be missing, in this case value shall be set to -1(64)
|
|
173
|
+
finish(this: EnumValueParserL2) {
|
|
174
|
+
// Low part
|
|
175
|
+
this.parent.enumValueType.value = coerceInt64(parseInt(this.text, 10));
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
DisplayName: {
|
|
180
|
+
...localizedText_parser.LocalizedText,
|
|
181
|
+
finish(this: EnumValueParserL2L) {
|
|
182
|
+
this.parent.enumValueType.displayName = new LocalizedText({...this.localizedText});
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
Description: {
|
|
187
|
+
...localizedText_parser.LocalizedText,
|
|
188
|
+
finish(this: EnumValueParserL2L) {
|
|
189
|
+
this.parent.enumValueType.description = new LocalizedText({...this.localizedText});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
finish(this: EnumValueParser) {
|
|
194
|
+
this.enumValueType = new EnumValueType(this.enumValueType);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
// #endregion
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
export interface ExtensionObjectTypeIdParser {
|
|
203
|
+
parent: ExtensionObjectParser;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface ExtensionObjectTypeIdIdentifierParser {
|
|
207
|
+
text: string;
|
|
208
|
+
parent: ExtensionObjectTypeIdParser;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface ExtensionObjectParserInner {
|
|
212
|
+
typeDefinitionId: NodeId;
|
|
213
|
+
}
|
|
214
|
+
type ExtensionObjectParser = ExtensionObjectParserInner & any;
|
|
215
|
+
export interface ExtensionObjectBodyParser {
|
|
216
|
+
|
|
217
|
+
parent: ExtensionObjectParser;
|
|
218
|
+
_cloneFragment: InternalFragmentClonerReaderState;
|
|
219
|
+
engine: any;
|
|
220
|
+
parser: {
|
|
221
|
+
Argument: ArgumentParser,
|
|
222
|
+
EUInformation: EUInformationParser,
|
|
223
|
+
EnumValueType: EnumValueParser,
|
|
224
|
+
Range: RangeParser
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function makeExtensionObjectInnerParser<T>(
|
|
229
|
+
translateNodeId: (nodeId: string) => NodeId,
|
|
230
|
+
setExtensionObject: (extensionObject: ExtensionObject) => void,
|
|
231
|
+
setExtensionObjectPojo: (typeDefinition: NodeId, xmlData: string, data: T) => void,
|
|
232
|
+
): ReaderStateParserLike {
|
|
233
|
+
const a = makeExtensionObjectParser(translateNodeId, setExtensionObject, setExtensionObjectPojo);
|
|
234
|
+
return a.ExtensionObject;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export function makeExtensionObjectParser<T>(
|
|
238
|
+
translateNodeId: (nodeId: string) => NodeId,
|
|
239
|
+
setExtensionObject: (extensionObject: ExtensionObject, data: T) => void,
|
|
240
|
+
setExtensionObjectPojo: (typeDefinition: NodeId, xmlData: string, data: T) => void,
|
|
241
|
+
): ParserLike {
|
|
242
|
+
return {
|
|
243
|
+
ExtensionObject: <ExtensionObjectParser>{
|
|
244
|
+
init(this: ExtensionObjectParser) {
|
|
245
|
+
this.typeDefinitionId = NodeId.nullNodeId;
|
|
246
|
+
},
|
|
247
|
+
parser: {
|
|
248
|
+
TypeId: {
|
|
249
|
+
parser: {
|
|
250
|
+
Identifier: {
|
|
251
|
+
finish(this: ExtensionObjectTypeIdIdentifierParser) {
|
|
252
|
+
const typeDefinitionId = this.text.trim();
|
|
253
|
+
this.parent.parent.typeDefinitionId = translateNodeId(typeDefinitionId);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
// Body2: new FragmentClonerParser(),
|
|
260
|
+
|
|
261
|
+
Body: {
|
|
262
|
+
parser: {
|
|
263
|
+
Argument: makeArgumentParser(translateNodeId).Argument,
|
|
264
|
+
EUInformation: EUInformation_parser.EUInformation,
|
|
265
|
+
EnumValueType: enumValueType_parser.EnumValueType,
|
|
266
|
+
Range: Range_parser.Range
|
|
267
|
+
},
|
|
268
|
+
startElement(this: ExtensionObjectBodyParser, elementName: string, attrs: any) {
|
|
269
|
+
if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
|
|
270
|
+
// treat it as a opaque XML bloc for the time being
|
|
271
|
+
// until we find the definition of this object, so we know how to interpret the fields
|
|
272
|
+
this._cloneFragment = new InternalFragmentClonerReaderState();
|
|
273
|
+
this.engine!._promote(this._cloneFragment, this.engine!.currentLevel, elementName, attrs);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
finish(this: ExtensionObjectBodyParser) {
|
|
277
|
+
|
|
278
|
+
const data = this.parent.parent as T;
|
|
279
|
+
const typeDefinitionId = this.parent.typeDefinitionId;
|
|
280
|
+
// typeDefinitionId is also the "Default XML" encoding nodeId !
|
|
281
|
+
switch (typeDefinitionId.toString()) {
|
|
282
|
+
case "i=7616": // EnumValueType
|
|
283
|
+
case "ns=0;i=7616":
|
|
284
|
+
const extensionObject = this.parser.EnumValueType.enumValueType;
|
|
285
|
+
assert(extensionObject !== null && typeof extensionObject === "object");
|
|
286
|
+
assert(extensionObject instanceof ExtensionObject);
|
|
287
|
+
setExtensionObject(extensionObject, data);
|
|
288
|
+
break;
|
|
289
|
+
case "i=297": // Arguments
|
|
290
|
+
case "ns=0;i=297": {
|
|
291
|
+
const extensionObject = this.parser.Argument.argument;
|
|
292
|
+
assert(extensionObject !== null && typeof extensionObject === "object");
|
|
293
|
+
assert(extensionObject instanceof ExtensionObject);
|
|
294
|
+
setExtensionObject(extensionObject, data);
|
|
295
|
+
} break;
|
|
296
|
+
case "i=888":// EUInformation
|
|
297
|
+
case "ns=0;i=888": {
|
|
298
|
+
const extensionObject = this.parser.EUInformation.euInformation;
|
|
299
|
+
assert(extensionObject !== null && typeof extensionObject === "object");
|
|
300
|
+
assert(extensionObject instanceof ExtensionObject);
|
|
301
|
+
setExtensionObject(extensionObject, data);
|
|
302
|
+
} break;
|
|
303
|
+
case "i=885": // Range
|
|
304
|
+
case "ns=0;i=885": {
|
|
305
|
+
const extensionObject = this.parser.Range.range;
|
|
306
|
+
assert(extensionObject !== null && typeof extensionObject === "object");
|
|
307
|
+
assert(extensionObject instanceof ExtensionObject);
|
|
308
|
+
setExtensionObject(extensionObject, data);
|
|
309
|
+
} break;
|
|
310
|
+
default: {
|
|
311
|
+
// istanbul ignore next
|
|
312
|
+
if (!this._cloneFragment) {
|
|
313
|
+
// the XML file is probably not exposing standard UA extension object correctly.
|
|
314
|
+
// this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
|
|
315
|
+
// nodeid
|
|
316
|
+
errorLog(
|
|
317
|
+
"[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId",
|
|
318
|
+
typeDefinitionId.toString()
|
|
319
|
+
);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
const bodyXML = this._cloneFragment!.value;
|
|
323
|
+
this._cloneFragment!.value = null;
|
|
324
|
+
|
|
325
|
+
// the "Default Xml" encoding nodeId
|
|
326
|
+
const xmlEncodingNodeId = typeDefinitionId;
|
|
327
|
+
if (typeDefinitionId.isEmpty()) {
|
|
328
|
+
debugLog("xmlEncodingNodeId is empty for " + typeDefinitionId.toString());
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
setExtensionObjectPojo(xmlEncodingNodeId, bodyXML, data);
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
finish(this: ExtensionObjectParser) {
|
|
339
|
+
/* empty */
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
export function createXMLExtensionObjectDecodingTask(
|
|
347
|
+
translateNodeId: (nodeId:string) => NodeId,
|
|
348
|
+
xmlEncodingNodeId: NodeId, bodyXML: string,
|
|
349
|
+
withDecoded: (extensionObject: ExtensionObject) => void,
|
|
350
|
+
) {
|
|
351
|
+
|
|
352
|
+
const capturedXmlBody = bodyXML;
|
|
353
|
+
|
|
354
|
+
const task = async (addressSpace2: IAddressSpace) => {
|
|
355
|
+
const extensionObject: ExtensionObject | null = decodeXmlExtensionObject(
|
|
356
|
+
addressSpace2,
|
|
357
|
+
xmlEncodingNodeId,
|
|
358
|
+
capturedXmlBody,
|
|
359
|
+
translateNodeId
|
|
360
|
+
);
|
|
361
|
+
withDecoded(extensionObject!);
|
|
362
|
+
};
|
|
363
|
+
return task;
|
|
364
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { coerceLocalizedText, LocalizedTextOptions, LocalizedText } from "node-opcua-data-model";
|
|
2
|
+
import { ReaderStateParserLike } from "node-opcua-xml2json";
|
|
3
|
+
|
|
4
|
+
type LocalizedTextParserLikeL1 = ReaderStateParserLike & {
|
|
5
|
+
localizedText: LocalizedTextOptions;
|
|
6
|
+
value: LocalizedText | null;
|
|
7
|
+
};
|
|
8
|
+
type LocalizedTextParserLikeL2 = { parent: LocalizedTextParserLikeL1; text: string };
|
|
9
|
+
|
|
10
|
+
export const localizedText_parser = {
|
|
11
|
+
LocalizedText: {
|
|
12
|
+
init(this: LocalizedTextParserLikeL1) {
|
|
13
|
+
this.localizedText = { locale: undefined, text: undefined };
|
|
14
|
+
this.value = null;
|
|
15
|
+
},
|
|
16
|
+
parser: {
|
|
17
|
+
Locale: {
|
|
18
|
+
finish(this: LocalizedTextParserLikeL2) {
|
|
19
|
+
this.parent.localizedText = this.parent.localizedText || { text: undefined};
|
|
20
|
+
this.parent.localizedText.locale = this.text.trim();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
Text: {
|
|
24
|
+
finish(this: LocalizedTextParserLikeL2) {
|
|
25
|
+
this.parent.localizedText = this.parent.localizedText || { text: undefined };
|
|
26
|
+
this.parent.localizedText.text = this.text.trim();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
finish(this: LocalizedTextParserLikeL1) {
|
|
31
|
+
this.value = coerceLocalizedText(this.localizedText);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolveNodeId, NodeId, NodeIdLike } from "node-opcua-nodeid";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const makeNodeIdParser = (_translateNodeId: (nodeId: string) => NodeId) => ({
|
|
5
|
+
NodeId: {
|
|
6
|
+
init(this: any) {
|
|
7
|
+
this.nodeId = "";
|
|
8
|
+
},
|
|
9
|
+
parser: {
|
|
10
|
+
Identifier: {
|
|
11
|
+
finish(this: any) {
|
|
12
|
+
this.parent.nodeId = _translateNodeId(resolveNodeId(this.text.trim()).toString());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { QualifiedNameOptions, QualifiedName, coerceQualifiedName } from "node-opcua-data-model";
|
|
2
|
+
import { resolveNodeId, NodeId, NodeIdLike } from "node-opcua-nodeid";
|
|
3
|
+
import { ReaderStateParserLike } from "node-opcua-xml2json";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
interface QualifiedNameParserL1 extends ReaderStateParserLike {
|
|
7
|
+
value: QualifiedName| null;
|
|
8
|
+
qualifiedName: QualifiedNameOptions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface QualifiedNameParserL2 {
|
|
12
|
+
parent: QualifiedNameParserL1;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const makeQualifiedNameParser = (_translateNodeId: (nodeId: string)=> NodeId) => ({
|
|
17
|
+
QualifiedName: {
|
|
18
|
+
init(this: QualifiedNameParserL1) {
|
|
19
|
+
this.qualifiedName = {
|
|
20
|
+
namespaceIndex: 0,
|
|
21
|
+
name: null
|
|
22
|
+
} as QualifiedNameOptions;
|
|
23
|
+
this.value = null;
|
|
24
|
+
},
|
|
25
|
+
parser: {
|
|
26
|
+
Name: {
|
|
27
|
+
finish(this: QualifiedNameParserL2) {
|
|
28
|
+
this.parent.qualifiedName.name = this.text.trim();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
NamespaceIndex: {
|
|
32
|
+
finish(this: QualifiedNameParserL2) {
|
|
33
|
+
const ns = parseInt(this.text, 10);
|
|
34
|
+
const t = _translateNodeId(resolveNodeId(`ns=${ns};i=1`).toString());
|
|
35
|
+
this.parent.qualifiedName.namespaceIndex = t.namespace;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
finish(this: QualifiedNameParserL1) {
|
|
40
|
+
this.value = coerceQualifiedName(this.qualifiedName)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|