node-opcua-address-space 2.136.0 → 2.138.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 +3 -0
- package/dist/source/ua_interface.js +45 -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 +7 -8
- 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.d.ts +1 -9
- package/dist/src/namespace_impl.js +19 -12
- 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/nodeid_manager.js +35 -10
- package/dist/src/nodeid_manager.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 +4 -5
- 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.d.ts +1 -0
- package/dist/src/ua_object_type_impl.js +4 -1
- package/dist/src/ua_object_type_impl.js.map +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 +53 -0
- package/source/ua_interface.ts +49 -0
- package/source/xml_writer.ts +4 -5
- package/src/_instantiate_helpers.ts +9 -3
- 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/namespace_impl.ts +21 -10
- package/src/nodeid_manager.ts +46 -17
- 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/private_namespace.ts +2 -1
- package/src/tool_isSubtypeOf.ts +20 -16
- package/src/ua_data_type_impl.ts +5 -4
- package/src/ua_object_type_impl.ts +7 -2
- 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
|
@@ -1,86 +1,18 @@
|
|
|
1
|
+
import { IAddressSpace } from "node-opcua-address-space-base";
|
|
1
2
|
import { Byte, coerceInt64, coerceUInt64, Int16, Int32, Int64, SByte, UAString, UInt16, UInt32, UInt64 } from "node-opcua-basic-types";
|
|
2
|
-
import { LocalizedTextOptions } from "node-opcua-data-model";
|
|
3
3
|
import { make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
4
4
|
import { coerceNodeId, INodeId, NodeId, NodeIdType } from "node-opcua-nodeid";
|
|
5
5
|
import { EnumDefinition, StructureDefinition } from "node-opcua-types";
|
|
6
6
|
import { lowerFirstLetter } from "node-opcua-utils";
|
|
7
|
-
import { DataType } from "node-opcua-variant";
|
|
8
|
-
import { ReaderState, ReaderStateParserLike, ParserLike, XmlAttributes } from "node-opcua-xml2json";
|
|
7
|
+
import { DataType, VariantOptions, Variant } from "node-opcua-variant";
|
|
8
|
+
import { ReaderState, ReaderStateParserLike, ParserLike, XmlAttributes, IReaderState, Xml2Json, ReaderStateParser } from "node-opcua-xml2json";
|
|
9
|
+
import { localizedText_parser } from "./parsers/localized_text_parser";
|
|
10
|
+
import { makeQualifiedNameParser } from "./parsers/qualified_name_parser";
|
|
11
|
+
import { makeVariantReader } from "./parsers/variant_parser";
|
|
9
12
|
|
|
10
13
|
const warningLog = make_warningLog(__filename);
|
|
11
14
|
const debugLog = make_debugLog(__filename);
|
|
12
15
|
|
|
13
|
-
export interface QualifiedNameOptions {
|
|
14
|
-
namespaceIndex?: UInt16;
|
|
15
|
-
name?: UAString;
|
|
16
|
-
}
|
|
17
|
-
interface QualifiedNameParserChild {
|
|
18
|
-
parent: {
|
|
19
|
-
qualifiedName: QualifiedNameOptions;
|
|
20
|
-
};
|
|
21
|
-
text: string;
|
|
22
|
-
}
|
|
23
|
-
interface QualifiedNameParser {
|
|
24
|
-
value: QualifiedNameOptions;
|
|
25
|
-
qualifiedName: QualifiedNameOptions;
|
|
26
|
-
text: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const qualifiedNameReader: ReaderStateParserLike = {
|
|
30
|
-
init(this: QualifiedNameParser) {
|
|
31
|
-
this.qualifiedName = {};
|
|
32
|
-
this.value = {};
|
|
33
|
-
},
|
|
34
|
-
parser: {
|
|
35
|
-
Name: {
|
|
36
|
-
finish(this: QualifiedNameParserChild) {
|
|
37
|
-
this.parent.qualifiedName.name = this.text.trim();
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
NamespaceIndex: {
|
|
41
|
-
finish(this: QualifiedNameParserChild) {
|
|
42
|
-
const ns = parseInt(this.text, 10);
|
|
43
|
-
this.parent.qualifiedName.namespaceIndex = ns;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
finish(this: QualifiedNameParser) {
|
|
48
|
-
this.value = this.qualifiedName;
|
|
49
|
-
this.value.name = "qdqsdqs";
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
interface LocalizedTextParser {
|
|
54
|
-
localizedText: LocalizedTextOptions;
|
|
55
|
-
value: LocalizedTextOptions;
|
|
56
|
-
}
|
|
57
|
-
interface LocalizedTextChildParser {
|
|
58
|
-
parent: LocalizedTextParser;
|
|
59
|
-
text: string;
|
|
60
|
-
}
|
|
61
|
-
const localizedTextReader: ReaderStateParserLike = {
|
|
62
|
-
init(this: LocalizedTextParser) {
|
|
63
|
-
this.localizedText = {};
|
|
64
|
-
},
|
|
65
|
-
parser: {
|
|
66
|
-
Locale: {
|
|
67
|
-
finish(this: LocalizedTextChildParser) {
|
|
68
|
-
this.parent.localizedText = this.parent.localizedText || {};
|
|
69
|
-
this.parent.localizedText.locale = this.text.trim();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
Text: {
|
|
73
|
-
finish(this: LocalizedTextChildParser) {
|
|
74
|
-
this.parent.localizedText = this.parent.localizedText || {};
|
|
75
|
-
this.parent.localizedText.text = this.text.trim();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
finish(this: LocalizedTextParser) {
|
|
80
|
-
this.value = this.localizedText;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
16
|
function clamp(value: number, minValue: number, maxValue: number) {
|
|
85
17
|
if (value < minValue) {
|
|
86
18
|
warningLog(`invalid value range : ${value} < ${minValue} but should be [${minValue} , ${maxValue}]`);
|
|
@@ -93,22 +25,22 @@ function clamp(value: number, minValue: number, maxValue: number) {
|
|
|
93
25
|
return value;
|
|
94
26
|
}
|
|
95
27
|
|
|
96
|
-
interface Parser<T> {
|
|
28
|
+
interface Parser<T> extends ReaderStateParserLike {
|
|
97
29
|
value: T | null;
|
|
98
30
|
parent: any;
|
|
99
31
|
text: string;
|
|
100
32
|
}
|
|
101
|
-
const partials
|
|
102
|
-
LocalizedText:
|
|
103
|
-
QualifiedName:
|
|
104
|
-
String: {
|
|
33
|
+
const partials = {
|
|
34
|
+
LocalizedText: localizedText_parser.LocalizedText,
|
|
35
|
+
QualifiedName: makeQualifiedNameParser((nodeId: string) => coerceNodeId(nodeId)).QualifiedName,
|
|
36
|
+
String: <Parser<string>>{
|
|
105
37
|
finish(this: Parser<string>) {
|
|
106
38
|
this.value = this.text;
|
|
107
39
|
}
|
|
108
40
|
},
|
|
109
41
|
Guid: {
|
|
110
42
|
parser: {
|
|
111
|
-
String: {
|
|
43
|
+
String: <Parser<string>>{
|
|
112
44
|
finish(this: Parser<string>) {
|
|
113
45
|
this.parent.value = this.text;
|
|
114
46
|
}
|
|
@@ -116,91 +48,91 @@ const partials: { [key: string]: ReaderStateParserLike } = {
|
|
|
116
48
|
}
|
|
117
49
|
},
|
|
118
50
|
|
|
119
|
-
Boolean: {
|
|
51
|
+
Boolean: <Parser<boolean>>{
|
|
120
52
|
finish(this: Parser<boolean>) {
|
|
121
53
|
this.value = this.text.toLowerCase() === "true" ? true : false;
|
|
122
54
|
}
|
|
123
55
|
},
|
|
124
56
|
|
|
125
|
-
ByteString: {
|
|
126
|
-
init(this: Parser<Buffer
|
|
57
|
+
ByteString: <Parser<Buffer>>{
|
|
58
|
+
init(this: Parser<Buffer>, name: string, attrs: XmlAttributes, parent: IReaderState, engine: Xml2Json) {
|
|
127
59
|
this.value = null;
|
|
128
60
|
},
|
|
129
|
-
finish(this:
|
|
61
|
+
finish(this: Parser<Buffer>) {
|
|
130
62
|
const base64text = this.text;
|
|
131
63
|
const byteString = Buffer.from(base64text, "base64");
|
|
132
64
|
this.value = byteString;
|
|
133
65
|
}
|
|
134
66
|
},
|
|
135
67
|
|
|
136
|
-
Float: {
|
|
68
|
+
Float: <Parser<number>> {
|
|
137
69
|
finish(this: Parser<number>) {
|
|
138
70
|
this.value = parseFloat(this.text);
|
|
139
71
|
}
|
|
140
72
|
},
|
|
141
73
|
|
|
142
|
-
Double: {
|
|
74
|
+
Double: <Parser<number>> {
|
|
143
75
|
finish(this: Parser<number>) {
|
|
144
76
|
this.value = parseFloat(this.text);
|
|
145
77
|
}
|
|
146
78
|
},
|
|
147
|
-
Byte: {
|
|
79
|
+
Byte: <Parser<Byte>> {
|
|
148
80
|
finish(this: Parser<Byte>) {
|
|
149
81
|
this.value = clamp(parseInt(this.text, 10), 0, 255);
|
|
150
82
|
}
|
|
151
83
|
},
|
|
152
|
-
SByte: {
|
|
84
|
+
SByte: <Parser<SByte>> {
|
|
153
85
|
finish(this: Parser<SByte>) {
|
|
154
86
|
this.value = clamp(parseInt(this.text, 10), -128, 127);
|
|
155
87
|
}
|
|
156
88
|
},
|
|
157
|
-
Int8: {
|
|
89
|
+
Int8: <Parser<SByte>> {
|
|
158
90
|
finish(this: Parser<SByte>) {
|
|
159
91
|
this.value = clamp(parseInt(this.text, 10), -128, 127);
|
|
160
92
|
}
|
|
161
93
|
},
|
|
162
94
|
|
|
163
|
-
Int16: {
|
|
95
|
+
Int16: <Parser<Int16>> {
|
|
164
96
|
finish(this: Parser<Int16>) {
|
|
165
97
|
this.value = clamp(parseInt(this.text, 10), -32768, 32767);
|
|
166
98
|
}
|
|
167
99
|
},
|
|
168
|
-
Int32: {
|
|
100
|
+
Int32: <Parser<Int32>> {
|
|
169
101
|
finish(this: Parser<Int32>) {
|
|
170
102
|
this.value = clamp(parseInt(this.text, 10), -2147483648, 2147483647);
|
|
171
103
|
}
|
|
172
104
|
},
|
|
173
|
-
Int64: {
|
|
105
|
+
Int64: <Parser<Int64>> {
|
|
174
106
|
finish(this: Parser<Int64>) {
|
|
175
107
|
this.value = coerceInt64(parseInt(this.text, 10));
|
|
176
108
|
}
|
|
177
109
|
},
|
|
178
110
|
|
|
179
|
-
UInt8: {
|
|
111
|
+
UInt8: <Parser<Byte>> {
|
|
180
112
|
finish(this: Parser<Byte>) {
|
|
181
113
|
this.value = clamp(parseInt(this.text, 10), 0, 255);
|
|
182
114
|
}
|
|
183
115
|
},
|
|
184
116
|
|
|
185
|
-
UInt16: {
|
|
117
|
+
UInt16: <Parser<UInt16>> {
|
|
186
118
|
finish(this: Parser<UInt16>) {
|
|
187
119
|
this.value = clamp(parseInt(this.text, 10), 0, 65535);
|
|
188
120
|
}
|
|
189
121
|
},
|
|
190
122
|
|
|
191
|
-
UInt32: {
|
|
123
|
+
UInt32: <Parser<UInt32>>{
|
|
192
124
|
finish(this: Parser<UInt32>) {
|
|
193
125
|
this.value = clamp(parseInt(this.text, 10), 0, 4294967295);
|
|
194
126
|
}
|
|
195
127
|
},
|
|
196
128
|
|
|
197
|
-
UInt64: {
|
|
129
|
+
UInt64: <Parser<UInt64>>{
|
|
198
130
|
finish(this: Parser<UInt64>) {
|
|
199
131
|
this.value = coerceUInt64(parseInt(this.text, 10));
|
|
200
132
|
}
|
|
201
133
|
},
|
|
202
134
|
|
|
203
|
-
DateTime: {
|
|
135
|
+
DateTime: <Parser<Date>>{
|
|
204
136
|
finish(this: Parser<Date>) {
|
|
205
137
|
// to do check Local or GMT
|
|
206
138
|
this.value = new Date(this.text);
|
|
@@ -214,7 +146,7 @@ const partials: { [key: string]: ReaderStateParserLike } = {
|
|
|
214
146
|
}
|
|
215
147
|
},
|
|
216
148
|
|
|
217
|
-
NodeId: {
|
|
149
|
+
NodeId: <Parser<NodeId>> {
|
|
218
150
|
finish(this: Parser<NodeId>) {
|
|
219
151
|
// to do check Local or GMT
|
|
220
152
|
this.value = coerceNodeId(this.text);
|
|
@@ -259,43 +191,48 @@ function _clone(a: any): any {
|
|
|
259
191
|
function _makeTypeReader(
|
|
260
192
|
dataTypeNodeId1: NodeId,
|
|
261
193
|
definitionMap: DefinitionMap2,
|
|
262
|
-
readerMap:
|
|
263
|
-
|
|
194
|
+
readerMap: Map<string, ReaderStateParserLike>,
|
|
195
|
+
translateNodeId: (nodeId: string) => NodeId
|
|
196
|
+
): { name: string; reader: ReaderStateParser } {
|
|
264
197
|
const n = dataTypeNodeId1 as INodeId;
|
|
265
198
|
if (n.identifierType === NodeIdType.NUMERIC && n.namespace === 0 && n.value === 0) {
|
|
266
199
|
// a generic Extension Object
|
|
267
|
-
return { name: "Variant",
|
|
200
|
+
return { name: "Variant", reader: partials["Variant"] };
|
|
268
201
|
}
|
|
202
|
+
|
|
269
203
|
if (
|
|
270
204
|
n.namespace === 0 &&
|
|
271
205
|
n.identifierType === NodeIdType.NUMERIC &&
|
|
272
206
|
n.value < DataType.ExtensionObject
|
|
273
207
|
) {
|
|
274
208
|
const name = DataType[n.value as number] as string;
|
|
275
|
-
const
|
|
276
|
-
return { name,
|
|
209
|
+
const reader = partials[name as keyof typeof partials] as ReaderStateParser;
|
|
210
|
+
return { name, reader };
|
|
277
211
|
}
|
|
278
212
|
|
|
279
213
|
const { name, definition } = definitionMap.findDefinition(n);
|
|
214
|
+
|
|
280
215
|
const dataTypeName = name;
|
|
281
216
|
|
|
282
|
-
let reader: ReaderStateParserLike = readerMap
|
|
217
|
+
let reader: ReaderStateParserLike = readerMap.get(dataTypeName)!;
|
|
283
218
|
|
|
284
219
|
if (reader) {
|
|
285
|
-
return { name,
|
|
220
|
+
return { name, reader: reader.parser! };
|
|
286
221
|
}
|
|
287
222
|
|
|
288
223
|
reader = {
|
|
289
224
|
finish(this: any) {
|
|
290
225
|
/** empty */
|
|
291
226
|
},
|
|
292
|
-
parser: {
|
|
227
|
+
parser: {
|
|
228
|
+
/** empty */
|
|
229
|
+
}
|
|
293
230
|
};
|
|
294
231
|
|
|
295
232
|
if (definition instanceof StructureDefinition) {
|
|
296
233
|
for (const field of definition.fields || []) {
|
|
297
|
-
const typeReader = _makeTypeReader(field.dataType, definitionMap, readerMap);
|
|
298
|
-
const fieldParser = typeReader.
|
|
234
|
+
const typeReader = _makeTypeReader(field.dataType, definitionMap, readerMap, translateNodeId);
|
|
235
|
+
const fieldParser = typeReader.reader;
|
|
299
236
|
const fieldTypename = typeReader.name;
|
|
300
237
|
// istanbul ignore next
|
|
301
238
|
if (!fieldParser) {
|
|
@@ -319,7 +256,7 @@ function _makeTypeReader(
|
|
|
319
256
|
} else {
|
|
320
257
|
debugLog("xxx check " + fieldTypename);
|
|
321
258
|
}
|
|
322
|
-
this.parent.value = this.parent.value ||
|
|
259
|
+
this.parent.value = this.parent.value || Object.create(null);
|
|
323
260
|
this.parent.value[elName] = _clone(this.value);
|
|
324
261
|
}
|
|
325
262
|
};
|
|
@@ -328,10 +265,10 @@ function _makeTypeReader(
|
|
|
328
265
|
init(this: any) {
|
|
329
266
|
this.value = [];
|
|
330
267
|
},
|
|
331
|
-
parser: {},
|
|
268
|
+
parser: { /** empty */},
|
|
332
269
|
finish(this: any) {
|
|
333
270
|
const elName = lowerFirstLetter(this.name);
|
|
334
|
-
this.parent.value = this.parent.value ||
|
|
271
|
+
this.parent.value = this.parent.value || Object.create(null);
|
|
335
272
|
this.parent.value[elName] = this.value;
|
|
336
273
|
this.value = undefined;
|
|
337
274
|
},
|
|
@@ -348,10 +285,8 @@ function _makeTypeReader(
|
|
|
348
285
|
throw new Error("Unsupported ValueRank !");
|
|
349
286
|
}
|
|
350
287
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
readerMap[dataTypeName] = reader;
|
|
354
|
-
return { name, parser: reader };
|
|
288
|
+
readerMap.set(dataTypeName,reader);
|
|
289
|
+
return { name, reader };
|
|
355
290
|
} else if (definition instanceof EnumDefinition) {
|
|
356
291
|
const turnToInt = (value: any) => {
|
|
357
292
|
// Green_100
|
|
@@ -359,28 +294,57 @@ function _makeTypeReader(
|
|
|
359
294
|
};
|
|
360
295
|
return {
|
|
361
296
|
name,
|
|
362
|
-
|
|
297
|
+
reader: {
|
|
363
298
|
finish(this: any) {
|
|
364
299
|
this.value = turnToInt(this.text);
|
|
365
300
|
}
|
|
366
301
|
}
|
|
367
302
|
};
|
|
303
|
+
} else if (definition?.dataType == DataType.Variant) {
|
|
304
|
+
// <Value><String>Foo</String></Value>
|
|
305
|
+
type Task = (addressSpace: any) => Promise<void>;
|
|
306
|
+
|
|
307
|
+
let variantOptions: VariantOptions = Object.create(null);
|
|
308
|
+
|
|
309
|
+
const variantReader = makeVariantReader(
|
|
310
|
+
(self, data: VariantOptions) => variantOptions = data,
|
|
311
|
+
/*setDeferredValue: */(self,data, deferedTask) => {
|
|
312
|
+
// to do
|
|
313
|
+
},
|
|
314
|
+
/* postExtensionObjectDecoding:*/(task: (addressSpace: IAddressSpace) => Promise<void>) => {
|
|
315
|
+
// to do
|
|
316
|
+
},
|
|
317
|
+
translateNodeId,
|
|
318
|
+
);
|
|
319
|
+
return {
|
|
320
|
+
name,
|
|
321
|
+
reader: {
|
|
322
|
+
init(this: any , name: string, attrs: XmlAttributes, parent: IReaderState, engine: Xml2Json) {
|
|
323
|
+
this.obj = {};
|
|
324
|
+
},
|
|
325
|
+
...variantReader,
|
|
326
|
+
finish(this: any & { value: Variant }) {
|
|
327
|
+
this.value = new Variant(variantOptions);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
368
331
|
} else {
|
|
369
332
|
// basic datatype
|
|
370
333
|
const typeName: string = DataType[definition.dataType];
|
|
371
|
-
const
|
|
334
|
+
const reader = partials[typeName as keyof typeof partials] as ReaderStateParser;
|
|
372
335
|
// istanbul ignore next
|
|
373
|
-
if (!
|
|
336
|
+
if (!reader) {
|
|
374
337
|
throw new Error("missing parse for " + typeName);
|
|
375
338
|
}
|
|
376
|
-
return { name,
|
|
339
|
+
return { name, reader };
|
|
377
340
|
}
|
|
378
341
|
}
|
|
379
342
|
|
|
380
343
|
export function makeXmlExtensionObjectReader(
|
|
381
344
|
dataTypeNodeId: NodeId,
|
|
382
345
|
definitionMap: DefinitionMap2,
|
|
383
|
-
readerMap:
|
|
346
|
+
readerMap: Map<string, ReaderStateParserLike>,
|
|
347
|
+
translateNodeId: (nodeId: string) => NodeId
|
|
384
348
|
): ReaderState {
|
|
385
349
|
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
386
350
|
|
|
@@ -389,14 +353,14 @@ export function makeXmlExtensionObjectReader(
|
|
|
389
353
|
throw new Error("Expecting StructureDefinition");
|
|
390
354
|
}
|
|
391
355
|
//
|
|
392
|
-
const reader1:
|
|
356
|
+
const reader1: ReaderStateParser = {
|
|
393
357
|
parser: {},
|
|
394
358
|
endElement(this: any) {
|
|
395
359
|
this._pojo = this.parser[name].value;
|
|
396
360
|
}
|
|
397
361
|
};
|
|
398
|
-
const {
|
|
399
|
-
reader1.parser![name] =
|
|
362
|
+
const { reader } = _makeTypeReader(dataTypeNodeId, definitionMap, readerMap, translateNodeId);
|
|
363
|
+
reader1.parser![name] = reader as ReaderStateParserLike;
|
|
400
364
|
|
|
401
365
|
return new ReaderState(reader1);
|
|
402
366
|
}
|
|
@@ -9,12 +9,13 @@ const doDebug = checkDebugFlag(__filename);
|
|
|
9
9
|
|
|
10
10
|
export type Promoter = ((node: UAVariable) => UAVariable) | ((node: UAObject) => UAObject);
|
|
11
11
|
|
|
12
|
-
export const g_promotableObject:
|
|
13
|
-
|
|
12
|
+
export const g_promotableObject: Map<
|
|
13
|
+
string,
|
|
14
|
+
{
|
|
14
15
|
promoter: Promoter;
|
|
15
16
|
onInstanceOnly: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
> = new Map();
|
|
18
19
|
|
|
19
20
|
function parentIsObjectOrVariableType(node: UAVariable | UAObject): boolean {
|
|
20
21
|
if (node.parent && (node.parent.nodeClass === NodeClass.VariableType || node.parent?.nodeClass === NodeClass.ObjectType)) {
|
|
@@ -34,7 +35,7 @@ export async function promoteObjectAndVariablesInNamespace(namespace: INamespace
|
|
|
34
35
|
const aa = a as UAObject | UAVariable;
|
|
35
36
|
|
|
36
37
|
if (aa.typeDefinition) {
|
|
37
|
-
const promoter = g_promotableObject
|
|
38
|
+
const promoter = g_promotableObject.get(aa.typeDefinition.toString());
|
|
38
39
|
if (promoter) {
|
|
39
40
|
if (promoter.onInstanceOnly && parentIsObjectOrVariableType(aa)) {
|
|
40
41
|
continue;
|