Compare commits
1 Commits
75d16c620a
...
e50be2ee66
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e50be2ee66 |
@@ -411,6 +411,34 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"mode": {
|
||||
"current": {
|
||||
"default": "analog",
|
||||
"rules": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"value": "analog",
|
||||
"description": "Single-scalar input mode (classic 4-20mA / PLC style). msg.payload is a number; the node runs one offset/scaling/smoothing/outlier pipeline and emits one MeasurementContainer slot."
|
||||
},
|
||||
{
|
||||
"value": "digital",
|
||||
"description": "Multi-channel input mode (MQTT / IoT JSON style). msg.payload is an object keyed by channel names declared under config.channels; the node routes each key through its own pipeline and emits N slots from one input message."
|
||||
}
|
||||
],
|
||||
"description": "Selects how incoming msg.payload is interpreted."
|
||||
}
|
||||
}
|
||||
},
|
||||
"channels": {
|
||||
"default": [],
|
||||
"rules": {
|
||||
"type": "array",
|
||||
"itemType": "object",
|
||||
"minLength": 0,
|
||||
"description": "Channel map used in digital mode. Each entry is a self-contained pipeline definition: {key, type, position, unit, scaling?, smoothing?, outlierDetection?, distance?}. Ignored in analog mode."
|
||||
}
|
||||
},
|
||||
"outlierDetection": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
|
||||
@@ -141,11 +141,17 @@ class MeasurementContainer {
|
||||
}
|
||||
|
||||
isUnitCompatible(measurementType, unit) {
|
||||
const desc = this._describeUnit(unit);
|
||||
if (!desc) return false;
|
||||
// Unknown type (not in measureMap): accept any unit. This lets user-
|
||||
// defined measurement types (e.g. 'humidity', 'co2', arbitrary IoT
|
||||
// channels in digital mode) pass through without being rejected just
|
||||
// because their unit string ('%', 'ppm', …) is not a known physical
|
||||
// unit to the convert module. Known types are still validated strictly.
|
||||
const normalizedType = this._normalizeType(measurementType);
|
||||
const expectedMeasure = this.measureMap[normalizedType];
|
||||
if (!expectedMeasure) return true;
|
||||
|
||||
const desc = this._describeUnit(unit);
|
||||
if (!desc) return false;
|
||||
return desc.measure === expectedMeasure;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user