Compare commits

..

2 Commits

Author SHA1 Message Date
znetsixe
00e35302b4 fix(examples): complete ui-chart required props in edge.flow.json (flow-lint)
State-code chart was missing interpolation, axis property types, action, colors.
Lint-clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 19:18:44 +02:00
znetsixe
0a3a0be15b feat(commands): adopt unified command envelope — msg.origin + unit shorthand
- Provenance resolved via msg.origin (registry-stamped, default parent) with a
  legacy fallback to payload.source; feeds handleInput's mode/source gating.
- set.flow-setpoint: units:{measure,default} -> unit:'m3/h' shorthand.

181/181 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 18:41:14 +02:00
3 changed files with 33 additions and 7 deletions

View File

@@ -322,6 +322,22 @@
"removeOlderUnit": "3600",
"x": 1230,
"y": 300,
"wires": []
"wires": [],
"interpolation": "linear",
"xAxisPropertyType": "timestamp",
"yAxisProperty": "payload",
"yAxisPropertyType": "msg",
"action": "append",
"colors": [
"#0095FF",
"#FF0000",
"#FF7F0E",
"#2CA02C",
"#A347E1",
"#D62728",
"#FF9896",
"#9467BD",
"#C5B0D5"
]
}
]

View File

@@ -16,6 +16,16 @@ function _logger(source, ctx) {
return ctx?.logger || source?.logger || null;
}
// Resolve the command origin (control authority: parent | GUI | fysical).
// The shared commandRegistry stamps msg.origin (default 'parent'); legacy flows
// carried the origin as payload.source. Prefer the legacy field when present so
// existing flows keep working, otherwise use the registry-stamped msg.origin.
function _origin(msg) {
const p = msg && msg.payload;
if (p && typeof p === 'object' && typeof p.source === 'string' && p.source) return p.source;
return (typeof msg?.origin === 'string' && msg.origin) ? msg.origin : 'parent';
}
function _send(ctx, ports) {
if (typeof ctx?.send === 'function') ctx.send(ports);
}
@@ -28,19 +38,19 @@ exports.setMode = (source, msg) => {
// forwards to these directly so behaviour is identical.
exports.startup = async (source, msg) => {
const p = msg.payload || {};
await source.handleInput(p.source ?? 'parent', 'execSequence', 'startup');
await source.handleInput(_origin(msg), 'execSequence', 'startup');
};
exports.shutdown = async (source, msg) => {
const p = msg.payload || {};
await source.handleInput(p.source ?? 'parent', 'execSequence', 'shutdown');
await source.handleInput(_origin(msg), 'execSequence', 'shutdown');
};
exports.estop = async (source, msg) => {
const p = msg.payload || {};
// Legacy emergencystop carried { source, action } — action defaults to
// 'emergencystop' when only source is supplied via the canonical topic.
await source.handleInput(p.source ?? 'parent', p.action ?? 'emergencystop');
await source.handleInput(_origin(msg), p.action ?? 'emergencystop');
};
// Content-based alias router: legacy `execSequence` carried payload.action in
@@ -57,13 +67,13 @@ exports.execSequenceAlias = async (source, msg, ctx) => {
exports.setSetpoint = async (source, msg) => {
const p = msg.payload || {};
const action = p.action ?? 'execMovement';
await source.handleInput(p.source ?? 'parent', action, Number(p.setpoint));
await source.handleInput(_origin(msg), action, Number(p.setpoint));
};
exports.setFlowSetpoint = async (source, msg) => {
const p = msg.payload || {};
const action = p.action ?? 'flowMovement';
await source.handleInput(p.source ?? 'parent', action, Number(p.setpoint));
await source.handleInput(_origin(msg), action, Number(p.setpoint));
};
exports.simulateMeasurement = (source, msg, ctx) => {

View File

@@ -63,7 +63,7 @@ module.exports = [
topic: 'set.flow-setpoint',
aliases: ['flowMovement'],
payloadSchema: { type: 'object' },
units: { measure: 'volumeFlowRate', default: 'm3/h' },
unit: 'm3/h',
description: 'Move the machine to a flow setpoint via flowMovement.',
handler: handlers.setFlowSetpoint,
},