@yarkivaev/scada 2.3.90 → 2.3.112
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/README.md +6 -1
- package/charts/scada/Chart.yaml +6 -0
- package/charts/scada/templates/_helpers.tpl +63 -0
- package/charts/scada/templates/clickhouse.yaml +57 -0
- package/charts/scada/templates/collector.yaml +115 -0
- package/charts/scada/templates/postgres.yaml +70 -0
- package/charts/scada/templates/rabbitmq.yaml +150 -0
- package/charts/scada/templates/site-server.yaml +110 -0
- package/charts/scada/templates/supervisor-sink.yaml +64 -0
- package/charts/scada/values.yaml +30 -0
- package/index.js +10 -0
- package/package.json +3 -1
- package/src/application/deploy/appReleases.js +50 -0
- package/src/application/deploy/applyIncludes.js +31 -0
- package/src/application/deploy/expand.js +49 -0
- package/src/application/deploy/expandDevices.js +135 -0
- package/src/application/deploy/expandFlows.js +281 -0
- package/src/application/deploy/expandNamespace.js +193 -0
- package/src/application/deploy/expandPattern.js +207 -0
- package/src/application/deploy/expandProfiles.js +70 -0
- package/src/application/deploy/frozen.js +23 -0
- package/src/application/deploy/mergeDocuments.js +98 -0
- package/src/application/deploy/paths.js +86 -0
- package/src/application/deploy/pointPaths.js +20 -0
- package/src/application/deploy/readDocument.js +169 -0
- package/src/application/deploy/releaseEdges.js +185 -0
- package/src/application/deploy/releaseNodes.js +118 -0
- package/src/application/deploy/releaseValues.js +200 -0
- package/src/application/deploy/releases.js +115 -0
- package/src/application/deploy/withCollectors.js +28 -0
- package/src/bin/modbus-to-mqtt.js +57 -0
- package/src/infrastructure/ingest/mqtt/addressWindow.js +79 -0
- package/src/infrastructure/ingest/mqtt/modbusPublish.js +277 -0
- package/src/infrastructure/ingest/mqtt/registerPoint.js +90 -0
- package/src/infrastructure/ingest/mqtt/registerPublish.js +84 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { decodePoint } from './registerPoint.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Measurement name for one mapped parameter.
|
|
5
|
+
*
|
|
6
|
+
* A stream path plus the parameter id is the document path. An empty
|
|
7
|
+
* stream keeps the parameter id, which is the generic fallback name.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* measurementPath('mill/electrical', 'voltage');
|
|
11
|
+
*
|
|
12
|
+
* @param {string} stream - document path
|
|
13
|
+
* @param {string} key - parameter id
|
|
14
|
+
* @returns {string} MQTT topic
|
|
15
|
+
*/
|
|
16
|
+
export function measurementPath(stream, key) {
|
|
17
|
+
if (typeof stream === 'string' && stream.length > 0) {
|
|
18
|
+
return `${stream}/${key}`;
|
|
19
|
+
}
|
|
20
|
+
return String(key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Publish plan for one device map.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* measurementPlans('mill/electrical', { voltage: 'holding:4000:cdab' });
|
|
28
|
+
*
|
|
29
|
+
* @param {string} stream - document path
|
|
30
|
+
* @param {object} mapping - parameter id to register point
|
|
31
|
+
* @returns {Array<{point: string, topic: string}>} publish plan
|
|
32
|
+
*/
|
|
33
|
+
export function measurementPlans(stream, mapping) {
|
|
34
|
+
return Object.keys(mapping || {}).map((key) => {
|
|
35
|
+
return {
|
|
36
|
+
point: String(mapping[key]),
|
|
37
|
+
topic: measurementPath(stream, key)
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Publishes one MQTT record per holding-register point.
|
|
44
|
+
*
|
|
45
|
+
* Each record is `{topic, payload}` and the payload is JSON `{ts, value}`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const transformer = registerPublish(plans, 4000, collector);
|
|
49
|
+
* transformer.accept([0, 16256]);
|
|
50
|
+
*
|
|
51
|
+
* @param {Array<{point: string, topic: string}>} plans - publish plan
|
|
52
|
+
* @param {number} origin - first PDU address in the window
|
|
53
|
+
* @param {object} collector - collector with accept()
|
|
54
|
+
* @returns {object} transformer with accept(registers)
|
|
55
|
+
*/
|
|
56
|
+
export default function registerPublish(plans, origin, collector) {
|
|
57
|
+
if (!collector || typeof collector.accept !== 'function') {
|
|
58
|
+
throw new Error('Collector must have an accept() method');
|
|
59
|
+
}
|
|
60
|
+
const rows = (plans || []).map((item) => {
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
point: item.point,
|
|
63
|
+
topic: item.topic
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
/**
|
|
68
|
+
* Decodes the window and publishes one record per point.
|
|
69
|
+
*
|
|
70
|
+
* @param {Array<number>} registers - uint16 window
|
|
71
|
+
*/
|
|
72
|
+
accept(registers) {
|
|
73
|
+
rows.forEach((item) => {
|
|
74
|
+
collector.accept({
|
|
75
|
+
payload: JSON.stringify({
|
|
76
|
+
ts: Date.now(),
|
|
77
|
+
value: decodePoint(item.point, origin, registers)
|
|
78
|
+
}),
|
|
79
|
+
topic: item.topic
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|