Files
generalFunctions/index.js

108 lines
3.6 KiB
JavaScript
Raw Normal View History

2025-06-10 12:36:39 +02:00
/**
2025-09-22 16:02:04 +02:00
* generalFunctions/index.js
2025-06-10 12:36:39 +02:00
* -----------------------------------------------------------
* Central barrel file for re-exporting helpers and configurations.
* Provides both namespace exports and dynamic loading capabilities.
2025-06-25 10:55:50 +02:00
* now we can load modules like this:
2025-09-22 16:02:04 +02:00
* const { menuUtils, outputUtils } = require('generalFunctions');
2025-06-10 12:36:39 +02:00
*/
// Core helper modules
2026-02-23 13:17:47 +01:00
const helper = require('./src/helper/index.js');
const {
outputUtils,
logger,
validation,
configUtils,
assertions,
childRegistrationUtils,
gravity,
} = helper;
2025-10-07 18:10:04 +02:00
const coolprop = require('./src/coolprop-node/src/index.js');
2026-01-29 09:16:41 +01:00
const assetApiConfig = require('./src/configs/assetApiConfig.js');
2025-06-10 12:36:39 +02:00
// Domain-specific modules
2025-06-25 17:27:32 +02:00
const { MeasurementContainer } = require('./src/measurements/index.js');
2025-06-25 10:55:50 +02:00
const configManager = require('./src/configs/index.js');
2026-02-23 13:17:47 +01:00
const { nrmse } = require('./src/nrmse/index.js');
const { state } = require('./src/state/index.js');
2025-06-25 10:55:50 +02:00
const convert = require('./src/convert/index.js');
const MenuManager = require('./src/menu/index.js');
2026-02-23 13:17:47 +01:00
const { predict, interpolation } = require('./src/predict/index.js');
2026-03-11 11:13:05 +01:00
const { PIDController, CascadePIDController, createPidController, createCascadePidController } = require('./src/pid/index.js');
feat(registry): AssetResolver + diffuser supplier curves (Jäger / Aerostrip / PIK / PRK) Two related changes bundled together because the diffuser curve files only make sense once the registry namespace they live in exists. src/registry — new asset-metadata resolver: - AssetResolver with synchronous resolve(namespace, id) + lazy cache, async refresh() for future remote pulls. - FileBackend (per-id or single-file layouts, case-insensitive) and a stub HttpBackend (disabled unless EVOLV_ASSET_REMOTE=1). - Namespaces: curves, menu, monsterSamples, monsterSpecs, units. Menu namespace re-keys by inner softwareType + filename so editors that pass either string resolve to the same tree. - README explains how to add a namespace. - AssetCategoryManager (datasets/assetData/index.js) becomes a thin facade over the resolver so existing consumers don't move. - 246/246 tests pass — including the 39-test registry suite. datasets/assetData — file moves + new diffuser data: - modelData/*.json deleted; curves/*.json is the canonical home. - New diffuser.json menu tree with GVA, Jäger, Aquaconsult/Entec, PIK/PRK suppliers. - gva-elastox-r.json migrated from the inline _loadSpecs hardcode, re-tagged coverageBasis="bottom-coverage-pct" (the legacy 2.4 elements/m² was a prior mis-conversion; we can't recover the original % so it's a single-point curve under key "0"). - jaeger-jetflex-td-65-2-g-epdm-1000.json — extracted from the Jäger EPDM-1000mm SSOTE/DWP chart on the data sheet (vector-PDF read). SSOTE 8.20→6.40 %/m, DWP 25→48 mbar across Q 2-12 Nm³/h. Single coverage (vendor doesn't state test conditions). - aerostrip-phoenix.json — 4-coverage SOTE family at 4.75 m water depth (DD 5/10/15/20 %, flux 10-70 Nm³/h·m²) from the Entec/de Winter 2023-11-22 dataset; DWP curve from the 21 % @ 4.05 m chart. - pik300.json / prk300.json — 5-coverage SOTE + SSOTR (DD 5-25 %) with split DWP per model variant, water depth ≈ 4.0 m inferred from the SOTE↔SSOTR ratio in the source spreadsheet. src/configs/diffuser.json: - New asset.{model, assetTagNumber} block so the editor's selected model id survives validation. - diffuser.density description corrected to "Bottom coverage [%]"; default 2.4 → 15 (typical fine-bubble install). src/configs/{rotatingMachine,valve}.json: small alignment edits that came with the registry phase. src/menu/asset.js + src/menu/aquonSamples.js: rewritten as facades over assetResolver, keeping the editor-side cascade behaviour intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 17:12:13 +02:00
const { AssetResolver, FileBackend, HttpBackend, assetResolver } = require('./src/registry/index.js');
// loadCurve(model) is now a thin shim over assetResolver.resolve('curves', model).
// Same contract: sync, case-insensitive, returns null on miss. New code should
// prefer `assetResolver.resolve('curves', ...)` directly; this shim is kept so
// external consumers don't have to change in one go.
function loadCurve(modelId) {
return assetResolver.resolve('curves', modelId);
}
const { POSITIONS, POSITION_VALUES, isValidPosition } = require('./src/constants/positions.js');
const Fysics = require('./src/convert/fysics.js');
2025-06-10 12:45:35 +02:00
// Refactor platform infrastructure (additive — see .claude/refactor/CONTRACTS.md).
// Domain-side
const UnitPolicy = require('./src/domain/UnitPolicy.js');
const ChildRouter = require('./src/domain/ChildRouter.js');
const LatestWinsGate = require('./src/domain/LatestWinsGate.js');
const HealthStatus = require('./src/domain/HealthStatus.js');
const BaseDomain = require('./src/domain/BaseDomain.js');
// Node-RED-side
const { statusBadge } = require('./src/nodered/statusBadge.js');
const { StatusUpdater } = require('./src/nodered/statusUpdater.js');
const { createRegistry, CommandRegistry } = require('./src/nodered/commandRegistry.js');
const BaseNodeAdapter = require('./src/nodered/BaseNodeAdapter.js');
// Stats helpers
const stats = require('./src/stats/index.js');
2025-06-10 12:45:35 +02:00
// Export everything
module.exports = {
2025-06-25 17:27:32 +02:00
predict,
interpolation,
2025-06-25 10:55:50 +02:00
configManager,
2026-01-29 09:16:41 +01:00
assetApiConfig,
2025-06-12 17:04:02 +02:00
outputUtils,
configUtils,
2025-06-10 12:45:35 +02:00
logger,
validation,
assertions,
2025-06-25 17:27:32 +02:00
MeasurementContainer,
2025-06-10 12:45:35 +02:00
nrmse,
state,
2025-10-07 18:10:04 +02:00
coolprop,
2025-06-25 10:55:50 +02:00
convert,
2025-06-25 17:27:32 +02:00
MenuManager,
2026-03-11 11:13:05 +01:00
PIDController,
CascadePIDController,
createPidController,
createCascadePidController,
2025-07-01 17:05:09 +02:00
childRegistrationUtils,
feat(registry): AssetResolver + diffuser supplier curves (Jäger / Aerostrip / PIK / PRK) Two related changes bundled together because the diffuser curve files only make sense once the registry namespace they live in exists. src/registry — new asset-metadata resolver: - AssetResolver with synchronous resolve(namespace, id) + lazy cache, async refresh() for future remote pulls. - FileBackend (per-id or single-file layouts, case-insensitive) and a stub HttpBackend (disabled unless EVOLV_ASSET_REMOTE=1). - Namespaces: curves, menu, monsterSamples, monsterSpecs, units. Menu namespace re-keys by inner softwareType + filename so editors that pass either string resolve to the same tree. - README explains how to add a namespace. - AssetCategoryManager (datasets/assetData/index.js) becomes a thin facade over the resolver so existing consumers don't move. - 246/246 tests pass — including the 39-test registry suite. datasets/assetData — file moves + new diffuser data: - modelData/*.json deleted; curves/*.json is the canonical home. - New diffuser.json menu tree with GVA, Jäger, Aquaconsult/Entec, PIK/PRK suppliers. - gva-elastox-r.json migrated from the inline _loadSpecs hardcode, re-tagged coverageBasis="bottom-coverage-pct" (the legacy 2.4 elements/m² was a prior mis-conversion; we can't recover the original % so it's a single-point curve under key "0"). - jaeger-jetflex-td-65-2-g-epdm-1000.json — extracted from the Jäger EPDM-1000mm SSOTE/DWP chart on the data sheet (vector-PDF read). SSOTE 8.20→6.40 %/m, DWP 25→48 mbar across Q 2-12 Nm³/h. Single coverage (vendor doesn't state test conditions). - aerostrip-phoenix.json — 4-coverage SOTE family at 4.75 m water depth (DD 5/10/15/20 %, flux 10-70 Nm³/h·m²) from the Entec/de Winter 2023-11-22 dataset; DWP curve from the 21 % @ 4.05 m chart. - pik300.json / prk300.json — 5-coverage SOTE + SSOTR (DD 5-25 %) with split DWP per model variant, water depth ≈ 4.0 m inferred from the SOTE↔SSOTR ratio in the source spreadsheet. src/configs/diffuser.json: - New asset.{model, assetTagNumber} block so the editor's selected model id survives validation. - diffuser.density description corrected to "Bottom coverage [%]"; default 2.4 → 15 (typical fine-bubble install). src/configs/{rotatingMachine,valve}.json: small alignment edits that came with the registry phase. src/menu/asset.js + src/menu/aquonSamples.js: rewritten as facades over assetResolver, keeping the editor-side cascade behaviour intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 17:12:13 +02:00
loadCurve,
gravity,
POSITIONS,
POSITION_VALUES,
isValidPosition,
Fysics,
// refactor infra (Phase 1)
UnitPolicy,
ChildRouter,
LatestWinsGate,
HealthStatus,
BaseDomain,
statusBadge,
StatusUpdater,
createRegistry,
CommandRegistry,
BaseNodeAdapter,
feat(registry): AssetResolver + diffuser supplier curves (Jäger / Aerostrip / PIK / PRK) Two related changes bundled together because the diffuser curve files only make sense once the registry namespace they live in exists. src/registry — new asset-metadata resolver: - AssetResolver with synchronous resolve(namespace, id) + lazy cache, async refresh() for future remote pulls. - FileBackend (per-id or single-file layouts, case-insensitive) and a stub HttpBackend (disabled unless EVOLV_ASSET_REMOTE=1). - Namespaces: curves, menu, monsterSamples, monsterSpecs, units. Menu namespace re-keys by inner softwareType + filename so editors that pass either string resolve to the same tree. - README explains how to add a namespace. - AssetCategoryManager (datasets/assetData/index.js) becomes a thin facade over the resolver so existing consumers don't move. - 246/246 tests pass — including the 39-test registry suite. datasets/assetData — file moves + new diffuser data: - modelData/*.json deleted; curves/*.json is the canonical home. - New diffuser.json menu tree with GVA, Jäger, Aquaconsult/Entec, PIK/PRK suppliers. - gva-elastox-r.json migrated from the inline _loadSpecs hardcode, re-tagged coverageBasis="bottom-coverage-pct" (the legacy 2.4 elements/m² was a prior mis-conversion; we can't recover the original % so it's a single-point curve under key "0"). - jaeger-jetflex-td-65-2-g-epdm-1000.json — extracted from the Jäger EPDM-1000mm SSOTE/DWP chart on the data sheet (vector-PDF read). SSOTE 8.20→6.40 %/m, DWP 25→48 mbar across Q 2-12 Nm³/h. Single coverage (vendor doesn't state test conditions). - aerostrip-phoenix.json — 4-coverage SOTE family at 4.75 m water depth (DD 5/10/15/20 %, flux 10-70 Nm³/h·m²) from the Entec/de Winter 2023-11-22 dataset; DWP curve from the 21 % @ 4.05 m chart. - pik300.json / prk300.json — 5-coverage SOTE + SSOTR (DD 5-25 %) with split DWP per model variant, water depth ≈ 4.0 m inferred from the SOTE↔SSOTR ratio in the source spreadsheet. src/configs/diffuser.json: - New asset.{model, assetTagNumber} block so the editor's selected model id survives validation. - diffuser.density description corrected to "Bottom coverage [%]"; default 2.4 → 15 (typical fine-bubble install). src/configs/{rotatingMachine,valve}.json: small alignment edits that came with the registry phase. src/menu/asset.js + src/menu/aquonSamples.js: rewritten as facades over assetResolver, keeping the editor-side cascade behaviour intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 17:12:13 +02:00
stats,
// Asset metadata registry (replaces loadCurve / AssetCategoryManager /
// ad-hoc JSON readers — see src/registry/README.md). Backend-swappable;
// sync at runtime by contract.
AssetResolver,
FileBackend,
HttpBackend,
assetResolver,
2025-09-23 11:55:44 +02:00
};