node-opcua-utils 2.64.1 → 2.69.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/buffer_ellipsis.d.ts +5 -5
- package/dist/buffer_ellipsis.js +16 -16
- package/dist/compare_buffers.d.ts +2 -2
- package/dist/compare_buffers.js +26 -26
- package/dist/function_variadic.d.ts +1 -1
- package/dist/function_variadic.js +2 -2
- package/dist/get_clock_tick.d.ts +4 -4
- package/dist/get_clock_tick.js +16 -16
- package/dist/get_function_parameters_name.d.ts +2 -2
- package/dist/get_function_parameters_name.js +17 -17
- package/dist/hrtime.d.ts +2 -2
- package/dist/hrtime.js +31 -31
- package/dist/index.d.ts +28 -28
- package/dist/index.js +74 -70
- package/dist/index.js.map +1 -1
- package/dist/line_file.d.ts +9 -9
- package/dist/line_file.js +23 -23
- package/dist/match_uri.d.ts +11 -11
- package/dist/match_uri.js +23 -23
- package/dist/object_classname.d.ts +9 -9
- package/dist/object_classname.js +15 -15
- package/dist/replace_buffer_with_hex_dump.d.ts +6 -6
- package/dist/replace_buffer_with_hex_dump.js +20 -20
- package/dist/set_deprecated.d.ts +2 -2
- package/dist/set_deprecated.js +25 -25
- package/dist/string_utils.d.ts +66 -66
- package/dist/string_utils.js +127 -127
- package/dist/string_utils.js.map +1 -1
- package/dist/timestamp.d.ts +1 -1
- package/dist/timestamp.js +13 -13
- package/dist/timestamp.js.map +1 -1
- package/dist/watchdog.d.ts +57 -57
- package/dist/watchdog.js +142 -142
- package/package.json +6 -6
- package/source/string_utils.ts +3 -3
- package/source/timestamp.ts +1 -1
- package/dist/construct_filename.d.ts +0 -4
- package/dist/construct_filename.js +0 -13
- package/dist/construct_filename.js.map +0 -1
- package/dist/linefile.d.ts +0 -8
- package/dist/linefile.js +0 -36
- package/dist/linefile.js.map +0 -1
package/dist/watchdog.d.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* @module node-opcua-utils
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
declare type ArbitraryClockTick = number;
|
|
7
|
-
declare type DurationInMillisecond = number;
|
|
8
|
-
export interface IWatchdogData2 {
|
|
9
|
-
key: number;
|
|
10
|
-
subscriber: ISubscriber;
|
|
11
|
-
timeout: DurationInMillisecond;
|
|
12
|
-
lastSeen: ArbitraryClockTick;
|
|
13
|
-
visitCount: number;
|
|
14
|
-
}
|
|
15
|
-
export interface ISubscriber {
|
|
16
|
-
_watchDog?: WatchDog;
|
|
17
|
-
_watchDogData?: IWatchdogData2;
|
|
18
|
-
watchdogReset: () => void;
|
|
19
|
-
keepAlive?: () => void;
|
|
20
|
-
onClientSeen?: () => void;
|
|
21
|
-
}
|
|
22
|
-
export declare class WatchDog extends EventEmitter {
|
|
23
|
-
static lastSeenToDuration(lastSeen: number): number;
|
|
24
|
-
static emptyKeepAlive: () => void;
|
|
25
|
-
/**
|
|
26
|
-
* returns the number of subscribers using the WatchDog object.
|
|
27
|
-
*/
|
|
28
|
-
get subscriberCount(): number;
|
|
29
|
-
private readonly _watchdogDataMap;
|
|
30
|
-
private _counter;
|
|
31
|
-
private _currentTime;
|
|
32
|
-
private _timer;
|
|
33
|
-
private readonly _visitSubscriberB;
|
|
34
|
-
constructor();
|
|
35
|
-
/**
|
|
36
|
-
* add a subscriber to the WatchDog.
|
|
37
|
-
* @method addSubscriber
|
|
38
|
-
*
|
|
39
|
-
* add a subscriber to the WatchDog.
|
|
40
|
-
*
|
|
41
|
-
* This method modifies the subscriber be adding a
|
|
42
|
-
* new method to it called 'keepAlive'
|
|
43
|
-
* The subscriber must also provide a "watchdogReset". watchdogReset will be called
|
|
44
|
-
* if the subscriber failed to call keepAlive withing the timeout period.
|
|
45
|
-
* @param subscriber
|
|
46
|
-
* @param timeout
|
|
47
|
-
* @return the numerical key associated with this subscriber
|
|
48
|
-
*/
|
|
49
|
-
addSubscriber(subscriber: ISubscriber, timeout: number): number;
|
|
50
|
-
removeSubscriber(subscriber: ISubscriber): void;
|
|
51
|
-
shutdown(): void;
|
|
52
|
-
getCurrentSystemTick(): ArbitraryClockTick;
|
|
53
|
-
private _visit_subscriber;
|
|
54
|
-
private _start_timer;
|
|
55
|
-
private _stop_timer;
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-utils
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
declare type ArbitraryClockTick = number;
|
|
7
|
+
declare type DurationInMillisecond = number;
|
|
8
|
+
export interface IWatchdogData2 {
|
|
9
|
+
key: number;
|
|
10
|
+
subscriber: ISubscriber;
|
|
11
|
+
timeout: DurationInMillisecond;
|
|
12
|
+
lastSeen: ArbitraryClockTick;
|
|
13
|
+
visitCount: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ISubscriber {
|
|
16
|
+
_watchDog?: WatchDog;
|
|
17
|
+
_watchDogData?: IWatchdogData2;
|
|
18
|
+
watchdogReset: () => void;
|
|
19
|
+
keepAlive?: () => void;
|
|
20
|
+
onClientSeen?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare class WatchDog extends EventEmitter {
|
|
23
|
+
static lastSeenToDuration(lastSeen: number): number;
|
|
24
|
+
static emptyKeepAlive: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* returns the number of subscribers using the WatchDog object.
|
|
27
|
+
*/
|
|
28
|
+
get subscriberCount(): number;
|
|
29
|
+
private readonly _watchdogDataMap;
|
|
30
|
+
private _counter;
|
|
31
|
+
private _currentTime;
|
|
32
|
+
private _timer;
|
|
33
|
+
private readonly _visitSubscriberB;
|
|
34
|
+
constructor();
|
|
35
|
+
/**
|
|
36
|
+
* add a subscriber to the WatchDog.
|
|
37
|
+
* @method addSubscriber
|
|
38
|
+
*
|
|
39
|
+
* add a subscriber to the WatchDog.
|
|
40
|
+
*
|
|
41
|
+
* This method modifies the subscriber be adding a
|
|
42
|
+
* new method to it called 'keepAlive'
|
|
43
|
+
* The subscriber must also provide a "watchdogReset". watchdogReset will be called
|
|
44
|
+
* if the subscriber failed to call keepAlive withing the timeout period.
|
|
45
|
+
* @param subscriber
|
|
46
|
+
* @param timeout
|
|
47
|
+
* @return the numerical key associated with this subscriber
|
|
48
|
+
*/
|
|
49
|
+
addSubscriber(subscriber: ISubscriber, timeout: number): number;
|
|
50
|
+
removeSubscriber(subscriber: ISubscriber): void;
|
|
51
|
+
shutdown(): void;
|
|
52
|
+
getCurrentSystemTick(): ArbitraryClockTick;
|
|
53
|
+
private _visit_subscriber;
|
|
54
|
+
private _start_timer;
|
|
55
|
+
private _stop_timer;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
package/dist/watchdog.js
CHANGED
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WatchDog = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @module node-opcua-utils
|
|
6
|
-
*/
|
|
7
|
-
const events_1 = require("events");
|
|
8
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
-
const get_clock_tick_1 = require("./get_clock_tick");
|
|
10
|
-
function hasExpired(watchDogData, currentTime) {
|
|
11
|
-
const elapsedTime = currentTime - watchDogData.lastSeen;
|
|
12
|
-
return elapsedTime > watchDogData.timeout;
|
|
13
|
-
}
|
|
14
|
-
function keepAliveFunc() {
|
|
15
|
-
(0, node_opcua_assert_1.assert)(this._watchDog instanceof WatchDog);
|
|
16
|
-
// istanbul ignore next
|
|
17
|
-
if (!this._watchDogData || !this._watchDog) {
|
|
18
|
-
throw new Error("Internal error");
|
|
19
|
-
}
|
|
20
|
-
(0, node_opcua_assert_1.assert)(typeof this._watchDogData.key === "number");
|
|
21
|
-
this._watchDogData.lastSeen = this._watchDog.getCurrentSystemTick();
|
|
22
|
-
if (this.onClientSeen) {
|
|
23
|
-
this.onClientSeen();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class WatchDog extends events_1.EventEmitter {
|
|
27
|
-
constructor() {
|
|
28
|
-
super();
|
|
29
|
-
this._watchdogDataMap = {};
|
|
30
|
-
this._counter = 0;
|
|
31
|
-
this._currentTime = this.getCurrentSystemTick();
|
|
32
|
-
this._visitSubscriberB = this._visit_subscriber.bind(this);
|
|
33
|
-
this._timer = null; // as NodeJS.Timer;
|
|
34
|
-
}
|
|
35
|
-
static lastSeenToDuration(lastSeen) {
|
|
36
|
-
return (0, get_clock_tick_1.get_clock_tick)() - lastSeen;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* returns the number of subscribers using the WatchDog object.
|
|
40
|
-
*/
|
|
41
|
-
get subscriberCount() {
|
|
42
|
-
return Object.keys(this._watchdogDataMap).length;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* add a subscriber to the WatchDog.
|
|
46
|
-
* @method addSubscriber
|
|
47
|
-
*
|
|
48
|
-
* add a subscriber to the WatchDog.
|
|
49
|
-
*
|
|
50
|
-
* This method modifies the subscriber be adding a
|
|
51
|
-
* new method to it called 'keepAlive'
|
|
52
|
-
* The subscriber must also provide a "watchdogReset". watchdogReset will be called
|
|
53
|
-
* if the subscriber failed to call keepAlive withing the timeout period.
|
|
54
|
-
* @param subscriber
|
|
55
|
-
* @param timeout
|
|
56
|
-
* @return the numerical key associated with this subscriber
|
|
57
|
-
*/
|
|
58
|
-
addSubscriber(subscriber, timeout) {
|
|
59
|
-
this._currentTime = this.getCurrentSystemTick();
|
|
60
|
-
timeout = timeout || 1000;
|
|
61
|
-
(0, node_opcua_assert_1.assert)(typeof timeout === "number", " invalid timeout ");
|
|
62
|
-
(0, node_opcua_assert_1.assert)(typeof subscriber.watchdogReset === "function", " the subscriber must provide a watchdogReset method ");
|
|
63
|
-
(0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive !== "function" || subscriber.keepAlive === WatchDog.emptyKeepAlive);
|
|
64
|
-
this._counter += 1;
|
|
65
|
-
const key = this._counter;
|
|
66
|
-
subscriber._watchDog = this;
|
|
67
|
-
subscriber._watchDogData = {
|
|
68
|
-
key,
|
|
69
|
-
lastSeen: this._currentTime,
|
|
70
|
-
subscriber,
|
|
71
|
-
timeout,
|
|
72
|
-
visitCount: 0
|
|
73
|
-
};
|
|
74
|
-
this._watchdogDataMap[key] = subscriber._watchDogData;
|
|
75
|
-
if (subscriber.onClientSeen) {
|
|
76
|
-
subscriber.onClientSeen();
|
|
77
|
-
}
|
|
78
|
-
subscriber.keepAlive = keepAliveFunc.bind(subscriber);
|
|
79
|
-
// start timer when the first subscriber comes in
|
|
80
|
-
if (this.subscriberCount === 1) {
|
|
81
|
-
(0, node_opcua_assert_1.assert)(this._timer === null);
|
|
82
|
-
this._start_timer();
|
|
83
|
-
}
|
|
84
|
-
(0, node_opcua_assert_1.assert)(this._timer !== null);
|
|
85
|
-
return key;
|
|
86
|
-
}
|
|
87
|
-
removeSubscriber(subscriber) {
|
|
88
|
-
if (!subscriber._watchDog) {
|
|
89
|
-
return; // already removed !!!
|
|
90
|
-
}
|
|
91
|
-
if (!subscriber._watchDogData) {
|
|
92
|
-
throw new Error("Internal error");
|
|
93
|
-
}
|
|
94
|
-
(0, node_opcua_assert_1.assert)(subscriber._watchDog instanceof WatchDog);
|
|
95
|
-
(0, node_opcua_assert_1.assert)(typeof subscriber._watchDogData.key === "number");
|
|
96
|
-
(0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive === "function");
|
|
97
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key));
|
|
98
|
-
delete this._watchdogDataMap[subscriber._watchDogData.key];
|
|
99
|
-
delete subscriber._watchDog;
|
|
100
|
-
// leave it as it might be usefull, delete subscriber._watchDogData;
|
|
101
|
-
subscriber.keepAlive = WatchDog.emptyKeepAlive;
|
|
102
|
-
// delete timer when the last subscriber comes out
|
|
103
|
-
if (this.subscriberCount === 0) {
|
|
104
|
-
this._stop_timer();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
shutdown() {
|
|
108
|
-
(0, node_opcua_assert_1.assert)(this._timer === null && Object.keys(this._watchdogDataMap).length === 0, " leaking subscriber in watchdog");
|
|
109
|
-
}
|
|
110
|
-
getCurrentSystemTick() {
|
|
111
|
-
return (0, get_clock_tick_1.get_clock_tick)();
|
|
112
|
-
}
|
|
113
|
-
_visit_subscriber() {
|
|
114
|
-
this._currentTime = this.getCurrentSystemTick();
|
|
115
|
-
const expiredSubscribers = Object.values(this._watchdogDataMap).filter((watchDogData) => {
|
|
116
|
-
watchDogData.visitCount += 1;
|
|
117
|
-
return hasExpired(watchDogData, this._currentTime);
|
|
118
|
-
});
|
|
119
|
-
if (expiredSubscribers.length) {
|
|
120
|
-
this.emit("timeout", expiredSubscribers);
|
|
121
|
-
}
|
|
122
|
-
expiredSubscribers.forEach((watchDogData) => {
|
|
123
|
-
this.removeSubscriber(watchDogData.subscriber);
|
|
124
|
-
watchDogData.subscriber.watchdogReset();
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
_start_timer() {
|
|
128
|
-
(0, node_opcua_assert_1.assert)(this._timer === null, " setInterval already called ?");
|
|
129
|
-
this._timer = setInterval(this._visitSubscriberB, 1000);
|
|
130
|
-
}
|
|
131
|
-
_stop_timer() {
|
|
132
|
-
(0, node_opcua_assert_1.assert)(this._timer !== null, "_stop_timer already called ?");
|
|
133
|
-
if (this._timer !== null) {
|
|
134
|
-
clearInterval(this._timer);
|
|
135
|
-
this._timer = null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
exports.WatchDog = WatchDog;
|
|
140
|
-
WatchDog.emptyKeepAlive = () => {
|
|
141
|
-
/* */
|
|
142
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WatchDog = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
+
const get_clock_tick_1 = require("./get_clock_tick");
|
|
10
|
+
function hasExpired(watchDogData, currentTime) {
|
|
11
|
+
const elapsedTime = currentTime - watchDogData.lastSeen;
|
|
12
|
+
return elapsedTime > watchDogData.timeout;
|
|
13
|
+
}
|
|
14
|
+
function keepAliveFunc() {
|
|
15
|
+
(0, node_opcua_assert_1.assert)(this._watchDog instanceof WatchDog);
|
|
16
|
+
// istanbul ignore next
|
|
17
|
+
if (!this._watchDogData || !this._watchDog) {
|
|
18
|
+
throw new Error("Internal error");
|
|
19
|
+
}
|
|
20
|
+
(0, node_opcua_assert_1.assert)(typeof this._watchDogData.key === "number");
|
|
21
|
+
this._watchDogData.lastSeen = this._watchDog.getCurrentSystemTick();
|
|
22
|
+
if (this.onClientSeen) {
|
|
23
|
+
this.onClientSeen();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class WatchDog extends events_1.EventEmitter {
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this._watchdogDataMap = {};
|
|
30
|
+
this._counter = 0;
|
|
31
|
+
this._currentTime = this.getCurrentSystemTick();
|
|
32
|
+
this._visitSubscriberB = this._visit_subscriber.bind(this);
|
|
33
|
+
this._timer = null; // as NodeJS.Timer;
|
|
34
|
+
}
|
|
35
|
+
static lastSeenToDuration(lastSeen) {
|
|
36
|
+
return (0, get_clock_tick_1.get_clock_tick)() - lastSeen;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* returns the number of subscribers using the WatchDog object.
|
|
40
|
+
*/
|
|
41
|
+
get subscriberCount() {
|
|
42
|
+
return Object.keys(this._watchdogDataMap).length;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* add a subscriber to the WatchDog.
|
|
46
|
+
* @method addSubscriber
|
|
47
|
+
*
|
|
48
|
+
* add a subscriber to the WatchDog.
|
|
49
|
+
*
|
|
50
|
+
* This method modifies the subscriber be adding a
|
|
51
|
+
* new method to it called 'keepAlive'
|
|
52
|
+
* The subscriber must also provide a "watchdogReset". watchdogReset will be called
|
|
53
|
+
* if the subscriber failed to call keepAlive withing the timeout period.
|
|
54
|
+
* @param subscriber
|
|
55
|
+
* @param timeout
|
|
56
|
+
* @return the numerical key associated with this subscriber
|
|
57
|
+
*/
|
|
58
|
+
addSubscriber(subscriber, timeout) {
|
|
59
|
+
this._currentTime = this.getCurrentSystemTick();
|
|
60
|
+
timeout = timeout || 1000;
|
|
61
|
+
(0, node_opcua_assert_1.assert)(typeof timeout === "number", " invalid timeout ");
|
|
62
|
+
(0, node_opcua_assert_1.assert)(typeof subscriber.watchdogReset === "function", " the subscriber must provide a watchdogReset method ");
|
|
63
|
+
(0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive !== "function" || subscriber.keepAlive === WatchDog.emptyKeepAlive);
|
|
64
|
+
this._counter += 1;
|
|
65
|
+
const key = this._counter;
|
|
66
|
+
subscriber._watchDog = this;
|
|
67
|
+
subscriber._watchDogData = {
|
|
68
|
+
key,
|
|
69
|
+
lastSeen: this._currentTime,
|
|
70
|
+
subscriber,
|
|
71
|
+
timeout,
|
|
72
|
+
visitCount: 0
|
|
73
|
+
};
|
|
74
|
+
this._watchdogDataMap[key] = subscriber._watchDogData;
|
|
75
|
+
if (subscriber.onClientSeen) {
|
|
76
|
+
subscriber.onClientSeen();
|
|
77
|
+
}
|
|
78
|
+
subscriber.keepAlive = keepAliveFunc.bind(subscriber);
|
|
79
|
+
// start timer when the first subscriber comes in
|
|
80
|
+
if (this.subscriberCount === 1) {
|
|
81
|
+
(0, node_opcua_assert_1.assert)(this._timer === null);
|
|
82
|
+
this._start_timer();
|
|
83
|
+
}
|
|
84
|
+
(0, node_opcua_assert_1.assert)(this._timer !== null);
|
|
85
|
+
return key;
|
|
86
|
+
}
|
|
87
|
+
removeSubscriber(subscriber) {
|
|
88
|
+
if (!subscriber._watchDog) {
|
|
89
|
+
return; // already removed !!!
|
|
90
|
+
}
|
|
91
|
+
if (!subscriber._watchDogData) {
|
|
92
|
+
throw new Error("Internal error");
|
|
93
|
+
}
|
|
94
|
+
(0, node_opcua_assert_1.assert)(subscriber._watchDog instanceof WatchDog);
|
|
95
|
+
(0, node_opcua_assert_1.assert)(typeof subscriber._watchDogData.key === "number");
|
|
96
|
+
(0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive === "function");
|
|
97
|
+
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key));
|
|
98
|
+
delete this._watchdogDataMap[subscriber._watchDogData.key];
|
|
99
|
+
delete subscriber._watchDog;
|
|
100
|
+
// leave it as it might be usefull, delete subscriber._watchDogData;
|
|
101
|
+
subscriber.keepAlive = WatchDog.emptyKeepAlive;
|
|
102
|
+
// delete timer when the last subscriber comes out
|
|
103
|
+
if (this.subscriberCount === 0) {
|
|
104
|
+
this._stop_timer();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
shutdown() {
|
|
108
|
+
(0, node_opcua_assert_1.assert)(this._timer === null && Object.keys(this._watchdogDataMap).length === 0, " leaking subscriber in watchdog");
|
|
109
|
+
}
|
|
110
|
+
getCurrentSystemTick() {
|
|
111
|
+
return (0, get_clock_tick_1.get_clock_tick)();
|
|
112
|
+
}
|
|
113
|
+
_visit_subscriber() {
|
|
114
|
+
this._currentTime = this.getCurrentSystemTick();
|
|
115
|
+
const expiredSubscribers = Object.values(this._watchdogDataMap).filter((watchDogData) => {
|
|
116
|
+
watchDogData.visitCount += 1;
|
|
117
|
+
return hasExpired(watchDogData, this._currentTime);
|
|
118
|
+
});
|
|
119
|
+
if (expiredSubscribers.length) {
|
|
120
|
+
this.emit("timeout", expiredSubscribers);
|
|
121
|
+
}
|
|
122
|
+
expiredSubscribers.forEach((watchDogData) => {
|
|
123
|
+
this.removeSubscriber(watchDogData.subscriber);
|
|
124
|
+
watchDogData.subscriber.watchdogReset();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
_start_timer() {
|
|
128
|
+
(0, node_opcua_assert_1.assert)(this._timer === null, " setInterval already called ?");
|
|
129
|
+
this._timer = setInterval(this._visitSubscriberB, 1000);
|
|
130
|
+
}
|
|
131
|
+
_stop_timer() {
|
|
132
|
+
(0, node_opcua_assert_1.assert)(this._timer !== null, "_stop_timer already called ?");
|
|
133
|
+
if (this._timer !== null) {
|
|
134
|
+
clearInterval(this._timer);
|
|
135
|
+
this._timer = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.WatchDog = WatchDog;
|
|
140
|
+
WatchDog.emptyKeepAlive = () => {
|
|
141
|
+
/* */
|
|
142
|
+
};
|
|
143
143
|
//# sourceMappingURL=watchdog.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.69.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -utils",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"lint": "eslint source test",
|
|
10
10
|
"format": "prettier --write source test",
|
|
11
11
|
"test": "mocha",
|
|
12
|
-
"clean": "
|
|
12
|
+
"clean": "npx rimraf dist *.tsbuildinfo"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"chalk": "4.1.2",
|
|
16
|
-
"node-opcua-assert": "2.
|
|
16
|
+
"node-opcua-assert": "2.66.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "17.0.
|
|
19
|
+
"@types/node": "17.0.36",
|
|
20
20
|
"should": "^13.2.3",
|
|
21
|
-
"sinon": "^
|
|
21
|
+
"sinon": "^14.0.0"
|
|
22
22
|
},
|
|
23
23
|
"author": "Etienne Rossignon",
|
|
24
24
|
"license": "MIT",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"internet of things"
|
|
36
36
|
],
|
|
37
37
|
"homepage": "http://node-opcua.github.io/",
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "6c88d05e8c82ce4bc9c8af9f0a8eb6136f31d2ce"
|
|
39
39
|
}
|
package/source/string_utils.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function capitalizeFirstLetter(str: string): string {
|
|
|
6
6
|
if (str == null) {
|
|
7
7
|
return str;
|
|
8
8
|
}
|
|
9
|
-
return str.
|
|
9
|
+
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const ACode = "A".charCodeAt(0);
|
|
@@ -113,9 +113,9 @@ export function lowerFirstLetter(str: string): string {
|
|
|
113
113
|
if (str.match(/_/)) {
|
|
114
114
|
return str.split("_").map(lowerFirstLetter).join("_");
|
|
115
115
|
}
|
|
116
|
-
let result = str.
|
|
116
|
+
let result = str.substring(0, 1).toLowerCase() + str.substring(1);
|
|
117
117
|
if (result.length > 3 && isUpperCaseChar(str[1]) && isUpperCaseChar(str[2])) {
|
|
118
|
-
result = str.
|
|
118
|
+
result = str.substring(0, 2).toLowerCase() + str.substring(2);
|
|
119
119
|
}
|
|
120
120
|
return result;
|
|
121
121
|
}
|
package/source/timestamp.ts
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* @module node-opcua-utils
|
|
5
|
-
*/
|
|
6
|
-
function constructFilename(filename) {
|
|
7
|
-
throw new Error("constructFilename has been deprecated ! use node-opcua-nodesets.constructFilename or ....");
|
|
8
|
-
// xx var dirname = $_$.dirname;
|
|
9
|
-
// xx var file = path.join(dirname, filename);
|
|
10
|
-
// xx return file;
|
|
11
|
-
}
|
|
12
|
-
exports.constructFilename = constructFilename;
|
|
13
|
-
//# sourceMappingURL=construct_filename.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"construct_filename.js","sourceRoot":"","sources":["../source/construct_filename.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,SAAgB,iBAAiB,CAAC,QAAgB;IAC9C,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;IAC7G,mCAAmC;IACnC,iDAAiD;IACjD,qBAAqB;AACzB,CAAC;AALD,8CAKC"}
|
package/dist/linefile.d.ts
DELETED
package/dist/linefile.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* @module node-opcua-utils
|
|
5
|
-
*/
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const os = require("os");
|
|
8
|
-
class LineFile {
|
|
9
|
-
constructor() {
|
|
10
|
-
this._line = [];
|
|
11
|
-
this.write("// --------- This code has been automatically generated !!! " + new Date().toISOString());
|
|
12
|
-
this.write("/**");
|
|
13
|
-
this.write(" * @module node-opcua-types");
|
|
14
|
-
this.write(" */");
|
|
15
|
-
}
|
|
16
|
-
write(...arg) {
|
|
17
|
-
let str = "";
|
|
18
|
-
// tslint:disable:prefer-for-of
|
|
19
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
20
|
-
str += arguments[i];
|
|
21
|
-
}
|
|
22
|
-
this._line.push(str);
|
|
23
|
-
}
|
|
24
|
-
toString() {
|
|
25
|
-
return this._line.join(os.EOL);
|
|
26
|
-
}
|
|
27
|
-
save(filename) {
|
|
28
|
-
fs_1.writeFileSync(filename, this.toString(), "ascii");
|
|
29
|
-
}
|
|
30
|
-
saveFormat(filename, formatter) {
|
|
31
|
-
const code = formatter(this.toString());
|
|
32
|
-
fs_1.writeFileSync(filename, code, "ascii");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.LineFile = LineFile;
|
|
36
|
-
//# sourceMappingURL=linefile.js.map
|
package/dist/linefile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linefile.js","sourceRoot":"","sources":["../source/linefile.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,2BAAmC;AACnC,yBAAyB;AAEzB,MAAa,QAAQ;IAIjB;QACI,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,8DAA8D,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACtG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,GAAG,GAAa;QACzB,IAAI,GAAG,GAAG,EAAE,CAAC;QAEb,+BAA+B;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACvB;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAEM,IAAI,CAAC,QAAgB;QACxB,kBAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAEM,UAAU,CAAC,QAAgB,EAAE,SAAmC;QACnE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxC,kBAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACJ;AAlCD,4BAkCC"}
|