node-opcua-server 2.73.1 → 2.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -1
- package/dist/base_server.d.ts +110 -110
- package/dist/base_server.js +473 -473
- package/dist/factory.d.ts +12 -12
- package/dist/factory.js +23 -23
- package/dist/filter/check_where_clause_on_address_space.d.ts +3 -0
- package/dist/filter/check_where_clause_on_address_space.js +23 -0
- package/dist/filter/check_where_clause_on_address_space.js.map +1 -0
- package/dist/filter/extract_event_fields.d.ts +10 -0
- package/dist/filter/extract_event_fields.js +18 -0
- package/dist/filter/extract_event_fields.js.map +1 -0
- package/dist/helper.d.ts +10 -10
- package/dist/helper.js +75 -75
- package/dist/history_server_capabilities.d.ts +35 -35
- package/dist/history_server_capabilities.js +43 -43
- package/dist/i_channel_data.d.ts +13 -13
- package/dist/i_channel_data.js +2 -2
- package/dist/i_register_server_manager.d.ts +16 -16
- package/dist/i_register_server_manager.js +2 -2
- package/dist/i_server_side_publish_engine.d.ts +36 -36
- package/dist/i_server_side_publish_engine.js +49 -49
- package/dist/i_socket_data.d.ts +11 -11
- package/dist/i_socket_data.js +2 -2
- package/dist/index.d.ts +16 -16
- package/dist/index.js +32 -32
- package/dist/monitored_item.d.ts +177 -177
- package/dist/monitored_item.js +1001 -999
- package/dist/monitored_item.js.map +1 -1
- package/dist/node_sampler.d.ts +3 -3
- package/dist/node_sampler.js +75 -75
- package/dist/opcua_server.d.ts +747 -650
- package/dist/opcua_server.js +2431 -2394
- package/dist/opcua_server.js.map +1 -1
- package/dist/queue.d.ts +11 -11
- package/dist/queue.js +71 -71
- package/dist/register_server_manager.d.ts +96 -96
- package/dist/register_server_manager.js +584 -584
- package/dist/register_server_manager_hidden.d.ts +17 -17
- package/dist/register_server_manager_hidden.js +27 -27
- package/dist/register_server_manager_mdns_only.d.ts +22 -22
- package/dist/register_server_manager_mdns_only.js +55 -55
- package/dist/server_capabilities.d.ts +148 -148
- package/dist/server_capabilities.js +92 -92
- package/dist/server_end_point.d.ts +183 -183
- package/dist/server_end_point.js +817 -817
- package/dist/server_engine.d.ts +317 -317
- package/dist/server_engine.js +1716 -1716
- package/dist/server_publish_engine.d.ts +113 -112
- package/dist/server_publish_engine.js +541 -535
- package/dist/server_publish_engine.js.map +1 -1
- package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +16 -16
- package/dist/server_publish_engine_for_orphan_subscriptions.js +51 -51
- package/dist/server_session.d.ts +182 -182
- package/dist/server_session.js +739 -739
- package/dist/server_subscription.d.ts +421 -421
- package/dist/server_subscription.js +1346 -1345
- package/dist/server_subscription.js.map +1 -1
- package/dist/sessions_compatible_for_transfer.d.ts +2 -2
- package/dist/sessions_compatible_for_transfer.js +39 -39
- package/dist/user_manager.d.ts +32 -32
- package/dist/user_manager.js +74 -74
- package/dist/user_manager_ua.d.ts +3 -3
- package/dist/user_manager_ua.js +39 -39
- package/dist/validate_filter.d.ts +5 -5
- package/dist/validate_filter.js +60 -60
- package/package.json +50 -51
- package/source/filter/check_where_clause_on_address_space.ts +29 -0
- package/source/filter/extract_event_fields.ts +21 -0
- package/source/monitored_item.ts +5 -11
- package/source/opcua_server.ts +175 -36
- package/source/server_publish_engine.ts +24 -19
- package/source/server_subscription.ts +11 -10
package/dist/server_engine.d.ts
CHANGED
|
@@ -1,317 +1,317 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* @module node-opcua-server
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import { AddressSpace, ISessionContext, ContinuationData } from "node-opcua-address-space";
|
|
7
|
-
import { DataValue } from "node-opcua-data-value";
|
|
8
|
-
import { ServerDiagnosticsSummaryDataType, ServerState, ServerStatusDataType } from "node-opcua-common";
|
|
9
|
-
import { AttributeIds, LocalizedTextLike } from "node-opcua-data-model";
|
|
10
|
-
import { NodeId, NodeIdLike } from "node-opcua-nodeid";
|
|
11
|
-
import { BrowseResult } from "node-opcua-service-browse";
|
|
12
|
-
import { ReadRequest, TimestampsToReturn } from "node-opcua-service-read";
|
|
13
|
-
import { CreateSubscriptionRequestLike } from "node-opcua-client";
|
|
14
|
-
import { ObjectRegistry } from "node-opcua-object-registry";
|
|
15
|
-
import { TransferResult } from "node-opcua-service-subscription";
|
|
16
|
-
import { ApplicationDescription } from "node-opcua-service-endpoints";
|
|
17
|
-
import { HistoryReadRequest, HistoryReadResult, HistoryReadValueId } from "node-opcua-service-history";
|
|
18
|
-
import { StatusCode } from "node-opcua-status-code";
|
|
19
|
-
import { BrowseDescription, BrowsePath, BrowsePathResult, BuildInfo, BuildInfoOptions, ReadAtTimeDetails, ReadEventDetails, ReadProcessedDetails, ReadRawModifiedDetails, WriteValue, ReadValueId } from "node-opcua-types";
|
|
20
|
-
import { HistoryServerCapabilities, HistoryServerCapabilitiesOptions } from "./history_server_capabilities";
|
|
21
|
-
import { ServerCapabilities, ServerCapabilitiesOptions } from "./server_capabilities";
|
|
22
|
-
import { ServerSession } from "./server_session";
|
|
23
|
-
import { Subscription } from "./server_subscription";
|
|
24
|
-
import { OPCUAServerOptions } from "./opcua_server";
|
|
25
|
-
export declare type StringGetter = () => string;
|
|
26
|
-
export interface ServerEngineOptions {
|
|
27
|
-
applicationUri: string | StringGetter;
|
|
28
|
-
buildInfo?: BuildInfoOptions;
|
|
29
|
-
isAuditing?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* set to true to enable serverDiagnostics
|
|
32
|
-
*/
|
|
33
|
-
serverDiagnosticsEnabled?: boolean;
|
|
34
|
-
serverCapabilities?: ServerCapabilitiesOptions;
|
|
35
|
-
historyServerCapabilities?: HistoryServerCapabilitiesOptions;
|
|
36
|
-
}
|
|
37
|
-
export interface CreateSessionOption {
|
|
38
|
-
clientDescription?: ApplicationDescription;
|
|
39
|
-
sessionTimeout?: number;
|
|
40
|
-
}
|
|
41
|
-
export declare type ClosingReason = "Timeout" | "Terminated" | "CloseSession" | "Forcing";
|
|
42
|
-
export declare type ShutdownTask = (this: ServerEngine) => void | Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
export declare class ServerEngine extends EventEmitter {
|
|
47
|
-
static readonly registry: ObjectRegistry;
|
|
48
|
-
isAuditing: boolean;
|
|
49
|
-
serverDiagnosticsSummary: ServerDiagnosticsSummaryDataType;
|
|
50
|
-
serverDiagnosticsEnabled: boolean;
|
|
51
|
-
serverCapabilities: ServerCapabilities;
|
|
52
|
-
historyServerCapabilities: HistoryServerCapabilities;
|
|
53
|
-
clientDescription?: ApplicationDescription;
|
|
54
|
-
addressSpace: AddressSpace | null;
|
|
55
|
-
_internalState: "creating" | "initializing" | "initialized" | "shutdown" | "disposed";
|
|
56
|
-
private _sessions;
|
|
57
|
-
private _closedSessions;
|
|
58
|
-
private _orphanPublishEngine?;
|
|
59
|
-
private _shutdownTasks;
|
|
60
|
-
private _applicationUri;
|
|
61
|
-
private _expectedShutdownTime;
|
|
62
|
-
private _serverStatus;
|
|
63
|
-
private _globalCounter;
|
|
64
|
-
constructor(options: ServerEngineOptions);
|
|
65
|
-
isStarted(): boolean;
|
|
66
|
-
dispose(): void;
|
|
67
|
-
get startTime(): Date;
|
|
68
|
-
get currentTime(): Date;
|
|
69
|
-
get buildInfo(): BuildInfo;
|
|
70
|
-
/**
|
|
71
|
-
* register a function that will be called when the server will perform its shut down.
|
|
72
|
-
* @method registerShutdownTask
|
|
73
|
-
*/
|
|
74
|
-
registerShutdownTask(task: (this: ServerEngine) => void): void;
|
|
75
|
-
/**
|
|
76
|
-
* @method shutdown
|
|
77
|
-
*/
|
|
78
|
-
shutdown(): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* the number of active sessions
|
|
81
|
-
*/
|
|
82
|
-
get currentSessionCount(): number;
|
|
83
|
-
/**
|
|
84
|
-
* the cumulated number of sessions that have been opened since this object exists
|
|
85
|
-
*/
|
|
86
|
-
get cumulatedSessionCount(): number;
|
|
87
|
-
/**
|
|
88
|
-
* the number of active subscriptions.
|
|
89
|
-
*/
|
|
90
|
-
get currentSubscriptionCount(): number;
|
|
91
|
-
/**
|
|
92
|
-
* the cumulated number of subscriptions that have been created since this object exists
|
|
93
|
-
*/
|
|
94
|
-
get cumulatedSubscriptionCount(): number;
|
|
95
|
-
get rejectedSessionCount(): number;
|
|
96
|
-
get rejectedRequestsCount(): number;
|
|
97
|
-
get sessionAbortCount(): number;
|
|
98
|
-
get sessionTimeoutCount(): number;
|
|
99
|
-
get publishingIntervalCount(): number;
|
|
100
|
-
incrementSessionTimeoutCount(): void;
|
|
101
|
-
incrementSessionAbortCount(): void;
|
|
102
|
-
incrementRejectedRequestsCount(): void;
|
|
103
|
-
/**
|
|
104
|
-
* increment rejected session count (also increment rejected requests count)
|
|
105
|
-
*/
|
|
106
|
-
incrementRejectedSessionCount(): void;
|
|
107
|
-
incrementSecurityRejectedRequestsCount(): void;
|
|
108
|
-
/**
|
|
109
|
-
* increment rejected session count (also increment rejected requests count)
|
|
110
|
-
*/
|
|
111
|
-
incrementSecurityRejectedSessionCount(): void;
|
|
112
|
-
setShutdownTime(date: Date): void;
|
|
113
|
-
setShutdownReason(reason: LocalizedTextLike): void;
|
|
114
|
-
/**
|
|
115
|
-
* @method secondsTillShutdown
|
|
116
|
-
* @return the approximate number of seconds until the server will be shut down. The
|
|
117
|
-
* value is only relevant once the state changes into SHUTDOWN.
|
|
118
|
-
*/
|
|
119
|
-
secondsTillShutdown(): number;
|
|
120
|
-
/**
|
|
121
|
-
* the name of the server
|
|
122
|
-
*/
|
|
123
|
-
get serverName(): string;
|
|
124
|
-
/**
|
|
125
|
-
* the server urn
|
|
126
|
-
*/
|
|
127
|
-
get serverNameUrn(): string;
|
|
128
|
-
/**
|
|
129
|
-
* the urn of the server namespace
|
|
130
|
-
*/
|
|
131
|
-
get serverNamespaceUrn(): string;
|
|
132
|
-
get serverStatus(): ServerStatusDataType;
|
|
133
|
-
setServerState(serverState: ServerState): void;
|
|
134
|
-
getServerDiagnosticsEnabledFlag(): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* @method initialize
|
|
137
|
-
* @async
|
|
138
|
-
*
|
|
139
|
-
* @param options {Object}
|
|
140
|
-
* @param options.nodeset_filename {String} - [option](default : 'mini.Node.Set2.xml' )
|
|
141
|
-
* @param callback
|
|
142
|
-
*/
|
|
143
|
-
initialize(options: OPCUAServerOptions, callback: () => void): void;
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* @method browseSingleNode
|
|
147
|
-
* @param nodeId {NodeId|String} : the nodeid of the element to browse
|
|
148
|
-
* @param browseDescription
|
|
149
|
-
* @param browseDescription.browseDirection {BrowseDirection} :
|
|
150
|
-
* @param browseDescription.referenceTypeId {String|NodeId}
|
|
151
|
-
* @param [context]
|
|
152
|
-
* @return the browse result
|
|
153
|
-
*/
|
|
154
|
-
browseSingleNode(nodeId: NodeIdLike, browseDescription: BrowseDescription, context?: ISessionContext): BrowseResult;
|
|
155
|
-
browseWithAutomaticExpansion(nodesToBrowse: BrowseDescription[], context?: ISessionContext): Promise<BrowseResult[]>;
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
*/
|
|
159
|
-
browse(nodesToBrowse: BrowseDescription[], context?: ISessionContext): BrowseResult[];
|
|
160
|
-
/**
|
|
161
|
-
*
|
|
162
|
-
* @method readSingleNode
|
|
163
|
-
* @param context
|
|
164
|
-
* @param nodeId
|
|
165
|
-
* @param attributeId
|
|
166
|
-
* @param [timestampsToReturn=TimestampsToReturn.Neither]
|
|
167
|
-
* @return DataValue
|
|
168
|
-
*/
|
|
169
|
-
readSingleNode(context: ISessionContext, nodeId: NodeId | string, attributeId: AttributeIds, timestampsToReturn?: TimestampsToReturn): DataValue;
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* Maximum age of the value to be read in milliseconds. The age of the value is based on the difference between
|
|
174
|
-
* the ServerTimestamp and the time when the Server starts processing the request. For example if the Client
|
|
175
|
-
* specifies a maxAge of 500 milliseconds and it takes 100 milliseconds until the Server starts processing
|
|
176
|
-
* the request, the age of the returned value could be 600 milliseconds prior to the time it was requested.
|
|
177
|
-
* If the Server has one or more values of an Attribute that are within the maximum age, it can return any one
|
|
178
|
-
* of the values or it can read a new value from the data source. The number of values of an Attribute that
|
|
179
|
-
* a Server has depends on the number of MonitoredItems that are defined for the Attribute. In any case,
|
|
180
|
-
* the Client can make no assumption about which copy of the data will be returned.
|
|
181
|
-
* If the Server does not have a value that is within the maximum age, it shall attempt to read a new value
|
|
182
|
-
* from the data source.
|
|
183
|
-
* If the Server cannot meet the requested maxAge, it returns its 'best effort' value rather than rejecting the
|
|
184
|
-
* request.
|
|
185
|
-
* This may occur when the time it takes the Server to process and return the new data value after it has been
|
|
186
|
-
* accessed is greater than the specified maximum age.
|
|
187
|
-
* If maxAge is set to 0, the Server shall attempt to read a new value from the data source.
|
|
188
|
-
* If maxAge is set to the max Int32 value or greater, the Server shall attempt to get a cached value.
|
|
189
|
-
* Negative values are invalid for maxAge.
|
|
190
|
-
*
|
|
191
|
-
* @return an array of DataValue
|
|
192
|
-
*/
|
|
193
|
-
read(context: ISessionContext, readRequest: ReadRequest): DataValue[];
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
* @method writeSingleNode
|
|
197
|
-
* @param context
|
|
198
|
-
* @param writeValue
|
|
199
|
-
* @param callback
|
|
200
|
-
* @param callback.err
|
|
201
|
-
* @param callback.statusCode
|
|
202
|
-
* @async
|
|
203
|
-
*/
|
|
204
|
-
writeSingleNode(context: ISessionContext, writeValue: WriteValue, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
|
|
205
|
-
/**
|
|
206
|
-
* write a collection of nodes
|
|
207
|
-
* @method write
|
|
208
|
-
* @param context
|
|
209
|
-
* @param nodesToWrite
|
|
210
|
-
* @param callback
|
|
211
|
-
* @param callback.err
|
|
212
|
-
* @param callback.results
|
|
213
|
-
* @async
|
|
214
|
-
*/
|
|
215
|
-
write(context: ISessionContext, nodesToWrite: WriteValue[], callback: (err: Error | null, statusCodes?: StatusCode[]) => void): void;
|
|
216
|
-
/**
|
|
217
|
-
*
|
|
218
|
-
*/
|
|
219
|
-
historyReadSingleNode(context: ISessionContext, nodeId: NodeId, attributeId: AttributeIds, historyReadDetails: ReadRawModifiedDetails | ReadEventDetails | ReadProcessedDetails | ReadAtTimeDetails, timestampsToReturn: TimestampsToReturn, continuationData: ContinuationData, callback: (err: Error | null, results?: HistoryReadResult) => void): void;
|
|
220
|
-
/**
|
|
221
|
-
*
|
|
222
|
-
* @method historyRead
|
|
223
|
-
* @param context {SessionContext}
|
|
224
|
-
* @param historyReadRequest {HistoryReadRequest}
|
|
225
|
-
* @param historyReadRequest.requestHeader {RequestHeader}
|
|
226
|
-
* @param historyReadRequest.historyReadDetails {HistoryReadDetails}
|
|
227
|
-
* @param historyReadRequest.timestampsToReturn {TimestampsToReturn}
|
|
228
|
-
* @param historyReadRequest.releaseContinuationPoints {Boolean}
|
|
229
|
-
* @param historyReadRequest.nodesToRead {HistoryReadValueId[]}
|
|
230
|
-
* @param callback
|
|
231
|
-
* @param callback.err
|
|
232
|
-
* @param callback.results {HistoryReadResult[]}
|
|
233
|
-
*/
|
|
234
|
-
historyRead(context: ISessionContext, historyReadRequest: HistoryReadRequest, callback: (err: Error | null, results: HistoryReadResult[]) => void): void;
|
|
235
|
-
getOldestInactiveSession(): ServerSession | null;
|
|
236
|
-
/**
|
|
237
|
-
* create a new server session object.
|
|
238
|
-
* @class ServerEngine
|
|
239
|
-
* @method createSession
|
|
240
|
-
* @param [options] {Object}
|
|
241
|
-
* @param [options.sessionTimeout = 1000] {Number} sessionTimeout
|
|
242
|
-
* @param [options.clientDescription] {ApplicationDescription}
|
|
243
|
-
* @return {ServerSession}
|
|
244
|
-
*/
|
|
245
|
-
createSession(options: CreateSessionOption): ServerSession;
|
|
246
|
-
/**
|
|
247
|
-
* @method closeSession
|
|
248
|
-
* @param authenticationToken
|
|
249
|
-
* @param deleteSubscriptions {Boolean} : true if session's subscription shall be deleted
|
|
250
|
-
* @param {String} [reason = "CloseSession"] the reason for closing the session (
|
|
251
|
-
* shall be "Timeout", "Terminated" or "CloseSession")
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* what the specs say:
|
|
255
|
-
* -------------------
|
|
256
|
-
*
|
|
257
|
-
* If a Client invokes the CloseSession Service then all Subscriptions associated with the Session are also deleted
|
|
258
|
-
* if the deleteSubscriptions flag is set to TRUE. If a Server terminates a Session for any other reason,
|
|
259
|
-
* Subscriptions associated with the Session, are not deleted. Each Subscription has its own lifetime to protect
|
|
260
|
-
* against data loss in the case of a Session termination. In these cases, the Subscription can be reassigned to
|
|
261
|
-
* another Client before its lifetime expires.
|
|
262
|
-
*/
|
|
263
|
-
closeSession(authenticationToken: NodeId, deleteSubscriptions: boolean, reason: ClosingReason): void;
|
|
264
|
-
findSubscription(subscriptionId: number): Subscription | null;
|
|
265
|
-
findOrphanSubscription(subscriptionId: number): Subscription | null;
|
|
266
|
-
deleteOrphanSubscription(subscription: Subscription): StatusCode;
|
|
267
|
-
/**
|
|
268
|
-
* @method transferSubscription
|
|
269
|
-
* @param session {ServerSession} - the new session that will own the subscription
|
|
270
|
-
* @param subscriptionId {IntegerId} - the subscription Id to transfer
|
|
271
|
-
* @param sendInitialValues {Boolean} - true if initial values will be resent.
|
|
272
|
-
* @return {TransferResult}
|
|
273
|
-
*/
|
|
274
|
-
transferSubscription(session: ServerSession, subscriptionId: number, sendInitialValues: boolean): Promise<TransferResult>;
|
|
275
|
-
/**
|
|
276
|
-
* retrieve a session by its authenticationToken.
|
|
277
|
-
*
|
|
278
|
-
* @method getSession
|
|
279
|
-
* @param authenticationToken
|
|
280
|
-
* @param activeOnly
|
|
281
|
-
* @return {ServerSession}
|
|
282
|
-
*/
|
|
283
|
-
getSession(authenticationToken: NodeId, activeOnly?: boolean): ServerSession | null;
|
|
284
|
-
/**
|
|
285
|
-
*/
|
|
286
|
-
browsePath(browsePath: BrowsePath): BrowsePathResult;
|
|
287
|
-
/**
|
|
288
|
-
*
|
|
289
|
-
* performs a call to ```asyncRefresh``` on all variable nodes that provide an async refresh func.
|
|
290
|
-
*
|
|
291
|
-
* @method refreshValues
|
|
292
|
-
* @param nodesToRefresh {Array<Object>} an array containing the node to consider
|
|
293
|
-
* Each element of the array shall be of the form { nodeId: <xxx>, attributeIds: <value> }.
|
|
294
|
-
* @param callback
|
|
295
|
-
* @param callback.err
|
|
296
|
-
* @param callback.data an array containing value read
|
|
297
|
-
* The array length matches the number of nodeIds that are candidate for an async refresh (i.e: nodes that
|
|
298
|
-
* are of type Variable with asyncRefresh func }
|
|
299
|
-
*
|
|
300
|
-
* @async
|
|
301
|
-
*/
|
|
302
|
-
refreshValues(nodesToRefresh: ReadValueId[] | HistoryReadValueId[], maxAge: number, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
303
|
-
private _exposeSubscriptionDiagnostics;
|
|
304
|
-
protected _unexposeSubscriptionDiagnostics(subscription: Subscription): void;
|
|
305
|
-
/**
|
|
306
|
-
* create a new subscription
|
|
307
|
-
* @return {Subscription}
|
|
308
|
-
*/
|
|
309
|
-
_createSubscriptionOnSession(session: ServerSession, request: CreateSubscriptionRequestLike): Subscription;
|
|
310
|
-
private __findNode;
|
|
311
|
-
private _readSingleNode;
|
|
312
|
-
private _historyReadSingleNode;
|
|
313
|
-
/**
|
|
314
|
-
*/
|
|
315
|
-
private __internal_bindMethod;
|
|
316
|
-
private _getServerSubscriptionDiagnosticsArrayNode;
|
|
317
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-server
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { AddressSpace, ISessionContext, ContinuationData } from "node-opcua-address-space";
|
|
7
|
+
import { DataValue } from "node-opcua-data-value";
|
|
8
|
+
import { ServerDiagnosticsSummaryDataType, ServerState, ServerStatusDataType } from "node-opcua-common";
|
|
9
|
+
import { AttributeIds, LocalizedTextLike } from "node-opcua-data-model";
|
|
10
|
+
import { NodeId, NodeIdLike } from "node-opcua-nodeid";
|
|
11
|
+
import { BrowseResult } from "node-opcua-service-browse";
|
|
12
|
+
import { ReadRequest, TimestampsToReturn } from "node-opcua-service-read";
|
|
13
|
+
import { CreateSubscriptionRequestLike } from "node-opcua-client";
|
|
14
|
+
import { ObjectRegistry } from "node-opcua-object-registry";
|
|
15
|
+
import { TransferResult } from "node-opcua-service-subscription";
|
|
16
|
+
import { ApplicationDescription } from "node-opcua-service-endpoints";
|
|
17
|
+
import { HistoryReadRequest, HistoryReadResult, HistoryReadValueId } from "node-opcua-service-history";
|
|
18
|
+
import { StatusCode } from "node-opcua-status-code";
|
|
19
|
+
import { BrowseDescription, BrowsePath, BrowsePathResult, BuildInfo, BuildInfoOptions, ReadAtTimeDetails, ReadEventDetails, ReadProcessedDetails, ReadRawModifiedDetails, WriteValue, ReadValueId } from "node-opcua-types";
|
|
20
|
+
import { HistoryServerCapabilities, HistoryServerCapabilitiesOptions } from "./history_server_capabilities";
|
|
21
|
+
import { ServerCapabilities, ServerCapabilitiesOptions } from "./server_capabilities";
|
|
22
|
+
import { ServerSession } from "./server_session";
|
|
23
|
+
import { Subscription } from "./server_subscription";
|
|
24
|
+
import { OPCUAServerOptions } from "./opcua_server";
|
|
25
|
+
export declare type StringGetter = () => string;
|
|
26
|
+
export interface ServerEngineOptions {
|
|
27
|
+
applicationUri: string | StringGetter;
|
|
28
|
+
buildInfo?: BuildInfoOptions;
|
|
29
|
+
isAuditing?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* set to true to enable serverDiagnostics
|
|
32
|
+
*/
|
|
33
|
+
serverDiagnosticsEnabled?: boolean;
|
|
34
|
+
serverCapabilities?: ServerCapabilitiesOptions;
|
|
35
|
+
historyServerCapabilities?: HistoryServerCapabilitiesOptions;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateSessionOption {
|
|
38
|
+
clientDescription?: ApplicationDescription;
|
|
39
|
+
sessionTimeout?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare type ClosingReason = "Timeout" | "Terminated" | "CloseSession" | "Forcing";
|
|
42
|
+
export declare type ShutdownTask = (this: ServerEngine) => void | Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export declare class ServerEngine extends EventEmitter {
|
|
47
|
+
static readonly registry: ObjectRegistry;
|
|
48
|
+
isAuditing: boolean;
|
|
49
|
+
serverDiagnosticsSummary: ServerDiagnosticsSummaryDataType;
|
|
50
|
+
serverDiagnosticsEnabled: boolean;
|
|
51
|
+
serverCapabilities: ServerCapabilities;
|
|
52
|
+
historyServerCapabilities: HistoryServerCapabilities;
|
|
53
|
+
clientDescription?: ApplicationDescription;
|
|
54
|
+
addressSpace: AddressSpace | null;
|
|
55
|
+
_internalState: "creating" | "initializing" | "initialized" | "shutdown" | "disposed";
|
|
56
|
+
private _sessions;
|
|
57
|
+
private _closedSessions;
|
|
58
|
+
private _orphanPublishEngine?;
|
|
59
|
+
private _shutdownTasks;
|
|
60
|
+
private _applicationUri;
|
|
61
|
+
private _expectedShutdownTime;
|
|
62
|
+
private _serverStatus;
|
|
63
|
+
private _globalCounter;
|
|
64
|
+
constructor(options: ServerEngineOptions);
|
|
65
|
+
isStarted(): boolean;
|
|
66
|
+
dispose(): void;
|
|
67
|
+
get startTime(): Date;
|
|
68
|
+
get currentTime(): Date;
|
|
69
|
+
get buildInfo(): BuildInfo;
|
|
70
|
+
/**
|
|
71
|
+
* register a function that will be called when the server will perform its shut down.
|
|
72
|
+
* @method registerShutdownTask
|
|
73
|
+
*/
|
|
74
|
+
registerShutdownTask(task: (this: ServerEngine) => void): void;
|
|
75
|
+
/**
|
|
76
|
+
* @method shutdown
|
|
77
|
+
*/
|
|
78
|
+
shutdown(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* the number of active sessions
|
|
81
|
+
*/
|
|
82
|
+
get currentSessionCount(): number;
|
|
83
|
+
/**
|
|
84
|
+
* the cumulated number of sessions that have been opened since this object exists
|
|
85
|
+
*/
|
|
86
|
+
get cumulatedSessionCount(): number;
|
|
87
|
+
/**
|
|
88
|
+
* the number of active subscriptions.
|
|
89
|
+
*/
|
|
90
|
+
get currentSubscriptionCount(): number;
|
|
91
|
+
/**
|
|
92
|
+
* the cumulated number of subscriptions that have been created since this object exists
|
|
93
|
+
*/
|
|
94
|
+
get cumulatedSubscriptionCount(): number;
|
|
95
|
+
get rejectedSessionCount(): number;
|
|
96
|
+
get rejectedRequestsCount(): number;
|
|
97
|
+
get sessionAbortCount(): number;
|
|
98
|
+
get sessionTimeoutCount(): number;
|
|
99
|
+
get publishingIntervalCount(): number;
|
|
100
|
+
incrementSessionTimeoutCount(): void;
|
|
101
|
+
incrementSessionAbortCount(): void;
|
|
102
|
+
incrementRejectedRequestsCount(): void;
|
|
103
|
+
/**
|
|
104
|
+
* increment rejected session count (also increment rejected requests count)
|
|
105
|
+
*/
|
|
106
|
+
incrementRejectedSessionCount(): void;
|
|
107
|
+
incrementSecurityRejectedRequestsCount(): void;
|
|
108
|
+
/**
|
|
109
|
+
* increment rejected session count (also increment rejected requests count)
|
|
110
|
+
*/
|
|
111
|
+
incrementSecurityRejectedSessionCount(): void;
|
|
112
|
+
setShutdownTime(date: Date): void;
|
|
113
|
+
setShutdownReason(reason: LocalizedTextLike): void;
|
|
114
|
+
/**
|
|
115
|
+
* @method secondsTillShutdown
|
|
116
|
+
* @return the approximate number of seconds until the server will be shut down. The
|
|
117
|
+
* value is only relevant once the state changes into SHUTDOWN.
|
|
118
|
+
*/
|
|
119
|
+
secondsTillShutdown(): number;
|
|
120
|
+
/**
|
|
121
|
+
* the name of the server
|
|
122
|
+
*/
|
|
123
|
+
get serverName(): string;
|
|
124
|
+
/**
|
|
125
|
+
* the server urn
|
|
126
|
+
*/
|
|
127
|
+
get serverNameUrn(): string;
|
|
128
|
+
/**
|
|
129
|
+
* the urn of the server namespace
|
|
130
|
+
*/
|
|
131
|
+
get serverNamespaceUrn(): string;
|
|
132
|
+
get serverStatus(): ServerStatusDataType;
|
|
133
|
+
setServerState(serverState: ServerState): void;
|
|
134
|
+
getServerDiagnosticsEnabledFlag(): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* @method initialize
|
|
137
|
+
* @async
|
|
138
|
+
*
|
|
139
|
+
* @param options {Object}
|
|
140
|
+
* @param options.nodeset_filename {String} - [option](default : 'mini.Node.Set2.xml' )
|
|
141
|
+
* @param callback
|
|
142
|
+
*/
|
|
143
|
+
initialize(options: OPCUAServerOptions, callback: () => void): void;
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @method browseSingleNode
|
|
147
|
+
* @param nodeId {NodeId|String} : the nodeid of the element to browse
|
|
148
|
+
* @param browseDescription
|
|
149
|
+
* @param browseDescription.browseDirection {BrowseDirection} :
|
|
150
|
+
* @param browseDescription.referenceTypeId {String|NodeId}
|
|
151
|
+
* @param [context]
|
|
152
|
+
* @return the browse result
|
|
153
|
+
*/
|
|
154
|
+
browseSingleNode(nodeId: NodeIdLike, browseDescription: BrowseDescription, context?: ISessionContext): BrowseResult;
|
|
155
|
+
browseWithAutomaticExpansion(nodesToBrowse: BrowseDescription[], context?: ISessionContext): Promise<BrowseResult[]>;
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
browse(nodesToBrowse: BrowseDescription[], context?: ISessionContext): BrowseResult[];
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
* @method readSingleNode
|
|
163
|
+
* @param context
|
|
164
|
+
* @param nodeId
|
|
165
|
+
* @param attributeId
|
|
166
|
+
* @param [timestampsToReturn=TimestampsToReturn.Neither]
|
|
167
|
+
* @return DataValue
|
|
168
|
+
*/
|
|
169
|
+
readSingleNode(context: ISessionContext, nodeId: NodeId | string, attributeId: AttributeIds, timestampsToReturn?: TimestampsToReturn): DataValue;
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
*
|
|
173
|
+
* Maximum age of the value to be read in milliseconds. The age of the value is based on the difference between
|
|
174
|
+
* the ServerTimestamp and the time when the Server starts processing the request. For example if the Client
|
|
175
|
+
* specifies a maxAge of 500 milliseconds and it takes 100 milliseconds until the Server starts processing
|
|
176
|
+
* the request, the age of the returned value could be 600 milliseconds prior to the time it was requested.
|
|
177
|
+
* If the Server has one or more values of an Attribute that are within the maximum age, it can return any one
|
|
178
|
+
* of the values or it can read a new value from the data source. The number of values of an Attribute that
|
|
179
|
+
* a Server has depends on the number of MonitoredItems that are defined for the Attribute. In any case,
|
|
180
|
+
* the Client can make no assumption about which copy of the data will be returned.
|
|
181
|
+
* If the Server does not have a value that is within the maximum age, it shall attempt to read a new value
|
|
182
|
+
* from the data source.
|
|
183
|
+
* If the Server cannot meet the requested maxAge, it returns its 'best effort' value rather than rejecting the
|
|
184
|
+
* request.
|
|
185
|
+
* This may occur when the time it takes the Server to process and return the new data value after it has been
|
|
186
|
+
* accessed is greater than the specified maximum age.
|
|
187
|
+
* If maxAge is set to 0, the Server shall attempt to read a new value from the data source.
|
|
188
|
+
* If maxAge is set to the max Int32 value or greater, the Server shall attempt to get a cached value.
|
|
189
|
+
* Negative values are invalid for maxAge.
|
|
190
|
+
*
|
|
191
|
+
* @return an array of DataValue
|
|
192
|
+
*/
|
|
193
|
+
read(context: ISessionContext, readRequest: ReadRequest): DataValue[];
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* @method writeSingleNode
|
|
197
|
+
* @param context
|
|
198
|
+
* @param writeValue
|
|
199
|
+
* @param callback
|
|
200
|
+
* @param callback.err
|
|
201
|
+
* @param callback.statusCode
|
|
202
|
+
* @async
|
|
203
|
+
*/
|
|
204
|
+
writeSingleNode(context: ISessionContext, writeValue: WriteValue, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
|
|
205
|
+
/**
|
|
206
|
+
* write a collection of nodes
|
|
207
|
+
* @method write
|
|
208
|
+
* @param context
|
|
209
|
+
* @param nodesToWrite
|
|
210
|
+
* @param callback
|
|
211
|
+
* @param callback.err
|
|
212
|
+
* @param callback.results
|
|
213
|
+
* @async
|
|
214
|
+
*/
|
|
215
|
+
write(context: ISessionContext, nodesToWrite: WriteValue[], callback: (err: Error | null, statusCodes?: StatusCode[]) => void): void;
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
historyReadSingleNode(context: ISessionContext, nodeId: NodeId, attributeId: AttributeIds, historyReadDetails: ReadRawModifiedDetails | ReadEventDetails | ReadProcessedDetails | ReadAtTimeDetails, timestampsToReturn: TimestampsToReturn, continuationData: ContinuationData, callback: (err: Error | null, results?: HistoryReadResult) => void): void;
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* @method historyRead
|
|
223
|
+
* @param context {SessionContext}
|
|
224
|
+
* @param historyReadRequest {HistoryReadRequest}
|
|
225
|
+
* @param historyReadRequest.requestHeader {RequestHeader}
|
|
226
|
+
* @param historyReadRequest.historyReadDetails {HistoryReadDetails}
|
|
227
|
+
* @param historyReadRequest.timestampsToReturn {TimestampsToReturn}
|
|
228
|
+
* @param historyReadRequest.releaseContinuationPoints {Boolean}
|
|
229
|
+
* @param historyReadRequest.nodesToRead {HistoryReadValueId[]}
|
|
230
|
+
* @param callback
|
|
231
|
+
* @param callback.err
|
|
232
|
+
* @param callback.results {HistoryReadResult[]}
|
|
233
|
+
*/
|
|
234
|
+
historyRead(context: ISessionContext, historyReadRequest: HistoryReadRequest, callback: (err: Error | null, results: HistoryReadResult[]) => void): void;
|
|
235
|
+
getOldestInactiveSession(): ServerSession | null;
|
|
236
|
+
/**
|
|
237
|
+
* create a new server session object.
|
|
238
|
+
* @class ServerEngine
|
|
239
|
+
* @method createSession
|
|
240
|
+
* @param [options] {Object}
|
|
241
|
+
* @param [options.sessionTimeout = 1000] {Number} sessionTimeout
|
|
242
|
+
* @param [options.clientDescription] {ApplicationDescription}
|
|
243
|
+
* @return {ServerSession}
|
|
244
|
+
*/
|
|
245
|
+
createSession(options: CreateSessionOption): ServerSession;
|
|
246
|
+
/**
|
|
247
|
+
* @method closeSession
|
|
248
|
+
* @param authenticationToken
|
|
249
|
+
* @param deleteSubscriptions {Boolean} : true if session's subscription shall be deleted
|
|
250
|
+
* @param {String} [reason = "CloseSession"] the reason for closing the session (
|
|
251
|
+
* shall be "Timeout", "Terminated" or "CloseSession")
|
|
252
|
+
*
|
|
253
|
+
*
|
|
254
|
+
* what the specs say:
|
|
255
|
+
* -------------------
|
|
256
|
+
*
|
|
257
|
+
* If a Client invokes the CloseSession Service then all Subscriptions associated with the Session are also deleted
|
|
258
|
+
* if the deleteSubscriptions flag is set to TRUE. If a Server terminates a Session for any other reason,
|
|
259
|
+
* Subscriptions associated with the Session, are not deleted. Each Subscription has its own lifetime to protect
|
|
260
|
+
* against data loss in the case of a Session termination. In these cases, the Subscription can be reassigned to
|
|
261
|
+
* another Client before its lifetime expires.
|
|
262
|
+
*/
|
|
263
|
+
closeSession(authenticationToken: NodeId, deleteSubscriptions: boolean, reason: ClosingReason): void;
|
|
264
|
+
findSubscription(subscriptionId: number): Subscription | null;
|
|
265
|
+
findOrphanSubscription(subscriptionId: number): Subscription | null;
|
|
266
|
+
deleteOrphanSubscription(subscription: Subscription): StatusCode;
|
|
267
|
+
/**
|
|
268
|
+
* @method transferSubscription
|
|
269
|
+
* @param session {ServerSession} - the new session that will own the subscription
|
|
270
|
+
* @param subscriptionId {IntegerId} - the subscription Id to transfer
|
|
271
|
+
* @param sendInitialValues {Boolean} - true if initial values will be resent.
|
|
272
|
+
* @return {TransferResult}
|
|
273
|
+
*/
|
|
274
|
+
transferSubscription(session: ServerSession, subscriptionId: number, sendInitialValues: boolean): Promise<TransferResult>;
|
|
275
|
+
/**
|
|
276
|
+
* retrieve a session by its authenticationToken.
|
|
277
|
+
*
|
|
278
|
+
* @method getSession
|
|
279
|
+
* @param authenticationToken
|
|
280
|
+
* @param activeOnly
|
|
281
|
+
* @return {ServerSession}
|
|
282
|
+
*/
|
|
283
|
+
getSession(authenticationToken: NodeId, activeOnly?: boolean): ServerSession | null;
|
|
284
|
+
/**
|
|
285
|
+
*/
|
|
286
|
+
browsePath(browsePath: BrowsePath): BrowsePathResult;
|
|
287
|
+
/**
|
|
288
|
+
*
|
|
289
|
+
* performs a call to ```asyncRefresh``` on all variable nodes that provide an async refresh func.
|
|
290
|
+
*
|
|
291
|
+
* @method refreshValues
|
|
292
|
+
* @param nodesToRefresh {Array<Object>} an array containing the node to consider
|
|
293
|
+
* Each element of the array shall be of the form { nodeId: <xxx>, attributeIds: <value> }.
|
|
294
|
+
* @param callback
|
|
295
|
+
* @param callback.err
|
|
296
|
+
* @param callback.data an array containing value read
|
|
297
|
+
* The array length matches the number of nodeIds that are candidate for an async refresh (i.e: nodes that
|
|
298
|
+
* are of type Variable with asyncRefresh func }
|
|
299
|
+
*
|
|
300
|
+
* @async
|
|
301
|
+
*/
|
|
302
|
+
refreshValues(nodesToRefresh: ReadValueId[] | HistoryReadValueId[], maxAge: number, callback: (err: Error | null, dataValues?: DataValue[]) => void): void;
|
|
303
|
+
private _exposeSubscriptionDiagnostics;
|
|
304
|
+
protected _unexposeSubscriptionDiagnostics(subscription: Subscription): void;
|
|
305
|
+
/**
|
|
306
|
+
* create a new subscription
|
|
307
|
+
* @return {Subscription}
|
|
308
|
+
*/
|
|
309
|
+
_createSubscriptionOnSession(session: ServerSession, request: CreateSubscriptionRequestLike): Subscription;
|
|
310
|
+
private __findNode;
|
|
311
|
+
private _readSingleNode;
|
|
312
|
+
private _historyReadSingleNode;
|
|
313
|
+
/**
|
|
314
|
+
*/
|
|
315
|
+
private __internal_bindMethod;
|
|
316
|
+
private _getServerSubscriptionDiagnosticsArrayNode;
|
|
317
|
+
}
|