# Measurement Function Anchor (Preparation Baseline) ## 0) Connection Map (At a Glance) - **Node type**: `measurement` (`nodes/measurement/measurement.js:1`, `nodes/measurement/measurement.html:14`) - **Consumes topics**: `measurement`, `simulator`, `outlierDetection`, `calibrate` (`nodes/measurement/src/nodeClass.js:147`) - **Publishes periodic outputs**: - Output `0`: process payload (`nodes/measurement/src/nodeClass.js:137`) - Output `1`: influx payload (`nodes/measurement/src/nodeClass.js:138`) - Output `2`: parent registration (`registerChild`) (`nodes/measurement/src/nodeClass.js:118`) - **Cross-node integrations (direct observed)**: - Registers as child to parent with `positionVsParent` and optional `distance` (`nodes/measurement/src/nodeClass.js:118`) - Emits measurement updates through `MeasurementContainer` in `specificClass` (`nodes/measurement/src/specificClass.js:479`) - **Admin/UI endpoints**: - `GET /measurement/menu.js` (`nodes/measurement/measurement.js:23`) - `GET /measurement/configData.js` (`nodes/measurement/measurement.js:33`) - `POST /measurement/asset-reg` (`nodes/measurement/measurement.js:43`) ## 1) Unit Table (Initial Baseline) | Signal/Field | Represents | Default Unit | Source of Truth | Produced By | Consumed By | Fallback/Degraded Behavior | |---|---|---|---|---|---|---| | `inputValue` | raw measurement input | asset-dependent | `nodes/measurement/src/specificClass.js:30` | `measurement` topic or simulator | scaling/smoothing pipeline | defaults to `0` | | `outputAbs` (`mAbs`) | processed absolute output | `config.asset.unit` | `nodes/measurement/src/specificClass.js:472` | `updateOutputAbs()` | process/influx outputs + event emitter | constrained to configured abs range | | `outputPercent` (`mPercent`) | normalized percent-like output | `%` semantic | `nodes/measurement/src/specificClass.js:483` | `updateOutputPercent()` | process/influx outputs | interpolated from abs range or observed min/max | | `storedValues` | smoothing window values | same as processed value | `nodes/measurement/src/specificClass.js:24` | `applySmoothing()` | smoothing and repeatability checks | capped to `smoothWindow` length | | `simulation.enabled` | internal simulated signal mode | boolean | `nodes/measurement/src/specificClass.js:52` | config/topic toggle | `tick()` behavior | off by default | ## 2) Class Identity - **Runtime registration + endpoints**: `nodes/measurement/measurement.js` - **Node-RED wrapper/routing**: `nodes/measurement/src/nodeClass.js` - **Domain measurement logic**: `nodes/measurement/src/specificClass.js` - **Editor UI/defaults**: `nodes/measurement/measurement.html` ## 3) Current Gaps To Resolve Before Declaring Anchor Complete 1. Node label precedence can hide fallback text due to expression order: - `return this.positionIcon + " " + this.assetType || "Measurement";` (`nodes/measurement/measurement.html:63`) 2. `success` variable is assigned without declaration in editor save path: - `success = window.EVOLV.nodes.measurement.assetMenu.saveEditor(this);` (`nodes/measurement/measurement.html:131`) 3. `toggleOutlierDetection()` mutates config object to boolean: - `this.config.outlierDetection = !this.config.outlierDetection;` (`nodes/measurement/src/specificClass.js:503`) 4. Input handler ignores numeric strings for `measurement` topic: - accepts only `typeof msg.payload === 'number'` (`nodes/measurement/src/nodeClass.js:152`) ## 4) Standardization Plan (Mirror RotatingMachine) 1. Keep this anchor pair (`.md` + `.html`) and evidence file maintained with behavior changes. 2. Maintain test layout under `nodes/measurement/test/`: - `basic/`, `integration/`, `edge/`, `helpers/` 3. Maintain examples package under `nodes/measurement/examples/`: - `README.md`, `basic.flow.json`, `integration.flow.json`, `edge.flow.json` ## 5) Acceptance Criteria For Completion - Required anchor artifacts exist and map to current behavior. - Test suite runs with node-level command. - Example flow files exist and pass flow-structure tests.