From 6c4db03aba7e2f96d9f4c3d7bb1e3e49d4c70fee Mon Sep 17 00:00:00 2001 From: znetsixe Date: Thu, 21 May 2026 15:06:39 +0200 Subject: [PATCH] feat(formatters): frost handoff formatter + config wiring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds src/helper/formatters/frostFormatter.js — structured-envelope formatter parallel to the InfluxDB one. Produces dbase messages that a CoreSync collector can forward to FROST/SensorThings without coupling producing nodes to FROST HTTP details. Registered in formatters/index.js. Config additions in 4 node schemas (machineGroupControl, measurement, pumpingStation, rotatingMachine) expose the new dbase format option in the editor. Part of the CoreSync FROST handoff initiative — see superproject CORESYNC_FROST_INTERVIEW_HANDOFF.md. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/configs/machineGroupControl.json | 1 + src/configs/measurement.json | 3 ++- src/configs/pumpingStation.json | 4 ++++ src/configs/rotatingMachine.json | 1 + src/helper/formatters/frostFormatter.js | 23 +++++++++++++++++++++++ src/helper/formatters/index.js | 2 ++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/helper/formatters/frostFormatter.js diff --git a/src/configs/machineGroupControl.json b/src/configs/machineGroupControl.json index 95f5ac3..df407b4 100644 --- a/src/configs/machineGroupControl.json +++ b/src/configs/machineGroupControl.json @@ -134,6 +134,7 @@ "type": "enum", "values": [ { "value": "influxdb", "description": "InfluxDB line-protocol payload (default)." }, + { "value": "frost", "description": "FROST/SensorThings CoreSync payload." }, { "value": "json", "description": "Raw JSON payload." }, { "value": "csv", "description": "CSV-formatted payload." } ], diff --git a/src/configs/measurement.json b/src/configs/measurement.json index c8eb188..2d2652e 100644 --- a/src/configs/measurement.json +++ b/src/configs/measurement.json @@ -120,6 +120,7 @@ "type": "enum", "values": [ { "value": "influxdb", "description": "InfluxDB line-protocol payload (default)." }, + { "value": "frost", "description": "FROST/SensorThings CoreSync payload." }, { "value": "json", "description": "Raw JSON payload." }, { "value": "csv", "description": "CSV-formatted payload." } ], @@ -512,4 +513,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/configs/pumpingStation.json b/src/configs/pumpingStation.json index 793053b..d126de2 100644 --- a/src/configs/pumpingStation.json +++ b/src/configs/pumpingStation.json @@ -166,6 +166,10 @@ "value": "influxdb", "description": "InfluxDB telemetry payload." }, + { + "value": "frost", + "description": "FROST/SensorThings CoreSync payload." + }, { "value": "json", "description": "JSON payload." diff --git a/src/configs/rotatingMachine.json b/src/configs/rotatingMachine.json index 36e92aa..dc00374 100644 --- a/src/configs/rotatingMachine.json +++ b/src/configs/rotatingMachine.json @@ -134,6 +134,7 @@ "type": "enum", "values": [ { "value": "influxdb", "description": "InfluxDB line-protocol payload (default)." }, + { "value": "frost", "description": "FROST/SensorThings CoreSync payload." }, { "value": "json", "description": "Raw JSON payload." }, { "value": "csv", "description": "CSV-formatted payload." } ], diff --git a/src/helper/formatters/frostFormatter.js b/src/helper/formatters/frostFormatter.js new file mode 100644 index 0000000..0393f80 --- /dev/null +++ b/src/helper/formatters/frostFormatter.js @@ -0,0 +1,23 @@ +/** + * FROST handoff formatter + * ----------------------- + * Keeps the same structured envelope as the InfluxDB formatter so a shared + * CoreSync collector can accept existing EVOLV dbase messages without coupling + * producing nodes to FROST HTTP details. + */ +function format(measurement, metadata) { + const { fields, tags, config } = metadata; + return { + measurement, + fields, + tags: tags || {}, + timestamp: new Date().toISOString(), + source: { + nodeId: config?.general?.id, + softwareType: config?.functionality?.softwareType, + unit: config?.general?.unit || config?.asset?.unit, + }, + }; +} + +module.exports = { format }; diff --git a/src/helper/formatters/index.js b/src/helper/formatters/index.js index 9d57313..29f00ec 100644 --- a/src/helper/formatters/index.js +++ b/src/helper/formatters/index.js @@ -14,6 +14,7 @@ const influxdbFormatter = require('./influxdbFormatter'); const jsonFormatter = require('./jsonFormatter'); const csvFormatter = require('./csvFormatter'); const processFormatter = require('./processFormatter'); +const frostFormatter = require('./frostFormatter'); // Built-in registry const registry = { @@ -21,6 +22,7 @@ const registry = { json: jsonFormatter, csv: csvFormatter, process: processFormatter, + frost: frostFormatter, }; /**