node-opcua-address-space 2.178.0 → 2.180.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/source/address_space_ts.d.ts +16 -6
- package/dist/source/address_space_ts.js +1 -1
- package/dist/source/address_space_ts.js.map +1 -1
- package/dist/source/helpers/argument_list.js +2 -2
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +3 -0
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +6 -2
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +3 -1
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/interfaces/extension_object_constructor.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +0 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -1
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +2 -1
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +12 -8
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.js +26 -7
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +6 -4
- package/dist/source/loader/parsers/extension_object_parser.js +12 -6
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -1
- package/dist/source/loader/parsers/localized_text_parser.d.ts +1 -1
- package/dist/source/loader/parsers/nodeid_parser.d.ts +10 -2
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -1
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +1 -2
- package/dist/source/loader/parsers/variant_parser.d.ts +8 -2
- package/dist/source/loader/parsers/variant_parser.js +11 -8
- package/dist/source/loader/parsers/variant_parser.js.map +1 -1
- package/dist/source/pseudo_session.js +70 -24
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.js +26 -19
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/xml_writer.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +0 -3
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +0 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +7 -2
- package/dist/src/address_space.js +36 -28
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +6 -9
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +6 -6
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +8 -4
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +6 -5
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +3 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +17 -8
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +0 -6
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/extension_object_array_node.d.ts +9 -1
- package/dist/src/extension_object_array_node.js +20 -3
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +3 -1
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +2 -4
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/namespace_impl.js +6 -5
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +4 -5
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +10 -11
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +2 -4
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +71 -43
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.d.ts +2 -2
- package/dist/src/reference_impl.js +5 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +1 -1
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +9 -7
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +4 -4
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +21 -11
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +5 -2
- package/dist/src/ua_object_type_impl.js +4 -3
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +1 -2
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +9 -11
- package/dist/src/ua_variable_impl.js +103 -65
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.d.ts +6 -6
- package/dist/src/ua_variable_impl_ext_obj.js +33 -22
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +6 -2
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +3 -0
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/boiler_system.js +27 -6
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +3 -3
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/dump_statemachine.js +1 -1
- package/distHelpers/dump_statemachine.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +0 -1
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/package.json +41 -41
- package/source/address_space_ts.ts +19 -9
- package/source/helpers/argument_list.ts +2 -2
- package/source/helpers/call_helpers.ts +4 -1
- package/source/helpers/dump_tools.ts +7 -3
- package/source/helpers/make_optionals_map.ts +4 -2
- package/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.ts +4 -3
- package/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.ts +10 -11
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +6 -7
- package/source/interfaces/extension_object_constructor.ts +1 -1
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +0 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +0 -1
- package/source/loader/decode_xml_extension_object.ts +3 -3
- package/source/loader/ensure_datatype_extracted.ts +6 -2
- package/source/loader/generateAddressSpaceRaw.ts +5 -4
- package/source/loader/load_nodeset2.ts +12 -8
- package/source/loader/make_xml_extension_object_parser.ts +78 -45
- package/source/loader/namespace_post_step.ts +1 -1
- package/source/loader/parsers/extension_object_parser.ts +36 -27
- package/source/loader/parsers/localized_text_parser.ts +1 -1
- package/source/loader/parsers/nodeid_parser.ts +10 -2
- package/source/loader/parsers/qualified_name_parser.ts +1 -1
- package/source/loader/parsers/variant_parser.ts +53 -40
- package/source/pseudo_session.ts +81 -28
- package/source/session_context.ts +28 -19
- package/source/xml_writer.ts +1 -1
- package/src/_instantiate_helpers.ts +0 -3
- package/src/_mandatory_child_or_requested_optional_filter.ts +3 -4
- package/src/address_space.ts +58 -42
- package/src/address_space_private.ts +2 -0
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +6 -10
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +5 -7
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +20 -13
- package/src/alarms_and_conditions/ua_base_event_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +12 -10
- package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +8 -5
- package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +0 -1
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +0 -1
- package/src/apply_condition_refresh.ts +1 -1
- package/src/base_node_impl.ts +30 -35
- package/src/base_node_private.ts +0 -6
- package/src/extension_object_array_node.ts +44 -15
- package/src/get_basic_datatype.ts +4 -1
- package/src/historical_access/address_space_historical_data_node.ts +2 -5
- package/src/namespace_impl.ts +24 -17
- package/src/nodeid_manager.ts +8 -11
- package/src/nodeset_tools/construct_namespace_dependency.ts +18 -15
- package/src/nodeset_tools/dump_to_bsd.ts +6 -8
- package/src/nodeset_tools/nodeset_to_xml.ts +105 -75
- package/src/private_namespace.ts +7 -2
- package/src/reference_impl.ts +11 -10
- package/src/state_machine/finite_state_machine.ts +12 -10
- package/src/state_machine/ua_shelving_state_machine_ex.ts +4 -4
- package/src/state_machine/ua_two_state_variable.ts +12 -9
- package/src/tool_isSubtypeOf.ts +2 -9
- package/src/ua_data_type_impl.ts +4 -4
- package/src/ua_method_impl.ts +24 -14
- package/src/ua_object_type_impl.ts +12 -6
- package/src/ua_reference_type_impl.ts +2 -3
- package/src/ua_variable_impl.ts +142 -96
- package/src/ua_variable_impl_ext_obj.ts +110 -82
- package/src/ua_variable_type_impl.ts +17 -5
|
@@ -24,31 +24,32 @@ function _w(str: string, n: number): string {
|
|
|
24
24
|
return str.padEnd(n).substring(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function isProxy(ext:
|
|
28
|
-
return !!ext
|
|
27
|
+
function isProxy(ext: unknown): boolean {
|
|
28
|
+
return !!(ext as Record<string, unknown> | null)?.$isProxy;
|
|
29
29
|
}
|
|
30
|
-
function getProxyVariable(ext:
|
|
30
|
+
function getProxyVariable(ext: Record<string, unknown>): UAVariable | null {
|
|
31
31
|
assert(isProxy(ext));
|
|
32
32
|
return ext.$variable as UAVariable | null;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function getProxyVariableForProp(ext:
|
|
35
|
+
function getProxyVariableForProp(ext: Record<string, unknown>, prop: string) {
|
|
36
36
|
const uaVariable = getProxyVariable(ext);
|
|
37
37
|
if (!uaVariable) return undefined;
|
|
38
|
-
return (uaVariable as
|
|
38
|
+
return (uaVariable as unknown as Record<string, unknown>)[prop] as UAVariableImpl | undefined;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function getProxyTarget(ext:
|
|
41
|
+
export function getProxyTarget(ext: Record<string, unknown>): unknown {
|
|
42
42
|
assert(isProxy(ext));
|
|
43
43
|
const target = ext.$proxyTarget;
|
|
44
|
-
if (target && isProxy(target)) {
|
|
45
|
-
return getProxyTarget(target);
|
|
44
|
+
if (target && isProxy(target as Record<string, unknown>)) {
|
|
45
|
+
return getProxyTarget(target as Record<string, unknown>);
|
|
46
46
|
}
|
|
47
47
|
return target;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function unProxy(ext: ExtensionObject) {
|
|
51
|
-
|
|
50
|
+
function unProxy(ext: ExtensionObject): ExtensionObject {
|
|
51
|
+
const extAsRecord = ext as unknown as Record<string, unknown>;
|
|
52
|
+
return isProxy(extAsRecord) ? (getProxyTarget(extAsRecord) as ExtensionObject) : ext;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function getExtensionObjectArray(uaVariable: UAVariableImpl): ExtensionObject[] {
|
|
@@ -61,7 +62,7 @@ function getExtensionObjectArray(uaVariable: UAVariableImpl): ExtensionObject[]
|
|
|
61
62
|
return arr;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
function _extensionObjectFieldGetter(getVariable: () => UAVariable | null, target:
|
|
65
|
+
function _extensionObjectFieldGetter(getVariable: () => UAVariable | null, target: ExtensionObject, key: string /*, receiver*/) {
|
|
65
66
|
if (key === "$isProxy") {
|
|
66
67
|
return true;
|
|
67
68
|
}
|
|
@@ -72,24 +73,26 @@ function _extensionObjectFieldGetter(getVariable: () => UAVariable | null, targe
|
|
|
72
73
|
return getVariable();
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
const targetAsRecord = target as unknown as Record<string, unknown>;
|
|
77
|
+
if (targetAsRecord[key] === undefined) {
|
|
76
78
|
return undefined;
|
|
77
79
|
}
|
|
78
|
-
return
|
|
80
|
+
return targetAsRecord[key];
|
|
79
81
|
}
|
|
80
82
|
function _extensionObjectFieldSetter(
|
|
81
83
|
getVariable: () => UAVariable | null,
|
|
82
|
-
target:
|
|
84
|
+
target: ExtensionObject,
|
|
83
85
|
key: string,
|
|
84
|
-
value:
|
|
86
|
+
value: unknown /*, receiver*/
|
|
85
87
|
): boolean {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const targetAsRecord = target as unknown as Record<string, unknown>;
|
|
89
|
+
targetAsRecord[key] = value;
|
|
90
|
+
if (isProxy(targetAsRecord)) {
|
|
88
91
|
return true;
|
|
89
92
|
}
|
|
90
93
|
const uaVariable = getVariable();
|
|
91
94
|
if (!uaVariable) return true;
|
|
92
|
-
const child = (uaVariable as
|
|
95
|
+
const child = (uaVariable as unknown as Record<string, UAVariable | null>)[key];
|
|
93
96
|
if (child?.touchValue) {
|
|
94
97
|
child.touchValue();
|
|
95
98
|
}
|
|
@@ -157,7 +160,11 @@ export function propagateTouchValueDownward(self: UAVariableImpl, now: PreciseCl
|
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
export function setExtensionObjectPartialValue(
|
|
163
|
+
export function setExtensionObjectPartialValue(
|
|
164
|
+
node: UAVariableImpl,
|
|
165
|
+
partialObject: Record<string, unknown> | undefined,
|
|
166
|
+
sourceTimestamp?: PreciseClock
|
|
167
|
+
) {
|
|
161
168
|
const variablesToUpdate: Set<UAVariableImpl> = new Set();
|
|
162
169
|
|
|
163
170
|
const extensionObject = node.$extensionObject;
|
|
@@ -177,19 +184,19 @@ export function setExtensionObjectPartialValue(node: UAVariableImpl, partialObje
|
|
|
177
184
|
* DiagnosticInfo, arrays, etc.) is a terminal value and should be
|
|
178
185
|
* assigned directly — even if it has a `schema` property.
|
|
179
186
|
*/
|
|
180
|
-
function _shouldRecurseIntoExisting(value:
|
|
187
|
+
function _shouldRecurseIntoExisting(value: unknown): boolean {
|
|
181
188
|
if (value === null || value === undefined) return false;
|
|
182
189
|
if (typeof value !== "object") return false;
|
|
183
190
|
if (Array.isArray(value)) return false;
|
|
184
191
|
// proxied sub-structures: installed by bindExtensionObject for nested structs
|
|
185
|
-
if (isProxy(value)) return true;
|
|
192
|
+
if (isProxy(value as Record<string, unknown>)) return true;
|
|
186
193
|
// plain objects (unlikely on the existing side but safe fallback)
|
|
187
194
|
const proto = Object.getPrototypeOf(value);
|
|
188
195
|
if (proto === Object.prototype || proto === null) return true;
|
|
189
196
|
return false;
|
|
190
197
|
}
|
|
191
198
|
|
|
192
|
-
function _shouldRecurseIntoNew(value:
|
|
199
|
+
function _shouldRecurseIntoNew(value: unknown): boolean {
|
|
193
200
|
if (value === null || value === undefined) return false;
|
|
194
201
|
if (typeof value !== "object") return false;
|
|
195
202
|
if (Array.isArray(value)) return false;
|
|
@@ -201,26 +208,30 @@ export function setExtensionObjectPartialValue(node: UAVariableImpl, partialObje
|
|
|
201
208
|
// checking the *existing* side with isProxy, not here.
|
|
202
209
|
// Instead, only recurse if it's a schema'd type AND has
|
|
203
210
|
// Extension-Object-like characteristics (constructor with schema.name)
|
|
211
|
+
const valueRecord = value as Record<string, unknown>;
|
|
204
212
|
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
213
|
+
valueRecord.schema !== undefined &&
|
|
214
|
+
(valueRecord.constructor as { name?: string })?.name !== "QualifiedName" &&
|
|
215
|
+
(valueRecord.constructor as { name?: string })?.name !== "LocalizedText" &&
|
|
216
|
+
(valueRecord.constructor as { name?: string })?.name !== "DiagnosticInfo"
|
|
209
217
|
) {
|
|
210
218
|
return true;
|
|
211
219
|
}
|
|
212
220
|
return false;
|
|
213
221
|
}
|
|
214
222
|
|
|
215
|
-
function _update_extension_object(extObject:
|
|
223
|
+
function _update_extension_object(extObject: Record<string, unknown>, partialObject1: Record<string, unknown>) {
|
|
216
224
|
const keys = Object.keys(partialObject1);
|
|
217
225
|
for (const prop of keys) {
|
|
218
226
|
if (_shouldRecurseIntoExisting(extObject[prop]) && _shouldRecurseIntoNew(partialObject1[prop])) {
|
|
219
|
-
_update_extension_object(
|
|
227
|
+
_update_extension_object(
|
|
228
|
+
extObject[prop] as Record<string, unknown>,
|
|
229
|
+
partialObject1[prop] as Record<string, unknown>
|
|
230
|
+
);
|
|
220
231
|
} else {
|
|
221
232
|
if (isProxy(extObject)) {
|
|
222
233
|
// collect element we have to update
|
|
223
|
-
const target = getProxyTarget(extObject)
|
|
234
|
+
const target = getProxyTarget(extObject) as Record<string, unknown>;
|
|
224
235
|
assert(!isProxy(target), "something wierd!");
|
|
225
236
|
target[prop] = partialObject1[prop];
|
|
226
237
|
const variable = getProxyVariableForProp(extObject, prop);
|
|
@@ -231,7 +242,7 @@ export function setExtensionObjectPartialValue(node: UAVariableImpl, partialObje
|
|
|
231
242
|
}
|
|
232
243
|
}
|
|
233
244
|
}
|
|
234
|
-
_update_extension_object(extensionObject, partialObject);
|
|
245
|
+
_update_extension_object(extensionObject as unknown as Record<string, unknown>, partialObject as Record<string, unknown>);
|
|
235
246
|
|
|
236
247
|
const now = sourceTimestamp || getCurrentClock();
|
|
237
248
|
const cache: Set<UAVariable> = new Set();
|
|
@@ -261,7 +272,8 @@ function getOrCreateProperty(
|
|
|
261
272
|
// c8 ignore next
|
|
262
273
|
if (field.dataType.value === DataType.Variant) {
|
|
263
274
|
// this means that any type of extensions being used here
|
|
264
|
-
|
|
275
|
+
// c8 ignore next
|
|
276
|
+
doDebug && debugLog("Warning : variant is not supported in ExtensionObject");
|
|
265
277
|
}
|
|
266
278
|
|
|
267
279
|
if (selectedComponents.length === 1) {
|
|
@@ -271,7 +283,14 @@ function getOrCreateProperty(
|
|
|
271
283
|
if (!options?.createMissingProp) {
|
|
272
284
|
return null;
|
|
273
285
|
}
|
|
274
|
-
|
|
286
|
+
// c8 ignore next
|
|
287
|
+
doDebug &&
|
|
288
|
+
debugLog(
|
|
289
|
+
"adding missing array variable",
|
|
290
|
+
field.name,
|
|
291
|
+
variableNode.browseName.toString(),
|
|
292
|
+
variableNode.nodeId.toString()
|
|
293
|
+
);
|
|
275
294
|
// todo: Handle array appropriately...
|
|
276
295
|
assert(selectedComponents.length === 0);
|
|
277
296
|
// create a variable (Note we may use ns=1;s=parentName/0:PropertyName)
|
|
@@ -298,21 +317,24 @@ function installExt(uaVariable: UAVariableImpl, ext: ExtensionObject) {
|
|
|
298
317
|
|
|
299
318
|
const addressSpace = uaVariable.addressSpace;
|
|
300
319
|
const definition = uaVariable.dataTypeObj.getStructureDefinition();
|
|
301
|
-
const structure = addressSpace.findDataType("Structure")
|
|
320
|
+
const structure = addressSpace.findDataType("Structure");
|
|
321
|
+
if (!structure) {
|
|
322
|
+
throw new Error("Cannot find 'Structure' DataType in standard address Space");
|
|
323
|
+
}
|
|
302
324
|
for (const field of definition.fields || []) {
|
|
303
325
|
if (field.dataType) {
|
|
304
326
|
const dataTypeNode = addressSpace.findDataType(field.dataType);
|
|
305
327
|
// c8 ignore next
|
|
306
328
|
if (dataTypeNode?.isSubtypeOf(structure)) {
|
|
307
329
|
// sub structure .. let make an handler too
|
|
308
|
-
const camelCaseName = lowerFirstLetter(field.name
|
|
330
|
+
const camelCaseName = lowerFirstLetter(field.name || "");
|
|
309
331
|
|
|
310
332
|
const subExtObj = uaVariable.$extensionObject[camelCaseName];
|
|
311
333
|
if (subExtObj) {
|
|
312
334
|
uaVariable.$extensionObject[camelCaseName] = new Proxy(
|
|
313
335
|
subExtObj,
|
|
314
336
|
makeHandler(() => {
|
|
315
|
-
return uaVariable.getComponentByName(field.name
|
|
337
|
+
return uaVariable.getComponentByName(field.name || "") as UAVariable | null;
|
|
316
338
|
})
|
|
317
339
|
);
|
|
318
340
|
} else {
|
|
@@ -360,8 +382,8 @@ function _installFields2(
|
|
|
360
382
|
get,
|
|
361
383
|
set
|
|
362
384
|
}: {
|
|
363
|
-
get: (fieldName: string) =>
|
|
364
|
-
set: (fieldName: string, value:
|
|
385
|
+
get: (fieldName: string) => unknown;
|
|
386
|
+
set: (fieldName: string, value: unknown, sourceTime: PreciseClock) => void;
|
|
365
387
|
},
|
|
366
388
|
options?: BindExtensionObjectOptions
|
|
367
389
|
) {
|
|
@@ -399,14 +421,14 @@ function _installFields2(
|
|
|
399
421
|
: VariantArrayType.Matrix;
|
|
400
422
|
propertyNode.$dataValue.value.dimensions = propertyNode.valueRank > 1 ? propertyNode.arrayDimensions : null;
|
|
401
423
|
|
|
402
|
-
const fieldName = field.name
|
|
424
|
+
const fieldName = field.name || "";
|
|
403
425
|
installDataValueGetter(propertyNode, () => get(fieldName));
|
|
404
426
|
assert(propertyNode._inner_replace_dataValue);
|
|
405
427
|
propertyNode._inner_replace_dataValue = (dataValue: DataValue, _indexRange?: NumericRange | null) => {
|
|
406
428
|
/** */
|
|
407
429
|
const sourceTime = coerceClock(dataValue.sourceTimestamp, dataValue.sourcePicoseconds);
|
|
408
430
|
const value = dataValue.value.value;
|
|
409
|
-
set(field.name
|
|
431
|
+
set(field.name || "", value, sourceTime);
|
|
410
432
|
propertyNode.touchValue(sourceTime);
|
|
411
433
|
};
|
|
412
434
|
|
|
@@ -415,12 +437,12 @@ function _installFields2(
|
|
|
415
437
|
propertyNode,
|
|
416
438
|
{
|
|
417
439
|
get: (fieldName: string) => {
|
|
418
|
-
const mainFieldName = field.name
|
|
419
|
-
return get(mainFieldName)[lowerFirstLetter(fieldName)];
|
|
440
|
+
const mainFieldName = field.name || "";
|
|
441
|
+
return (get(mainFieldName) as Record<string, unknown>)[lowerFirstLetter(fieldName)];
|
|
420
442
|
},
|
|
421
|
-
set: (fieldName: string, value:
|
|
422
|
-
const mainFieldName = field.name
|
|
423
|
-
get(mainFieldName)[lowerFirstLetter(fieldName)] = value;
|
|
443
|
+
set: (fieldName: string, value: unknown, _sourceTime: PreciseClock) => {
|
|
444
|
+
const mainFieldName = field.name || "";
|
|
445
|
+
(get(mainFieldName) as Record<string, unknown>)[lowerFirstLetter(fieldName)] = value;
|
|
424
446
|
}
|
|
425
447
|
},
|
|
426
448
|
options
|
|
@@ -429,7 +451,7 @@ function _installFields2(
|
|
|
429
451
|
}
|
|
430
452
|
}
|
|
431
453
|
|
|
432
|
-
function installDataValueGetter(propertyNode: UAVariableImpl, get: () =>
|
|
454
|
+
function installDataValueGetter(propertyNode: UAVariableImpl, get: () => unknown) {
|
|
433
455
|
Object.defineProperty(propertyNode.$dataValue.value, "value", { get });
|
|
434
456
|
const $ = propertyNode.$dataValue;
|
|
435
457
|
Object.defineProperty(propertyNode, "$dataValue", {
|
|
@@ -470,7 +492,7 @@ function _innerBindExtensionObjectScalar(
|
|
|
470
492
|
}: {
|
|
471
493
|
get: () => ExtensionObject;
|
|
472
494
|
set: (value: ExtensionObject, sourceTimestamp: PreciseClock, cache: Set<UAVariableImpl>) => void;
|
|
473
|
-
setField: (fieldName: string, value:
|
|
495
|
+
setField: (fieldName: string, value: unknown, sourceTimestamp: PreciseClock, cache?: Set<UAVariableImpl>) => void;
|
|
474
496
|
},
|
|
475
497
|
options?: BindExtensionObjectOptions
|
|
476
498
|
) {
|
|
@@ -489,10 +511,10 @@ function _innerBindExtensionObjectScalar(
|
|
|
489
511
|
uaVariable,
|
|
490
512
|
{
|
|
491
513
|
get: (fieldName: string) => {
|
|
492
|
-
const extObj = get() as
|
|
514
|
+
const extObj = get() as unknown as Record<string, unknown>;
|
|
493
515
|
return extObj[lowerFirstLetter(fieldName)];
|
|
494
516
|
},
|
|
495
|
-
set: (fieldName: string, value:
|
|
517
|
+
set: (fieldName: string, value: unknown, sourceTime: PreciseClock) => {
|
|
496
518
|
setField(fieldName, value, sourceTime);
|
|
497
519
|
}
|
|
498
520
|
},
|
|
@@ -500,7 +522,6 @@ function _innerBindExtensionObjectScalar(
|
|
|
500
522
|
);
|
|
501
523
|
}
|
|
502
524
|
|
|
503
|
-
// eslint-disable-next-line complexity
|
|
504
525
|
export function _bindExtensionObject(
|
|
505
526
|
uaVariable: UAVariableImpl,
|
|
506
527
|
optionalExtensionObject?: ExtensionObject,
|
|
@@ -540,9 +561,9 @@ export function _bindExtensionObject(
|
|
|
540
561
|
) {
|
|
541
562
|
const parentDataType = (uaVariable.parent as UAVariable | UAVariableType).dataType;
|
|
542
563
|
const dataTypeNode = addressSpace.findNode(parentDataType) as UADataType;
|
|
543
|
-
const structure = addressSpace.findDataType("Structure")
|
|
564
|
+
const structure = addressSpace.findDataType("Structure");
|
|
544
565
|
// c8 ignore next
|
|
545
|
-
if (dataTypeNode?.isSubtypeOf(structure)) {
|
|
566
|
+
if (structure && dataTypeNode?.isSubtypeOf(structure)) {
|
|
546
567
|
// warningLog(
|
|
547
568
|
// "Ignoring bindExtensionObject on sub extension object",
|
|
548
569
|
// "child=",
|
|
@@ -557,7 +578,7 @@ export function _bindExtensionObject(
|
|
|
557
578
|
// -------------------- make sure we do not bind a variable twice ....
|
|
558
579
|
if (uaVariable.$extensionObject && !optionalExtensionObject) {
|
|
559
580
|
// c8 ignore next
|
|
560
|
-
if (!uaVariable.checkExtensionObjectIsCorrect(uaVariable.$extensionObject
|
|
581
|
+
if (!uaVariable.checkExtensionObjectIsCorrect(uaVariable.$extensionObject)) {
|
|
561
582
|
warningLog(
|
|
562
583
|
"on node : ",
|
|
563
584
|
uaVariable.browseName.toString(),
|
|
@@ -612,11 +633,11 @@ export function _bindExtensionObject(
|
|
|
612
633
|
_innerBindExtensionObjectScalar(
|
|
613
634
|
uaVariable,
|
|
614
635
|
{
|
|
615
|
-
get: () => uaVariable.$extensionObject,
|
|
636
|
+
get: () => uaVariable.$extensionObject as ExtensionObject,
|
|
616
637
|
set: (value: ExtensionObject) => installExt(uaVariable, value),
|
|
617
|
-
setField: (fieldName: string, value:
|
|
618
|
-
const extObj = uaVariable.$extensionObject
|
|
619
|
-
getProxyTarget(extObj)[lowerFirstLetter(fieldName)] = value;
|
|
638
|
+
setField: (fieldName: string, value: unknown) => {
|
|
639
|
+
const extObj = uaVariable.$extensionObject as unknown as Record<string, unknown>;
|
|
640
|
+
(getProxyTarget(extObj) as Record<string, unknown>)[lowerFirstLetter(fieldName)] = value;
|
|
620
641
|
}
|
|
621
642
|
},
|
|
622
643
|
options
|
|
@@ -635,11 +656,11 @@ export function _bindExtensionObject(
|
|
|
635
656
|
_innerBindExtensionObjectScalar(
|
|
636
657
|
uaVariable,
|
|
637
658
|
{
|
|
638
|
-
get: () => uaVariable.$extensionObject,
|
|
659
|
+
get: () => uaVariable.$extensionObject as ExtensionObject,
|
|
639
660
|
set: (value: ExtensionObject) => installExt(uaVariable, value),
|
|
640
|
-
setField: (fieldName: string, value:
|
|
641
|
-
const extObj = uaVariable.$extensionObject
|
|
642
|
-
getProxyTarget(extObj)[lowerFirstLetter(fieldName)] = value;
|
|
661
|
+
setField: (fieldName: string, value: unknown) => {
|
|
662
|
+
const extObj = uaVariable.$extensionObject as unknown as Record<string, unknown>;
|
|
663
|
+
(getProxyTarget(extObj) as Record<string, unknown>)[lowerFirstLetter(fieldName)] = value;
|
|
643
664
|
}
|
|
644
665
|
},
|
|
645
666
|
options
|
|
@@ -662,7 +683,6 @@ const composeBrowseNameAndNodeId = (uaVariable: UAVariable, indexes: number[]) =
|
|
|
662
683
|
return { browseName, nodeId };
|
|
663
684
|
};
|
|
664
685
|
|
|
665
|
-
// eslint-disable-next-line max-statements, complexity
|
|
666
686
|
export function _bindExtensionObjectArrayOrMatrix(
|
|
667
687
|
uaVariable: UAVariableImpl,
|
|
668
688
|
optionalExtensionObjectArray?: ExtensionObject[],
|
|
@@ -787,10 +807,15 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
787
807
|
propagateTouchValueDownward(capturedUaElement, sourceTimestamp, cache);
|
|
788
808
|
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
789
809
|
},
|
|
790
|
-
setField: (
|
|
810
|
+
setField: (
|
|
811
|
+
fieldName: string,
|
|
812
|
+
newValue: unknown,
|
|
813
|
+
sourceTimestamp: PreciseClock,
|
|
814
|
+
cache?: Set<UAVariableImpl>
|
|
815
|
+
) => {
|
|
791
816
|
// c8 ignore next doDebug && debugLog("setField", fieldName, newValue, sourceTimestamp, cache);
|
|
792
817
|
const extObj = getExtensionObjectArray(uaVariable)[capturedIndex];
|
|
793
|
-
unProxy(extObj)[lowerFirstLetter(fieldName)] = newValue;
|
|
818
|
+
(unProxy(extObj) as unknown as Record<string, unknown>)[lowerFirstLetter(fieldName)] = newValue;
|
|
794
819
|
propagateTouchValueUpward(capturedUaElement, sourceTimestamp, cache);
|
|
795
820
|
}
|
|
796
821
|
},
|
|
@@ -801,55 +826,58 @@ export function _bindExtensionObjectArrayOrMatrix(
|
|
|
801
826
|
return uaVariable.$$extensionObjectArray;
|
|
802
827
|
}
|
|
803
828
|
|
|
804
|
-
export function getElement(path: string | string[], data:
|
|
829
|
+
export function getElement(path: string | string[], data: Record<string, unknown>): unknown {
|
|
805
830
|
if (typeof path === "string") {
|
|
806
831
|
path = path.split(".");
|
|
807
832
|
}
|
|
808
|
-
let a = data;
|
|
833
|
+
let a: Record<string, unknown> = data;
|
|
809
834
|
for (const e of path) {
|
|
810
|
-
a = a[e]
|
|
835
|
+
a = a[e] as Record<string, unknown>;
|
|
811
836
|
}
|
|
812
837
|
return a;
|
|
813
838
|
}
|
|
814
|
-
export function setElement(path: string | string[], data:
|
|
839
|
+
export function setElement(path: string | string[], data: Record<string, unknown>, value: unknown): void {
|
|
815
840
|
if (typeof path === "string") {
|
|
816
841
|
path = path.split(".");
|
|
817
842
|
}
|
|
818
|
-
const last
|
|
819
|
-
|
|
843
|
+
const last = path.pop();
|
|
844
|
+
if (last === undefined) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
let a: Record<string, unknown> = data;
|
|
820
848
|
for (const e of path) {
|
|
821
|
-
a = a[e]
|
|
849
|
+
a = a[e] as Record<string, unknown>;
|
|
822
850
|
}
|
|
823
851
|
a[last] = value;
|
|
824
852
|
}
|
|
825
|
-
export function incrementElement(path: string | string[], data:
|
|
826
|
-
const value = getElement(path, data);
|
|
853
|
+
export function incrementElement(path: string | string[], data: Record<string, unknown>): void {
|
|
854
|
+
const value = getElement(path, data) as number;
|
|
827
855
|
setElement(path, data, value + 1);
|
|
828
856
|
}
|
|
829
857
|
export function extractPartialData(path: string | string[], extensionObject: ExtensionObject) {
|
|
830
|
-
let name
|
|
858
|
+
let name: string;
|
|
831
859
|
if (typeof path === "string") {
|
|
832
860
|
path = path.split(".");
|
|
833
861
|
}
|
|
834
|
-
let i
|
|
862
|
+
let i: number;
|
|
835
863
|
// read partial value
|
|
836
|
-
const partialData:
|
|
837
|
-
let p:
|
|
864
|
+
const partialData: Record<string, unknown> = {};
|
|
865
|
+
let p: Record<string, unknown> = partialData;
|
|
838
866
|
for (i = 0; i < path.length - 1; i++) {
|
|
839
867
|
name = path[i];
|
|
840
868
|
p[name] = {};
|
|
841
|
-
p = p[name]
|
|
869
|
+
p = p[name] as Record<string, unknown>;
|
|
842
870
|
}
|
|
843
871
|
name = path[path.length - 1];
|
|
844
872
|
p[name] = 0;
|
|
845
873
|
|
|
846
|
-
let c1 = partialData;
|
|
847
|
-
let c2:
|
|
874
|
+
let c1: Record<string, unknown> = partialData;
|
|
875
|
+
let c2: Record<string, unknown> = extensionObject as unknown as Record<string, unknown>;
|
|
848
876
|
|
|
849
877
|
for (i = 0; i < path.length - 1; i++) {
|
|
850
878
|
name = path[i];
|
|
851
|
-
c1 = partialData[name]
|
|
852
|
-
c2 = (extensionObject as
|
|
879
|
+
c1 = partialData[name] as Record<string, unknown>;
|
|
880
|
+
c2 = (extensionObject as unknown as Record<string, unknown>)[name] as Record<string, unknown>;
|
|
853
881
|
}
|
|
854
882
|
name = path[path.length - 1];
|
|
855
883
|
c1[name] = c2[name];
|
|
@@ -865,7 +893,7 @@ export function propagateTouchValueDownwardArray(uaVariable: UAVariableImpl, now
|
|
|
865
893
|
for (let i = 0; i < totalLength; i++) {
|
|
866
894
|
const index = indexIterator.next();
|
|
867
895
|
|
|
868
|
-
const { browseName
|
|
896
|
+
const { browseName } = composeBrowseNameAndNodeId(uaVariable, index);
|
|
869
897
|
const uaElement = uaVariable.getComponentByName(browseName) as UAVariableImpl | null;
|
|
870
898
|
if (uaElement?.nodeClass === NodeClass.Variable) {
|
|
871
899
|
uaElement.touchValue(now);
|
|
@@ -17,9 +17,16 @@ import type {
|
|
|
17
17
|
} from "node-opcua-address-space-base";
|
|
18
18
|
import { assert } from "node-opcua-assert";
|
|
19
19
|
import type { UInt32 } from "node-opcua-basic-types";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
AttributeIds,
|
|
22
|
+
BrowseDirection,
|
|
23
|
+
coerceQualifiedName,
|
|
24
|
+
type LocalizedTextLike,
|
|
25
|
+
NodeClass,
|
|
26
|
+
type QualifiedName
|
|
27
|
+
} from "node-opcua-data-model";
|
|
21
28
|
import { DataValue, type DataValueLike } from "node-opcua-data-value";
|
|
22
|
-
import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
29
|
+
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
23
30
|
import { coerceNodeId, NodeId, type NodeIdLike } from "node-opcua-nodeid";
|
|
24
31
|
import { StatusCodes } from "node-opcua-status-code";
|
|
25
32
|
import { isNullOrUndefined } from "node-opcua-utils";
|
|
@@ -34,6 +41,7 @@ import { _getBasicDataType } from "./get_basic_datatype";
|
|
|
34
41
|
import { construct_isSubtypeOf, get_subtypeOf, get_subtypeOfObj } from "./tool_isSubtypeOf";
|
|
35
42
|
|
|
36
43
|
const debugLog = make_debugLog(__filename);
|
|
44
|
+
const doDebug = checkDebugFlag(__filename);
|
|
37
45
|
const warningLog = make_warningLog(__filename);
|
|
38
46
|
const errorLog = make_errorLog(__filename);
|
|
39
47
|
|
|
@@ -157,7 +165,8 @@ export class UAVariableTypeImpl extends BaseNodeImpl<BaseNodeEvents> implements
|
|
|
157
165
|
options.value = this.value as Variant;
|
|
158
166
|
options.statusCode = StatusCodes.Good;
|
|
159
167
|
} else {
|
|
160
|
-
|
|
168
|
+
// c8 ignore next
|
|
169
|
+
doDebug && debugLog(" warning Value not implemented");
|
|
161
170
|
options.value = { dataType: DataType.Null };
|
|
162
171
|
options.statusCode = StatusCodes.BadAttributeIdInvalid;
|
|
163
172
|
}
|
|
@@ -267,7 +276,10 @@ export class UAVariableTypeImpl extends BaseNodeImpl<BaseNodeEvents> implements
|
|
|
267
276
|
browseName: options.browseName,
|
|
268
277
|
componentOf: options.componentOf,
|
|
269
278
|
dataType,
|
|
270
|
-
description:
|
|
279
|
+
description:
|
|
280
|
+
options.description === undefined
|
|
281
|
+
? (this.description?.clone() as LocalizedTextLike | undefined)
|
|
282
|
+
: options.description,
|
|
271
283
|
displayName: options.displayName || "",
|
|
272
284
|
eventSourceOf: options.eventSourceOf,
|
|
273
285
|
minimumSamplingInterval: options.minimumSamplingInterval,
|
|
@@ -335,7 +347,7 @@ function hasChildWithBrowseName(parent: BaseNode, childBrowseName: QualifiedName
|
|
|
335
347
|
);
|
|
336
348
|
}
|
|
337
349
|
|
|
338
|
-
function getParent(addressSpace: IAddressSpace, options:
|
|
350
|
+
function getParent(addressSpace: IAddressSpace, options: InstantiateVariableOptions) {
|
|
339
351
|
const parent = options.componentOf || options.organizedBy;
|
|
340
352
|
if (parent instanceof NodeId) {
|
|
341
353
|
return addressSpace.findNode(parent as NodeId);
|