@yarkivaev/scada 2.3.56 → 2.3.57
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarkivaev/scada",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.57",
|
|
4
4
|
"description": "SCADA domain objects, state persistence, and plant monitoring",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@clickhouse/client": "^1.0.0",
|
|
31
31
|
"@yarkivaev/simple-server": "1.0.1",
|
|
32
|
-
"@yarkivaev/source-to-sink": "1.3.
|
|
32
|
+
"@yarkivaev/source-to-sink": "1.3.3",
|
|
33
33
|
"amqplib": "^0.10.9",
|
|
34
34
|
"pg": "^8.0.0",
|
|
35
35
|
"stompit": "^1.0.0"
|
|
@@ -18,37 +18,37 @@ function isSilent(lastSeen, name, clk, budgetMs) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Stops one
|
|
21
|
+
* Stops one started poll if present. The poll instance is kept for reuse.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {object} state - Gate mutable state
|
|
24
24
|
* @param {string} name - Stream id
|
|
25
25
|
*/
|
|
26
|
-
function stopOne(
|
|
27
|
-
|
|
28
|
-
if (!poll) {
|
|
26
|
+
function stopOne(state, name) {
|
|
27
|
+
if (!state.live.has(name)) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
state.held.get(name).stop();
|
|
31
|
+
state.live.delete(name);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
|
-
* Starts one poll
|
|
35
|
+
* Starts one poll, opening the source only the first time.
|
|
37
36
|
*
|
|
38
|
-
* @param {
|
|
37
|
+
* @param {object} state - Gate mutable state
|
|
39
38
|
* @param {object} source - Stream source
|
|
40
|
-
* @param {object} collector - Metrics collector
|
|
41
|
-
* @param {object} clk - Clock
|
|
42
|
-
* @param {number} intervalSec - Poll interval seconds
|
|
43
39
|
*/
|
|
44
|
-
function startOne(
|
|
40
|
+
function startOne(state, source) {
|
|
45
41
|
const name = source.name();
|
|
46
|
-
if (
|
|
42
|
+
if (state.live.has(name)) {
|
|
47
43
|
return;
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
let poll = state.held.get(name);
|
|
46
|
+
if (!poll) {
|
|
47
|
+
poll = source.open(state.collector, state.clk, state.intervalSec);
|
|
48
|
+
state.held.set(name, poll);
|
|
49
|
+
}
|
|
51
50
|
poll.start();
|
|
51
|
+
state.live.add(name);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -63,9 +63,9 @@ function pulse(state) {
|
|
|
63
63
|
for (const source of state.sources) {
|
|
64
64
|
const name = source.name();
|
|
65
65
|
if (isSilent(state.lastSeen, name, state.clk, state.budgetMs)) {
|
|
66
|
-
startOne(state
|
|
66
|
+
startOne(state, source);
|
|
67
67
|
} else {
|
|
68
|
-
stopOne(state
|
|
68
|
+
stopOne(state, name);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -88,7 +88,8 @@ function gateState(config) {
|
|
|
88
88
|
}),
|
|
89
89
|
clear: config.clear || clearInterval,
|
|
90
90
|
lastSeen: new Map(),
|
|
91
|
-
|
|
91
|
+
held: new Map(),
|
|
92
|
+
live: new Set(),
|
|
92
93
|
collector: undefined,
|
|
93
94
|
timer: undefined,
|
|
94
95
|
running: false
|
|
@@ -143,9 +144,10 @@ export default function silentStreams(config) {
|
|
|
143
144
|
state.clear(state.timer);
|
|
144
145
|
state.timer = undefined;
|
|
145
146
|
}
|
|
146
|
-
for (const name of [...state.
|
|
147
|
-
stopOne(state
|
|
147
|
+
for (const name of [...state.live]) {
|
|
148
|
+
stopOne(state, name);
|
|
148
149
|
}
|
|
150
|
+
state.held.clear();
|
|
149
151
|
},
|
|
150
152
|
pulse: runPulse
|
|
151
153
|
};
|