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>
This commit is contained in:
44
datasets/assetData/curves/aerostrip-phoenix.json
Normal file
44
datasets/assetData/curves/aerostrip-phoenix.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"_meta": {
|
||||
"supplier": "Aquaconsult Anlagenbau / Entec",
|
||||
"type": "Strip",
|
||||
"model": "AEROSTRIP",
|
||||
"membrane": "PHOENIX",
|
||||
"stdAir": { "temp_C": 0, "pressure_mbar": 1013.25, "RH_pct": 0 },
|
||||
"coverageBasis": "bottom-coverage-pct",
|
||||
"coverageReference": [5, 10, 15, 20],
|
||||
"dataQuality": "multi-coverage",
|
||||
"xAxisBasis": "per-m2-membrane-Nm3h",
|
||||
"yAxisBasis": "ssotr-g-per-Nm3-per-m",
|
||||
"waterDepth_m": 4.75,
|
||||
"sources": [
|
||||
"Floris de Winter (Entec Holland) email to R. de Ren on 2023-11-22 — tabulated SOTE [%] at 4.75 m water depth for bottom coverage 5/10/15/20 % at fluxes 10/25/40/55/70 Nm3/(h*m2 membrane). Original chart in 'SSOTE_4.75m different density.pdf'.",
|
||||
"'SSOTR_dP.pdf' — AEROSTRIP fine-bubble diffuser SSOTR + Druckverlust (DWP) chart at water depth 4.05 m, blow-in depth 4.00 m, 21 % bottom coverage. Used for the DWP curve only (read off the vector chart)."
|
||||
],
|
||||
"note": "X-axis is flux per m² of membrane area, NOT per element. The existing diffuser specificClass passes `flow_per_element` to the interpolator — if you wire an AEROSTRIP model in, you must either set elements/area such that flow_per_element == flux_per_m2_membrane, OR extend _calcOtrPressure to apply the membrane-area conversion. SSOTR values are SOTE [%] / water_depth_m * 0.299 kg-O2/Nm3 * 10 (linear depth scaling). DWP curve was measured at 21 % bottom coverage; pressure loss is intrinsic to the diffuser geometry so the curve is shared across coverage values."
|
||||
},
|
||||
"sote_curve": {
|
||||
"5": { "x": [10, 25, 40, 55, 70], "y": [34.20, 28.75, 26.16, 24.89, 24.19] },
|
||||
"10": { "x": [10, 25, 40, 55, 70], "y": [42.01, 35.32, 32.14, 30.58, 29.71] },
|
||||
"15": { "x": [10, 25, 40, 55, 70], "y": [43.39, 36.48, 33.20, 31.59, 30.69] },
|
||||
"20": { "x": [10, 25, 40, 55, 70], "y": [43.80, 36.82, 33.51, 31.88, 30.97] }
|
||||
},
|
||||
"ssote_curve": {
|
||||
"5": { "x": [10, 25, 40, 55, 70], "y": [7.20, 6.05, 5.51, 5.24, 5.09] },
|
||||
"10": { "x": [10, 25, 40, 55, 70], "y": [8.84, 7.44, 6.77, 6.44, 6.26] },
|
||||
"15": { "x": [10, 25, 40, 55, 70], "y": [9.14, 7.68, 6.99, 6.65, 6.46] },
|
||||
"20": { "x": [10, 25, 40, 55, 70], "y": [9.22, 7.75, 7.06, 6.71, 6.52] }
|
||||
},
|
||||
"otr_curve": {
|
||||
"5": { "x": [10, 25, 40, 55, 70], "y": [21.53, 18.10, 16.47, 15.67, 15.23] },
|
||||
"10": { "x": [10, 25, 40, 55, 70], "y": [26.44, 22.23, 20.23, 19.25, 18.70] },
|
||||
"15": { "x": [10, 25, 40, 55, 70], "y": [27.31, 22.96, 20.90, 19.89, 19.32] },
|
||||
"20": { "x": [10, 25, 40, 55, 70], "y": [27.57, 23.18, 21.10, 20.06, 19.49] }
|
||||
},
|
||||
"p_curve": {
|
||||
"21": {
|
||||
"x": [5, 10, 25, 40, 55, 70, 80],
|
||||
"y": [46.0, 47.3, 51.1, 54.9, 58.7, 62.4, 65.0]
|
||||
}
|
||||
}
|
||||
}
|
||||
27
datasets/assetData/curves/gva-elastox-r.json
Normal file
27
datasets/assetData/curves/gva-elastox-r.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"_meta": {
|
||||
"supplier": "GVA",
|
||||
"type": "Tube",
|
||||
"model": "ELASTOX-R",
|
||||
"stdAir": { "temp_C": 20, "pressure_bar": 1.01325, "RH_pct": 0 },
|
||||
"coverageBasis": "bottom-coverage-pct",
|
||||
"coverageReference": null,
|
||||
"dataQuality": "point",
|
||||
"xAxisBasis": "per-element-Nm3h",
|
||||
"yAxisBasis": "ssotr-g-per-Nm3-per-m",
|
||||
"waterDepth_m": null,
|
||||
"note": "Migrated 2026-05-12 from nodes/diffuser/src/specificClass.js _loadSpecs(). The legacy hardcoded data was tagged '2.4 elements/m²' by a prior agent; the originating vendor data was always intended as % surface-area coverage but the original test-bench coverage was not preserved when the numbers were inlined. Treat as a single-coverage point estimate (key '0' = unspecified). Do not extrapolate across density. SSOTR in g O2 / (Nm3 air * m of submergence)."
|
||||
},
|
||||
"otr_curve": {
|
||||
"0": {
|
||||
"x": [2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
"y": [26, 25, 24, 23.5, 23, 22.75, 22.5, 22.25, 22]
|
||||
}
|
||||
},
|
||||
"p_curve": {
|
||||
"0": {
|
||||
"x": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
"y": [40, 42.5, 45, 47.5, 50, 51.5, 53, 54.5, 56, 57.5, 59]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
class AssetLoader {
|
||||
constructor(maxCacheSize = 100) {
|
||||
this.relPath = './'
|
||||
this.baseDir = path.resolve(__dirname, this.relPath);
|
||||
this.cache = new Map();
|
||||
this.maxCacheSize = maxCacheSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a specific curve by type
|
||||
* @param {string} curveType - The curve identifier (e.g., 'hidrostal-H05K-S03R')
|
||||
* @returns {Object|null} The curve data object or null if not found
|
||||
*/
|
||||
loadCurve(curveType) {
|
||||
return this.loadAsset('curves', curveType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load any asset from a specific dataset folder
|
||||
* @param {string} datasetType - The dataset folder name (e.g., 'curves', 'assetData')
|
||||
* @param {string} assetId - The specific asset identifier
|
||||
* @returns {Object|null} The asset data object or null if not found
|
||||
*/
|
||||
loadAsset(datasetType, assetId) {
|
||||
//const cacheKey = `${datasetType}/${assetId}`;
|
||||
const normalizedAssetId = String(assetId || '').trim();
|
||||
if (!normalizedAssetId) {
|
||||
return null;
|
||||
}
|
||||
const cacheKey = normalizedAssetId.toLowerCase();
|
||||
|
||||
|
||||
// Check cache first
|
||||
if (this.cache.has(cacheKey)) {
|
||||
return this.cache.get(cacheKey);
|
||||
}
|
||||
|
||||
try {
|
||||
const filePath = this._resolveAssetPath(normalizedAssetId);
|
||||
|
||||
// Check if file exists
|
||||
if (!filePath || !fs.existsSync(filePath)) {
|
||||
console.warn(`Asset not found for id '${normalizedAssetId}' in ${this.baseDir}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load and parse JSON
|
||||
const rawData = fs.readFileSync(filePath, 'utf8');
|
||||
const assetData = JSON.parse(rawData);
|
||||
|
||||
// Cache the result (evict oldest if at capacity)
|
||||
if (this.cache.size >= this.maxCacheSize) {
|
||||
const oldestKey = this.cache.keys().next().value;
|
||||
this.cache.delete(oldestKey);
|
||||
}
|
||||
this.cache.set(cacheKey, assetData);
|
||||
|
||||
return assetData;
|
||||
} catch (error) {
|
||||
console.error(`Error loading asset ${cacheKey}:`, error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_resolveAssetPath(assetId) {
|
||||
const exactPath = path.join(this.baseDir, `${assetId}.json`);
|
||||
if (fs.existsSync(exactPath)) {
|
||||
return exactPath;
|
||||
}
|
||||
|
||||
const target = `${assetId}.json`.toLowerCase();
|
||||
const files = fs.readdirSync(this.baseDir);
|
||||
const matched = files.find((file) => file.toLowerCase() === target);
|
||||
if (!matched) {
|
||||
return null;
|
||||
}
|
||||
return path.join(this.baseDir, matched);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available assets in a dataset
|
||||
* @param {string} datasetType - The dataset folder name
|
||||
* @returns {string[]} Array of available asset IDs
|
||||
*/
|
||||
getAvailableAssets(datasetType) {
|
||||
try {
|
||||
const datasetPath = path.join(this.baseDir, datasetType);
|
||||
|
||||
if (!fs.existsSync(datasetPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return fs.readdirSync(datasetPath)
|
||||
.filter(file => file.endsWith('.json'))
|
||||
.map(file => file.replace('.json', ''));
|
||||
} catch (error) {
|
||||
console.error(`Error reading dataset ${datasetType}:`, error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache (useful for development/testing)
|
||||
*/
|
||||
clearCache() {
|
||||
this.cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export a singleton instance
|
||||
const assetLoader = new AssetLoader();
|
||||
|
||||
module.exports = {
|
||||
AssetLoader,
|
||||
assetLoader,
|
||||
// Convenience methods for backward compatibility
|
||||
loadCurve: (curveType) => assetLoader.loadCurve(curveType),
|
||||
loadAsset: (datasetType, assetId) => assetLoader.loadAsset(datasetType, assetId),
|
||||
getAvailableAssets: (datasetType) => assetLoader.getAvailableAssets(datasetType)
|
||||
};
|
||||
|
||||
/*
|
||||
// Example usage in your scripts
|
||||
const loader = new AssetLoader();
|
||||
|
||||
// Load a specific curve
|
||||
const curve = loader.loadCurve('hidrostal-H05K-S03R');
|
||||
if (curve) {
|
||||
console.log('Curve loaded:', curve);
|
||||
} else {
|
||||
console.log('Curve not found');
|
||||
}
|
||||
/*
|
||||
// Load any asset from any dataset
|
||||
const someAsset = loadAsset('assetData', 'some-asset-id');
|
||||
|
||||
// Get list of available curves
|
||||
const availableCurves = getAvailableAssets('curves');
|
||||
console.log('Available curves:', availableCurves);
|
||||
|
||||
// Using the class directly for more control
|
||||
const { AssetLoader } = require('./index.js');
|
||||
const customLoader = new AssetLoader();
|
||||
const data = customLoader.loadCurve('hidrostal-H05K-S03R');
|
||||
*/
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"_meta": {
|
||||
"supplier": "Jäger Umwelt-Technik",
|
||||
"type": "Tube",
|
||||
"model": "JetFlex TD 65-2 G",
|
||||
"membrane": "EPDM",
|
||||
"tubeLength_mm": 1000,
|
||||
"totalLength_mm": 1062.5,
|
||||
"perforatedArea_m2": 0.18,
|
||||
"outerDiameter_mm": 65,
|
||||
"operating": {
|
||||
"continuousFlow_Nm3h": [2, 12],
|
||||
"maxOverloadFlow_Nm3h": 20,
|
||||
"operatingMode": "continuous-or-intermittent"
|
||||
},
|
||||
"stdAir": { "temp_C": 0, "pressure_mbar": 1013.25, "RH_pct": 0 },
|
||||
"coverageBasis": "bottom-coverage-pct",
|
||||
"coverageReference": null,
|
||||
"dataQuality": "point",
|
||||
"xAxisBasis": "per-element-Nm3h",
|
||||
"yAxisBasis": "ssotr-g-per-Nm3-per-m",
|
||||
"waterDepth_m": null,
|
||||
"source": "Jäger Umwelt-Technik 'JETFLEX TD 65-2 G Tube Diffuser' data sheet — vector chart on page 2 ('SSOTE and headloss for EPDM 1000 mm'). Curve coordinates recovered directly from the PDF vector paths on 2026-05-12 (bezier endpoints of the red SSOTE polyline and blue DWP polyline); axis calibration against the gridlines is exact.",
|
||||
"note": "Vendor sheet states neither the tank-floor coverage nor the water depth at which the SSOTE curve was measured. Treat as a single-coverage point estimate (key '0' = unspecified); do not extrapolate across density. SSOTR = SSOTE * 0.299 kg-O2/Nm3 (DIN-1343 dry air, 0 °C 1013.25 mbar)."
|
||||
},
|
||||
"ssote_curve": {
|
||||
"0": {
|
||||
"x": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
"y": [8.20, 7.85, 7.57, 7.30, 7.10, 6.97, 6.85, 6.72, 6.60, 6.50, 6.40]
|
||||
}
|
||||
},
|
||||
"otr_curve": {
|
||||
"0": {
|
||||
"x": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
"y": [24.52, 23.47, 22.63, 21.83, 21.23, 20.84, 20.48, 20.09, 19.73, 19.44, 19.14]
|
||||
}
|
||||
},
|
||||
"p_curve": {
|
||||
"0": {
|
||||
"x": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||
"y": [25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.0, 44.0, 46.0, 48.0]
|
||||
}
|
||||
}
|
||||
}
|
||||
36
datasets/assetData/curves/pik300.json
Normal file
36
datasets/assetData/curves/pik300.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"_meta": {
|
||||
"supplier": "Unknown (PIK/PRK family)",
|
||||
"type": "Disc",
|
||||
"model": "PIK300",
|
||||
"stdAir": { "temp_C": 20, "pressure_bar": 1.01325, "RH_pct": 0 },
|
||||
"coverageBasis": "bottom-coverage-pct",
|
||||
"coverageReference": [5, 10, 15, 20, 25],
|
||||
"dataQuality": "multi-coverage",
|
||||
"xAxisBasis": "per-element-Sm3h",
|
||||
"yAxisBasis": "ssotr-g-per-Nm3-per-m",
|
||||
"waterDepth_m": 4.0,
|
||||
"source": "'PIK & PRK300 data from QM.xlsx' (Sheet1). Two paired models PIK300 and PRK300: identical SOTE/SSOTR curves at DD 5/10/15/20/25 %, separate DWP curves per model. Water depth inferred from the relationship SOTE[%] = SSOTR[g/(Nm3*m)] * depth_m * 100 / 0.2786 kg-O2/Sm3 — gives depth ≈ 4.0 m for every row when standard-cubic-meter mass is taken at 20 °C / 1013.25 mbar.",
|
||||
"note": "X-axis air flow uses 'Sm3' (US standard, 20 °C / 1013.25 mbar) rather than 'Nm3' (DIN, 0 °C). The existing diffuser specificClass internally normalises to 20 °C — so the values are usable as-is with that convention. SOTE [%] values are the raw spreadsheet entries; otr_curve is the per-meter SSOTR g/(Nm3*m) already in canonical units."
|
||||
},
|
||||
"sote_curve": {
|
||||
"5": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [27.87, 26.99, 25.80, 24.97, 24.38, 23.89, 23.46, 23.12] },
|
||||
"10": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [30.18, 29.33, 28.15, 27.33, 26.73, 26.21, 25.83, 25.49] },
|
||||
"15": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [31.51, 30.53, 29.16, 28.27, 27.57, 27.01, 26.55, 26.15] },
|
||||
"20": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [32.52, 31.39, 29.88, 28.84, 28.06, 27.45, 26.92, 26.49] },
|
||||
"25": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [33.26, 32.04, 30.39, 29.27, 28.45, 27.77, 27.22, 26.76] }
|
||||
},
|
||||
"otr_curve": {
|
||||
"5": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [19.509, 18.893, 18.060, 17.479, 17.066, 16.723, 16.422, 16.184] },
|
||||
"10": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [21.126, 20.531, 19.705, 19.131, 18.711, 18.347, 18.081, 17.843] },
|
||||
"15": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [22.057, 21.371, 20.412, 19.789, 19.299, 18.907, 18.585, 18.305] },
|
||||
"20": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [22.764, 21.973, 20.916, 20.188, 19.642, 19.215, 18.844, 18.543] },
|
||||
"25": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [23.282, 22.428, 21.273, 20.489, 19.915, 19.439, 19.054, 18.732] }
|
||||
},
|
||||
"p_curve": {
|
||||
"0": {
|
||||
"x": [1.5, 2, 3, 4, 5, 6, 7, 8],
|
||||
"y": [25.5, 26.0, 27.5, 30.3, 34.0, 39.0, 45.0, 52.0]
|
||||
}
|
||||
}
|
||||
}
|
||||
36
datasets/assetData/curves/prk300.json
Normal file
36
datasets/assetData/curves/prk300.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"_meta": {
|
||||
"supplier": "Unknown (PIK/PRK family)",
|
||||
"type": "Disc",
|
||||
"model": "PRK300",
|
||||
"stdAir": { "temp_C": 20, "pressure_bar": 1.01325, "RH_pct": 0 },
|
||||
"coverageBasis": "bottom-coverage-pct",
|
||||
"coverageReference": [5, 10, 15, 20, 25],
|
||||
"dataQuality": "multi-coverage",
|
||||
"xAxisBasis": "per-element-Sm3h",
|
||||
"yAxisBasis": "ssotr-g-per-Nm3-per-m",
|
||||
"waterDepth_m": 4.0,
|
||||
"source": "'PIK & PRK300 data from QM.xlsx' (Sheet1). Same SOTE/SSOTR curves as the PIK300 sibling; the PRK300 differs only in DWP characteristics.",
|
||||
"note": "X-axis air flow uses 'Sm3' (US standard, 20 °C / 1013.25 mbar) rather than 'Nm3' (DIN, 0 °C). The existing diffuser specificClass internally normalises to 20 °C — so the values are usable as-is with that convention."
|
||||
},
|
||||
"sote_curve": {
|
||||
"5": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [27.87, 26.99, 25.80, 24.97, 24.38, 23.89, 23.46, 23.12] },
|
||||
"10": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [30.18, 29.33, 28.15, 27.33, 26.73, 26.21, 25.83, 25.49] },
|
||||
"15": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [31.51, 30.53, 29.16, 28.27, 27.57, 27.01, 26.55, 26.15] },
|
||||
"20": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [32.52, 31.39, 29.88, 28.84, 28.06, 27.45, 26.92, 26.49] },
|
||||
"25": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [33.26, 32.04, 30.39, 29.27, 28.45, 27.77, 27.22, 26.76] }
|
||||
},
|
||||
"otr_curve": {
|
||||
"5": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [19.509, 18.893, 18.060, 17.479, 17.066, 16.723, 16.422, 16.184] },
|
||||
"10": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [21.126, 20.531, 19.705, 19.131, 18.711, 18.347, 18.081, 17.843] },
|
||||
"15": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [22.057, 21.371, 20.412, 19.789, 19.299, 18.907, 18.585, 18.305] },
|
||||
"20": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [22.764, 21.973, 20.916, 20.188, 19.642, 19.215, 18.844, 18.543] },
|
||||
"25": { "x": [1.5, 2, 3, 4, 5, 6, 7, 8], "y": [23.282, 22.428, 21.273, 20.489, 19.915, 19.439, 19.054, 18.732] }
|
||||
},
|
||||
"p_curve": {
|
||||
"0": {
|
||||
"x": [1.5, 2, 3, 4, 5, 6, 7, 8],
|
||||
"y": [21.3, 24.0, 29.3, 35.3, 41.3, 46.8, 52.4, 58.6]
|
||||
}
|
||||
}
|
||||
}
|
||||
68
datasets/assetData/diffuser.json
Normal file
68
datasets/assetData/diffuser.json
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"id": "diffuser",
|
||||
"label": "diffuser",
|
||||
"softwareType": "diffuser",
|
||||
"suppliers": [
|
||||
{
|
||||
"id": "gva",
|
||||
"name": "GVA",
|
||||
"types": [
|
||||
{
|
||||
"id": "diffuser-tube",
|
||||
"name": "Tube",
|
||||
"models": [
|
||||
{ "id": "gva-elastox-r", "name": "ELASTOX-R", "units": ["Nm3/h"] }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "jaeger",
|
||||
"name": "Jäger Umwelt-Technik",
|
||||
"types": [
|
||||
{
|
||||
"id": "diffuser-tube",
|
||||
"name": "Tube",
|
||||
"models": [
|
||||
{
|
||||
"id": "jaeger-jetflex-td-65-2-g-epdm-1000",
|
||||
"name": "JetFlex TD 65-2 G — EPDM 1000 mm",
|
||||
"units": ["Nm3/h"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "aquaconsult",
|
||||
"name": "Aquaconsult / Entec",
|
||||
"types": [
|
||||
{
|
||||
"id": "diffuser-strip",
|
||||
"name": "Strip",
|
||||
"models": [
|
||||
{
|
||||
"id": "aerostrip-phoenix",
|
||||
"name": "AEROSTRIP — Phoenix membrane",
|
||||
"units": ["Nm3/h"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "pikprk",
|
||||
"name": "PIK / PRK (vendor TBD)",
|
||||
"types": [
|
||||
{
|
||||
"id": "diffuser-disc",
|
||||
"name": "Disc",
|
||||
"models": [
|
||||
{ "id": "pik300", "name": "PIK300", "units": ["Sm3/h", "Nm3/h"] },
|
||||
{ "id": "prk300", "name": "PRK300", "units": ["Sm3/h", "Nm3/h"] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,89 +1,83 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
'use strict';
|
||||
|
||||
// AssetCategoryManager is now a thin facade over src/registry/assetResolver.
|
||||
// The public surface (getCategory / listCategories / hasCategory / searchCategories)
|
||||
// is preserved so existing consumers (src/menu/asset.js, src/helper/assetUtils.js)
|
||||
// don't need to change in this phase. New code should use assetResolver directly.
|
||||
|
||||
const { assetResolver } = require('../../src/registry');
|
||||
|
||||
class AssetCategoryManager {
|
||||
constructor(relPath = '.') {
|
||||
this.assetDir = path.resolve(__dirname, relPath);
|
||||
this.cache = new Map();
|
||||
}
|
||||
// relPath is retained for signature compatibility with the prior on-disk
|
||||
// implementation; it is unused now — the resolver owns file locations.
|
||||
constructor(/* relPath = '.' */) {}
|
||||
|
||||
getCategory(softwareType) {
|
||||
if (!softwareType) {
|
||||
throw new Error('softwareType is required');
|
||||
}
|
||||
|
||||
if (this.cache.has(softwareType)) {
|
||||
return this.cache.get(softwareType);
|
||||
}
|
||||
|
||||
const filePath = path.resolve(this.assetDir, `${softwareType}.json`);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`Asset data '${softwareType}' not found in ${this.assetDir}`);
|
||||
}
|
||||
|
||||
const raw = fs.readFileSync(filePath, 'utf8');
|
||||
const parsed = JSON.parse(raw);
|
||||
this.cache.set(softwareType, parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
hasCategory(softwareType) {
|
||||
const filePath = path.resolve(this.assetDir, `${softwareType}.json`);
|
||||
return fs.existsSync(filePath);
|
||||
}
|
||||
|
||||
listCategories({ withMeta = false } = {}) {
|
||||
const files = fs.readdirSync(this.assetDir, { withFileTypes: true });
|
||||
|
||||
return files
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.isFile() &&
|
||||
entry.name.endsWith('.json') &&
|
||||
entry.name !== 'index.json' &&
|
||||
entry.name !== 'assetData.json'
|
||||
)
|
||||
.map((entry) => path.basename(entry.name, '.json'))
|
||||
.map((name) => {
|
||||
if (!withMeta) {
|
||||
return name;
|
||||
getCategory(softwareType) {
|
||||
if (!softwareType) {
|
||||
throw new Error('softwareType is required');
|
||||
}
|
||||
|
||||
const data = this.getCategory(name);
|
||||
return {
|
||||
softwareType: data.softwareType || name,
|
||||
label: data.label || name,
|
||||
file: `${name}.json`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
searchCategories(query) {
|
||||
const term = (query || '').trim().toLowerCase();
|
||||
if (!term) {
|
||||
return [];
|
||||
const data = assetResolver.resolve('menu', softwareType);
|
||||
if (!data) {
|
||||
throw new Error(`Asset data '${softwareType}' not found in menu namespace`);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
return this.listCategories({ withMeta: true }).filter(
|
||||
({ softwareType, label }) =>
|
||||
softwareType.toLowerCase().includes(term) ||
|
||||
label.toLowerCase().includes(term)
|
||||
);
|
||||
}
|
||||
hasCategory(softwareType) {
|
||||
if (!softwareType) return false;
|
||||
return assetResolver.resolve('menu', softwareType) != null;
|
||||
}
|
||||
|
||||
clearCache() {
|
||||
this.cache.clear();
|
||||
}
|
||||
listCategories({ withMeta = false } = {}) {
|
||||
// The resolver indexes each menu file under BOTH its inner softwareType
|
||||
// and its filename slug — those may differ. Dedupe by payload identity
|
||||
// so we return one entry per source file.
|
||||
const seen = new Set();
|
||||
const out = [];
|
||||
for (const key of assetResolver.list('menu')) {
|
||||
const data = assetResolver.resolve('menu', key);
|
||||
if (!data || seen.has(data)) continue;
|
||||
seen.add(data);
|
||||
const softwareType = data.softwareType || key;
|
||||
if (withMeta) {
|
||||
out.push({
|
||||
softwareType,
|
||||
label: data.label || softwareType,
|
||||
file: `${softwareType}.json`,
|
||||
});
|
||||
} else {
|
||||
out.push(softwareType);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
searchCategories(query) {
|
||||
const term = (query || '').trim().toLowerCase();
|
||||
if (!term) return [];
|
||||
return this.listCategories({ withMeta: true }).filter(
|
||||
({ softwareType, label }) =>
|
||||
softwareType.toLowerCase().includes(term) ||
|
||||
(label || '').toLowerCase().includes(term),
|
||||
);
|
||||
}
|
||||
|
||||
clearCache() {
|
||||
// Caches live in the resolver namespaces. Force-refresh menu.
|
||||
// refresh() is async but the legacy contract here is sync —
|
||||
// fire-and-forget; the next resolve() lazily warms in the worst case.
|
||||
assetResolver.refresh('menu').catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
const assetCategoryManager = new AssetCategoryManager();
|
||||
|
||||
module.exports = {
|
||||
AssetCategoryManager,
|
||||
assetCategoryManager,
|
||||
getCategory: (softwareType) => assetCategoryManager.getCategory(softwareType),
|
||||
listCategories: (options) => assetCategoryManager.listCategories(options),
|
||||
searchCategories: (query) => assetCategoryManager.searchCategories(query),
|
||||
hasCategory: (softwareType) => assetCategoryManager.hasCategory(softwareType),
|
||||
clearCache: () => assetCategoryManager.clearCache()
|
||||
AssetCategoryManager,
|
||||
assetCategoryManager,
|
||||
getCategory: (softwareType) => assetCategoryManager.getCategory(softwareType),
|
||||
listCategories: (options) => assetCategoryManager.listCategories(options),
|
||||
searchCategories: (query) => assetCategoryManager.searchCategories(query),
|
||||
hasCategory: (softwareType) => assetCategoryManager.hasCategory(softwareType),
|
||||
clearCache: () => assetCategoryManager.clearCache(),
|
||||
};
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"1.204": {
|
||||
"125": {
|
||||
"x": [0,10,20,30,40,50,60,70,80,90,100],
|
||||
"y": [0,18,50,95,150,216,337,564,882,1398,1870]
|
||||
},
|
||||
"150": {
|
||||
"x": [0,10,20,30,40,50,60,70,80,90,100],
|
||||
"y": [0,25,73,138,217,314,490,818,1281,2029,2715]
|
||||
},
|
||||
"400": {
|
||||
"x": [0,10,20,30,40,50,60,70,80,90,100],
|
||||
"y": [0,155,443,839,1322,1911,2982,4980,7795,12349,16524]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,838 +0,0 @@
|
||||
{
|
||||
"np": {
|
||||
"400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5953611390998625,
|
||||
1.6935085477165994,
|
||||
3.801139124304824,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.8497068236812997,
|
||||
3.801139124304824,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.7497197821018213,
|
||||
3.801139124304824,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.788320579602724,
|
||||
3.9982668237045984,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.7824519364844427,
|
||||
3.9885060367793064,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6934482683506376,
|
||||
3.9879559558537054,
|
||||
7.367829525776738,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1000": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6954385513069579,
|
||||
4.0743508382926795,
|
||||
7.422392692482345,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1100": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.160745720731654,
|
||||
7.596626714476177,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1200": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.302551231007837,
|
||||
7.637247864947884,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1300": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.37557913990704,
|
||||
7.773442147000839,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.334434337766139,
|
||||
7.940911352646818,
|
||||
12.081735423116616
|
||||
]
|
||||
},
|
||||
"1500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.2327206586037995,
|
||||
8.005238800611183,
|
||||
12.254836577088351
|
||||
]
|
||||
},
|
||||
"1600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
4.195405588464695,
|
||||
7.991827302945298,
|
||||
12.423663269044452
|
||||
]
|
||||
},
|
||||
"1700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
14.255458319309813,
|
||||
8.096768422220196,
|
||||
12.584668380908582
|
||||
]
|
||||
},
|
||||
"1800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
31.54620347513727,
|
||||
12.637080520201405
|
||||
]
|
||||
},
|
||||
"1900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.148423429611098,
|
||||
12.74916725120127
|
||||
]
|
||||
},
|
||||
"2000": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.146439484120116,
|
||||
12.905178964345618
|
||||
]
|
||||
},
|
||||
"2100": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.149576025637684,
|
||||
13.006940917309247
|
||||
]
|
||||
},
|
||||
"2200": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.126246430368305,
|
||||
13.107503837410825
|
||||
]
|
||||
},
|
||||
"2300": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.104379361635342,
|
||||
13.223235973280122
|
||||
]
|
||||
},
|
||||
"2400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
8.135190080423746,
|
||||
13.36128347785936
|
||||
]
|
||||
},
|
||||
"2500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
7.981219508598527,
|
||||
13.473697427231842
|
||||
]
|
||||
},
|
||||
"2600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
7.863899404441271,
|
||||
13.50303289156837
|
||||
]
|
||||
},
|
||||
"2700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
7.658860522528131,
|
||||
13.485230880073107
|
||||
]
|
||||
},
|
||||
"2800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
7.44407948309266,
|
||||
13.446135725634615
|
||||
]
|
||||
},
|
||||
"2900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
0.5522732775894703,
|
||||
1.6920721090317592,
|
||||
3.8742719210788685,
|
||||
7.44407948309266,
|
||||
13.413693596332184
|
||||
]
|
||||
}
|
||||
},
|
||||
"nq": {
|
||||
"400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
7.6803204433986965,
|
||||
25.506609120436963,
|
||||
35.4,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
22.622804921188227,
|
||||
35.4,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
19.966301579194372,
|
||||
35.4,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
17.430763940163832,
|
||||
33.79508340848005,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
14.752921911234477,
|
||||
31.71885034449889,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
11.854693031181021,
|
||||
29.923046639543475,
|
||||
44.4,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"1000": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.549433913822687,
|
||||
26.734189128096668,
|
||||
43.96760750800311,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"1100": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
26.26933164936586,
|
||||
42.23523193272671,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"1200": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
24.443114637042832,
|
||||
40.57167959798151,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"1300": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
22.41596168949836,
|
||||
39.04561852479495,
|
||||
52.5
|
||||
]
|
||||
},
|
||||
"1400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
20.276864821170303,
|
||||
37.557663261443224,
|
||||
52.252852231224054
|
||||
]
|
||||
},
|
||||
"1500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
18.252772588147742,
|
||||
35.9974418607538,
|
||||
50.68604059588987
|
||||
]
|
||||
},
|
||||
"1600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
16.31441663648616,
|
||||
34.51170378091407,
|
||||
49.20153034100798
|
||||
]
|
||||
},
|
||||
"1700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
14.255458319309813,
|
||||
33.043410795291045,
|
||||
47.820213744181245
|
||||
]
|
||||
},
|
||||
"1800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
31.54620347513727,
|
||||
46.51705619739449
|
||||
]
|
||||
},
|
||||
"1900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
29.986013742375484,
|
||||
45.29506741639918
|
||||
]
|
||||
},
|
||||
"2000": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
28.432646044605782,
|
||||
44.107822395271945
|
||||
]
|
||||
},
|
||||
"2100": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
26.892634464336055,
|
||||
42.758175515158776
|
||||
]
|
||||
},
|
||||
"2200": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
25.270679127870263,
|
||||
41.467063889795895
|
||||
]
|
||||
},
|
||||
"2300": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
23.531132157718837,
|
||||
40.293041104955826
|
||||
]
|
||||
},
|
||||
"2400": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
21.815645106750623,
|
||||
39.03109248860755
|
||||
]
|
||||
},
|
||||
"2500": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
20.34997949463564,
|
||||
37.71320701654063
|
||||
]
|
||||
},
|
||||
"2600": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
18.81710568651804,
|
||||
36.35563657017404
|
||||
]
|
||||
},
|
||||
"2700": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
17.259072160217805,
|
||||
35.02979557646653
|
||||
]
|
||||
},
|
||||
"2800": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
16,
|
||||
33.74372254979665
|
||||
]
|
||||
},
|
||||
"2900": {
|
||||
"x": [
|
||||
0,
|
||||
25.510204081632654,
|
||||
51.020408163265309,
|
||||
76.530612244897952,
|
||||
100
|
||||
],
|
||||
"y": [
|
||||
6.4,
|
||||
9.500000000000002,
|
||||
12.7,
|
||||
16,
|
||||
32.54934541379723
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
class AssetLoader {
|
||||
constructor() {
|
||||
this.relPath = './'
|
||||
this.baseDir = path.resolve(__dirname, this.relPath);
|
||||
this.cache = new Map(); // Cache loaded JSON files for better performance
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a specific curve by type
|
||||
* @param {string} curveType - The curve identifier (e.g., 'hidrostal-H05K-S03R')
|
||||
* @returns {Object|null} The curve data object or null if not found
|
||||
*/
|
||||
loadModel(modelType) {
|
||||
return this.loadAsset('models', modelType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load any asset from a specific dataset folder
|
||||
* @param {string} datasetType - The dataset folder name (e.g., 'curves', 'assetData')
|
||||
* @param {string} assetId - The specific asset identifier
|
||||
* @returns {Object|null} The asset data object or null if not found
|
||||
*/
|
||||
loadAsset(datasetType, assetId) {
|
||||
//const cacheKey = `${datasetType}/${assetId}`;
|
||||
const cacheKey = `${assetId}`;
|
||||
|
||||
|
||||
// Check cache first
|
||||
if (this.cache.has(cacheKey)) {
|
||||
return this.cache.get(cacheKey);
|
||||
}
|
||||
|
||||
try {
|
||||
const filePath = path.join(this.baseDir, `${assetId}.json`);
|
||||
|
||||
// Check if file exists
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.warn(`Asset not found: ${filePath}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load and parse JSON
|
||||
const rawData = fs.readFileSync(filePath, 'utf8');
|
||||
const assetData = JSON.parse(rawData);
|
||||
|
||||
// Cache the result
|
||||
this.cache.set(cacheKey, assetData);
|
||||
|
||||
return assetData;
|
||||
} catch (error) {
|
||||
console.error(`Error loading asset ${cacheKey}:`, error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available assets in a dataset
|
||||
* @param {string} datasetType - The dataset folder name
|
||||
* @returns {string[]} Array of available asset IDs
|
||||
*/
|
||||
getAvailableAssets(datasetType) {
|
||||
try {
|
||||
const datasetPath = path.join(this.baseDir, datasetType);
|
||||
|
||||
if (!fs.existsSync(datasetPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return fs.readdirSync(datasetPath)
|
||||
.filter(file => file.endsWith('.json'))
|
||||
.map(file => file.replace('.json', ''));
|
||||
} catch (error) {
|
||||
console.error(`Error reading dataset ${datasetType}:`, error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cache (useful for development/testing)
|
||||
*/
|
||||
clearCache() {
|
||||
this.cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export a singleton instance
|
||||
const assetLoader = new AssetLoader();
|
||||
|
||||
module.exports = {
|
||||
AssetLoader,
|
||||
assetLoader,
|
||||
// Convenience methods for backward compatibility
|
||||
loadModel: (modelType) => assetLoader.loadModel(modelType),
|
||||
loadAsset: (datasetType, assetId) => assetLoader.loadAsset(datasetType, assetId),
|
||||
getAvailableAssets: (datasetType) => assetLoader.getAvailableAssets(datasetType)
|
||||
};
|
||||
|
||||
/*
|
||||
// Example usage in your scripts
|
||||
const loader = new AssetLoader();
|
||||
|
||||
// Load a specific curve
|
||||
const curve = loader.loadModel('hidrostal-H05K-S03R');
|
||||
if (curve) {
|
||||
console.log('Model loaded:', curve);
|
||||
} else {
|
||||
console.log('Model not found');
|
||||
}
|
||||
/*
|
||||
// Load any asset from any dataset
|
||||
const someAsset = loadAsset('assetData', 'some-asset-id');
|
||||
|
||||
// Get list of available models
|
||||
const availableCurves = getAvailableAssets('curves');
|
||||
console.log('Available curves:', availableCurves);
|
||||
|
||||
// Using the class directly for more control
|
||||
const { AssetLoader } = require('./index.js');
|
||||
const customLoader = new AssetLoader();
|
||||
const data = customLoader.loadCurve('hidrostal-H05K-S03R');
|
||||
*/
|
||||
Reference in New Issue
Block a user