node-opcua-address-space 2.156.0 → 2.158.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.js +1 -0
- package/dist/source/address_space_ts.js.map +1 -1
- package/dist/source/continuation_points/continuation_point_manager.js +1 -0
- package/dist/source/continuation_points/continuation_point_manager.js.map +1 -1
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +1 -0
- package/dist/source/index.js.map +1 -1
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +1 -0
- package/dist/source/loader/load_nodeset2.js +2 -0
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/pseudo_session.js +6 -3
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.js +7 -2
- package/dist/source/session_context.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +4 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +1 -1
- package/dist/src/address_space.js +75 -29
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_info_impl.js +4 -4
- package/dist/src/alarms_and_conditions/condition_info_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +217 -208
- package/dist/src/alarms_and_conditions/condition_snapshot_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_certificate_expiration_alarm_impl.js +1 -4
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +9 -11
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +8 -2
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +4 -4
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/event_data.js +3 -0
- package/dist/src/event_data.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +5 -0
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/idx_iterator.js +2 -1
- package/dist/src/idx_iterator.js.map +1 -1
- package/dist/src/index_current.d.ts +1 -0
- package/dist/src/index_current.js +1 -0
- package/dist/src/index_current.js.map +1 -1
- package/dist/src/namespace_impl.js +20 -6
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +5 -2
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/reference_impl.js +7 -0
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +2 -0
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +12 -5
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +5 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +3 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +5 -4
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +14 -11
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +25 -2
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +11 -4
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/ua_view_impl.js +3 -1
- package/dist/src/ua_view_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -0
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/distNodeJS/generate_address_space.d.ts +1 -1
- package/package.json +44 -43
- package/source/index.ts +2 -0
- package/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.ts +2 -0
- package/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.ts +0 -1
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +2 -0
- package/source_nodejs/generate_address_space.ts +1 -1
- package/src/address_space.ts +62 -22
- package/src/alarms_and_conditions/ua_condition_impl.ts +4 -3
- package/src/index_current.ts +1 -0
- package/src/ua_variable_impl.ts +1 -1
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var _ConditionSnapshotImpl_instances, _a, _ConditionSnapshotImpl__ensure_condition_values_correctness, _ConditionSnapshotImpl__visit, _ConditionSnapshotImpl__installOnChangeEventHandlers, _ConditionSnapshotImpl__record_condition_state, _ConditionSnapshotImpl__get_var, _ConditionSnapshotImpl__set_var, _ConditionSnapshotImpl__set_twoStateVariable, _ConditionSnapshotImpl__get_twoStateVariable;
|
|
2
|
+
var _a;
|
|
8
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
4
|
exports.ConditionSnapshotImpl = void 0;
|
|
10
5
|
/**
|
|
@@ -51,29 +46,30 @@ const _varTable = {
|
|
|
51
46
|
Time: 1
|
|
52
47
|
};
|
|
53
48
|
class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
49
|
+
static normalizeName = normalizeName;
|
|
50
|
+
condition;
|
|
51
|
+
eventData = null;
|
|
52
|
+
branchId = null;
|
|
53
|
+
_map = new Map();
|
|
54
|
+
_node_index = new Map();
|
|
54
55
|
/**
|
|
55
56
|
*/
|
|
56
57
|
constructor(condition, branchId) {
|
|
57
58
|
super();
|
|
58
|
-
_ConditionSnapshotImpl_instances.add(this);
|
|
59
|
-
this.eventData = null;
|
|
60
|
-
this.branchId = null;
|
|
61
|
-
this._map = new Map();
|
|
62
|
-
this._node_index = new Map();
|
|
63
59
|
(0, node_opcua_assert_1.assert)(branchId instanceof node_opcua_nodeid_1.NodeId);
|
|
64
60
|
// xx self.branchId = branchId;
|
|
65
61
|
this.condition = condition;
|
|
66
62
|
this.eventData = new event_data_1.EventData(condition);
|
|
67
63
|
// a nodeId/Variant map
|
|
68
|
-
|
|
64
|
+
this.#_record_condition_state(condition);
|
|
69
65
|
if ((0, node_opcua_nodeid_1.sameNodeId)(branchId, node_opcua_nodeid_1.NodeId.nullNodeId)) {
|
|
70
|
-
|
|
66
|
+
this.#_installOnChangeEventHandlers(condition, "");
|
|
71
67
|
}
|
|
72
|
-
|
|
68
|
+
this.#_set_var("BranchId", node_opcua_variant_1.DataType.NodeId, branchId);
|
|
73
69
|
}
|
|
74
70
|
_constructEventData() {
|
|
75
71
|
if (this.branchId && (0, node_opcua_nodeid_1.sameNodeId)(this.branchId, node_opcua_nodeid_1.NodeId.nullNodeId)) {
|
|
76
|
-
|
|
72
|
+
this.#_ensure_condition_values_correctness(this.condition, "", []);
|
|
77
73
|
}
|
|
78
74
|
const c = this.condition;
|
|
79
75
|
const isDisabled = !c.getEnabledState();
|
|
@@ -93,30 +89,157 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
93
89
|
}
|
|
94
90
|
return eventData;
|
|
95
91
|
}
|
|
92
|
+
#_ensure_condition_values_correctness(node, prefix, error) {
|
|
93
|
+
const displayError = !!error;
|
|
94
|
+
error = error || [];
|
|
95
|
+
const aggregates = node.getAggregates();
|
|
96
|
+
for (const aggregate of aggregates) {
|
|
97
|
+
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
98
|
+
const name = aggregate.browseName.toString();
|
|
99
|
+
const key = prefix + name;
|
|
100
|
+
const snapshot_value = this._map.get(key).toString();
|
|
101
|
+
const aggregateVariable = aggregate;
|
|
102
|
+
const condition_value = aggregateVariable.readValue().value.toString();
|
|
103
|
+
if (snapshot_value !== condition_value) {
|
|
104
|
+
error.push(" Condition Branch0 is not in sync with node values for " +
|
|
105
|
+
key +
|
|
106
|
+
"\n v1= " +
|
|
107
|
+
snapshot_value +
|
|
108
|
+
"\n v2= " +
|
|
109
|
+
condition_value);
|
|
110
|
+
}
|
|
111
|
+
this._node_index.set(key, aggregateVariable);
|
|
112
|
+
this.#_ensure_condition_values_correctness(aggregate, prefix + name + ".", error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (displayError && error.length) {
|
|
116
|
+
throw new Error(error.join("\n"));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
#_visit(node, prefix) {
|
|
120
|
+
const aggregates = node.getAggregates();
|
|
121
|
+
for (const aggregate of aggregates) {
|
|
122
|
+
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
123
|
+
const name = aggregate.browseName.toString();
|
|
124
|
+
const key = prefix + name;
|
|
125
|
+
// istanbul ignore next
|
|
126
|
+
if (doDebug) {
|
|
127
|
+
debugLog("adding key =", key);
|
|
128
|
+
}
|
|
129
|
+
const aggregateVariable = aggregate;
|
|
130
|
+
this._map.set(key, aggregateVariable.readValue().value);
|
|
131
|
+
this._node_index.set(key, aggregateVariable);
|
|
132
|
+
this.#_visit(aggregate, prefix + name + ".");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
#_installOnChangeEventHandlers(node, prefix) {
|
|
137
|
+
const aggregates = node.getAggregates();
|
|
138
|
+
for (const aggregate of aggregates) {
|
|
139
|
+
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
140
|
+
const name = aggregate.browseName.toString();
|
|
141
|
+
const key = prefix + name;
|
|
142
|
+
// istanbul ignore next
|
|
143
|
+
if (doDebug) {
|
|
144
|
+
debugLog("adding key =", key);
|
|
145
|
+
}
|
|
146
|
+
aggregate.on("value_changed", (newDataValue) => {
|
|
147
|
+
this._map.set(key, newDataValue.value);
|
|
148
|
+
this._node_index.set(key, aggregate);
|
|
149
|
+
});
|
|
150
|
+
this.#_installOnChangeEventHandlers(aggregate, prefix + name + ".");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
#_record_condition_state(condition) {
|
|
155
|
+
this._map.clear();
|
|
156
|
+
this._node_index.clear();
|
|
157
|
+
(0, node_opcua_assert_1.assert)(condition instanceof ua_condition_impl_1.UAConditionImpl);
|
|
158
|
+
this.#_visit(condition, "");
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
#_get_var(varName) {
|
|
164
|
+
const c = this.condition;
|
|
165
|
+
if (!c.getEnabledState() && !Object.prototype.hasOwnProperty.call(_varTable, varName)) {
|
|
166
|
+
// xx debuglog("ConditionSnapshot#_get_var condition enabled =", self.condition.getEnabledState());
|
|
167
|
+
return disabledVar;
|
|
168
|
+
}
|
|
169
|
+
const key = normalizeName(varName);
|
|
170
|
+
const variant = this._map.get(key);
|
|
171
|
+
if (!variant) {
|
|
172
|
+
throw new Error("cannot find key " + key);
|
|
173
|
+
}
|
|
174
|
+
return variant.value;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
#_set_var(varName, dataType, value, options) {
|
|
180
|
+
const key = normalizeName(varName);
|
|
181
|
+
// istanbul ignore next
|
|
182
|
+
if (!this._map.has(key)) {
|
|
183
|
+
// istanbul ignore next
|
|
184
|
+
if (doDebug) {
|
|
185
|
+
debugLog(" cannot find node " + varName);
|
|
186
|
+
debugLog(" map=", [...this._map.keys()].join(" "));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
this._map.set(key, new node_opcua_variant_1.Variant({
|
|
190
|
+
dataType,
|
|
191
|
+
value
|
|
192
|
+
}));
|
|
193
|
+
const sourceTimestamp = options?.sourceTimestamp || new Date();
|
|
194
|
+
const sourceTimestampKey = key + ".SourceTimestamp";
|
|
195
|
+
if (this._map.has(sourceTimestampKey)) {
|
|
196
|
+
// from spec 1.03 : 5.3 condition variables
|
|
197
|
+
// a condition VariableType has a sourceTimeStamp exposed property
|
|
198
|
+
// SourceTimestamp indicates the time of the last change of the Value of this ConditionVariable.
|
|
199
|
+
// It shall be the same time that would be returned from the Read Service inside the DataValue
|
|
200
|
+
// structure for the ConditionVariable Value Attribute.
|
|
201
|
+
const variant = new node_opcua_variant_1.Variant({
|
|
202
|
+
dataType: node_opcua_variant_1.DataType.DateTime,
|
|
203
|
+
value: sourceTimestamp
|
|
204
|
+
});
|
|
205
|
+
this._map.set(sourceTimestampKey, variant);
|
|
206
|
+
const node = this._node_index.get(sourceTimestampKey);
|
|
207
|
+
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
208
|
+
}
|
|
209
|
+
const variant = this._map.get(key);
|
|
210
|
+
const node = this._node_index.get(key);
|
|
211
|
+
if (!node) {
|
|
212
|
+
// for instance localTime is optional
|
|
213
|
+
debugLog("Cannot serVar " + varName + " dataType " + node_opcua_variant_1.DataType[dataType]);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
|
|
217
|
+
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
218
|
+
}
|
|
96
219
|
/**
|
|
97
220
|
*
|
|
98
221
|
*/
|
|
99
222
|
getBranchId() {
|
|
100
|
-
return
|
|
223
|
+
return this.#_get_var("BranchId");
|
|
101
224
|
}
|
|
102
225
|
/**
|
|
103
226
|
*
|
|
104
227
|
*/
|
|
105
228
|
getEventId() {
|
|
106
|
-
return
|
|
229
|
+
return this.#_get_var("EventId");
|
|
107
230
|
}
|
|
108
231
|
/**
|
|
109
232
|
*
|
|
110
233
|
*/
|
|
111
234
|
getRetain() {
|
|
112
|
-
return
|
|
235
|
+
return this.#_get_var("Retain");
|
|
113
236
|
}
|
|
114
237
|
/**
|
|
115
238
|
*
|
|
116
239
|
*/
|
|
117
240
|
setRetain(retainFlag) {
|
|
118
241
|
retainFlag = !!retainFlag;
|
|
119
|
-
return
|
|
242
|
+
return this.#_set_var("Retain", node_opcua_variant_1.DataType.Boolean, retainFlag);
|
|
120
243
|
}
|
|
121
244
|
/**
|
|
122
245
|
*
|
|
@@ -125,32 +248,32 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
125
248
|
const addressSpace = this.condition.addressSpace;
|
|
126
249
|
// create a new event Id for this new condition
|
|
127
250
|
const eventId = addressSpace.generateEventId();
|
|
128
|
-
const ret =
|
|
251
|
+
const ret = this.#_set_var("EventId", node_opcua_variant_1.DataType.ByteString, eventId.value);
|
|
129
252
|
return ret;
|
|
130
253
|
}
|
|
131
254
|
/**
|
|
132
255
|
*
|
|
133
256
|
*/
|
|
134
257
|
getEnabledState() {
|
|
135
|
-
return
|
|
258
|
+
return this.#_get_twoStateVariable("EnabledState");
|
|
136
259
|
}
|
|
137
260
|
/**
|
|
138
261
|
*
|
|
139
262
|
*/
|
|
140
263
|
setEnabledState(value, options) {
|
|
141
|
-
return
|
|
264
|
+
return this.#_set_twoStateVariable("EnabledState", value, options);
|
|
142
265
|
}
|
|
143
266
|
/**
|
|
144
267
|
*
|
|
145
268
|
*/
|
|
146
269
|
getEnabledStateAsString() {
|
|
147
|
-
return
|
|
270
|
+
return this.#_get_var("EnabledState").text;
|
|
148
271
|
}
|
|
149
272
|
/**
|
|
150
273
|
*
|
|
151
274
|
*/
|
|
152
275
|
getComment() {
|
|
153
|
-
return
|
|
276
|
+
return this.#_get_var("Comment");
|
|
154
277
|
}
|
|
155
278
|
/**
|
|
156
279
|
* Set condition comment
|
|
@@ -164,20 +287,20 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
164
287
|
*/
|
|
165
288
|
setComment(txtMessage, options) {
|
|
166
289
|
const txtMessage1 = (0, node_opcua_data_model_1.coerceLocalizedText)(txtMessage);
|
|
167
|
-
|
|
290
|
+
this.#_set_var("Comment", node_opcua_variant_1.DataType.LocalizedText, txtMessage1, options);
|
|
168
291
|
}
|
|
169
292
|
/**
|
|
170
293
|
* set the condition message (localized text)
|
|
171
294
|
*/
|
|
172
295
|
setMessage(txtMessage) {
|
|
173
296
|
const txtMessage1 = (0, node_opcua_data_model_1.coerceLocalizedText)(txtMessage);
|
|
174
|
-
return
|
|
297
|
+
return this.#_set_var("Message", node_opcua_variant_1.DataType.LocalizedText, txtMessage1);
|
|
175
298
|
}
|
|
176
299
|
/**
|
|
177
300
|
*
|
|
178
301
|
*/
|
|
179
302
|
setClientUserId(userIdentity) {
|
|
180
|
-
return
|
|
303
|
+
return this.#_set_var("ClientUserId", node_opcua_variant_1.DataType.String, userIdentity.toString());
|
|
181
304
|
}
|
|
182
305
|
/*
|
|
183
306
|
*
|
|
@@ -220,13 +343,13 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
220
343
|
* it is up to the application to determine what quality is displayed as part of the condition.
|
|
221
344
|
*/
|
|
222
345
|
setQuality(quality, options) {
|
|
223
|
-
|
|
346
|
+
this.#_set_var("Quality", node_opcua_variant_1.DataType.StatusCode, quality, options);
|
|
224
347
|
}
|
|
225
348
|
/**
|
|
226
349
|
*
|
|
227
350
|
*/
|
|
228
351
|
getQuality() {
|
|
229
|
-
return
|
|
352
|
+
return this.#_get_var("Quality");
|
|
230
353
|
}
|
|
231
354
|
/**
|
|
232
355
|
* **as per spec 1.0.3 - Part 9**
|
|
@@ -282,14 +405,14 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
282
405
|
const lastSeverity = this.getSeverity();
|
|
283
406
|
const sourceTimestamp = this.getSeveritySourceTimestamp();
|
|
284
407
|
this.setLastSeverity(lastSeverity, { sourceTimestamp });
|
|
285
|
-
|
|
408
|
+
this.#_set_var("Severity", node_opcua_variant_1.DataType.UInt16, severity, options);
|
|
286
409
|
}
|
|
287
410
|
/**
|
|
288
411
|
*/
|
|
289
412
|
getSeverity() {
|
|
290
413
|
const c = this.condition;
|
|
291
414
|
(0, node_opcua_assert_1.assert)(c.getEnabledState(), "condition must be enabled");
|
|
292
|
-
const value =
|
|
415
|
+
const value = this.#_get_var("Severity");
|
|
293
416
|
return +value;
|
|
294
417
|
}
|
|
295
418
|
getSeveritySourceTimestamp() {
|
|
@@ -309,13 +432,13 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
309
432
|
*/
|
|
310
433
|
setLastSeverity(severity, options) {
|
|
311
434
|
severity = +severity;
|
|
312
|
-
return
|
|
435
|
+
return this.#_set_var("LastSeverity", node_opcua_variant_1.DataType.UInt16, severity, options);
|
|
313
436
|
}
|
|
314
437
|
/**
|
|
315
438
|
*
|
|
316
439
|
*/
|
|
317
440
|
getLastSeverity() {
|
|
318
|
-
const value =
|
|
441
|
+
const value = this.#_get_var("LastSeverity");
|
|
319
442
|
return +value;
|
|
320
443
|
}
|
|
321
444
|
/**
|
|
@@ -336,7 +459,7 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
336
459
|
*
|
|
337
460
|
*/
|
|
338
461
|
setReceiveTime(time) {
|
|
339
|
-
return
|
|
462
|
+
return this.#_set_var("ReceiveTime", node_opcua_variant_1.DataType.DateTime, time, { sourceTimestamp: time || undefined });
|
|
340
463
|
}
|
|
341
464
|
/**
|
|
342
465
|
* Time provides the time the Event occurred.
|
|
@@ -350,7 +473,7 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
350
473
|
*
|
|
351
474
|
*/
|
|
352
475
|
setTime(time) {
|
|
353
|
-
return
|
|
476
|
+
return this.#_set_var("Time", node_opcua_variant_1.DataType.DateTime, time, { sourceTimestamp: time });
|
|
354
477
|
}
|
|
355
478
|
/**
|
|
356
479
|
* LocalTime is a structure containing the Offset and the DaylightSavingInOffset flag.
|
|
@@ -368,29 +491,29 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
368
491
|
*/
|
|
369
492
|
setLocalTime(localTime) {
|
|
370
493
|
(0, node_opcua_assert_1.assert)(localTime instanceof node_opcua_types_1.TimeZoneDataType);
|
|
371
|
-
return
|
|
494
|
+
return this.#_set_var("LocalTime", node_opcua_variant_1.DataType.ExtensionObject, new node_opcua_types_1.TimeZoneDataType(localTime));
|
|
372
495
|
}
|
|
373
496
|
// read only !
|
|
374
497
|
getSourceName() {
|
|
375
|
-
return
|
|
498
|
+
return this.#_get_var("SourceName");
|
|
376
499
|
}
|
|
377
500
|
/**
|
|
378
501
|
*
|
|
379
502
|
*/
|
|
380
503
|
getSourceNode() {
|
|
381
|
-
return
|
|
504
|
+
return this.#_get_var("SourceNode");
|
|
382
505
|
}
|
|
383
506
|
/**
|
|
384
507
|
*
|
|
385
508
|
*/
|
|
386
509
|
getEventType() {
|
|
387
|
-
return
|
|
510
|
+
return this.#_get_var("EventType");
|
|
388
511
|
}
|
|
389
512
|
getMessage() {
|
|
390
|
-
return
|
|
513
|
+
return this.#_get_var("Message");
|
|
391
514
|
}
|
|
392
515
|
isCurrentBranch() {
|
|
393
|
-
return (0, node_opcua_nodeid_1.sameNodeId)(
|
|
516
|
+
return (0, node_opcua_nodeid_1.sameNodeId)(this.#_get_var("BranchId"), node_opcua_nodeid_1.NodeId.nullNodeId);
|
|
394
517
|
}
|
|
395
518
|
// -- ACKNOWLEDGEABLE -------------------------------------------------------------------
|
|
396
519
|
getAckedState() {
|
|
@@ -402,7 +525,7 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
402
525
|
acknowledgeableCondition.typeDefinitionObj.browseName.toString() +
|
|
403
526
|
" has no AckedState");
|
|
404
527
|
}
|
|
405
|
-
return
|
|
528
|
+
return this.#_get_twoStateVariable("AckedState");
|
|
406
529
|
}
|
|
407
530
|
setAckedState(ackedState, options) {
|
|
408
531
|
ackedState = !!ackedState;
|
|
@@ -411,7 +534,7 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
411
534
|
getConfirmedState() {
|
|
412
535
|
const acknowledgeableCondition = this.condition;
|
|
413
536
|
(0, node_opcua_assert_1.assert)(acknowledgeableCondition.confirmedState, "Must have a confirmed state");
|
|
414
|
-
return
|
|
537
|
+
return this.#_get_twoStateVariable("ConfirmedState");
|
|
415
538
|
}
|
|
416
539
|
setConfirmedStateIfExists(confirmedState, options) {
|
|
417
540
|
confirmedState = !!confirmedState;
|
|
@@ -422,7 +545,7 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
422
545
|
return;
|
|
423
546
|
}
|
|
424
547
|
// todo deal with Error code BadConditionBranchAlreadyConfirmed
|
|
425
|
-
return
|
|
548
|
+
return this.#_set_twoStateVariable("ConfirmedState", confirmedState, options);
|
|
426
549
|
}
|
|
427
550
|
setConfirmedState(confirmedState) {
|
|
428
551
|
const acknowledgeableCondition = this.condition;
|
|
@@ -431,43 +554,43 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
431
554
|
}
|
|
432
555
|
// ---- Shelving
|
|
433
556
|
getSuppressedState() {
|
|
434
|
-
return
|
|
557
|
+
return this.#_get_twoStateVariable("SuppressedState");
|
|
435
558
|
}
|
|
436
559
|
setSuppressedState(suppressed, options) {
|
|
437
560
|
suppressed = !!suppressed;
|
|
438
|
-
|
|
561
|
+
this.#_set_twoStateVariable("SuppressedState", suppressed, options);
|
|
439
562
|
}
|
|
440
563
|
getActiveState() {
|
|
441
|
-
return
|
|
564
|
+
return this.#_get_twoStateVariable("ActiveState");
|
|
442
565
|
}
|
|
443
566
|
setActiveState(newActiveState, options) {
|
|
444
567
|
// xx var activeState = self.getActiveState();
|
|
445
568
|
// xx if (activeState === newActiveState) {
|
|
446
569
|
// xx return StatusCodes.Bad;
|
|
447
570
|
// xx }
|
|
448
|
-
|
|
571
|
+
this.#_set_twoStateVariable("ActiveState", newActiveState, options);
|
|
449
572
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
450
573
|
}
|
|
451
574
|
setLatchedState(newLatchedState, options) {
|
|
452
|
-
|
|
575
|
+
this.#_set_twoStateVariable("LatchedState", newLatchedState, options);
|
|
453
576
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
454
577
|
}
|
|
455
578
|
getLatchedState() {
|
|
456
|
-
return
|
|
579
|
+
return this.#_get_twoStateVariable("LatchedState");
|
|
457
580
|
}
|
|
458
581
|
setOutOfServiceState(newOutOfServiceState, options) {
|
|
459
|
-
|
|
582
|
+
this.#_set_twoStateVariable("OutOfServiceState", newOutOfServiceState, options);
|
|
460
583
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
461
584
|
}
|
|
462
585
|
getOutOfServiceState() {
|
|
463
|
-
return
|
|
586
|
+
return this.#_get_twoStateVariable("OutOfServiceState");
|
|
464
587
|
}
|
|
465
588
|
setSilentState(newSilentState, options) {
|
|
466
|
-
|
|
589
|
+
this.#_set_twoStateVariable("SilentState", newSilentState, options);
|
|
467
590
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
468
591
|
}
|
|
469
592
|
getSilentState() {
|
|
470
|
-
return
|
|
593
|
+
return this.#_get_twoStateVariable("SilentState");
|
|
471
594
|
}
|
|
472
595
|
setShelvingState() {
|
|
473
596
|
throw new Error("Method not implemented.");
|
|
@@ -498,167 +621,53 @@ class ConditionSnapshotImpl extends events_1.EventEmitter {
|
|
|
498
621
|
", comment: " +
|
|
499
622
|
this.getComment());
|
|
500
623
|
}
|
|
624
|
+
#_set_twoStateVariable(varName, value, options) {
|
|
625
|
+
value = !!value;
|
|
626
|
+
const hrKey = _a.normalizeName(varName);
|
|
627
|
+
const idKey = _a.normalizeName(varName + ".Id");
|
|
628
|
+
const variant = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Boolean, value });
|
|
629
|
+
this._map.set(idKey, variant);
|
|
630
|
+
// also change varName with human readable text
|
|
631
|
+
const twoStateNode = this._node_index.get(hrKey);
|
|
632
|
+
if (!twoStateNode) {
|
|
633
|
+
throw new Error("Cannot find twoState Variable with name " + varName);
|
|
634
|
+
}
|
|
635
|
+
if (!(twoStateNode instanceof ua_two_state_variable_1.UATwoStateVariableImpl)) {
|
|
636
|
+
throw new Error("Cannot find twoState Variable with name " + varName + " " + twoStateNode);
|
|
637
|
+
}
|
|
638
|
+
const hrValue = new node_opcua_variant_1.Variant({
|
|
639
|
+
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
640
|
+
value: value ? twoStateNode.getTrueState() : twoStateNode.getFalseState()
|
|
641
|
+
});
|
|
642
|
+
this._map.set(hrKey, hrValue);
|
|
643
|
+
const node = this._node_index.get(idKey);
|
|
644
|
+
// also change ConditionNode if we are on currentBranch
|
|
645
|
+
if (this.isCurrentBranch()) {
|
|
646
|
+
(0, node_opcua_assert_1.assert)(twoStateNode instanceof ua_two_state_variable_1.UATwoStateVariableImpl);
|
|
647
|
+
twoStateNode.setValue(value, options);
|
|
648
|
+
}
|
|
649
|
+
const sourceTimestamp = options?.effectiveTransitionTime || new Date();
|
|
650
|
+
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
651
|
+
}
|
|
652
|
+
#_get_twoStateVariable(varName) {
|
|
653
|
+
const key = _a.normalizeName(varName) + ".Id";
|
|
654
|
+
const variant = this._map.get(key);
|
|
655
|
+
// istanbul ignore next
|
|
656
|
+
if (!variant) {
|
|
657
|
+
return "???";
|
|
658
|
+
// throw new Error("Cannot find TwoStateVariable with name " + varName);
|
|
659
|
+
}
|
|
660
|
+
return variant.value;
|
|
661
|
+
}
|
|
501
662
|
_setAckedState(requestedAckedState, conditionEventId, comment, options) {
|
|
502
663
|
const ackedState = this.getAckedState();
|
|
503
664
|
if (ackedState && requestedAckedState) {
|
|
504
665
|
return node_opcua_status_code_1.StatusCodes.BadConditionBranchAlreadyAcked;
|
|
505
666
|
}
|
|
506
|
-
|
|
667
|
+
this.#_set_twoStateVariable("AckedState", requestedAckedState, options);
|
|
507
668
|
return node_opcua_status_code_1.StatusCodes.Good;
|
|
508
669
|
}
|
|
509
670
|
}
|
|
510
671
|
exports.ConditionSnapshotImpl = ConditionSnapshotImpl;
|
|
511
|
-
_a = ConditionSnapshotImpl
|
|
512
|
-
const displayError = !!error;
|
|
513
|
-
error = error || [];
|
|
514
|
-
const aggregates = node.getAggregates();
|
|
515
|
-
for (const aggregate of aggregates) {
|
|
516
|
-
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
517
|
-
const name = aggregate.browseName.toString();
|
|
518
|
-
const key = prefix + name;
|
|
519
|
-
const snapshot_value = this._map.get(key).toString();
|
|
520
|
-
const aggregateVariable = aggregate;
|
|
521
|
-
const condition_value = aggregateVariable.readValue().value.toString();
|
|
522
|
-
if (snapshot_value !== condition_value) {
|
|
523
|
-
error.push(" Condition Branch0 is not in sync with node values for " +
|
|
524
|
-
key +
|
|
525
|
-
"\n v1= " +
|
|
526
|
-
snapshot_value +
|
|
527
|
-
"\n v2= " +
|
|
528
|
-
condition_value);
|
|
529
|
-
}
|
|
530
|
-
this._node_index.set(key, aggregateVariable);
|
|
531
|
-
__classPrivateFieldGet(this, _ConditionSnapshotImpl_instances, "m", _ConditionSnapshotImpl__ensure_condition_values_correctness).call(this, aggregate, prefix + name + ".", error);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (displayError && error.length) {
|
|
535
|
-
throw new Error(error.join("\n"));
|
|
536
|
-
}
|
|
537
|
-
}, _ConditionSnapshotImpl__visit = function _ConditionSnapshotImpl__visit(node, prefix) {
|
|
538
|
-
const aggregates = node.getAggregates();
|
|
539
|
-
for (const aggregate of aggregates) {
|
|
540
|
-
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
541
|
-
const name = aggregate.browseName.toString();
|
|
542
|
-
const key = prefix + name;
|
|
543
|
-
// istanbul ignore next
|
|
544
|
-
if (doDebug) {
|
|
545
|
-
debugLog("adding key =", key);
|
|
546
|
-
}
|
|
547
|
-
const aggregateVariable = aggregate;
|
|
548
|
-
this._map.set(key, aggregateVariable.readValue().value);
|
|
549
|
-
this._node_index.set(key, aggregateVariable);
|
|
550
|
-
__classPrivateFieldGet(this, _ConditionSnapshotImpl_instances, "m", _ConditionSnapshotImpl__visit).call(this, aggregate, prefix + name + ".");
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}, _ConditionSnapshotImpl__installOnChangeEventHandlers = function _ConditionSnapshotImpl__installOnChangeEventHandlers(node, prefix) {
|
|
554
|
-
const aggregates = node.getAggregates();
|
|
555
|
-
for (const aggregate of aggregates) {
|
|
556
|
-
if (aggregate.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
557
|
-
const name = aggregate.browseName.toString();
|
|
558
|
-
const key = prefix + name;
|
|
559
|
-
// istanbul ignore next
|
|
560
|
-
if (doDebug) {
|
|
561
|
-
debugLog("adding key =", key);
|
|
562
|
-
}
|
|
563
|
-
aggregate.on("value_changed", (newDataValue) => {
|
|
564
|
-
this._map.set(key, newDataValue.value);
|
|
565
|
-
this._node_index.set(key, aggregate);
|
|
566
|
-
});
|
|
567
|
-
__classPrivateFieldGet(this, _ConditionSnapshotImpl_instances, "m", _ConditionSnapshotImpl__installOnChangeEventHandlers).call(this, aggregate, prefix + name + ".");
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}, _ConditionSnapshotImpl__record_condition_state = function _ConditionSnapshotImpl__record_condition_state(condition) {
|
|
571
|
-
this._map.clear();
|
|
572
|
-
this._node_index.clear();
|
|
573
|
-
(0, node_opcua_assert_1.assert)(condition instanceof ua_condition_impl_1.UAConditionImpl);
|
|
574
|
-
__classPrivateFieldGet(this, _ConditionSnapshotImpl_instances, "m", _ConditionSnapshotImpl__visit).call(this, condition, "");
|
|
575
|
-
}, _ConditionSnapshotImpl__get_var = function _ConditionSnapshotImpl__get_var(varName) {
|
|
576
|
-
const c = this.condition;
|
|
577
|
-
if (!c.getEnabledState() && !Object.prototype.hasOwnProperty.call(_varTable, varName)) {
|
|
578
|
-
// xx debuglog("ConditionSnapshot#_get_var condition enabled =", self.condition.getEnabledState());
|
|
579
|
-
return disabledVar;
|
|
580
|
-
}
|
|
581
|
-
const key = normalizeName(varName);
|
|
582
|
-
const variant = this._map.get(key);
|
|
583
|
-
if (!variant) {
|
|
584
|
-
throw new Error("cannot find key " + key);
|
|
585
|
-
}
|
|
586
|
-
return variant.value;
|
|
587
|
-
}, _ConditionSnapshotImpl__set_var = function _ConditionSnapshotImpl__set_var(varName, dataType, value, options) {
|
|
588
|
-
const key = normalizeName(varName);
|
|
589
|
-
// istanbul ignore next
|
|
590
|
-
if (!this._map.has(key)) {
|
|
591
|
-
// istanbul ignore next
|
|
592
|
-
if (doDebug) {
|
|
593
|
-
debugLog(" cannot find node " + varName);
|
|
594
|
-
debugLog(" map=", [...this._map.keys()].join(" "));
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
this._map.set(key, new node_opcua_variant_1.Variant({
|
|
598
|
-
dataType,
|
|
599
|
-
value
|
|
600
|
-
}));
|
|
601
|
-
const sourceTimestamp = options?.sourceTimestamp || new Date();
|
|
602
|
-
const sourceTimestampKey = key + ".SourceTimestamp";
|
|
603
|
-
if (this._map.has(sourceTimestampKey)) {
|
|
604
|
-
// from spec 1.03 : 5.3 condition variables
|
|
605
|
-
// a condition VariableType has a sourceTimeStamp exposed property
|
|
606
|
-
// SourceTimestamp indicates the time of the last change of the Value of this ConditionVariable.
|
|
607
|
-
// It shall be the same time that would be returned from the Read Service inside the DataValue
|
|
608
|
-
// structure for the ConditionVariable Value Attribute.
|
|
609
|
-
const variant = new node_opcua_variant_1.Variant({
|
|
610
|
-
dataType: node_opcua_variant_1.DataType.DateTime,
|
|
611
|
-
value: sourceTimestamp
|
|
612
|
-
});
|
|
613
|
-
this._map.set(sourceTimestampKey, variant);
|
|
614
|
-
const node = this._node_index.get(sourceTimestampKey);
|
|
615
|
-
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
616
|
-
}
|
|
617
|
-
const variant = this._map.get(key);
|
|
618
|
-
const node = this._node_index.get(key);
|
|
619
|
-
if (!node) {
|
|
620
|
-
// for instance localTime is optional
|
|
621
|
-
debugLog("Cannot serVar " + varName + " dataType " + node_opcua_variant_1.DataType[dataType]);
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
|
|
625
|
-
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
626
|
-
}, _ConditionSnapshotImpl__set_twoStateVariable = function _ConditionSnapshotImpl__set_twoStateVariable(varName, value, options) {
|
|
627
|
-
value = !!value;
|
|
628
|
-
const hrKey = _a.normalizeName(varName);
|
|
629
|
-
const idKey = _a.normalizeName(varName + ".Id");
|
|
630
|
-
const variant = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Boolean, value });
|
|
631
|
-
this._map.set(idKey, variant);
|
|
632
|
-
// also change varName with human readable text
|
|
633
|
-
const twoStateNode = this._node_index.get(hrKey);
|
|
634
|
-
if (!twoStateNode) {
|
|
635
|
-
throw new Error("Cannot find twoState Variable with name " + varName);
|
|
636
|
-
}
|
|
637
|
-
if (!(twoStateNode instanceof ua_two_state_variable_1.UATwoStateVariableImpl)) {
|
|
638
|
-
throw new Error("Cannot find twoState Variable with name " + varName + " " + twoStateNode);
|
|
639
|
-
}
|
|
640
|
-
const hrValue = new node_opcua_variant_1.Variant({
|
|
641
|
-
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
642
|
-
value: value ? twoStateNode.getTrueState() : twoStateNode.getFalseState()
|
|
643
|
-
});
|
|
644
|
-
this._map.set(hrKey, hrValue);
|
|
645
|
-
const node = this._node_index.get(idKey);
|
|
646
|
-
// also change ConditionNode if we are on currentBranch
|
|
647
|
-
if (this.isCurrentBranch()) {
|
|
648
|
-
(0, node_opcua_assert_1.assert)(twoStateNode instanceof ua_two_state_variable_1.UATwoStateVariableImpl);
|
|
649
|
-
twoStateNode.setValue(value, options);
|
|
650
|
-
}
|
|
651
|
-
const sourceTimestamp = options?.effectiveTransitionTime || new Date();
|
|
652
|
-
this.emit("valueChanged", node, variant, { sourceTimestamp });
|
|
653
|
-
}, _ConditionSnapshotImpl__get_twoStateVariable = function _ConditionSnapshotImpl__get_twoStateVariable(varName) {
|
|
654
|
-
const key = _a.normalizeName(varName) + ".Id";
|
|
655
|
-
const variant = this._map.get(key);
|
|
656
|
-
// istanbul ignore next
|
|
657
|
-
if (!variant) {
|
|
658
|
-
return "???";
|
|
659
|
-
// throw new Error("Cannot find TwoStateVariable with name " + varName);
|
|
660
|
-
}
|
|
661
|
-
return variant.value;
|
|
662
|
-
};
|
|
663
|
-
ConditionSnapshotImpl.normalizeName = normalizeName;
|
|
672
|
+
_a = ConditionSnapshotImpl;
|
|
664
673
|
//# sourceMappingURL=condition_snapshot_impl.js.map
|