opcjs-client 0.1.13 → 0.1.16-alpha
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/index.cjs +396 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -5
- package/dist/index.d.ts +141 -5
- package/dist/index.js +397 -33
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -27,8 +27,9 @@ var SessionService = class _SessionService extends ServiceBase {
|
|
|
27
27
|
super(authToken, secureChannel);
|
|
28
28
|
this.configuration = configuration;
|
|
29
29
|
}
|
|
30
|
+
logger = opcjsBase.getLogger("services.SessionService");
|
|
30
31
|
async createSession() {
|
|
31
|
-
|
|
32
|
+
this.logger.debug("Creating session...");
|
|
32
33
|
const clientDescription = new opcjsBase.ApplicationDescription();
|
|
33
34
|
clientDescription.applicationUri = this.configuration.applicationUri;
|
|
34
35
|
clientDescription.productUri = this.configuration.productUri;
|
|
@@ -47,7 +48,7 @@ var SessionService = class _SessionService extends ServiceBase {
|
|
|
47
48
|
request.clientCertificate = null;
|
|
48
49
|
request.requestedSessionTimeout = 6e4;
|
|
49
50
|
request.maxResponseMessageSize = 0;
|
|
50
|
-
|
|
51
|
+
this.logger.debug("Sending CreateSessionRequest...");
|
|
51
52
|
const response = await this.secureChannel.issueServiceRequest(request);
|
|
52
53
|
if (!response || !(response instanceof opcjsBase.CreateSessionResponse)) {
|
|
53
54
|
throw new Error("Invalid response type for CreateSessionRequest");
|
|
@@ -67,7 +68,7 @@ var SessionService = class _SessionService extends ServiceBase {
|
|
|
67
68
|
if (!serverEndpoint) {
|
|
68
69
|
throw new Error(`Server endpoint ${endpoint} not found in CreateSessionResponse`);
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
this.logger.debug("Session created with id:", castedResponse.sessionId.identifier);
|
|
71
72
|
return {
|
|
72
73
|
sessionId: castedResponse.sessionId.identifier,
|
|
73
74
|
authToken: castedResponse.authenticationToken,
|
|
@@ -85,9 +86,9 @@ var SessionService = class _SessionService extends ServiceBase {
|
|
|
85
86
|
request.localeIds = ["en-US"];
|
|
86
87
|
request.userIdentityToken = opcjsBase.ExtensionObject.newBinary(identityToken);
|
|
87
88
|
request.userTokenSignature = signatureData;
|
|
88
|
-
|
|
89
|
+
this.logger.debug("Sending ActivateSessionRequest...");
|
|
89
90
|
await this.secureChannel.issueServiceRequest(request);
|
|
90
|
-
|
|
91
|
+
this.logger.debug("Session activated.");
|
|
91
92
|
}
|
|
92
93
|
recreate(authToken) {
|
|
93
94
|
return new _SessionService(authToken, this.secureChannel, this.configuration);
|
|
@@ -170,6 +171,265 @@ var SessionHandler = class {
|
|
|
170
171
|
// src/services/attributeServiceAttributes.ts
|
|
171
172
|
var AttrIdValue = 13;
|
|
172
173
|
|
|
174
|
+
// ../base/src/types/statusCode.ts
|
|
175
|
+
function StatusCodeToString(statusCode) {
|
|
176
|
+
if (statusCode === void 0) {
|
|
177
|
+
return "Unknown";
|
|
178
|
+
}
|
|
179
|
+
const name = Object.entries(StatusCode).find(([, v]) => v === statusCode)?.[0];
|
|
180
|
+
return name ?? `0x${statusCode.toString(16).toUpperCase().padStart(8, "0")}`;
|
|
181
|
+
}
|
|
182
|
+
var StatusCode = /* @__PURE__ */ ((StatusCode2) => {
|
|
183
|
+
StatusCode2[StatusCode2["Good"] = 0] = "Good";
|
|
184
|
+
StatusCode2[StatusCode2["Uncertain"] = 1073741824] = "Uncertain";
|
|
185
|
+
StatusCode2[StatusCode2["Bad"] = 2147483648] = "Bad";
|
|
186
|
+
StatusCode2[StatusCode2["BadUnexpectedError"] = 2147549184] = "BadUnexpectedError";
|
|
187
|
+
StatusCode2[StatusCode2["BadInternalError"] = 2147614720] = "BadInternalError";
|
|
188
|
+
StatusCode2[StatusCode2["BadOutOfMemory"] = 2147680256] = "BadOutOfMemory";
|
|
189
|
+
StatusCode2[StatusCode2["BadResourceUnavailable"] = 2147745792] = "BadResourceUnavailable";
|
|
190
|
+
StatusCode2[StatusCode2["BadCommunicationError"] = 2147811328] = "BadCommunicationError";
|
|
191
|
+
StatusCode2[StatusCode2["BadEncodingError"] = 2147876864] = "BadEncodingError";
|
|
192
|
+
StatusCode2[StatusCode2["BadDecodingError"] = 2147942400] = "BadDecodingError";
|
|
193
|
+
StatusCode2[StatusCode2["BadEncodingLimitsExceeded"] = 2148007936] = "BadEncodingLimitsExceeded";
|
|
194
|
+
StatusCode2[StatusCode2["BadRequestTooLarge"] = 2159542272] = "BadRequestTooLarge";
|
|
195
|
+
StatusCode2[StatusCode2["BadResponseTooLarge"] = 2159607808] = "BadResponseTooLarge";
|
|
196
|
+
StatusCode2[StatusCode2["BadUnknownResponse"] = 2148073472] = "BadUnknownResponse";
|
|
197
|
+
StatusCode2[StatusCode2["BadTimeout"] = 2148139008] = "BadTimeout";
|
|
198
|
+
StatusCode2[StatusCode2["BadServiceUnsupported"] = 2148204544] = "BadServiceUnsupported";
|
|
199
|
+
StatusCode2[StatusCode2["BadShutdown"] = 2148270080] = "BadShutdown";
|
|
200
|
+
StatusCode2[StatusCode2["BadServerNotConnected"] = 2148335616] = "BadServerNotConnected";
|
|
201
|
+
StatusCode2[StatusCode2["BadServerHalted"] = 2148401152] = "BadServerHalted";
|
|
202
|
+
StatusCode2[StatusCode2["BadNothingToDo"] = 2148466688] = "BadNothingToDo";
|
|
203
|
+
StatusCode2[StatusCode2["BadTooManyOperations"] = 2148532224] = "BadTooManyOperations";
|
|
204
|
+
StatusCode2[StatusCode2["BadTooManyMonitoredItems"] = 2161836032] = "BadTooManyMonitoredItems";
|
|
205
|
+
StatusCode2[StatusCode2["BadDataTypeIdUnknown"] = 2148597760] = "BadDataTypeIdUnknown";
|
|
206
|
+
StatusCode2[StatusCode2["BadCertificateInvalid"] = 2148663296] = "BadCertificateInvalid";
|
|
207
|
+
StatusCode2[StatusCode2["BadSecurityChecksFailed"] = 2148728832] = "BadSecurityChecksFailed";
|
|
208
|
+
StatusCode2[StatusCode2["BadCertificatePolicyCheckFailed"] = 2165571584] = "BadCertificatePolicyCheckFailed";
|
|
209
|
+
StatusCode2[StatusCode2["BadCertificateTimeInvalid"] = 2148794368] = "BadCertificateTimeInvalid";
|
|
210
|
+
StatusCode2[StatusCode2["BadCertificateIssuerTimeInvalid"] = 2148859904] = "BadCertificateIssuerTimeInvalid";
|
|
211
|
+
StatusCode2[StatusCode2["BadCertificateHostNameInvalid"] = 2148925440] = "BadCertificateHostNameInvalid";
|
|
212
|
+
StatusCode2[StatusCode2["BadCertificateUriInvalid"] = 2148990976] = "BadCertificateUriInvalid";
|
|
213
|
+
StatusCode2[StatusCode2["BadCertificateUseNotAllowed"] = 2149056512] = "BadCertificateUseNotAllowed";
|
|
214
|
+
StatusCode2[StatusCode2["BadCertificateIssuerUseNotAllowed"] = 2149122048] = "BadCertificateIssuerUseNotAllowed";
|
|
215
|
+
StatusCode2[StatusCode2["BadCertificateUntrusted"] = 2149187584] = "BadCertificateUntrusted";
|
|
216
|
+
StatusCode2[StatusCode2["BadCertificateRevocationUnknown"] = 2149253120] = "BadCertificateRevocationUnknown";
|
|
217
|
+
StatusCode2[StatusCode2["BadCertificateIssuerRevocationUnknown"] = 2149318656] = "BadCertificateIssuerRevocationUnknown";
|
|
218
|
+
StatusCode2[StatusCode2["BadCertificateRevoked"] = 2149384192] = "BadCertificateRevoked";
|
|
219
|
+
StatusCode2[StatusCode2["BadCertificateIssuerRevoked"] = 2149449728] = "BadCertificateIssuerRevoked";
|
|
220
|
+
StatusCode2[StatusCode2["BadCertificateChainIncomplete"] = 2165112832] = "BadCertificateChainIncomplete";
|
|
221
|
+
StatusCode2[StatusCode2["BadUserAccessDenied"] = 2149515264] = "BadUserAccessDenied";
|
|
222
|
+
StatusCode2[StatusCode2["BadIdentityTokenInvalid"] = 2149580800] = "BadIdentityTokenInvalid";
|
|
223
|
+
StatusCode2[StatusCode2["BadIdentityTokenRejected"] = 2149646336] = "BadIdentityTokenRejected";
|
|
224
|
+
StatusCode2[StatusCode2["BadSecureChannelIdInvalid"] = 2149711872] = "BadSecureChannelIdInvalid";
|
|
225
|
+
StatusCode2[StatusCode2["BadInvalidTimestamp"] = 2149777408] = "BadInvalidTimestamp";
|
|
226
|
+
StatusCode2[StatusCode2["BadNonceInvalid"] = 2149842944] = "BadNonceInvalid";
|
|
227
|
+
StatusCode2[StatusCode2["BadSessionIdInvalid"] = 2149908480] = "BadSessionIdInvalid";
|
|
228
|
+
StatusCode2[StatusCode2["BadSessionClosed"] = 2149974016] = "BadSessionClosed";
|
|
229
|
+
StatusCode2[StatusCode2["BadSessionNotActivated"] = 2150039552] = "BadSessionNotActivated";
|
|
230
|
+
StatusCode2[StatusCode2["BadSubscriptionIdInvalid"] = 2150105088] = "BadSubscriptionIdInvalid";
|
|
231
|
+
StatusCode2[StatusCode2["BadRequestHeaderInvalid"] = 2150236160] = "BadRequestHeaderInvalid";
|
|
232
|
+
StatusCode2[StatusCode2["BadTimestampsToReturnInvalid"] = 2150301696] = "BadTimestampsToReturnInvalid";
|
|
233
|
+
StatusCode2[StatusCode2["BadRequestCancelledByClient"] = 2150367232] = "BadRequestCancelledByClient";
|
|
234
|
+
StatusCode2[StatusCode2["BadTooManyArguments"] = 2162491392] = "BadTooManyArguments";
|
|
235
|
+
StatusCode2[StatusCode2["BadLicenseExpired"] = 2165178368] = "BadLicenseExpired";
|
|
236
|
+
StatusCode2[StatusCode2["BadLicenseLimitsExceeded"] = 2165243904] = "BadLicenseLimitsExceeded";
|
|
237
|
+
StatusCode2[StatusCode2["BadLicenseNotAvailable"] = 2165309440] = "BadLicenseNotAvailable";
|
|
238
|
+
StatusCode2[StatusCode2["GoodSubscriptionTransferred"] = 2949120] = "GoodSubscriptionTransferred";
|
|
239
|
+
StatusCode2[StatusCode2["GoodCompletesAsynchronously"] = 3014656] = "GoodCompletesAsynchronously";
|
|
240
|
+
StatusCode2[StatusCode2["GoodOverload"] = 3080192] = "GoodOverload";
|
|
241
|
+
StatusCode2[StatusCode2["GoodClamped"] = 3145728] = "GoodClamped";
|
|
242
|
+
StatusCode2[StatusCode2["BadNoCommunication"] = 2150694912] = "BadNoCommunication";
|
|
243
|
+
StatusCode2[StatusCode2["BadWaitingForInitialData"] = 2150760448] = "BadWaitingForInitialData";
|
|
244
|
+
StatusCode2[StatusCode2["BadNodeIdInvalid"] = 2150825984] = "BadNodeIdInvalid";
|
|
245
|
+
StatusCode2[StatusCode2["BadNodeIdUnknown"] = 2150891520] = "BadNodeIdUnknown";
|
|
246
|
+
StatusCode2[StatusCode2["BadAttributeIdInvalid"] = 2150957056] = "BadAttributeIdInvalid";
|
|
247
|
+
StatusCode2[StatusCode2["BadIndexRangeInvalid"] = 2151022592] = "BadIndexRangeInvalid";
|
|
248
|
+
StatusCode2[StatusCode2["BadIndexRangeNoData"] = 2151088128] = "BadIndexRangeNoData";
|
|
249
|
+
StatusCode2[StatusCode2["BadDataEncodingInvalid"] = 2151153664] = "BadDataEncodingInvalid";
|
|
250
|
+
StatusCode2[StatusCode2["BadDataEncodingUnsupported"] = 2151219200] = "BadDataEncodingUnsupported";
|
|
251
|
+
StatusCode2[StatusCode2["BadNotReadable"] = 2151284736] = "BadNotReadable";
|
|
252
|
+
StatusCode2[StatusCode2["BadNotWritable"] = 2151350272] = "BadNotWritable";
|
|
253
|
+
StatusCode2[StatusCode2["BadOutOfRange"] = 2151415808] = "BadOutOfRange";
|
|
254
|
+
StatusCode2[StatusCode2["BadNotSupported"] = 2151481344] = "BadNotSupported";
|
|
255
|
+
StatusCode2[StatusCode2["BadNotFound"] = 2151546880] = "BadNotFound";
|
|
256
|
+
StatusCode2[StatusCode2["BadObjectDeleted"] = 2151612416] = "BadObjectDeleted";
|
|
257
|
+
StatusCode2[StatusCode2["BadNotImplemented"] = 2151677952] = "BadNotImplemented";
|
|
258
|
+
StatusCode2[StatusCode2["BadMonitoringModeInvalid"] = 2151743488] = "BadMonitoringModeInvalid";
|
|
259
|
+
StatusCode2[StatusCode2["BadMonitoredItemIdInvalid"] = 2151809024] = "BadMonitoredItemIdInvalid";
|
|
260
|
+
StatusCode2[StatusCode2["BadMonitoredItemFilterInvalid"] = 2151874560] = "BadMonitoredItemFilterInvalid";
|
|
261
|
+
StatusCode2[StatusCode2["BadMonitoredItemFilterUnsupported"] = 2151940096] = "BadMonitoredItemFilterUnsupported";
|
|
262
|
+
StatusCode2[StatusCode2["BadFilterNotAllowed"] = 2152005632] = "BadFilterNotAllowed";
|
|
263
|
+
StatusCode2[StatusCode2["BadStructureMissing"] = 2152071168] = "BadStructureMissing";
|
|
264
|
+
StatusCode2[StatusCode2["BadEventFilterInvalid"] = 2152136704] = "BadEventFilterInvalid";
|
|
265
|
+
StatusCode2[StatusCode2["BadContentFilterInvalid"] = 2152202240] = "BadContentFilterInvalid";
|
|
266
|
+
StatusCode2[StatusCode2["BadFilterOperatorInvalid"] = 2160132096] = "BadFilterOperatorInvalid";
|
|
267
|
+
StatusCode2[StatusCode2["BadFilterOperatorUnsupported"] = 2160197632] = "BadFilterOperatorUnsupported";
|
|
268
|
+
StatusCode2[StatusCode2["BadFilterOperandCountMismatch"] = 2160263168] = "BadFilterOperandCountMismatch";
|
|
269
|
+
StatusCode2[StatusCode2["BadFilterOperandInvalid"] = 2152267776] = "BadFilterOperandInvalid";
|
|
270
|
+
StatusCode2[StatusCode2["BadFilterElementInvalid"] = 2160328704] = "BadFilterElementInvalid";
|
|
271
|
+
StatusCode2[StatusCode2["BadFilterLiteralInvalid"] = 2160394240] = "BadFilterLiteralInvalid";
|
|
272
|
+
StatusCode2[StatusCode2["BadContinuationPointInvalid"] = 2152333312] = "BadContinuationPointInvalid";
|
|
273
|
+
StatusCode2[StatusCode2["BadNoContinuationPoints"] = 2152398848] = "BadNoContinuationPoints";
|
|
274
|
+
StatusCode2[StatusCode2["BadReferenceTypeIdInvalid"] = 2152464384] = "BadReferenceTypeIdInvalid";
|
|
275
|
+
StatusCode2[StatusCode2["BadBrowseDirectionInvalid"] = 2152529920] = "BadBrowseDirectionInvalid";
|
|
276
|
+
StatusCode2[StatusCode2["BadNodeNotInView"] = 2152595456] = "BadNodeNotInView";
|
|
277
|
+
StatusCode2[StatusCode2["BadNumericOverflow"] = 2165440512] = "BadNumericOverflow";
|
|
278
|
+
StatusCode2[StatusCode2["BadServerUriInvalid"] = 2152660992] = "BadServerUriInvalid";
|
|
279
|
+
StatusCode2[StatusCode2["BadServerNameMissing"] = 2152726528] = "BadServerNameMissing";
|
|
280
|
+
StatusCode2[StatusCode2["BadDiscoveryUrlMissing"] = 2152792064] = "BadDiscoveryUrlMissing";
|
|
281
|
+
StatusCode2[StatusCode2["BadSempahoreFileMissing"] = 2152857600] = "BadSempahoreFileMissing";
|
|
282
|
+
StatusCode2[StatusCode2["BadRequestTypeInvalid"] = 2152923136] = "BadRequestTypeInvalid";
|
|
283
|
+
StatusCode2[StatusCode2["BadSecurityModeRejected"] = 2152988672] = "BadSecurityModeRejected";
|
|
284
|
+
StatusCode2[StatusCode2["BadSecurityPolicyRejected"] = 2153054208] = "BadSecurityPolicyRejected";
|
|
285
|
+
StatusCode2[StatusCode2["BadTooManySessions"] = 2153119744] = "BadTooManySessions";
|
|
286
|
+
StatusCode2[StatusCode2["BadUserSignatureInvalid"] = 2153185280] = "BadUserSignatureInvalid";
|
|
287
|
+
StatusCode2[StatusCode2["BadApplicationSignatureInvalid"] = 2153250816] = "BadApplicationSignatureInvalid";
|
|
288
|
+
StatusCode2[StatusCode2["BadNoValidCertificates"] = 2153316352] = "BadNoValidCertificates";
|
|
289
|
+
StatusCode2[StatusCode2["BadIdentityChangeNotSupported"] = 2160459776] = "BadIdentityChangeNotSupported";
|
|
290
|
+
StatusCode2[StatusCode2["BadRequestCancelledByRequest"] = 2153381888] = "BadRequestCancelledByRequest";
|
|
291
|
+
StatusCode2[StatusCode2["BadParentNodeIdInvalid"] = 2153447424] = "BadParentNodeIdInvalid";
|
|
292
|
+
StatusCode2[StatusCode2["BadReferenceNotAllowed"] = 2153512960] = "BadReferenceNotAllowed";
|
|
293
|
+
StatusCode2[StatusCode2["BadNodeIdRejected"] = 2153578496] = "BadNodeIdRejected";
|
|
294
|
+
StatusCode2[StatusCode2["BadNodeIdExists"] = 2153644032] = "BadNodeIdExists";
|
|
295
|
+
StatusCode2[StatusCode2["BadNodeClassInvalid"] = 2153709568] = "BadNodeClassInvalid";
|
|
296
|
+
StatusCode2[StatusCode2["BadBrowseNameInvalid"] = 2153775104] = "BadBrowseNameInvalid";
|
|
297
|
+
StatusCode2[StatusCode2["BadBrowseNameDuplicated"] = 2153840640] = "BadBrowseNameDuplicated";
|
|
298
|
+
StatusCode2[StatusCode2["BadNodeAttributesInvalid"] = 2153906176] = "BadNodeAttributesInvalid";
|
|
299
|
+
StatusCode2[StatusCode2["BadTypeDefinitionInvalid"] = 2153971712] = "BadTypeDefinitionInvalid";
|
|
300
|
+
StatusCode2[StatusCode2["BadSourceNodeIdInvalid"] = 2154037248] = "BadSourceNodeIdInvalid";
|
|
301
|
+
StatusCode2[StatusCode2["BadTargetNodeIdInvalid"] = 2154102784] = "BadTargetNodeIdInvalid";
|
|
302
|
+
StatusCode2[StatusCode2["BadDuplicateReferenceNotAllowed"] = 2154168320] = "BadDuplicateReferenceNotAllowed";
|
|
303
|
+
StatusCode2[StatusCode2["BadInvalidSelfReference"] = 2154233856] = "BadInvalidSelfReference";
|
|
304
|
+
StatusCode2[StatusCode2["BadReferenceLocalOnly"] = 2154299392] = "BadReferenceLocalOnly";
|
|
305
|
+
StatusCode2[StatusCode2["BadNoDeleteRights"] = 2154364928] = "BadNoDeleteRights";
|
|
306
|
+
StatusCode2[StatusCode2["UncertainReferenceNotDeleted"] = 1086062592] = "UncertainReferenceNotDeleted";
|
|
307
|
+
StatusCode2[StatusCode2["BadServerIndexInvalid"] = 2154430464] = "BadServerIndexInvalid";
|
|
308
|
+
StatusCode2[StatusCode2["BadViewIdUnknown"] = 2154496e3] = "BadViewIdUnknown";
|
|
309
|
+
StatusCode2[StatusCode2["BadViewTimestampInvalid"] = 2160656384] = "BadViewTimestampInvalid";
|
|
310
|
+
StatusCode2[StatusCode2["BadViewParameterMismatch"] = 2160721920] = "BadViewParameterMismatch";
|
|
311
|
+
StatusCode2[StatusCode2["BadViewVersionInvalid"] = 2160787456] = "BadViewVersionInvalid";
|
|
312
|
+
StatusCode2[StatusCode2["UncertainNotAllNodesAvailable"] = 1086324736] = "UncertainNotAllNodesAvailable";
|
|
313
|
+
StatusCode2[StatusCode2["GoodResultsMayBeIncomplete"] = 12189696] = "GoodResultsMayBeIncomplete";
|
|
314
|
+
StatusCode2[StatusCode2["BadNotTypeDefinition"] = 2160590848] = "BadNotTypeDefinition";
|
|
315
|
+
StatusCode2[StatusCode2["UncertainReferenceOutOfServer"] = 1080819712] = "UncertainReferenceOutOfServer";
|
|
316
|
+
StatusCode2[StatusCode2["BadTooManyMatches"] = 2154627072] = "BadTooManyMatches";
|
|
317
|
+
StatusCode2[StatusCode2["BadQueryTooComplex"] = 2154692608] = "BadQueryTooComplex";
|
|
318
|
+
StatusCode2[StatusCode2["BadNoMatch"] = 2154758144] = "BadNoMatch";
|
|
319
|
+
StatusCode2[StatusCode2["BadMaxAgeInvalid"] = 2154823680] = "BadMaxAgeInvalid";
|
|
320
|
+
StatusCode2[StatusCode2["BadSecurityModeInsufficient"] = 2162556928] = "BadSecurityModeInsufficient";
|
|
321
|
+
StatusCode2[StatusCode2["BadHistoryOperationInvalid"] = 2154889216] = "BadHistoryOperationInvalid";
|
|
322
|
+
StatusCode2[StatusCode2["BadHistoryOperationUnsupported"] = 2154954752] = "BadHistoryOperationUnsupported";
|
|
323
|
+
StatusCode2[StatusCode2["BadInvalidTimestampArgument"] = 2159869952] = "BadInvalidTimestampArgument";
|
|
324
|
+
StatusCode2[StatusCode2["BadWriteNotSupported"] = 2155020288] = "BadWriteNotSupported";
|
|
325
|
+
StatusCode2[StatusCode2["BadTypeMismatch"] = 2155085824] = "BadTypeMismatch";
|
|
326
|
+
StatusCode2[StatusCode2["BadMethodInvalid"] = 2155151360] = "BadMethodInvalid";
|
|
327
|
+
StatusCode2[StatusCode2["BadArgumentsMissing"] = 2155216896] = "BadArgumentsMissing";
|
|
328
|
+
StatusCode2[StatusCode2["BadNotExecutable"] = 2165374976] = "BadNotExecutable";
|
|
329
|
+
StatusCode2[StatusCode2["BadTooManySubscriptions"] = 2155282432] = "BadTooManySubscriptions";
|
|
330
|
+
StatusCode2[StatusCode2["BadTooManyPublishRequests"] = 2155347968] = "BadTooManyPublishRequests";
|
|
331
|
+
StatusCode2[StatusCode2["BadNoSubscription"] = 2155413504] = "BadNoSubscription";
|
|
332
|
+
StatusCode2[StatusCode2["BadSequenceNumberUnknown"] = 2155479040] = "BadSequenceNumberUnknown";
|
|
333
|
+
StatusCode2[StatusCode2["BadMessageNotAvailable"] = 2155544576] = "BadMessageNotAvailable";
|
|
334
|
+
StatusCode2[StatusCode2["BadInsufficientClientProfile"] = 2155610112] = "BadInsufficientClientProfile";
|
|
335
|
+
StatusCode2[StatusCode2["BadStateNotActive"] = 2160001024] = "BadStateNotActive";
|
|
336
|
+
StatusCode2[StatusCode2["BadAlreadyExists"] = 2165637120] = "BadAlreadyExists";
|
|
337
|
+
StatusCode2[StatusCode2["BadTcpServerTooBusy"] = 2155675648] = "BadTcpServerTooBusy";
|
|
338
|
+
StatusCode2[StatusCode2["BadTcpMessageTypeInvalid"] = 2155741184] = "BadTcpMessageTypeInvalid";
|
|
339
|
+
StatusCode2[StatusCode2["BadTcpSecureChannelUnknown"] = 2155806720] = "BadTcpSecureChannelUnknown";
|
|
340
|
+
StatusCode2[StatusCode2["BadTcpMessageTooLarge"] = 2155872256] = "BadTcpMessageTooLarge";
|
|
341
|
+
StatusCode2[StatusCode2["BadTcpNotEnoughResources"] = 2155937792] = "BadTcpNotEnoughResources";
|
|
342
|
+
StatusCode2[StatusCode2["BadTcpInternalError"] = 2156003328] = "BadTcpInternalError";
|
|
343
|
+
StatusCode2[StatusCode2["BadTcpEndpointUrlInvalid"] = 2156068864] = "BadTcpEndpointUrlInvalid";
|
|
344
|
+
StatusCode2[StatusCode2["BadRequestInterrupted"] = 2156134400] = "BadRequestInterrupted";
|
|
345
|
+
StatusCode2[StatusCode2["BadRequestTimeout"] = 2156199936] = "BadRequestTimeout";
|
|
346
|
+
StatusCode2[StatusCode2["BadSecureChannelClosed"] = 2156265472] = "BadSecureChannelClosed";
|
|
347
|
+
StatusCode2[StatusCode2["BadSecureChannelTokenUnknown"] = 2156331008] = "BadSecureChannelTokenUnknown";
|
|
348
|
+
StatusCode2[StatusCode2["BadSequenceNumberInvalid"] = 2156396544] = "BadSequenceNumberInvalid";
|
|
349
|
+
StatusCode2[StatusCode2["BadProtocolVersionUnsupported"] = 2159935488] = "BadProtocolVersionUnsupported";
|
|
350
|
+
StatusCode2[StatusCode2["BadConfigurationError"] = 2156462080] = "BadConfigurationError";
|
|
351
|
+
StatusCode2[StatusCode2["BadNotConnected"] = 2156527616] = "BadNotConnected";
|
|
352
|
+
StatusCode2[StatusCode2["BadDeviceFailure"] = 2156593152] = "BadDeviceFailure";
|
|
353
|
+
StatusCode2[StatusCode2["BadSensorFailure"] = 2156658688] = "BadSensorFailure";
|
|
354
|
+
StatusCode2[StatusCode2["BadOutOfService"] = 2156724224] = "BadOutOfService";
|
|
355
|
+
StatusCode2[StatusCode2["BadDeadbandFilterInvalid"] = 2156789760] = "BadDeadbandFilterInvalid";
|
|
356
|
+
StatusCode2[StatusCode2["UncertainNoCommunicationLastUsableValue"] = 1083113472] = "UncertainNoCommunicationLastUsableValue";
|
|
357
|
+
StatusCode2[StatusCode2["UncertainLastUsableValue"] = 1083179008] = "UncertainLastUsableValue";
|
|
358
|
+
StatusCode2[StatusCode2["UncertainSubstituteValue"] = 1083244544] = "UncertainSubstituteValue";
|
|
359
|
+
StatusCode2[StatusCode2["UncertainInitialValue"] = 1083310080] = "UncertainInitialValue";
|
|
360
|
+
StatusCode2[StatusCode2["UncertainSensorNotAccurate"] = 1083375616] = "UncertainSensorNotAccurate";
|
|
361
|
+
StatusCode2[StatusCode2["UncertainEngineeringUnitsExceeded"] = 1083441152] = "UncertainEngineeringUnitsExceeded";
|
|
362
|
+
StatusCode2[StatusCode2["UncertainSubNormal"] = 1083506688] = "UncertainSubNormal";
|
|
363
|
+
StatusCode2[StatusCode2["GoodLocalOverride"] = 9830400] = "GoodLocalOverride";
|
|
364
|
+
StatusCode2[StatusCode2["BadRefreshInProgress"] = 2157379584] = "BadRefreshInProgress";
|
|
365
|
+
StatusCode2[StatusCode2["BadConditionAlreadyDisabled"] = 2157445120] = "BadConditionAlreadyDisabled";
|
|
366
|
+
StatusCode2[StatusCode2["BadConditionAlreadyEnabled"] = 2160852992] = "BadConditionAlreadyEnabled";
|
|
367
|
+
StatusCode2[StatusCode2["BadConditionDisabled"] = 2157510656] = "BadConditionDisabled";
|
|
368
|
+
StatusCode2[StatusCode2["BadEventIdUnknown"] = 2157576192] = "BadEventIdUnknown";
|
|
369
|
+
StatusCode2[StatusCode2["BadEventNotAcknowledgeable"] = 2159738880] = "BadEventNotAcknowledgeable";
|
|
370
|
+
StatusCode2[StatusCode2["BadDialogNotActive"] = 2160918528] = "BadDialogNotActive";
|
|
371
|
+
StatusCode2[StatusCode2["BadDialogResponseInvalid"] = 2160984064] = "BadDialogResponseInvalid";
|
|
372
|
+
StatusCode2[StatusCode2["BadConditionBranchAlreadyAcked"] = 2161049600] = "BadConditionBranchAlreadyAcked";
|
|
373
|
+
StatusCode2[StatusCode2["BadConditionBranchAlreadyConfirmed"] = 2161115136] = "BadConditionBranchAlreadyConfirmed";
|
|
374
|
+
StatusCode2[StatusCode2["BadConditionAlreadyShelved"] = 2161180672] = "BadConditionAlreadyShelved";
|
|
375
|
+
StatusCode2[StatusCode2["BadConditionNotShelved"] = 2161246208] = "BadConditionNotShelved";
|
|
376
|
+
StatusCode2[StatusCode2["BadShelvingTimeOutOfRange"] = 2161311744] = "BadShelvingTimeOutOfRange";
|
|
377
|
+
StatusCode2[StatusCode2["BadNoData"] = 2157641728] = "BadNoData";
|
|
378
|
+
StatusCode2[StatusCode2["BadBoundNotFound"] = 2161573888] = "BadBoundNotFound";
|
|
379
|
+
StatusCode2[StatusCode2["BadBoundNotSupported"] = 2161639424] = "BadBoundNotSupported";
|
|
380
|
+
StatusCode2[StatusCode2["BadDataLost"] = 2157772800] = "BadDataLost";
|
|
381
|
+
StatusCode2[StatusCode2["BadDataUnavailable"] = 2157838336] = "BadDataUnavailable";
|
|
382
|
+
StatusCode2[StatusCode2["BadEntryExists"] = 2157903872] = "BadEntryExists";
|
|
383
|
+
StatusCode2[StatusCode2["BadNoEntryExists"] = 2157969408] = "BadNoEntryExists";
|
|
384
|
+
StatusCode2[StatusCode2["BadTimestampNotSupported"] = 2158034944] = "BadTimestampNotSupported";
|
|
385
|
+
StatusCode2[StatusCode2["GoodEntryInserted"] = 10616832] = "GoodEntryInserted";
|
|
386
|
+
StatusCode2[StatusCode2["GoodEntryReplaced"] = 10682368] = "GoodEntryReplaced";
|
|
387
|
+
StatusCode2[StatusCode2["UncertainDataSubNormal"] = 1084489728] = "UncertainDataSubNormal";
|
|
388
|
+
StatusCode2[StatusCode2["GoodNoData"] = 10813440] = "GoodNoData";
|
|
389
|
+
StatusCode2[StatusCode2["GoodMoreData"] = 10878976] = "GoodMoreData";
|
|
390
|
+
StatusCode2[StatusCode2["BadAggregateListMismatch"] = 2161377280] = "BadAggregateListMismatch";
|
|
391
|
+
StatusCode2[StatusCode2["BadAggregateNotSupported"] = 2161442816] = "BadAggregateNotSupported";
|
|
392
|
+
StatusCode2[StatusCode2["BadAggregateInvalidInputs"] = 2161508352] = "BadAggregateInvalidInputs";
|
|
393
|
+
StatusCode2[StatusCode2["BadAggregateConfigurationRejected"] = 2161770496] = "BadAggregateConfigurationRejected";
|
|
394
|
+
StatusCode2[StatusCode2["GoodDataIgnored"] = 14221312] = "GoodDataIgnored";
|
|
395
|
+
StatusCode2[StatusCode2["BadRequestNotAllowed"] = 2162425856] = "BadRequestNotAllowed";
|
|
396
|
+
StatusCode2[StatusCode2["BadRequestNotComplete"] = 2165506048] = "BadRequestNotComplete";
|
|
397
|
+
StatusCode2[StatusCode2["GoodEdited"] = 14417920] = "GoodEdited";
|
|
398
|
+
StatusCode2[StatusCode2["GoodPostActionFailed"] = 14483456] = "GoodPostActionFailed";
|
|
399
|
+
StatusCode2[StatusCode2["UncertainDominantValueChanged"] = 1088290816] = "UncertainDominantValueChanged";
|
|
400
|
+
StatusCode2[StatusCode2["GoodDependentValueChanged"] = 14680064] = "GoodDependentValueChanged";
|
|
401
|
+
StatusCode2[StatusCode2["BadDominantValueChanged"] = 2162229248] = "BadDominantValueChanged";
|
|
402
|
+
StatusCode2[StatusCode2["UncertainDependentValueChanged"] = 1088552960] = "UncertainDependentValueChanged";
|
|
403
|
+
StatusCode2[StatusCode2["BadDependentValueChanged"] = 2162360320] = "BadDependentValueChanged";
|
|
404
|
+
StatusCode2[StatusCode2["GoodEditedDependentValueChanged"] = 18219008] = "GoodEditedDependentValueChanged";
|
|
405
|
+
StatusCode2[StatusCode2["GoodEditedDominantValueChanged"] = 18284544] = "GoodEditedDominantValueChanged";
|
|
406
|
+
StatusCode2[StatusCode2["GoodEditedDominantValueChangedDependentValueChanged"] = 18350080] = "GoodEditedDominantValueChangedDependentValueChanged";
|
|
407
|
+
StatusCode2[StatusCode2["BadEditedOutOfRange"] = 2165899264] = "BadEditedOutOfRange";
|
|
408
|
+
StatusCode2[StatusCode2["BadInitialValueOutOfRange"] = 2165964800] = "BadInitialValueOutOfRange";
|
|
409
|
+
StatusCode2[StatusCode2["BadOutOfRangeDominantValueChanged"] = 2166030336] = "BadOutOfRangeDominantValueChanged";
|
|
410
|
+
StatusCode2[StatusCode2["BadEditedOutOfRangeDominantValueChanged"] = 2166095872] = "BadEditedOutOfRangeDominantValueChanged";
|
|
411
|
+
StatusCode2[StatusCode2["BadOutOfRangeDominantValueChangedDependentValueChanged"] = 2166161408] = "BadOutOfRangeDominantValueChangedDependentValueChanged";
|
|
412
|
+
StatusCode2[StatusCode2["BadEditedOutOfRangeDominantValueChangedDependentValueChanged"] = 2166226944] = "BadEditedOutOfRangeDominantValueChangedDependentValueChanged";
|
|
413
|
+
StatusCode2[StatusCode2["GoodCommunicationEvent"] = 10944512] = "GoodCommunicationEvent";
|
|
414
|
+
StatusCode2[StatusCode2["GoodShutdownEvent"] = 11010048] = "GoodShutdownEvent";
|
|
415
|
+
StatusCode2[StatusCode2["GoodCallAgain"] = 11075584] = "GoodCallAgain";
|
|
416
|
+
StatusCode2[StatusCode2["GoodNonCriticalTimeout"] = 11141120] = "GoodNonCriticalTimeout";
|
|
417
|
+
StatusCode2[StatusCode2["BadInvalidArgument"] = 2158690304] = "BadInvalidArgument";
|
|
418
|
+
StatusCode2[StatusCode2["BadConnectionRejected"] = 2158755840] = "BadConnectionRejected";
|
|
419
|
+
StatusCode2[StatusCode2["BadDisconnect"] = 2158821376] = "BadDisconnect";
|
|
420
|
+
StatusCode2[StatusCode2["BadConnectionClosed"] = 2158886912] = "BadConnectionClosed";
|
|
421
|
+
StatusCode2[StatusCode2["BadInvalidState"] = 2158952448] = "BadInvalidState";
|
|
422
|
+
StatusCode2[StatusCode2["BadEndOfStream"] = 2159017984] = "BadEndOfStream";
|
|
423
|
+
StatusCode2[StatusCode2["BadNoDataAvailable"] = 2159083520] = "BadNoDataAvailable";
|
|
424
|
+
StatusCode2[StatusCode2["BadWaitingForResponse"] = 2159149056] = "BadWaitingForResponse";
|
|
425
|
+
StatusCode2[StatusCode2["BadOperationAbandoned"] = 2159214592] = "BadOperationAbandoned";
|
|
426
|
+
StatusCode2[StatusCode2["BadExpectedStreamToBlock"] = 2159280128] = "BadExpectedStreamToBlock";
|
|
427
|
+
StatusCode2[StatusCode2["BadWouldBlock"] = 2159345664] = "BadWouldBlock";
|
|
428
|
+
StatusCode2[StatusCode2["BadSyntaxError"] = 2159411200] = "BadSyntaxError";
|
|
429
|
+
StatusCode2[StatusCode2["BadMaxConnectionsReached"] = 2159476736] = "BadMaxConnectionsReached";
|
|
430
|
+
return StatusCode2;
|
|
431
|
+
})(StatusCode || {});
|
|
432
|
+
|
|
173
433
|
// src/services/attributeService.ts
|
|
174
434
|
var AttributeService = class extends ServiceBase {
|
|
175
435
|
async ReadValue(nodeIds) {
|
|
@@ -189,9 +449,9 @@ var AttributeService = class extends ServiceBase {
|
|
|
189
449
|
console.log("Sending ReadRequest...");
|
|
190
450
|
const response = await this.secureChannel.issueServiceRequest(request);
|
|
191
451
|
const results = new Array();
|
|
192
|
-
for (
|
|
452
|
+
for (const dataValue of response.results ?? []) {
|
|
193
453
|
const result = {
|
|
194
|
-
status: dataValue.statusCode
|
|
454
|
+
status: StatusCodeToString(dataValue.statusCode),
|
|
195
455
|
value: dataValue.value
|
|
196
456
|
};
|
|
197
457
|
results.push(result);
|
|
@@ -235,7 +495,7 @@ var SubscriptionHandler = class {
|
|
|
235
495
|
}
|
|
236
496
|
const subscriptionId = await this.subscriptionService.createSubscription();
|
|
237
497
|
const items = [];
|
|
238
|
-
for (
|
|
498
|
+
for (const id of ids) {
|
|
239
499
|
const entry = new SubscriptionHandlerEntry(
|
|
240
500
|
subscriptionId,
|
|
241
501
|
this.nextHandle++,
|
|
@@ -263,12 +523,12 @@ var SubscriptionHandler = class {
|
|
|
263
523
|
const response = await this.subscriptionService.publish(acknowledgements);
|
|
264
524
|
const messagesToAcknowledge = response.notificationMessage.sequenceNumber;
|
|
265
525
|
const notificationDatas = response.notificationMessage.notificationData;
|
|
266
|
-
for (
|
|
526
|
+
for (const notificationData of notificationDatas) {
|
|
267
527
|
const decodedData = notificationData.data;
|
|
268
528
|
const typeNodeId = notificationData.typeId;
|
|
269
529
|
if (typeNodeId.namespace === 0 && typeNodeId.identifier === 811) {
|
|
270
530
|
const dataChangeNotification = decodedData;
|
|
271
|
-
for (
|
|
531
|
+
for (const item of dataChangeNotification.monitoredItems) {
|
|
272
532
|
const clientHandle = item.clientHandle;
|
|
273
533
|
const value = item.value;
|
|
274
534
|
const entry = this.entries.find((e) => e.handle == clientHandle);
|
|
@@ -348,6 +608,34 @@ var MonitoredItemService = class extends ServiceBase {
|
|
|
348
608
|
super(authToken, secureChannel);
|
|
349
609
|
}
|
|
350
610
|
};
|
|
611
|
+
var MethodService = class extends ServiceBase {
|
|
612
|
+
/**
|
|
613
|
+
* Calls one or more methods on the server (OPC UA Part 4, Section 5.11.2).
|
|
614
|
+
* @param methodsToCall - Array of CallMethodRequest describing each method to invoke.
|
|
615
|
+
* @returns Array of CallMethodResult, one per requested method.
|
|
616
|
+
*/
|
|
617
|
+
async call(methodsToCall) {
|
|
618
|
+
const request = new opcjsBase.CallRequest();
|
|
619
|
+
request.requestHeader = this.createRequestHeader();
|
|
620
|
+
request.methodsToCall = methodsToCall;
|
|
621
|
+
const response = await this.secureChannel.issueServiceRequest(request);
|
|
622
|
+
return response.results.map((result) => ({
|
|
623
|
+
status: StatusCodeToString(result.statusCode),
|
|
624
|
+
value: result.outputArguments.map((arg) => arg.value)
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
627
|
+
constructor(authToken, secureChannel) {
|
|
628
|
+
super(authToken, secureChannel);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
// src/callMethodResult.ts
|
|
633
|
+
var CallMethodResult = class {
|
|
634
|
+
constructor(values, status) {
|
|
635
|
+
this.values = values;
|
|
636
|
+
this.status = status;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
351
639
|
|
|
352
640
|
// src/client.ts
|
|
353
641
|
var Client = class {
|
|
@@ -355,11 +643,15 @@ var Client = class {
|
|
|
355
643
|
this.configuration = configuration;
|
|
356
644
|
this.identity = identity;
|
|
357
645
|
this.endpointUrl = endpointUrl;
|
|
646
|
+
opcjsBase.initLoggerProvider(configuration.loggerFactory);
|
|
647
|
+
this.logger = opcjsBase.getLogger("Client");
|
|
358
648
|
}
|
|
359
649
|
endpointUrl;
|
|
360
|
-
|
|
650
|
+
attributeService;
|
|
651
|
+
methodService;
|
|
361
652
|
session;
|
|
362
653
|
subscriptionHandler;
|
|
654
|
+
logger;
|
|
363
655
|
getSession() {
|
|
364
656
|
if (!this.session) {
|
|
365
657
|
throw new Error("No session available");
|
|
@@ -367,43 +659,99 @@ var Client = class {
|
|
|
367
659
|
return this.session;
|
|
368
660
|
}
|
|
369
661
|
async connect() {
|
|
370
|
-
const
|
|
662
|
+
const wsOptions = { endpoint: this.endpointUrl };
|
|
663
|
+
const ws = new opcjsBase.WebSocketFascade(wsOptions);
|
|
664
|
+
const webSocketReadableStream = new opcjsBase.WebSocketReadableStream(ws, 1e3);
|
|
665
|
+
const webSocketWritableStream = new opcjsBase.WebSocketWritableStream(ws);
|
|
666
|
+
const scContext = new opcjsBase.SecureChannelContext(this.endpointUrl);
|
|
667
|
+
const tcpMessageInjector = new opcjsBase.TcpMessageInjector();
|
|
668
|
+
const tcpConnectionHandler = new opcjsBase.TcpConnectionHandler(tcpMessageInjector, scContext);
|
|
669
|
+
const tcpMessageDecoupler = new opcjsBase.TcpMessageDecoupler(tcpConnectionHandler.onTcpMessage.bind(tcpConnectionHandler));
|
|
670
|
+
const scMessageEncoder = new opcjsBase.SecureChannelMesssageEncoder(scContext);
|
|
671
|
+
const scTypeDecoder = new opcjsBase.SecureChannelTypeDecoder(
|
|
672
|
+
this.configuration.decoder
|
|
673
|
+
);
|
|
674
|
+
const scMessageDecoder = new opcjsBase.SecureChannelMessageDecoder(scContext);
|
|
675
|
+
const scTypeEncoder = new opcjsBase.SecureChannelTypeEncoder(
|
|
676
|
+
this.configuration.encoder
|
|
677
|
+
);
|
|
678
|
+
const scChunkWriter = new opcjsBase.SecureChannelChunkWriter(scContext);
|
|
679
|
+
const scChunkReader = new opcjsBase.SecureChannelChunkReader(scContext);
|
|
680
|
+
webSocketReadableStream.pipeTo(tcpMessageDecoupler.writable);
|
|
681
|
+
tcpMessageDecoupler.readable.pipeTo(scMessageDecoder.writable);
|
|
682
|
+
scMessageDecoder.readable.pipeTo(scChunkReader.writable);
|
|
683
|
+
scChunkReader.readable.pipeTo(scTypeDecoder.writable);
|
|
684
|
+
scTypeEncoder.readable.pipeTo(scChunkWriter.writable);
|
|
685
|
+
scChunkWriter.readable.pipeTo(scMessageEncoder.writable);
|
|
686
|
+
scMessageEncoder.readable.pipeTo(tcpMessageInjector.writable);
|
|
687
|
+
tcpMessageInjector.readable.pipeTo(webSocketWritableStream);
|
|
688
|
+
const sc = new opcjsBase.SecureChannelFacade(scContext, scTypeDecoder, scTypeEncoder);
|
|
371
689
|
let connected = false;
|
|
372
690
|
while (!connected) {
|
|
373
|
-
|
|
374
|
-
|
|
691
|
+
this.logger.debug(`Connecting to OPC UA server at ${this.endpointUrl}...`);
|
|
692
|
+
await ws.connect();
|
|
693
|
+
this.logger.debug("WebSocket connection established, now establishing TCP connection...");
|
|
694
|
+
connected = await tcpConnectionHandler.connect(this.endpointUrl);
|
|
375
695
|
if (!connected) {
|
|
376
|
-
|
|
696
|
+
this.logger.info("Connection failed, retrying in 2 seconds...");
|
|
377
697
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
378
698
|
}
|
|
379
699
|
}
|
|
380
|
-
|
|
381
|
-
this.
|
|
382
|
-
await
|
|
383
|
-
|
|
700
|
+
this.logger.info("Connected to OPC UA server.");
|
|
701
|
+
this.logger.debug("Opening secure channel...");
|
|
702
|
+
await sc.openSecureChannel();
|
|
703
|
+
this.logger.debug("Secure channel established.");
|
|
704
|
+
this.logger.debug("Creating session...");
|
|
705
|
+
const sessionHandler = new SessionHandler(sc, this.configuration);
|
|
384
706
|
this.session = await sessionHandler.createNewSession(this.identity);
|
|
707
|
+
this.logger.debug("Session created.");
|
|
708
|
+
this.logger.debug("Initializing services...");
|
|
709
|
+
this.attributeService = new AttributeService(this.session.getAuthToken(), sc);
|
|
710
|
+
this.methodService = new MethodService(this.session.getAuthToken(), sc);
|
|
385
711
|
this.subscriptionHandler = new SubscriptionHandler(
|
|
386
|
-
new SubscriptionService(this.session.getAuthToken(),
|
|
387
|
-
new MonitoredItemService(this.session.getAuthToken(),
|
|
712
|
+
new SubscriptionService(this.session.getAuthToken(), sc),
|
|
713
|
+
new MonitoredItemService(this.session.getAuthToken(), sc)
|
|
388
714
|
);
|
|
389
715
|
}
|
|
390
716
|
async disconnect() {
|
|
391
|
-
|
|
392
|
-
if (this.channel) {
|
|
393
|
-
await this.channel.disconnect();
|
|
394
|
-
}
|
|
717
|
+
this.logger.info("Disconnecting from OPC UA server...");
|
|
395
718
|
}
|
|
396
719
|
async read(ids) {
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
720
|
+
const result = await this.attributeService?.ReadValue(ids);
|
|
721
|
+
return result?.map((r) => new ReadValueResult(r.value, r.status)) || [];
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Method for calling a single method on the server.
|
|
725
|
+
* @param objectId - NodeId of the Object that owns the method.
|
|
726
|
+
* @param methodId - NodeId of the Method to invoke.
|
|
727
|
+
* @param inputArguments - Input argument Variants (default: empty).
|
|
728
|
+
* @returns The CallMethodResult for the invoked method.
|
|
729
|
+
*/
|
|
730
|
+
async callMethod(objectId, methodId, inputArguments = []) {
|
|
731
|
+
const request = new opcjsBase.CallMethodRequest();
|
|
732
|
+
request.objectId = objectId;
|
|
733
|
+
request.methodId = methodId;
|
|
734
|
+
request.inputArguments = inputArguments.map((arg) => opcjsBase.Variant.newFrom(arg));
|
|
735
|
+
const responses = await this.methodService.call([request]);
|
|
736
|
+
const response = responses[0];
|
|
737
|
+
return new CallMethodResult(response.value, response.status);
|
|
400
738
|
}
|
|
401
739
|
async subscribe(ids, callback) {
|
|
402
740
|
this.subscriptionHandler?.subscribe(ids, callback);
|
|
403
741
|
}
|
|
404
742
|
};
|
|
405
743
|
var ConfigurationClient = class _ConfigurationClient extends opcjsBase.Configuration {
|
|
406
|
-
static getSimple(name, company) {
|
|
744
|
+
static getSimple(name, company, loggerFactory) {
|
|
745
|
+
if (!loggerFactory) {
|
|
746
|
+
loggerFactory = new opcjsBase.LoggerFactory({
|
|
747
|
+
defaultLevel: "DEBUG",
|
|
748
|
+
//todo: use enum
|
|
749
|
+
categoryLevels: {
|
|
750
|
+
"transport.*": "TRACE",
|
|
751
|
+
"secureChannel.*": "TRACE"
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
407
755
|
const applicationUri = `urn:${company}:${name}`;
|
|
408
756
|
const productUri = `urn:${company}:${name}:product`;
|
|
409
757
|
const encoder = new opcjsBase.Encoder();
|
|
@@ -417,10 +765,26 @@ var ConfigurationClient = class _ConfigurationClient extends opcjsBase.Configura
|
|
|
417
765
|
});
|
|
418
766
|
opcjsBase.registerTypeDecoders(decoder);
|
|
419
767
|
opcjsBase.registerBinaryDecoders(decoder);
|
|
420
|
-
return new _ConfigurationClient(
|
|
768
|
+
return new _ConfigurationClient(
|
|
769
|
+
name,
|
|
770
|
+
applicationUri,
|
|
771
|
+
name,
|
|
772
|
+
productUri,
|
|
773
|
+
encoder,
|
|
774
|
+
decoder,
|
|
775
|
+
loggerFactory
|
|
776
|
+
);
|
|
421
777
|
}
|
|
422
|
-
constructor(applicationName, applicationUri, productName, productUri, encoder, decoder) {
|
|
423
|
-
super(
|
|
778
|
+
constructor(applicationName, applicationUri, productName, productUri, encoder, decoder, loggerFactory) {
|
|
779
|
+
super(
|
|
780
|
+
applicationName,
|
|
781
|
+
applicationUri,
|
|
782
|
+
productName,
|
|
783
|
+
productUri,
|
|
784
|
+
encoder,
|
|
785
|
+
decoder,
|
|
786
|
+
loggerFactory
|
|
787
|
+
);
|
|
424
788
|
}
|
|
425
789
|
};
|
|
426
790
|
var UserIdentity = class _UserIdentity {
|