@yarkivaev/scada 1.3.1 → 1.3.3

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": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "SCADA domain objects for plant monitoring",
5
5
  "repository": {
6
6
  "type": "git",
@@ -80,7 +80,7 @@ export default function clickhouseSensor(connection, topic, displayName, unit) {
80
80
  lastTs = timestamp;
81
81
  });
82
82
  } catch (err) {
83
- console.error('Stream query failed:', err.message); // eslint-disable-line no-console
83
+ console.error(`Stream query failed for ${topic} on ${connection.url()}:`, err.message); // eslint-disable-line no-console
84
84
  }
85
85
  }, step);
86
86
  return {
package/src/segments.js CHANGED
@@ -10,7 +10,7 @@ import pubsub from './pubsub.js';
10
10
  * @example
11
11
  * const segs = segments();
12
12
  * segs.add({ name: 'on', startTime: new Date(), endTime: new Date(), duration: 60 });
13
- * segs.relabel(startTime, 'heating');
13
+ * segs.relabel(startTime, ['heating'], {});
14
14
  * segs.query(); // all segments
15
15
  * segs.query({ from: '2024-01-01', to: '2024-01-02' }); // filtered
16
16
  * const sub = segs.stream((e) => console.log(e));
@@ -24,12 +24,24 @@ export default function segments() {
24
24
  items.push(segment);
25
25
  bus.emit({ type: 'created', segment });
26
26
  },
27
- relabel(start, name) {
27
+ relabel(start, tags, properties) {
28
28
  const found = items.find((item) => {
29
29
  return item.startTime.getTime() === start.getTime();
30
30
  });
31
31
  if (found) {
32
- found.name = name;
32
+ found.tags = tags;
33
+ found.properties = properties;
34
+ bus.emit({ type: 'relabeled', segment: found });
35
+ }
36
+ },
37
+ retag(start, tags, properties) {
38
+ const found = items.find((item) => {
39
+ return item.startTime.getTime() === start.getTime();
40
+ });
41
+ if (found) {
42
+ found.tags = tags;
43
+ found.properties = properties;
44
+ delete found.options;
33
45
  bus.emit({ type: 'relabeled', segment: found });
34
46
  }
35
47
  },