node-red-contrib-uos-nats 0.2.54 → 0.2.56
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/lib/payloads.js +11 -13
- package/nodes/datahub-output.js +5 -2
- package/package.json +1 -1
package/lib/payloads.js
CHANGED
|
@@ -288,28 +288,26 @@ function buildVariableList(defs, states, fingerprint) {
|
|
|
288
288
|
variables.push(encodeVariableState(def, state));
|
|
289
289
|
}
|
|
290
290
|
// Always provide a baseTimestamp to satisfy strict schema requirements
|
|
291
|
-
// Use
|
|
292
|
-
// This
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const nanos = Number(totalNs % 1_000_000_000n);
|
|
300
|
-
baseTimestamp = new TimestampT(secs, nanos);
|
|
291
|
+
// Use the timestamp of the first item if available, otherwise NOW.
|
|
292
|
+
// This allows relative timestamps in the list to be non-negative if we tracked deltas,
|
|
293
|
+
// but mostly ensures logical consistency (Base <= Item).
|
|
294
|
+
let baseTimestamp = null;
|
|
295
|
+
if (variables.length > 0 && variables[0].timestamp) {
|
|
296
|
+
baseTimestamp = variables[0].timestamp;
|
|
297
|
+
} else {
|
|
298
|
+
baseTimestamp = nowNs();
|
|
301
299
|
}
|
|
302
|
-
*/
|
|
303
300
|
|
|
304
301
|
const list = new VariableListT(fingerprint, baseTimestamp, variables);
|
|
305
|
-
// console.log(`[Payloads] Built VariableList with baseTimestamp: ${baseTimestamp ? 'SET' : 'NULL'}`);
|
|
306
302
|
return list;
|
|
307
303
|
}
|
|
308
304
|
function encodeVariableState(def, state) {
|
|
309
305
|
const varT = new VariableT();
|
|
310
306
|
varT.id = def.id;
|
|
311
307
|
varT.quality = VariableQuality[state?.quality?.toUpperCase?.()] ?? VariableQuality[DEFAULT_QUALITY];
|
|
312
|
-
|
|
308
|
+
|
|
309
|
+
// Logic matches Sample: use state.timestamp or now
|
|
310
|
+
if (state?.timestamp) {
|
|
313
311
|
const totalNs = BigInt(state.timestamp);
|
|
314
312
|
const secs = totalNs / 1_000_000_000n;
|
|
315
313
|
const nanos = Number(totalNs % 1_000_000_000n);
|
package/nodes/datahub-output.js
CHANGED
|
@@ -84,7 +84,7 @@ module.exports = function (RED) {
|
|
|
84
84
|
id: nextId += 1,
|
|
85
85
|
key: normalized,
|
|
86
86
|
dataType,
|
|
87
|
-
access: '
|
|
87
|
+
access: 'READ_ONLY',
|
|
88
88
|
};
|
|
89
89
|
defMap.set(normalized, def);
|
|
90
90
|
definitions.push(def);
|
|
@@ -175,7 +175,10 @@ module.exports = function (RED) {
|
|
|
175
175
|
nc = await connection.acquire();
|
|
176
176
|
console.log('[DataHub Output] NATS acquired.');
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
// Only publish definition if we have one. Empty definitions might be rejected?
|
|
179
|
+
if (definitions.length > 0) {
|
|
180
|
+
await sendDefinitionUpdate(payloads, subjects);
|
|
181
|
+
}
|
|
179
182
|
|
|
180
183
|
// Listen for Variable READ requests
|
|
181
184
|
sub = nc.subscribe(subjects.readVariablesQuery(this.providerId), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-uos-nats",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.56",
|
|
4
4
|
"description": "Node-RED nodes for Weidmüller u-OS Data Hub. Read, write, and provide variables via NATS protocol with OAuth2 authentication. Features: Variable Key resolution, custom icons, example flows, and provider definition caching.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "IoTUeli",
|