@yarkivaev/scada 2.6.10 → 2.6.12
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
|
@@ -30,6 +30,14 @@ function timelineBusesInPlant(p) {
|
|
|
30
30
|
return buses;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* STOMP destination for live HMI timeline segments.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* stompSource(url, timelineSegmentDestination, collector, credentials);
|
|
38
|
+
*/
|
|
39
|
+
export const timelineSegmentDestination = '/exchange/scada.segments/#';
|
|
40
|
+
|
|
33
41
|
function wireTimelineSegments(stomp, plant) {
|
|
34
42
|
if (!stomp || !stomp.url) {
|
|
35
43
|
return undefined;
|
|
@@ -40,7 +48,7 @@ function wireTimelineSegments(stomp, plant) {
|
|
|
40
48
|
}
|
|
41
49
|
const credentials = { login: stomp.login, passcode: stomp.passcode, host: stomp.host };
|
|
42
50
|
return stompTimelineSegments(
|
|
43
|
-
stompCollectorFactory(stomp.url,
|
|
51
|
+
stompCollectorFactory(stomp.url, timelineSegmentDestination, credentials),
|
|
44
52
|
buses
|
|
45
53
|
);
|
|
46
54
|
}
|
|
@@ -171,7 +171,8 @@ export default function historyPg(pool, { retentionDays = 30, now = Date.now, ob
|
|
|
171
171
|
if (observationSource) { try { await assertHistoryReady(pool,machine); } catch (error) { if (error.statusCode===409) { return {items:[]}; } throw error; } }
|
|
172
172
|
const fence = await historyFence(pool, machine, timeScale);
|
|
173
173
|
const result = await pool.query(`SELECT id,token,machine AS "streamId",from_ms AS "from",until_ms AS "until",cursor_ms AS cursor,end_ms AS end
|
|
174
|
-
FROM history_work WHERE machine=$1 AND until_ms < $2
|
|
174
|
+
FROM history_work WHERE machine=$1 AND until_ms < $2 - COALESCE((SELECT bucket_ms FROM history_topics WHERE machine=$1 LIMIT 1), 30000 * $3)
|
|
175
|
+
ORDER BY until_ms ASC,created_at,id LIMIT 8`, [machine, fence, timeScale]);
|
|
175
176
|
return { items: result.rows.map((row) => { return { ...row, from: Number(row.from), until: Number(row.until),cursor:row.cursor === null ? null : Number(row.cursor),end:row.end === null ? null : Number(row.end) }; }) };
|
|
176
177
|
},
|
|
177
178
|
commit(machine, workId, segments, base) { return commit(pool, machine, workId, segments, {base, observationSource,timeScale}); }
|
|
@@ -44,7 +44,7 @@ async function stamp(client,machine,time) {
|
|
|
44
44
|
async function enqueue(client,mapping,row) {
|
|
45
45
|
const pending=await client.query('SELECT id FROM history_work WHERE machine=$1 AND cursor_ms IS NULL AND end_ms IS NULL AND floor(from_ms::numeric/$2)=floor($3::numeric/$2) ORDER BY created_at LIMIT 1',[mapping.machine,mapping.bucket_ms,row.time]);
|
|
46
46
|
if(pending.rowCount){
|
|
47
|
-
await client.query('UPDATE history_work SET
|
|
47
|
+
await client.query('UPDATE history_work SET from_ms=least(from_ms,$2),until_ms=greatest(until_ms,$2) WHERE id=$1',[pending.rows[0].id,row.time]);
|
|
48
48
|
}else{await client.query('INSERT INTO history_work(id,machine,from_ms,until_ms) VALUES(gen_random_uuid(),$1,$2,$2)',[mapping.machine,row.time]);}
|
|
49
49
|
}
|
|
50
50
|
/** Durable queue redelivery owns payload recovery. Barriers never expire on a timer. */
|
|
@@ -21,7 +21,7 @@ export async function classifierSeed(pool,machine,before,key,{claim,cursor}={})
|
|
|
21
21
|
return result.rowCount ? {at:Number(result.rows[0].time_ms),state:result.rows[0].state} : null;
|
|
22
22
|
}
|
|
23
23
|
export async function classifierPage(pool,machine,page,key) {
|
|
24
|
-
const target=await pool.query('SELECT time_ms FROM history_checkpoints WHERE machine=$1 AND classifier_key=$2 AND time_ms BETWEEN $3 AND $4 ORDER BY time_ms LIMIT 1',[machine,key,page.from,page.until]);
|
|
24
|
+
const target=await pool.query('SELECT time_ms FROM history_checkpoints WHERE machine=$1 AND classifier_key=$2 AND valid AND time_ms BETWEEN $3 AND $4 ORDER BY time_ms LIMIT 1',[machine,key,page.from,page.until]);
|
|
25
25
|
if (!target.rowCount || Number(target.rows[0].time_ms)===page.until) { return page; }
|
|
26
26
|
const until=Number(target.rows[0].time_ms);
|
|
27
27
|
return {...page,until,next:until+1};
|