Generic updates completed for now

This commit is contained in:
znetsixe
2025-07-01 15:24:18 +02:00
parent b4803e5e9b
commit edf9b09af1
4 changed files with 17 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2025 Rene De Ren Copyright (c) 2025 wbd
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to use, of this software and associated documentation files (the "Software"), to use,

View File

@@ -9,7 +9,7 @@
defaults: { defaults: {
// Define default properties // Define default properties
name: { value: "", required: true }, // use asset category as name name: { value: "" }, // use asset category as name
// Define specific properties // Define specific properties
scaling: { value: false }, scaling: { value: false },
@@ -36,6 +36,7 @@
//physicalAspect //physicalAspect
positionVsParent: { value: "" }, positionVsParent: { value: "" },
positionIcon: { value: "" },
}, },
@@ -46,7 +47,7 @@
icon: "font-awesome/fa-tachometer", icon: "font-awesome/fa-tachometer",
label: function () { label: function () {
return this.name || "Measurement"; return this.positionIcon + " " + this.assetType || "Measurement";
}, },
oneditprepare: function() { oneditprepare: function() {
@@ -118,6 +119,11 @@
success = window.EVOLV.nodes.measurement.loggerMenu.saveEditor(node); success = window.EVOLV.nodes.measurement.loggerMenu.saveEditor(node);
} }
// save position field
if (window.EVOLV?.nodes?.rotatingMachine?.positionMenu?.saveEditor) {
window.EVOLV.nodes.rotatingMachine.positionMenu.saveEditor(this);
}
// Save basic properties // Save basic properties
["smooth_method"].forEach( ["smooth_method"].forEach(
(field) => (node[field] = document.getElementById(`node-input-${field}`).value || "") (field) => (node[field] = document.getElementById(`node-input-${field}`).value || "")

View File

@@ -1,7 +1,3 @@
/**
* Thin wrapper that registers a node with Node-RED and exposes HTTP endpoints. and loads EVOLV in a standard way
*/
const nameOfNode = 'measurement'; // this is the name of the node, it should match the file name and the node type in Node-RED const nameOfNode = 'measurement'; // this is the name of the node, it should match the file name and the node type in Node-RED
const nodeClass = require('./src/nodeClass.js'); // this is the specific node class const nodeClass = require('./src/nodeClass.js'); // this is the specific node class
const { MenuManager, configManager } = require('generalFunctions'); const { MenuManager, configManager } = require('generalFunctions');
@@ -12,7 +8,6 @@ module.exports = function(RED) {
RED.nodes.registerType(nameOfNode, function(config) { RED.nodes.registerType(nameOfNode, function(config) {
// Initialize the Node-RED node first // Initialize the Node-RED node first
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);
// Then create your custom class and attach it // Then create your custom class and attach it
this.nodeClass = new nodeClass(config, RED, this, nameOfNode); this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
}); });
@@ -21,10 +16,8 @@ module.exports = function(RED) {
const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically const menuMgr = new MenuManager(); //this will handle the menu endpoints so we can load them dynamically
const cfgMgr = new configManager(); // this will handle the config endpoints so we can load them dynamically const cfgMgr = new configManager(); // this will handle the config endpoints so we can load them dynamically
//console.log(`Loading endpoint for ${nameOfNode} menu...`);
// Register the different menu's for the measurement node (in the future we could automate this further by refering to the config) // Register the different menu's for the measurement node (in the future we could automate this further by refering to the config)
RED.httpAdmin.get('/measurement/menu.js', (req, res) => { RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
try { try {
const script = menuMgr.createEndpoint(nameOfNode, ['asset','logger','position']); const script = menuMgr.createEndpoint(nameOfNode, ['asset','logger','position']);
res.type('application/javascript').send(script); res.type('application/javascript').send(script);
@@ -33,10 +26,8 @@ module.exports = function(RED) {
} }
}); });
//console.log(`Loading endpoint for ${nameOfNode} config...`);
// Endpoint to get the configuration data for the specific node // Endpoint to get the configuration data for the specific node
RED.httpAdmin.get(`/measurement/configData.js`, (req, res) => { RED.httpAdmin.get(`/${nameOfNode}/configData.js`, (req, res) => {
try { try {
const script = cfgMgr.createEndpoint(nameOfNode); const script = cfgMgr.createEndpoint(nameOfNode);
// Send the configuration data as JSON response // Send the configuration data as JSON response
@@ -46,5 +37,4 @@ module.exports = function(RED) {
} }
}); });
//console.log(`Measurement node '${nameOfNode}' registered.`);
}; };

View File

@@ -7,14 +7,14 @@
const { outputUtils, configManager } = require('generalFunctions'); const { outputUtils, configManager } = require('generalFunctions');
const Specific = require("./specificClass"); const Specific = require("./specificClass");
/**
* Class representing a Measurement Node-RED node.
*/
class nodeClass { class nodeClass {
/** /**
* Create a MeasurementNode. * Create a MeasurementNode.
* @param {object} uiConfig - Node-RED node configuration. * @param {object} uiConfig - Node-RED node configuration.
* @param {object} RED - Node-RED runtime API. * @param {object} RED - Node-RED runtime API.
* @param {object} nodeInstance - The Node-RED node instance.
* @param {string} nameOfNode - The name of the node, used for
*/ */
constructor(uiConfig, RED, nodeInstance, nameOfNode) { constructor(uiConfig, RED, nodeInstance, nameOfNode) {
@@ -48,7 +48,7 @@ class nodeClass {
// Merge UI config over defaults // Merge UI config over defaults
this.config = { this.config = {
general: { general: {
name: this.name, name: uiConfig.name,
id: node.id, // node.id is for the child registration process id: node.id, // node.id is for the child registration process
unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards) unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
logging: { logging: {
@@ -94,6 +94,7 @@ class nodeClass {
*/ */
_setupSpecificClass() { _setupSpecificClass() {
this.source = new Specific(this.config); this.source = new Specific(this.config);
this.node.source = this.source; // Store the source in the node instance for easy access
} }
/** /**
@@ -114,7 +115,7 @@ class nodeClass {
this.node.send([ this.node.send([
null, null,
null, null,
{ topic: 'registerChild', payload: this.config.general.id, positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' }, { topic: 'registerChild', payload: this.node.id , positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' },
]); ]);
}, 100); }, 100);
} }