node-opcua-address-space 2.56.2 → 2.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/dist/source/address_space_ts.d.ts +0 -2
- package/dist/source/helpers/argument_list.js +12 -1
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +76 -67
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/session_context.js +2 -2
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.js +1 -1
- package/dist/src/address_space.d.ts +2 -3
- package/dist/src/address_space.js +9 -6
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +2 -3
- package/dist/src/alarms_and_conditions/condition_snapshot.js +3 -3
- package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +2 -1
- 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 +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +8 -6
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_private.js +2 -2
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/event_data.js +1 -1
- package/dist/src/event_data.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +2 -2
- package/dist/src/namespace_impl.js +9 -9
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +16 -10
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/nodeset_tools/typedictionary_to_xml.js +17 -10
- package/dist/src/nodeset_tools/typedictionary_to_xml.js.map +1 -1
- package/dist/src/reference_impl.js +1 -1
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +20 -13
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/ua_data_type_impl.d.ts +15 -5
- package/dist/src/ua_data_type_impl.js +129 -51
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.d.ts +3 -2
- package/dist/src/ua_method_impl.js +5 -0
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +6 -6
- package/dist/src/ua_variable_impl.js +236 -188
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +3 -4
- package/dist/src/ua_variable_type_impl.js +13 -18
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/mock_session.js +1 -1
- package/distHelpers/mock_session.js.map +1 -1
- package/generate.js +1 -1
- package/nodeJS.d.ts +1 -1
- package/package.json +36 -36
- package/source/address_space_ts.ts +0 -1
- package/source/helpers/argument_list.ts +13 -3
- package/source/loader/load_nodeset2.ts +99 -79
- package/source/session_context.ts +1 -1
- package/source/set_namespace_meta_data.ts +1 -1
- package/source_nodejs/index.ts +1 -1
- package/src/address_space.ts +21 -14
- package/src/address_space_private.ts +3 -3
- package/src/alarms_and_conditions/condition_snapshot.ts +4 -4
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +7 -6
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +2 -2
- package/src/alarms_and_conditions/ua_condition_impl.ts +29 -15
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +1 -1
- package/src/base_node_private.ts +6 -2
- package/src/event_data.ts +1 -1
- package/src/namespace_impl.ts +9 -9
- package/src/nodeset_tools/nodeset_to_xml.ts +22 -12
- package/src/nodeset_tools/typedictionary_to_xml.ts +17 -7
- package/src/reference_impl.ts +3 -3
- package/src/state_machine/ua_shelving_state_machine_ex.ts +32 -19
- package/src/ua_data_type_impl.ts +168 -61
- package/src/ua_method_impl.ts +11 -5
- package/src/ua_variable_impl.ts +290 -218
- package/src/ua_variable_type_impl.ts +9 -15
- package/testHelpers.d.ts +1 -1
- package/test_helpers/add_event_generator_object.ts +4 -3
- package/test_helpers/mock_session.ts +1 -1
- package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +150 -150
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +57 -57
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +135 -135
- package/test_helpers/test_fixtures/dataType_withEnumeration.xml +82 -82
- package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +194 -194
- package/test_helpers/test_fixtures/dataType_with_union.xml +1 -1
- package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +106 -106
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +1312 -1303
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +362 -362
- package/test_helpers/test_fixtures/issue_846.xml +3172 -3172
- package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +32 -32
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +14 -0
- package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +194 -194
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +8 -8
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +16 -16
- package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +45 -45
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.d.ts +0 -23
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +0 -3
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +0 -6
- package/dist/source/interfaces/data_access/ua_discrete_item.js +0 -3
- package/dist/source/interfaces/data_access/ua_discrete_item.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +0 -25
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +0 -27
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +0 -17
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +0 -19
- package/dist/source/interfaces/data_access/ua_y_array_item.js +0 -3
- package/dist/source/interfaces/data_access/ua_y_array_item.js.map +0 -1
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +0 -11
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +0 -70
- package/dist/source/interfaces/state_machine/finite_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/finite_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +0 -74
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/state_machine.d.ts +0 -342
- package/dist/source/interfaces/state_machine/state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +0 -18
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +0 -29
- package/dist/source/interfaces/state_machine/ua_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_state_variable.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +0 -26
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +0 -1
- package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +0 -41
- package/dist/source/interfaces/subscription_diagnostics_variable.js +0 -3
- package/dist/source/interfaces/subscription_diagnostics_variable.js.map +0 -1
- package/dist/src/alarms_and_conditions/base_event_type.d.ts +0 -26
- package/dist/src/alarms_and_conditions/base_event_type.js +0 -41
- package/dist/src/alarms_and_conditions/base_event_type.js.map +0 -1
- package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +0 -22
- package/dist/src/alarms_and_conditions/shelving_state_machine.js +0 -241
- package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +0 -1
- package/dist/src/alarms_and_conditions/trip_alarm.d.ts +0 -16
- package/dist/src/alarms_and_conditions/trip_alarm.js +0 -21
- package/dist/src/alarms_and_conditions/trip_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +0 -54
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +0 -255
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +0 -138
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +0 -460
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +0 -35
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +0 -32
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +0 -191
- package/dist/src/alarms_and_conditions/ua_condition_base.js +0 -1029
- package/dist/src/alarms_and_conditions/ua_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +0 -11
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +0 -58
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +0 -24
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +0 -59
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +0 -14
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +0 -17
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +0 -22
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +0 -87
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +0 -6
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +0 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +0 -76
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js +0 -237
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +0 -27
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +0 -62
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +0 -49
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +0 -176
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +0 -47
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +0 -151
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +0 -16
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +0 -18
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +0 -1
- package/dist/src/base_node.d.ts +0 -289
- package/dist/src/base_node.js +0 -1345
- package/dist/src/base_node.js.map +0 -1
- package/dist/src/data_access/ua_analog_item.d.ts +0 -13
- package/dist/src/data_access/ua_analog_item.js +0 -37
- package/dist/src/data_access/ua_analog_item.js.map +0 -1
- package/dist/src/data_access/ua_data_item.d.ts +0 -16
- package/dist/src/data_access/ua_data_item.js +0 -66
- package/dist/src/data_access/ua_data_item.js.map +0 -1
- package/dist/src/data_access/ua_multistate_discrete.d.ts +0 -24
- package/dist/src/data_access/ua_multistate_discrete.js +0 -132
- package/dist/src/data_access/ua_multistate_discrete.js.map +0 -1
- package/dist/src/namespace.d.ts +0 -472
- package/dist/src/namespace.js +0 -1751
- package/dist/src/namespace.js.map +0 -1
- package/dist/src/reference.d.ts +0 -43
- package/dist/src/reference.js +0 -138
- package/dist/src/reference.js.map +0 -1
- package/dist/src/session_context.d.ts +0 -4
- package/dist/src/session_context.js +0 -9
- package/dist/src/session_context.js.map +0 -1
- package/dist/src/ua_data_type.d.ts +0 -83
- package/dist/src/ua_data_type.js +0 -289
- package/dist/src/ua_data_type.js.map +0 -1
- package/dist/src/ua_method.d.ts +0 -41
- package/dist/src/ua_method.js +0 -202
- package/dist/src/ua_method.js.map +0 -1
- package/dist/src/ua_object.d.ts +0 -28
- package/dist/src/ua_object.js +0 -153
- package/dist/src/ua_object.js.map +0 -1
- package/dist/src/ua_object_type.d.ts +0 -49
- package/dist/src/ua_object_type.js +0 -123
- package/dist/src/ua_object_type.js.map +0 -1
- package/dist/src/ua_reference_type.d.ts +0 -42
- package/dist/src/ua_reference_type.js +0 -138
- package/dist/src/ua_reference_type.js.map +0 -1
- package/dist/src/ua_variable.d.ts +0 -339
- package/dist/src/ua_variable.js +0 -1706
- package/dist/src/ua_variable.js.map +0 -1
- package/dist/src/ua_variable_type.d.ts +0 -57
- package/dist/src/ua_variable_type.js +0 -530
- package/dist/src/ua_variable_type.js.map +0 -1
- package/dist/src/ua_view.d.ts +0 -16
- package/dist/src/ua_view.js +0 -42
- package/dist/src/ua_view.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UAVariableImplT = exports.UAVariableImpl = exports.
|
|
3
|
+
exports.UAVariableImplT = exports.UAVariableImpl = exports.adjust_userAccessLevel = exports.adjust_accessLevel = void 0;
|
|
4
4
|
/* eslint-disable max-statements */
|
|
5
5
|
/* eslint-disable complexity */
|
|
6
6
|
/**
|
|
@@ -104,13 +104,13 @@ function validateDataType(addressSpace, dataTypeNodeId, variantDataType, nodeId,
|
|
|
104
104
|
}
|
|
105
105
|
let builtInType;
|
|
106
106
|
let builtInUADataType;
|
|
107
|
-
const destUADataType = addressSpace.
|
|
107
|
+
const destUADataType = addressSpace.findDataType(dataTypeNodeId);
|
|
108
108
|
(0, node_opcua_assert_1.assert)(destUADataType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
109
109
|
if (destUADataType.isAbstract || destUADataType.nodeId.namespace !== 0) {
|
|
110
110
|
builtInUADataType = destUADataType;
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
builtInType =
|
|
113
|
+
builtInType = addressSpace.findCorrespondingBasicDataType(destUADataType);
|
|
114
114
|
builtInUADataType = addressSpace.findDataType(builtInType);
|
|
115
115
|
}
|
|
116
116
|
(0, node_opcua_assert_1.assert)(builtInUADataType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
@@ -121,8 +121,8 @@ function validateDataType(addressSpace, dataTypeNodeId, variantDataType, nodeId,
|
|
|
121
121
|
if (destUADataType.isSupertypeOf(enumerationUADataType)) {
|
|
122
122
|
// istanbul ignore next
|
|
123
123
|
if (doDebug) {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
debugLog("destUADataType.", destUADataType.browseName.toString(), destUADataType.nodeId.toString());
|
|
125
|
+
debugLog("enumerationUADataType.", enumerationUADataType.browseName.toString(), enumerationUADataType.nodeId.toString());
|
|
126
126
|
}
|
|
127
127
|
return true;
|
|
128
128
|
}
|
|
@@ -134,45 +134,18 @@ function validateDataType(addressSpace, dataTypeNodeId, variantDataType, nodeId,
|
|
|
134
134
|
if (doDebug) {
|
|
135
135
|
if (dest_isSuperTypeOf_variant) {
|
|
136
136
|
/* istanbul ignore next*/
|
|
137
|
-
|
|
137
|
+
debugLog(chalk.green(" ---------- Type match !!! "), " on ", nodeId.toString());
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
140
|
/* istanbul ignore next*/
|
|
141
|
-
|
|
141
|
+
debugLog(chalk.red(" ---------- Type mismatch "), " on ", nodeId.toString());
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
debugLog(chalk.cyan(" Variable data Type is = "), destUADataType.browseName.toString());
|
|
144
|
+
debugLog(chalk.cyan(" which matches basic Type = "), builtInUADataType.browseName.toString());
|
|
145
|
+
debugLog(chalk.yellow(" Actual dataType = "), variantUADataType.browseName.toString());
|
|
146
146
|
}
|
|
147
147
|
return dest_isSuperTypeOf_variant;
|
|
148
148
|
}
|
|
149
|
-
function verifyRankAndDimensions(options) {
|
|
150
|
-
// evaluate valueRank arrayDimensions is specified but valueRank is null
|
|
151
|
-
if (options.arrayDimensions && options.valueRank === undefined) {
|
|
152
|
-
options.valueRank = options.arrayDimensions.length;
|
|
153
|
-
}
|
|
154
|
-
options.valueRank = options.valueRank === undefined ? -1 : options.valueRank || 0; // UInt32
|
|
155
|
-
(0, node_opcua_assert_1.assert)(typeof options.valueRank === "number");
|
|
156
|
-
options.arrayDimensions = options.arrayDimensions || null;
|
|
157
|
-
(0, node_opcua_assert_1.assert)(options.arrayDimensions === null || Array.isArray(options.arrayDimensions));
|
|
158
|
-
if (options.arrayDimensions && options.valueRank <= 0) {
|
|
159
|
-
throw new Error("[CONFORMANCE] arrayDimensions must be null if valueRank <=0");
|
|
160
|
-
}
|
|
161
|
-
// specify default arrayDimension if not provided
|
|
162
|
-
if (options.valueRank > 0 && !options.arrayDimensions) {
|
|
163
|
-
options.arrayDimensions = new Array(options.valueRank).fill(0);
|
|
164
|
-
}
|
|
165
|
-
if (!options.arrayDimensions && options.valueRank > 0) {
|
|
166
|
-
throw new Error("[CONFORMANCE] arrayDimension must be specified if valueRank >0 " + options.valueRank);
|
|
167
|
-
}
|
|
168
|
-
if (options.valueRank > 0 && options.arrayDimensions.length !== options.valueRank) {
|
|
169
|
-
throw new Error("[CONFORMANCE] when valueRank> 0, arrayDimensions must have valueRank elements, this.valueRank =" +
|
|
170
|
-
options.valueRank +
|
|
171
|
-
" whereas arrayDimensions.length =" +
|
|
172
|
-
options.arrayDimensions.length);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.verifyRankAndDimensions = verifyRankAndDimensions;
|
|
176
149
|
/**
|
|
177
150
|
* A OPCUA Variable Node
|
|
178
151
|
*
|
|
@@ -203,16 +176,15 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
203
176
|
constructor(options) {
|
|
204
177
|
super(options);
|
|
205
178
|
this.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
206
|
-
verifyRankAndDimensions(options);
|
|
179
|
+
(0, node_opcua_variant_1.verifyRankAndDimensions)(options);
|
|
207
180
|
this.valueRank = options.valueRank;
|
|
208
181
|
this.arrayDimensions = options.arrayDimensions;
|
|
209
182
|
this.dataType = this.resolveNodeId(options.dataType); // DataType (NodeId)
|
|
210
183
|
this.accessLevel = adjust_accessLevel(options.accessLevel);
|
|
211
184
|
this.userAccessLevel = adjust_userAccessLevel(options.userAccessLevel, this.accessLevel);
|
|
212
185
|
this.minimumSamplingInterval = adjust_samplingInterval(options.minimumSamplingInterval || 0);
|
|
213
|
-
this.historizing = !!options.historizing; // coerced to boolean
|
|
214
|
-
this
|
|
215
|
-
// xx options.value = options.value || { dataType: DataType.Null };
|
|
186
|
+
this.historizing = !!options.historizing; // coerced to boolean"
|
|
187
|
+
this.$dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.UncertainInitialValue, value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
216
188
|
if (options.value) {
|
|
217
189
|
this.bindVariable(options.value);
|
|
218
190
|
}
|
|
@@ -301,10 +273,11 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
301
273
|
}
|
|
302
274
|
if (this._timestamped_get_func) {
|
|
303
275
|
if (this._timestamped_get_func.length === 0) {
|
|
304
|
-
this
|
|
276
|
+
this.$dataValue = this._timestamped_get_func();
|
|
277
|
+
this.verifyVariantCompatibility(this.$dataValue.value);
|
|
305
278
|
}
|
|
306
279
|
}
|
|
307
|
-
let dataValue = this
|
|
280
|
+
let dataValue = this.$dataValue;
|
|
308
281
|
if (isGoodish(dataValue.statusCode)) {
|
|
309
282
|
// note : extractRange will clone the dataValue
|
|
310
283
|
dataValue = (0, node_opcua_data_value_1.extractRange)(dataValue, indexRange);
|
|
@@ -342,6 +315,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
342
315
|
return dataTypeNode._getEnumerationInfo();
|
|
343
316
|
}
|
|
344
317
|
asyncRefresh(...args) {
|
|
318
|
+
this.verifyVariantCompatibility(this.$dataValue.value);
|
|
345
319
|
const oldestDate = args[0];
|
|
346
320
|
(0, node_opcua_assert_1.assert)(oldestDate instanceof Date);
|
|
347
321
|
const callback = args[1];
|
|
@@ -358,21 +332,31 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
358
332
|
return callback(null, dataValue);
|
|
359
333
|
}
|
|
360
334
|
}
|
|
361
|
-
if (this.
|
|
335
|
+
if (this.$dataValue.serverTimestamp && oldestDate.getTime() <= this.$dataValue.serverTimestamp.getTime()) {
|
|
362
336
|
const dataValue = this.readValue();
|
|
363
337
|
dataValue.serverTimestamp = oldestDate;
|
|
364
338
|
dataValue.serverPicoseconds = 0;
|
|
365
339
|
return callback(null, dataValue);
|
|
366
340
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
341
|
+
try {
|
|
342
|
+
this.refreshFunc.call(this, (err, dataValue) => {
|
|
343
|
+
if (err || !dataValue) {
|
|
344
|
+
errorLog("-------------- refresh call failed", this.browseName.toString(), this.nodeId.toString(), err === null || err === void 0 ? void 0 : err.message);
|
|
345
|
+
dataValue = { statusCode: node_opcua_status_code_1.StatusCodes.BadNoDataAvailable };
|
|
346
|
+
}
|
|
347
|
+
if (dataValue !== this.$dataValue) {
|
|
348
|
+
this._internal_set_dataValue(coerceDataValue(dataValue), null);
|
|
349
|
+
}
|
|
350
|
+
callback(err, this.$dataValue);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
catch (err) {
|
|
354
|
+
errorLog("-------------- refresh call failed 2", this.browseName.toString(), this.nodeId.toString());
|
|
355
|
+
errorLog(err);
|
|
356
|
+
const dataValue = new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadInternalError });
|
|
357
|
+
this._internal_set_dataValue(dataValue, null);
|
|
358
|
+
callback(err, this.$dataValue);
|
|
359
|
+
}
|
|
376
360
|
}
|
|
377
361
|
readEnumValue() {
|
|
378
362
|
const value = this.readValue().value.value;
|
|
@@ -441,10 +425,71 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
441
425
|
return base_node_impl_1.BaseNodeImpl.prototype.readAttribute.call(this, context, attributeId);
|
|
442
426
|
}
|
|
443
427
|
}
|
|
444
|
-
|
|
428
|
+
getBasicDataType() {
|
|
429
|
+
if (this._basicDataType) {
|
|
430
|
+
return this._basicDataType;
|
|
431
|
+
}
|
|
432
|
+
if (this.dataType.namespace === 0 && this.dataType.value === 0) {
|
|
433
|
+
return node_opcua_variant_1.DataType.Null;
|
|
434
|
+
}
|
|
445
435
|
const addressSpace = this.addressSpace;
|
|
446
|
-
const
|
|
447
|
-
|
|
436
|
+
const dataTypeNode = addressSpace.findDataType(this.dataType);
|
|
437
|
+
const basicDataType = dataTypeNode ? dataTypeNode.getBasicDataType() : node_opcua_variant_1.DataType.Null;
|
|
438
|
+
// const basicDataType = addressSpace.findCorrespondingBasicDataType(this.dataType);
|
|
439
|
+
this._basicDataType = basicDataType;
|
|
440
|
+
return basicDataType;
|
|
441
|
+
}
|
|
442
|
+
adjustVariant(variant) {
|
|
443
|
+
return (0, node_opcua_variant_1.adjustVariant)(variant, this.valueRank, this.getBasicDataType());
|
|
444
|
+
}
|
|
445
|
+
verifyVariantCompatibility(variant) {
|
|
446
|
+
var _a;
|
|
447
|
+
try {
|
|
448
|
+
// istanbul ignore next
|
|
449
|
+
if (Object.prototype.hasOwnProperty.call(variant, "value")) {
|
|
450
|
+
if (variant.dataType === null || variant.dataType === undefined) {
|
|
451
|
+
throw new Error("Variant must provide a valid dataType" + variant.toString());
|
|
452
|
+
}
|
|
453
|
+
if (variant.dataType === node_opcua_variant_1.DataType.Boolean &&
|
|
454
|
+
(this.dataType.namespace !== 0 || this.dataType.value !== node_opcua_variant_1.DataType.Boolean)) {
|
|
455
|
+
throw new Error("Variant must provide a valid Boolean" + variant.toString());
|
|
456
|
+
}
|
|
457
|
+
if (this.dataType.namespace === 0 &&
|
|
458
|
+
this.dataType.value === node_opcua_variant_1.DataType.LocalizedText &&
|
|
459
|
+
variant.dataType !== node_opcua_variant_1.DataType.LocalizedText) {
|
|
460
|
+
throw new Error("Variant must provide a valid LocalizedText" + variant.toString());
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const basicType = this.getBasicDataType();
|
|
464
|
+
if (basicType !== node_opcua_variant_1.DataType.Null &&
|
|
465
|
+
basicType !== node_opcua_variant_1.DataType.Variant &&
|
|
466
|
+
variant.dataType !== node_opcua_variant_1.DataType.Null &&
|
|
467
|
+
variant.dataType !== basicType) {
|
|
468
|
+
const message = "UAVariable.setValueFromSource " +
|
|
469
|
+
this.browseName.toString() +
|
|
470
|
+
" nodeId:" +
|
|
471
|
+
this.nodeId.toString() +
|
|
472
|
+
" dataType:" +
|
|
473
|
+
this.dataType.toString() +
|
|
474
|
+
":\n" +
|
|
475
|
+
"the provided variant must have the expected dataType!\n" +
|
|
476
|
+
" - the expected dataType is " +
|
|
477
|
+
chalk.cyan(node_opcua_variant_1.DataType[basicType]) +
|
|
478
|
+
"\n" +
|
|
479
|
+
" - the actual dataType is " +
|
|
480
|
+
chalk.magenta(node_opcua_variant_1.DataType[variant.dataType]) +
|
|
481
|
+
"\n" +
|
|
482
|
+
" - " +
|
|
483
|
+
variant.toString();
|
|
484
|
+
throw new Error(message);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
errorLog("UAVariable ", (_a = err) === null || _a === void 0 ? void 0 : _a.message, this.browseName.toString(), this.nodeId.toString());
|
|
489
|
+
errorLog(err.message);
|
|
490
|
+
errorLog(err.stack);
|
|
491
|
+
throw err;
|
|
492
|
+
}
|
|
448
493
|
}
|
|
449
494
|
/**
|
|
450
495
|
* setValueFromSource is used to let the device sets the variable values
|
|
@@ -458,32 +503,24 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
458
503
|
* @param [sourceTimestamp= Now]
|
|
459
504
|
*/
|
|
460
505
|
setValueFromSource(variant, statusCode, sourceTimestamp) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
506
|
+
try {
|
|
507
|
+
statusCode = statusCode || node_opcua_status_code_1.StatusCodes.Good;
|
|
508
|
+
const variant1 = node_opcua_variant_1.Variant.coerce(variant);
|
|
509
|
+
this.verifyVariantCompatibility(variant1);
|
|
510
|
+
const now = (0, node_opcua_date_time_1.coerceClock)(sourceTimestamp, 0);
|
|
511
|
+
const dataValue = new node_opcua_data_value_1.DataValue(null);
|
|
512
|
+
dataValue.serverPicoseconds = now.picoseconds;
|
|
513
|
+
dataValue.serverTimestamp = now.timestamp;
|
|
514
|
+
dataValue.sourcePicoseconds = now.picoseconds;
|
|
515
|
+
dataValue.sourceTimestamp = now.timestamp;
|
|
516
|
+
dataValue.statusCode = statusCode;
|
|
517
|
+
dataValue.value = variant1;
|
|
518
|
+
this._internal_set_dataValue(dataValue);
|
|
519
|
+
}
|
|
520
|
+
catch (err) {
|
|
521
|
+
errorLog("UAVariable#setValueFromString Error : ", this.browseName.toString(), this.nodeId.toString());
|
|
522
|
+
throw err;
|
|
476
523
|
}
|
|
477
|
-
const variant1 = node_opcua_variant_1.Variant.coerce(variant);
|
|
478
|
-
const now = (0, node_opcua_date_time_1.coerceClock)(sourceTimestamp, 0);
|
|
479
|
-
const dataValue = new node_opcua_data_value_1.DataValue(null);
|
|
480
|
-
dataValue.serverPicoseconds = now.picoseconds;
|
|
481
|
-
dataValue.serverTimestamp = now.timestamp;
|
|
482
|
-
dataValue.sourcePicoseconds = now.picoseconds;
|
|
483
|
-
dataValue.sourceTimestamp = now.timestamp;
|
|
484
|
-
dataValue.statusCode = statusCode;
|
|
485
|
-
dataValue.value = variant1;
|
|
486
|
-
this._internal_set_dataValue(dataValue);
|
|
487
524
|
}
|
|
488
525
|
writeValue(context, dataValue, ...args) {
|
|
489
526
|
context = context || session_context_1.SessionContext.defaultContext;
|
|
@@ -551,6 +588,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
551
588
|
if (!err) {
|
|
552
589
|
correctedDataValue = correctedDataValue || dataValue;
|
|
553
590
|
(0, node_opcua_assert_1.assert)(correctedDataValue instanceof node_opcua_data_value_1.DataValue);
|
|
591
|
+
correctedDataValue && this.verifyVariantCompatibility(correctedDataValue.value);
|
|
554
592
|
// xx assert(correctedDataValue.serverTimestamp);
|
|
555
593
|
if (indexRange && !indexRange.isEmpty()) {
|
|
556
594
|
if (!indexRange.isValid()) {
|
|
@@ -558,27 +596,27 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
558
596
|
}
|
|
559
597
|
const newArrayOrMatrix = correctedDataValue.value.value;
|
|
560
598
|
if (correctedDataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
561
|
-
if (this.
|
|
599
|
+
if (this.$dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Array) {
|
|
562
600
|
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
563
601
|
}
|
|
564
602
|
// check that destination data is also an array
|
|
565
|
-
(0, node_opcua_assert_1.assert)(check_valid_array(this.
|
|
566
|
-
const destArr = this.
|
|
603
|
+
(0, node_opcua_assert_1.assert)(check_valid_array(this.$dataValue.value.dataType, this.$dataValue.value.value));
|
|
604
|
+
const destArr = this.$dataValue.value.value;
|
|
567
605
|
const result = indexRange.set_values(destArr, newArrayOrMatrix);
|
|
568
606
|
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
569
607
|
return callback(null, result.statusCode);
|
|
570
608
|
}
|
|
571
609
|
correctedDataValue.value.value = result.array;
|
|
572
610
|
// scrap original array so we detect range
|
|
573
|
-
this.
|
|
611
|
+
this.$dataValue.value.value = null;
|
|
574
612
|
}
|
|
575
613
|
else if (correctedDataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
576
|
-
const dimensions = this.
|
|
577
|
-
if (this.
|
|
614
|
+
const dimensions = this.$dataValue.value.dimensions;
|
|
615
|
+
if (this.$dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Matrix || !dimensions) {
|
|
578
616
|
// not a matrix !
|
|
579
617
|
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
580
618
|
}
|
|
581
|
-
const matrix = this.
|
|
619
|
+
const matrix = this.$dataValue.value.value;
|
|
582
620
|
const result = indexRange.set_values_matrix({
|
|
583
621
|
matrix,
|
|
584
622
|
dimensions
|
|
@@ -586,10 +624,10 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
586
624
|
if (result.statusCode.isNot(node_opcua_status_code_1.StatusCodes.Good)) {
|
|
587
625
|
return callback(null, result.statusCode);
|
|
588
626
|
}
|
|
589
|
-
correctedDataValue.value.dimensions = this.
|
|
627
|
+
correctedDataValue.value.dimensions = this.$dataValue.value.dimensions;
|
|
590
628
|
correctedDataValue.value.value = result.matrix;
|
|
591
629
|
// scrap original array so we detect range
|
|
592
|
-
this.
|
|
630
|
+
this.$dataValue.value.value = null;
|
|
593
631
|
}
|
|
594
632
|
else {
|
|
595
633
|
return callback(null, node_opcua_status_code_1.StatusCodes.BadTypeMismatch);
|
|
@@ -656,6 +694,12 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
656
694
|
if (!this._validate_DataType(value.dataType)) {
|
|
657
695
|
return node_opcua_status_code_1.StatusCodes.BadTypeMismatch;
|
|
658
696
|
}
|
|
697
|
+
try {
|
|
698
|
+
this.verifyVariantCompatibility(value);
|
|
699
|
+
}
|
|
700
|
+
catch (err) {
|
|
701
|
+
return node_opcua_status_code_1.StatusCodes.BadTypeMismatch;
|
|
702
|
+
}
|
|
659
703
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
660
704
|
}
|
|
661
705
|
/**
|
|
@@ -669,11 +713,11 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
669
713
|
*/
|
|
670
714
|
touchValue(optionalNow) {
|
|
671
715
|
const now = optionalNow || (0, node_opcua_date_time_1.getCurrentClock)();
|
|
672
|
-
this.
|
|
673
|
-
this.
|
|
674
|
-
this.
|
|
675
|
-
this.
|
|
676
|
-
this.
|
|
716
|
+
this.$dataValue.sourceTimestamp = now.timestamp;
|
|
717
|
+
this.$dataValue.sourcePicoseconds = now.picoseconds;
|
|
718
|
+
this.$dataValue.serverTimestamp = now.timestamp;
|
|
719
|
+
this.$dataValue.serverPicoseconds = now.picoseconds;
|
|
720
|
+
this.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
677
721
|
if (this.minimumSamplingInterval === 0) {
|
|
678
722
|
if (this.listenerCount("value_changed") > 0) {
|
|
679
723
|
const clonedDataValue = this.readValue();
|
|
@@ -841,7 +885,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
841
885
|
return;
|
|
842
886
|
}
|
|
843
887
|
const readImmediate = (innerCallback) => {
|
|
844
|
-
(0, node_opcua_assert_1.assert)(this
|
|
888
|
+
(0, node_opcua_assert_1.assert)(this.$dataValue instanceof node_opcua_data_value_1.DataValue);
|
|
845
889
|
const dataValue = this.readValue();
|
|
846
890
|
innerCallback(null, dataValue);
|
|
847
891
|
};
|
|
@@ -899,7 +943,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
899
943
|
newVariable.bindVariable();
|
|
900
944
|
(0, node_opcua_assert_1.assert)(typeof newVariable._timestamped_set_func === "function");
|
|
901
945
|
(0, node_opcua_assert_1.assert)(newVariable.dataType === this.dataType);
|
|
902
|
-
newVariable
|
|
946
|
+
newVariable.$dataValue = this.$dataValue.clone();
|
|
903
947
|
return newVariable;
|
|
904
948
|
}
|
|
905
949
|
getDataTypeNode() {
|
|
@@ -919,8 +963,9 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
919
963
|
return true;
|
|
920
964
|
}
|
|
921
965
|
const addressSpace = this.addressSpace;
|
|
966
|
+
// istanbul ignore next
|
|
922
967
|
if (!(extObj && extObj.constructor)) {
|
|
923
|
-
|
|
968
|
+
errorLog(extObj);
|
|
924
969
|
throw new Error("expecting an valid extension object");
|
|
925
970
|
}
|
|
926
971
|
const dataType = addressSpace.findDataType(this.dataType);
|
|
@@ -948,7 +993,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
948
993
|
}
|
|
949
994
|
}
|
|
950
995
|
catch (err) {
|
|
951
|
-
|
|
996
|
+
errorLog(err);
|
|
952
997
|
return false;
|
|
953
998
|
}
|
|
954
999
|
}
|
|
@@ -957,7 +1002,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
957
1002
|
* @return {ExtensionObject}
|
|
958
1003
|
*/
|
|
959
1004
|
bindExtensionObject(optionalExtensionObject) {
|
|
960
|
-
var _a, _b
|
|
1005
|
+
var _a, _b;
|
|
961
1006
|
const addressSpace = this.addressSpace;
|
|
962
1007
|
const structure = addressSpace.findDataType("Structure");
|
|
963
1008
|
let extensionObject_;
|
|
@@ -968,7 +1013,7 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
968
1013
|
}
|
|
969
1014
|
// istanbul ignore next
|
|
970
1015
|
if (doDebug) {
|
|
971
|
-
|
|
1016
|
+
debugLog(" ------------------------------ binding ", this.browseName.toString(), this.nodeId.toString());
|
|
972
1017
|
}
|
|
973
1018
|
(0, node_opcua_assert_1.assert)(structure && structure.browseName.toString() === "Structure", "expecting DataType Structure to be in IAddressSpace");
|
|
974
1019
|
const dt = this.getDataTypeNode();
|
|
@@ -990,8 +1035,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
990
1035
|
// }
|
|
991
1036
|
// istanbul ignore next
|
|
992
1037
|
if (!this.checkExtensionObjectIsCorrect(this.$extensionObject)) {
|
|
993
|
-
|
|
994
|
-
|
|
1038
|
+
warningLog("on node : ", this.browseName.toString(), this.nodeId.toString(), "dataType=", this.dataType.toString({ addressSpace: this.addressSpace }));
|
|
1039
|
+
warningLog((_a = this.$extensionObject) === null || _a === void 0 ? void 0 : _a.toString());
|
|
995
1040
|
throw new Error("bindExtensionObject: $extensionObject is incorrect: we are expecting a " +
|
|
996
1041
|
this.dataType.toString({ addressSpace: this.addressSpace }) +
|
|
997
1042
|
" but we got a " +
|
|
@@ -1003,38 +1048,28 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1003
1048
|
this.$extensionObject = optionalExtensionObject;
|
|
1004
1049
|
// ------------------------------------------------------------------
|
|
1005
1050
|
function prepareVariantValue(dataType, value) {
|
|
1006
|
-
if (typeof dataType === "string") {
|
|
1007
|
-
dataType = node_opcua_variant_1.DataType[dataType];
|
|
1008
|
-
}
|
|
1009
1051
|
if ((dataType === node_opcua_variant_1.DataType.Int32 || dataType === node_opcua_variant_1.DataType.UInt32) && value && value.key) {
|
|
1010
1052
|
value = value.value;
|
|
1011
1053
|
}
|
|
1012
1054
|
return value;
|
|
1013
1055
|
}
|
|
1014
|
-
const bindProperty = (propertyNode, name, extensionObject,
|
|
1015
|
-
const dataTypeAsString = node_opcua_variant_1.DataType[dataTypeNodeId];
|
|
1016
|
-
/*
|
|
1017
|
-
property.setValueFromSource(new Variant({
|
|
1018
|
-
dataType: dataType,
|
|
1019
|
-
value: prepareVariantValue(dataType, this.$extensionObject[name])
|
|
1020
|
-
}));
|
|
1021
|
-
*/
|
|
1022
|
-
(0, node_opcua_assert_1.assert)(propertyNode.readValue().statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1056
|
+
const bindProperty = (propertyNode, name, extensionObject, dataType) => {
|
|
1023
1057
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1024
1058
|
const self = this;
|
|
1025
1059
|
propertyNode.bindVariable({
|
|
1026
1060
|
timestamped_get: () => {
|
|
1027
|
-
const
|
|
1028
|
-
if (
|
|
1029
|
-
propertyNode.
|
|
1030
|
-
propertyNode.
|
|
1031
|
-
propertyNode.
|
|
1032
|
-
return new node_opcua_data_value_1.DataValue(propertyNode
|
|
1061
|
+
const propertyValue = self.$extensionObject[name];
|
|
1062
|
+
if (propertyValue === undefined) {
|
|
1063
|
+
propertyNode.$dataValue.value.dataType = node_opcua_variant_1.DataType.Null;
|
|
1064
|
+
propertyNode.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1065
|
+
propertyNode.$dataValue.value.value = null;
|
|
1066
|
+
return new node_opcua_data_value_1.DataValue(propertyNode.$dataValue);
|
|
1033
1067
|
}
|
|
1034
|
-
const value = prepareVariantValue(
|
|
1035
|
-
propertyNode.
|
|
1036
|
-
propertyNode.
|
|
1037
|
-
|
|
1068
|
+
const value = prepareVariantValue(dataType, propertyValue);
|
|
1069
|
+
propertyNode.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1070
|
+
propertyNode.$dataValue.value.dataType = dataType;
|
|
1071
|
+
propertyNode.$dataValue.value.value = value;
|
|
1072
|
+
return new node_opcua_data_value_1.DataValue(propertyNode.$dataValue);
|
|
1038
1073
|
},
|
|
1039
1074
|
timestamped_set: (dataValue, callback) => {
|
|
1040
1075
|
dataValue;
|
|
@@ -1049,8 +1084,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1049
1084
|
const s = this.readValue();
|
|
1050
1085
|
// istanbul ignore next
|
|
1051
1086
|
if (this.dataTypeObj.isAbstract) {
|
|
1052
|
-
|
|
1053
|
-
|
|
1087
|
+
warningLog("Warning the DataType associated with this Variable is abstract ", this.dataTypeObj.browseName.toString());
|
|
1088
|
+
warningLog("You need to provide a extension object yourself ");
|
|
1054
1089
|
throw new Error("bindExtensionObject requires a extensionObject as associated dataType is only abstract");
|
|
1055
1090
|
}
|
|
1056
1091
|
if (s.value && (s.value.dataType === node_opcua_variant_1.DataType.Null || (s.value.dataType === node_opcua_variant_1.DataType.ExtensionObject && !s.value.value))) {
|
|
@@ -1067,8 +1102,8 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1067
1102
|
const self = this;
|
|
1068
1103
|
this.bindVariable({
|
|
1069
1104
|
timestamped_get() {
|
|
1070
|
-
self.
|
|
1071
|
-
const d = new node_opcua_data_value_1.DataValue(self
|
|
1105
|
+
self.$dataValue.value.value = self.$extensionObject;
|
|
1106
|
+
const d = new node_opcua_data_value_1.DataValue(self.$dataValue);
|
|
1072
1107
|
d.value = new node_opcua_variant_1.Variant(d.value);
|
|
1073
1108
|
return d;
|
|
1074
1109
|
},
|
|
@@ -1090,26 +1125,28 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1090
1125
|
(0, node_opcua_assert_1.assert)(this.checkExtensionObjectIsCorrect(this.$extensionObject));
|
|
1091
1126
|
(0, node_opcua_assert_1.assert)(s.statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1092
1127
|
}
|
|
1093
|
-
let property;
|
|
1094
|
-
let camelCaseName;
|
|
1095
1128
|
// ------------------------------------------------------
|
|
1096
1129
|
// now bind each member
|
|
1097
1130
|
// ------------------------------------------------------
|
|
1098
|
-
const definition = dt._getDefinition(
|
|
1131
|
+
const definition = dt._getDefinition();
|
|
1099
1132
|
// istanbul ignore next
|
|
1100
1133
|
if (!definition) {
|
|
1101
1134
|
throw new Error("xx definition missing in " + dt.toString());
|
|
1102
1135
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1106
|
-
if (
|
|
1107
|
-
|
|
1136
|
+
const getOrCreateProperty = (field) => {
|
|
1137
|
+
let property;
|
|
1138
|
+
const selectedComponents = components.filter((f) => f instanceof UAVariableImpl && f.browseName.name.toString() === field.name);
|
|
1139
|
+
if (field.dataType.value === node_opcua_variant_1.DataType.Variant) {
|
|
1140
|
+
warningLog("Warning : variant is not supported in ExtensionObject");
|
|
1141
|
+
}
|
|
1142
|
+
if (selectedComponents.length === 1) {
|
|
1143
|
+
property = selectedComponents[0];
|
|
1108
1144
|
/* istanbul ignore next */
|
|
1109
1145
|
}
|
|
1110
1146
|
else {
|
|
1147
|
+
debugLog("adding missing array variable", field.name, this.browseName.toString(), this.nodeId.toString());
|
|
1111
1148
|
// todo: Handle array appropriately...
|
|
1112
|
-
(0, node_opcua_assert_1.assert)(
|
|
1149
|
+
(0, node_opcua_assert_1.assert)(selectedComponents.length === 0);
|
|
1113
1150
|
// create a variable (Note we may use ns=1;s=parentName/0:PropertyName)
|
|
1114
1151
|
property = this.namespace.addVariable({
|
|
1115
1152
|
browseName: { namespaceIndex: structureNamespace, name: field.name.toString() },
|
|
@@ -1119,62 +1156,64 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1119
1156
|
});
|
|
1120
1157
|
(0, node_opcua_assert_1.assert)(property.minimumSamplingInterval === this.minimumSamplingInterval);
|
|
1121
1158
|
}
|
|
1122
|
-
property
|
|
1123
|
-
|
|
1159
|
+
return property;
|
|
1160
|
+
};
|
|
1161
|
+
for (const field of definition.fields || []) {
|
|
1124
1162
|
if (node_opcua_nodeid_1.NodeId.sameNodeId(node_opcua_nodeid_1.NodeId.nullNodeId, field.dataType)) {
|
|
1125
|
-
|
|
1126
|
-
|
|
1163
|
+
warningLog("field.dataType is null ! ", field.toString(), node_opcua_nodeid_1.NodeId.nullNodeId.toString());
|
|
1164
|
+
warningLog(" dataType replaced with BaseDataType ");
|
|
1165
|
+
warningLog(definition.toString());
|
|
1127
1166
|
field.dataType = this.resolveNodeId("BaseDataType");
|
|
1128
1167
|
}
|
|
1129
|
-
const
|
|
1168
|
+
const camelCaseName = (0, node_opcua_utils_1.lowerFirstLetter)(field.name);
|
|
1130
1169
|
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this.$extensionObject, camelCaseName));
|
|
1170
|
+
const propertyNode = getOrCreateProperty(field);
|
|
1171
|
+
propertyNode.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.Good;
|
|
1172
|
+
propertyNode.touchValue();
|
|
1173
|
+
const basicDataType = addressSpace.findCorrespondingBasicDataType(field.dataType);
|
|
1131
1174
|
// istanbul ignore next
|
|
1132
1175
|
if (doDebug) {
|
|
1133
1176
|
const x = addressSpace.findNode(field.dataType).browseName.toString();
|
|
1134
|
-
|
|
1135
|
-
debugLog(chalk.cyan("xxx"), " dataType", w(field.dataType.toString(), 8), w(field.name, 35), "valueRank", chalk.cyan(w((0, base_node_private_1.valueRankToString)(field.valueRank), 10)), chalk.green(w(x, 25)), "basicType = ", chalk.yellow(w(basicType.toString(), 20)), property.nodeId.toString(), property.readValue().statusCode.toString());
|
|
1177
|
+
debugLog(chalk.cyan("xxx"), " dataType", w(field.dataType.toString(), 8), w(field.name, 35), "valueRank", chalk.cyan(w((0, base_node_private_1.valueRankToString)(field.valueRank), 10)), chalk.green(w(x, 25)), "basicType = ", chalk.yellow(w(basicDataType.toString(), 20)), propertyNode.nodeId.toString(), propertyNode.readValue().statusCode.toString());
|
|
1136
1178
|
}
|
|
1137
|
-
if (this.$extensionObject[camelCaseName] !== undefined &&
|
|
1179
|
+
if (this.$extensionObject[camelCaseName] !== undefined && basicDataType === node_opcua_variant_1.DataType.ExtensionObject) {
|
|
1138
1180
|
(0, node_opcua_assert_1.assert)(this.$extensionObject[camelCaseName] instanceof Object);
|
|
1139
|
-
this.$extensionObject[camelCaseName] = new Proxy(this.$extensionObject[camelCaseName], makeHandler(
|
|
1140
|
-
|
|
1181
|
+
this.$extensionObject[camelCaseName] = new Proxy(this.$extensionObject[camelCaseName], makeHandler(propertyNode));
|
|
1182
|
+
propertyNode._internal_set_value(new node_opcua_variant_1.Variant({
|
|
1141
1183
|
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
1142
1184
|
value: this.$extensionObject[camelCaseName]
|
|
1143
|
-
});
|
|
1144
|
-
|
|
1145
|
-
|
|
1185
|
+
}));
|
|
1186
|
+
propertyNode.bindExtensionObject();
|
|
1187
|
+
propertyNode.$extensionObject = this.$extensionObject[camelCaseName];
|
|
1146
1188
|
}
|
|
1147
1189
|
else {
|
|
1148
|
-
const dataTypeAsString = node_opcua_variant_1.DataType[dataTypeNodeId];
|
|
1149
|
-
(0, node_opcua_assert_1.assert)(typeof dataTypeAsString === "string");
|
|
1150
1190
|
const prop = this.$extensionObject[camelCaseName];
|
|
1151
1191
|
if (prop === undefined) {
|
|
1152
|
-
|
|
1192
|
+
propertyNode._internal_set_value(new node_opcua_variant_1.Variant({
|
|
1153
1193
|
dataType: node_opcua_variant_1.DataType.Null
|
|
1154
|
-
});
|
|
1194
|
+
}));
|
|
1155
1195
|
}
|
|
1156
1196
|
else {
|
|
1157
|
-
const preparedValue = prepareVariantValue(
|
|
1158
|
-
|
|
1159
|
-
dataType:
|
|
1197
|
+
const preparedValue = prepareVariantValue(basicDataType, prop);
|
|
1198
|
+
propertyNode._internal_set_value(new node_opcua_variant_1.Variant({
|
|
1199
|
+
dataType: basicDataType,
|
|
1160
1200
|
value: preparedValue
|
|
1161
|
-
});
|
|
1201
|
+
}));
|
|
1162
1202
|
}
|
|
1163
1203
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1164
1204
|
const self = this;
|
|
1165
|
-
property.camelCaseName = camelCaseName;
|
|
1166
|
-
|
|
1205
|
+
// property.camelCaseName = camelCaseName;
|
|
1206
|
+
propertyNode.setValueFromSource = function (variant) {
|
|
1167
1207
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1168
1208
|
const inner_this = this;
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
self.$extensionObject[inner_this.camelCaseName] = variant.value;
|
|
1209
|
+
const variant1 = node_opcua_variant_1.Variant.coerce(variant);
|
|
1210
|
+
inner_this.verifyVariantCompatibility(variant1);
|
|
1211
|
+
self.$extensionObject[camelCaseName] = variant1.value;
|
|
1173
1212
|
self.touchValue();
|
|
1174
1213
|
};
|
|
1175
1214
|
}
|
|
1176
|
-
(0, node_opcua_assert_1.assert)(
|
|
1177
|
-
bindProperty(
|
|
1215
|
+
(0, node_opcua_assert_1.assert)(propertyNode.readValue().statusCode.equals(node_opcua_status_code_1.StatusCodes.Good));
|
|
1216
|
+
bindProperty(propertyNode, camelCaseName, this.$extensionObject, basicDataType);
|
|
1178
1217
|
}
|
|
1179
1218
|
(0, node_opcua_assert_1.assert)(this.$extensionObject instanceof Object);
|
|
1180
1219
|
return this.$extensionObject;
|
|
@@ -1211,7 +1250,6 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1211
1250
|
name = path[path.length - 1];
|
|
1212
1251
|
c1[name] = c2[name];
|
|
1213
1252
|
c1[name] += 1;
|
|
1214
|
-
// xx console.log(partialData);
|
|
1215
1253
|
setExtensionObjectValue(this, partialData);
|
|
1216
1254
|
}
|
|
1217
1255
|
constructExtensionObjectFromComponents() {
|
|
@@ -1261,10 +1299,16 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1261
1299
|
_validate_DataType(variantDataType) {
|
|
1262
1300
|
return validateDataType(this.addressSpace, this.dataType, variantDataType, this.nodeId, /* allow Nulls */ false);
|
|
1263
1301
|
}
|
|
1302
|
+
_internal_set_value(value) {
|
|
1303
|
+
if (value.dataType !== node_opcua_variant_1.DataType.Null) {
|
|
1304
|
+
this.verifyVariantCompatibility(value);
|
|
1305
|
+
}
|
|
1306
|
+
this.$dataValue.value = value;
|
|
1307
|
+
}
|
|
1264
1308
|
_internal_set_dataValue(dataValue, indexRange) {
|
|
1265
1309
|
(0, node_opcua_assert_1.assert)(dataValue, "expecting a dataValue");
|
|
1266
1310
|
(0, node_opcua_assert_1.assert)(dataValue instanceof node_opcua_data_value_1.DataValue, "expecting dataValue to be a DataValue");
|
|
1267
|
-
(0, node_opcua_assert_1.assert)(dataValue !== this
|
|
1311
|
+
(0, node_opcua_assert_1.assert)(dataValue !== this.$dataValue, "expecting dataValue to be different from previous DataValue instance");
|
|
1268
1312
|
if (dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
1269
1313
|
if (!dataValue.value.dimensions) {
|
|
1270
1314
|
throw new Error("missing dimensions: a Matrix Variant needs a dimension");
|
|
@@ -1283,23 +1327,26 @@ class UAVariableImpl extends base_node_impl_1.BaseNodeImpl {
|
|
|
1283
1327
|
// istanbul ignore next
|
|
1284
1328
|
if (this.dataType.namespace === 0) {
|
|
1285
1329
|
if (this.dataType.value === node_opcua_variant_1.DataType.LocalizedText && dataValue.value.dataType !== node_opcua_variant_1.DataType.LocalizedText) {
|
|
1286
|
-
|
|
1330
|
+
const message = "Invalid dataValue provided (expecting a LocalizedText) but got " + dataValue.toString();
|
|
1331
|
+
errorLog(message);
|
|
1332
|
+
throw new Error(message);
|
|
1287
1333
|
}
|
|
1288
1334
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
this
|
|
1335
|
+
this.verifyVariantCompatibility(dataValue.value);
|
|
1336
|
+
const old_dataValue = this.$dataValue;
|
|
1337
|
+
this.$dataValue = dataValue;
|
|
1338
|
+
this.$dataValue.statusCode = this.$dataValue.statusCode || node_opcua_status_code_1.StatusCodes.Good;
|
|
1292
1339
|
// repair missing timestamps
|
|
1293
1340
|
if (!dataValue.serverTimestamp) {
|
|
1294
|
-
this.
|
|
1295
|
-
this.
|
|
1341
|
+
this.$dataValue.serverTimestamp = old_dataValue.serverTimestamp;
|
|
1342
|
+
this.$dataValue.serverPicoseconds = old_dataValue.serverPicoseconds;
|
|
1296
1343
|
}
|
|
1297
1344
|
if (!dataValue.sourceTimestamp) {
|
|
1298
|
-
this.
|
|
1299
|
-
this.
|
|
1345
|
+
this.$dataValue.sourceTimestamp = old_dataValue.sourceTimestamp;
|
|
1346
|
+
this.$dataValue.sourcePicoseconds = old_dataValue.sourcePicoseconds;
|
|
1300
1347
|
}
|
|
1301
1348
|
if (!(0, node_opcua_data_value_1.sameDataValue)(old_dataValue, dataValue)) {
|
|
1302
|
-
this.emit("value_changed", this
|
|
1349
|
+
this.emit("value_changed", this.$dataValue, indexRange);
|
|
1303
1350
|
}
|
|
1304
1351
|
}
|
|
1305
1352
|
_conditionRefresh(_cache) {
|
|
@@ -1467,7 +1514,7 @@ function _calculateEffectiveUserAccessLevelFromPermission(node, context, userAcc
|
|
|
1467
1514
|
function adjustVariant2(variant) {
|
|
1468
1515
|
// convert Variant( Scalar|ByteString) => Variant(Array|ByteArray)
|
|
1469
1516
|
const addressSpace = this.addressSpace;
|
|
1470
|
-
const basicType =
|
|
1517
|
+
const basicType = this.getBasicDataType();
|
|
1471
1518
|
variant = (0, node_opcua_variant_1.adjustVariant)(variant, this.valueRank, basicType);
|
|
1472
1519
|
return variant;
|
|
1473
1520
|
}
|
|
@@ -1511,7 +1558,7 @@ function _Variable_bind_with_async_refresh(options) {
|
|
|
1511
1558
|
(0, node_opcua_assert_1.assert)(!this.refreshFunc);
|
|
1512
1559
|
this.refreshFunc = options.refreshFunc;
|
|
1513
1560
|
// assert(this.readValue().statusCode === StatusCodes.BadNodeIdUnknown);
|
|
1514
|
-
this.
|
|
1561
|
+
this.$dataValue.statusCode = node_opcua_status_code_1.StatusCodes.UncertainInitialValue;
|
|
1515
1562
|
// TO DO : REVISIT THIS ASSUMPTION
|
|
1516
1563
|
if (false && this.minimumSamplingInterval === 0) {
|
|
1517
1564
|
// when a getter /timestamped_getter or async_getter is provided
|
|
@@ -1530,7 +1577,10 @@ function _Variable_bind_with_timestamped_get(options) {
|
|
|
1530
1577
|
const async_refresh_func = (callback) => {
|
|
1531
1578
|
Promise.resolve(this._timestamped_get_func.call(this))
|
|
1532
1579
|
.then((dataValue) => callback(null, dataValue))
|
|
1533
|
-
.catch((err) =>
|
|
1580
|
+
.catch((err) => {
|
|
1581
|
+
errorLog("asyncRefresh error: Variable is ", this.nodeId.toString(), this.browseName.toString());
|
|
1582
|
+
callback(err);
|
|
1583
|
+
});
|
|
1534
1584
|
};
|
|
1535
1585
|
if (options.timestamped_get.length === 0) {
|
|
1536
1586
|
const timestamped_get = options.timestamped_get;
|
|
@@ -1575,13 +1625,10 @@ function _Variable_bind_with_simple_get(options) {
|
|
|
1575
1625
|
return new node_opcua_data_value_1.DataValue({ statusCode: value });
|
|
1576
1626
|
}
|
|
1577
1627
|
else {
|
|
1578
|
-
if (!this
|
|
1628
|
+
if (!this.$dataValue || !isGoodish(this.$dataValue.statusCode) || !(0, node_opcua_variant_1.sameVariant)(this.$dataValue.value, value)) {
|
|
1579
1629
|
this.setValueFromSource(value, node_opcua_status_code_1.StatusCodes.Good);
|
|
1580
1630
|
}
|
|
1581
|
-
|
|
1582
|
-
// XX console.log("YYYYYYYYYYYYYYYYYYYYYYYYYY",this.browseName.toString());
|
|
1583
|
-
}
|
|
1584
|
-
return this._dataValue;
|
|
1631
|
+
return this.$dataValue;
|
|
1585
1632
|
}
|
|
1586
1633
|
};
|
|
1587
1634
|
_Variable_bind_with_timestamped_get.call(this, {
|
|
@@ -1599,9 +1646,10 @@ function _Variable_bind_with_simple_set(options) {
|
|
|
1599
1646
|
this._timestamped_set_func = (timestamped_value, indexRange, callback) => {
|
|
1600
1647
|
(0, node_opcua_assert_1.assert)(timestamped_value instanceof node_opcua_data_value_1.DataValue);
|
|
1601
1648
|
this._set_func(timestamped_value.value, (err, statusCode) => {
|
|
1649
|
+
// istanbul ignore next
|
|
1602
1650
|
if (!err && !statusCode) {
|
|
1603
|
-
|
|
1604
|
-
|
|
1651
|
+
errorLog(chalk.red("UAVariable Binding Error _set_func must return a StatusCode, check the bindVariable parameters"));
|
|
1652
|
+
errorLog(chalk.yellow("StatusCode.Good is assumed"));
|
|
1605
1653
|
return callback(err, node_opcua_status_code_1.StatusCodes.Good, timestamped_value);
|
|
1606
1654
|
}
|
|
1607
1655
|
callback(err, statusCode, timestamped_value);
|