Compare commits
36 Commits
241ed1d3cb
...
dev-Pieter
| Author | SHA1 | Date | |
|---|---|---|---|
| d5d078413c | |||
| 17662ef7cb | |||
| f653a1e98c | |||
| 3886277616 | |||
| 83018fabe0 | |||
| e72579e5d0 | |||
| 0fb42865ff | |||
| b2b811e802 | |||
| bde2dcf7d8 | |||
| 76570280bc | |||
| d7017b5d33 | |||
| f93603c182 | |||
| c261335df5 | |||
| a41f053d5d | |||
| 8d7d98f126 | |||
| 3f90685834 | |||
| efc97d6cd1 | |||
|
|
d72bfd5560 | ||
| 6d30e25daa | |||
| 16e202e841 | |||
| 3876f86530 | |||
| 56be0f1840 | |||
| 302e122387 | |||
| 6dcd3c3d26 | |||
| 958ec2269c | |||
| 0bccad05f8 | |||
| 7191e57aea | |||
| aec2d3692d | |||
| 71643375fc | |||
| f13ee68938 | |||
| 475caa90db | |||
| 9aa38f9000 | |||
| 4a6273b037 | |||
| 8c9301b128 | |||
| 7cdfc87c83 | |||
| 839ae2f3da |
@@ -59,15 +59,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Level",
|
||||
"name": "Quantity (oxygen)",
|
||||
"models": [
|
||||
{
|
||||
"name": "VegaLevel 10",
|
||||
"units": ["m", "ft", "mm"]
|
||||
},
|
||||
"name": "VegaOxySense 10",
|
||||
"units": ["g/m³", "mol/m³"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Quantity (TSS)",
|
||||
"models": [
|
||||
{
|
||||
"name": "VegaLevel 20",
|
||||
"units": ["m", "ft", "mm"]
|
||||
"name": "VegaSolidsProbe",
|
||||
"units": ["g/m³"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
8
index.js
8
index.js
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* generalfunctions/index.js
|
||||
* generalFunctions/index.js
|
||||
* -----------------------------------------------------------
|
||||
* Central barrel file for re-exporting helpers and configurations.
|
||||
* Provides both namespace exports and dynamic loading capabilities.
|
||||
* now we can load modules like this:
|
||||
* const { menuUtils, outputUtils } = require('generalfunctions');
|
||||
* const { menuUtils, outputUtils } = require('generalFunctions');
|
||||
*/
|
||||
|
||||
// Core helper modules
|
||||
@@ -12,6 +12,7 @@ const outputUtils = require('./src/helper/outputUtils.js');
|
||||
const logger = require('./src/helper/logger.js');
|
||||
const validation = require('./src/helper/validationUtils.js');
|
||||
const configUtils = require('./src/helper/configUtils.js');
|
||||
const assertions = require('./src/helper/assertionUtils.js')
|
||||
|
||||
// Domain-specific modules
|
||||
const { MeasurementContainer } = require('./src/measurements/index.js');
|
||||
@@ -34,6 +35,7 @@ module.exports = {
|
||||
configUtils,
|
||||
logger,
|
||||
validation,
|
||||
assertions,
|
||||
MeasurementContainer,
|
||||
nrmse,
|
||||
state,
|
||||
@@ -41,4 +43,4 @@ module.exports = {
|
||||
MenuManager,
|
||||
childRegistrationUtils,
|
||||
loadCurve
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "generalfunctions",
|
||||
"name": "generalFunctions",
|
||||
"version": "1.0.0",
|
||||
"description": "General utility functions used across multiple Node-RED modules",
|
||||
"main": "./index.js",
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.centraal.wbd-rd.nl/RnD/generalfunctions.git"
|
||||
"url": "https://gitea.centraal.wbd-rd.nl/RnD/generalFunctions.git"
|
||||
},
|
||||
"keywords": [
|
||||
"utilities",
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
"taggcodeAPI": "https://pimmoerman.nl/rdlab/tagcode.app/v2.1/apiBLAH"
|
||||
},
|
||||
"local": {
|
||||
"units": "http://localhost:1880/generalfunctions/datasets/unitData.json",
|
||||
"taggcodeAPI": "http://localhost:1880/generalfunctions/datasets/assetData"
|
||||
"units": "http://localhost:1880/generalFunctions/datasets/unitData.json",
|
||||
"taggcodeAPI": "http://localhost:1880/generalFunctions/datasets/assetData"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ class ProjectSettings {
|
||||
taggcodeAPI: this.cloudAPI,
|
||||
},
|
||||
local: {
|
||||
units: "http://localhost:1880/generalfunctions/datasets/unitData.json",
|
||||
taggcodeAPI: "http://localhost:1880/generalfunctions/datasets/assetData",
|
||||
units: "http://localhost:1880/generalFunctions/datasets/unitData.json",
|
||||
taggcodeAPI: "http://localhost:1880/generalFunctions/datasets/assetData",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -91,6 +91,13 @@
|
||||
],
|
||||
"description": "Defines the position of the measurement relative to its parent equipment or system."
|
||||
}
|
||||
},
|
||||
"distance":{
|
||||
"default": null,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"description": "Defines the position of the measurement relative to its parent equipment or system."
|
||||
}
|
||||
}
|
||||
},
|
||||
"asset": {
|
||||
|
||||
@@ -412,6 +412,14 @@
|
||||
],
|
||||
"description": "The frequency at which calculations are performed."
|
||||
}
|
||||
},
|
||||
"flowNumber": {
|
||||
"default": 1,
|
||||
"rules": {
|
||||
"type": "number",
|
||||
"nullable": false,
|
||||
"description": "Defines which effluent flow of the parent node to handle."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,12 @@ class ChildRegistrationUtils {
|
||||
|
||||
this.logger.debug(`Registering child: ${name} (${id}) as ${softwareType} at ${positionVsParent}`);
|
||||
|
||||
// Enhanced child setup
|
||||
child.parent = this.mainClass;
|
||||
// Enhanced child setup - multiple parents
|
||||
if (Array.isArray(child.parent)) {
|
||||
child.parent.push(this.mainClass);
|
||||
} else {
|
||||
child.parent = [this.mainClass];
|
||||
}
|
||||
child.positionVsParent = positionVsParent;
|
||||
|
||||
// Enhanced measurement container with rich context
|
||||
|
||||
@@ -33,7 +33,7 @@ const nodeTemplates = {
|
||||
parent: "node-input-parent",
|
||||
},
|
||||
projectSettingsURL:
|
||||
"http://localhost:1880/generalfunctions/settings/projectSettings.json",
|
||||
"http://localhost:1880/generalFunctions/settings/projectSettings.json",
|
||||
},
|
||||
|
||||
exampleTemplate: {
|
||||
|
||||
@@ -131,7 +131,6 @@ class Measurement {
|
||||
const downIndex = downValues.timestamps.indexOf(upTimestamp);
|
||||
|
||||
if (downIndex !== -1) {
|
||||
|
||||
const diff = upValues.values[i] - downValues.values[downIndex];
|
||||
diffMeasurement.setValue(diff, upTimestamp);
|
||||
}
|
||||
|
||||
@@ -88,11 +88,18 @@ class MeasurementContainer {
|
||||
return this;
|
||||
}
|
||||
|
||||
position(positionName) {
|
||||
position(positionValue) {
|
||||
if (!this._currentVariant) {
|
||||
throw new Error('Variant must be specified before position');
|
||||
}
|
||||
this._currentPosition = positionName;
|
||||
|
||||
// Turn string positions into numeric values
|
||||
if (typeof positionValue == "string") {
|
||||
positionValue = this._convertPositionStr2Num(positionValue);
|
||||
}
|
||||
|
||||
this._currentPosition = positionValue;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -243,10 +250,12 @@ class MeasurementContainer {
|
||||
const savedPosition = this._currentPosition;
|
||||
|
||||
// Get upstream and downstream measurements
|
||||
this._currentPosition = 'upstream';
|
||||
const positions = this.getPositions();
|
||||
|
||||
this._currentPosition = Math.min(...positions);
|
||||
const upstream = this.get();
|
||||
|
||||
this._currentPosition = 'downstream';
|
||||
this._currentPosition = Math.max(...positions);
|
||||
const downstream = this.get();
|
||||
|
||||
this._currentPosition = savedPosition;
|
||||
@@ -319,7 +328,7 @@ class MeasurementContainer {
|
||||
Object.keys(this.measurements[this._currentType]) : [];
|
||||
}
|
||||
|
||||
getPositions() {
|
||||
getPositions(asNumber = false) {
|
||||
if (!this._currentType || !this._currentVariant) {
|
||||
throw new Error('Type and variant must be specified before listing positions');
|
||||
}
|
||||
@@ -328,8 +337,12 @@ class MeasurementContainer {
|
||||
!this.measurements[this._currentType][this._currentVariant]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Object.keys(this.measurements[this._currentType][this._currentVariant]);
|
||||
|
||||
if (asNumber) {
|
||||
return Object.keys(this.measurements[this._currentType][this._currentVariant]);
|
||||
}
|
||||
|
||||
return Object.keys(this.measurements[this._currentType][this._currentVariant]).map(this._convertPositionNum2Str);
|
||||
}
|
||||
|
||||
clear() {
|
||||
@@ -404,6 +417,39 @@ class MeasurementContainer {
|
||||
}
|
||||
}
|
||||
|
||||
_convertPositionStr2Num(positionString) {
|
||||
switch(positionString) {
|
||||
case "atEquipment":
|
||||
return 0;
|
||||
case "upstream":
|
||||
return Number.POSITIVE_INFINITY;
|
||||
case "downstream":
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
|
||||
default:
|
||||
if (this.logger) {
|
||||
this.logger.error(`Invalid positionVsParent provided: ${positionString}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_convertPositionNum2Str(positionValue) {
|
||||
if (positionValue === 0) {
|
||||
return "atEquipment";
|
||||
}
|
||||
if (positionValue < 0) {
|
||||
return "upstream";
|
||||
}
|
||||
if (positionValue > 0) {
|
||||
return "downstream";
|
||||
}
|
||||
|
||||
if (this.logger) {
|
||||
this.logger.error(`Invalid position provided: ${positionValue}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = MeasurementContainer;
|
||||
|
||||
Reference in New Issue
Block a user