updated template

This commit is contained in:
znetsixe
2025-06-02 16:56:36 +02:00
parent 96430d3592
commit b09d9e8327

View File

@@ -1,70 +1,55 @@
<script type="module">
import * as menuUtils from "/generalFunctions/helper/menuUtils.js";
import nodeTemplates from "/generalFunctions/helper/nodeTemplates.js";
// Grab the asset template from nodeTemplates
const tm = nodeTemplates.asset;
RED.nodes.registerType("rotatingMachine", {
category: "digital twin",
color: "#4f8582",
category: tm.category,
color: tm.color,
defaults: {
// Define default properties
name: { value: "", required: true },
enableLog: { value: false },
logLevel: { value: "error" },
// Define specific properties
speed: { value: 1, required: true },
startup: { value: 0 },
warmup: { value: 0 },
shutdown: { value: 0 },
cooldown: { value: 0 },
//define general asset properties
supplier: { value: "" },
subType: { value: "" },
model: { value: "" },
unit: { value: "" },
//define specific asset properties
machineCurve : { value: {}},
...tm.defaults,
machineCurve: { value: {} }, // used to interpolate values
speed: { value: 1, required: true },
startup: { value: 0, required: false },
warmup: { value: 0, required: false },
shutdown:{ value: 0, required: false },
cooldown:{ value: 0, required: false },
},
inputs: 1,
outputs: 4,
inputLabels: ["Machine Input"],
outputLabels: ["process", "dbase", "upstreamParent", "downstreamParent"],
icon: "font-awesome/fa-cogs",
inputs: tm.inputs,
outputs: tm.outputs,
inputLabels: tm.inputLabels,
outputLabels: tm.outputLabels,
icon: tm.icon,
label: function () {
return this.name || "Rotating Machine";
return this.name || "asset";
},
oneditprepare: function () {
const node = this;
console.log("Rotating Machine Node: Edit Prepare");
console.log("------------ Edit Prepare for Rotating Machine Node ------------");
// specific fields of node
const elements = {
// Basic fields
name: document.getElementById("node-input-name"),
// specific fields
speed: document.getElementById("node-input-speed"),
startup: document.getElementById("node-input-startup"),
warmup: document.getElementById("node-input-warmup"),
shutdown: document.getElementById("node-input-shutdown"),
cooldown: document.getElementById("node-input-cooldown"),
// Logging fields
logCheckbox: document.getElementById("node-input-enableLog"),
logLevelSelect: document.getElementById("node-input-logLevel"),
rowLogLevel: document.getElementById("row-logLevel"),
// Asset fields
supplier: document.getElementById("node-input-supplier"),
subType: document.getElementById("node-input-subType"),
model: document.getElementById("node-input-model"),
unit: document.getElementById("node-input-unit"),
};
const projecSettingstURL = "http://localhost:1880/generalFunctions/settings/projectSettings.json";
// Loop through tm.elements to add non-specific elements
Object.keys(tm.elements).forEach(key => {
elements[key] = document.getElementById(tm.elements[key]);
});
console.log("Elements:", elements);
const projecSettingstURL = tm.projectSettingsURL;
console.log("Project settings URL:", projecSettingstURL);
try{