specificClass._setupCurves now calls assetResolver.resolveAssetMetadata to derive supplier/type/units from the model id, instead of trusting denormalized fields on the node config. If the model isn't in the registry, installs a null-predictor stub and logs a clear "pick a model from the asset menu" error rather than crashing. rotatingMachine.html: defaults block trimmed (supplier/category/assetType were stale copies of registry data). Tests: - New test/basic/assetMetadata.basic.test.js covers the registry-resolve path and the missing-model fallback. - nodeClass-config / error-paths / nodeClass-routing / factories / abort-deadlock fixtures updated to the trimmed asset shape. - 209/209 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
118 lines
2.5 KiB
JavaScript
118 lines
2.5 KiB
JavaScript
const { MeasurementContainer } = require('generalFunctions');
|
|
|
|
function makeMachineConfig(overrides = {}) {
|
|
return {
|
|
general: {
|
|
id: 'rm-test-1',
|
|
name: 'rotating-machine-test',
|
|
unit: 'm3/h',
|
|
logging: { enabled: false, logLevel: 'error' },
|
|
},
|
|
functionality: {
|
|
positionVsParent: 'atEquipment',
|
|
},
|
|
// Post-AssetResolver: only model + unit + tagCode/uuid are saved on the
|
|
// node. supplier/category/type are derived from the registry. Keeping
|
|
// legacy fields in the factory would trip the strict-cutover guard in
|
|
// nodeClass.buildDomainConfig.
|
|
asset: {
|
|
model: 'hidrostal-H05K-S03R',
|
|
unit: 'm3/h',
|
|
curveUnits: {
|
|
pressure: 'mbar',
|
|
flow: 'm3/h',
|
|
power: 'kW',
|
|
control: '%',
|
|
},
|
|
},
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function makeStateConfig(overrides = {}) {
|
|
return {
|
|
general: {
|
|
logging: { enabled: false, logLevel: 'error' },
|
|
},
|
|
state: {
|
|
current: 'idle',
|
|
},
|
|
movement: {
|
|
mode: 'staticspeed',
|
|
speed: 1000,
|
|
maxSpeed: 1000,
|
|
interval: 10,
|
|
},
|
|
time: {
|
|
starting: 0,
|
|
warmingup: 0,
|
|
stopping: 0,
|
|
coolingdown: 0,
|
|
},
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function makeChildMeasurement({ id = 'child-1', name = 'PT-1', positionVsParent = 'downstream', type = 'pressure', unit = 'mbar' } = {}) {
|
|
const measurements = new MeasurementContainer({
|
|
autoConvert: true,
|
|
defaultUnits: {
|
|
pressure: 'mbar',
|
|
flow: 'm3/h',
|
|
temperature: 'C',
|
|
power: 'kW',
|
|
},
|
|
});
|
|
|
|
return {
|
|
config: {
|
|
general: { id, name },
|
|
functionality: { positionVsParent },
|
|
asset: { type, unit },
|
|
},
|
|
measurements,
|
|
};
|
|
}
|
|
|
|
function makeNodeStub() {
|
|
const handlers = {};
|
|
const sent = [];
|
|
const statuses = [];
|
|
const errors = [];
|
|
const warns = [];
|
|
return {
|
|
id: 'node-1',
|
|
source: null,
|
|
send(msg) { sent.push(msg); },
|
|
status(s) { statuses.push(s); },
|
|
error(e) { errors.push(e); },
|
|
warn(w) { warns.push(w); },
|
|
on(event, cb) { handlers[event] = cb; },
|
|
_handlers: handlers,
|
|
_sent: sent,
|
|
_statuses: statuses,
|
|
_errors: errors,
|
|
_warns: warns,
|
|
};
|
|
}
|
|
|
|
function makeREDStub(nodeMap = {}) {
|
|
return {
|
|
nodes: {
|
|
getNode(id) {
|
|
return nodeMap[id] || null;
|
|
},
|
|
createNode() {},
|
|
registerType() {},
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
makeMachineConfig,
|
|
makeStateConfig,
|
|
makeChildMeasurement,
|
|
makeNodeStub,
|
|
makeREDStub,
|
|
};
|