Files
rotatingMachine/rotatingMachine.html

137 lines
4.7 KiB
HTML
Raw Normal View History

2025-06-25 17:26:13 +02:00
<!-- Load the dynamic menu & config endpoints -->
<script src="/rotatingMachine/menu.js"></script>
<script src="/rotatingMachine/configData.js"></script>
<script>
RED.nodes.registerType("rotatingMachine", {
category: "EVOLV",
color: "#4f8582",
defaults: {
// Define default properties
2025-07-01 15:25:07 +02:00
name: { value: ""}, // use asset category as name ?
2025-06-25 17:26:13 +02:00
// Define specific properties
speed: { value: 1, required: true },
startup: { value: 0 },
warmup: { value: 0 },
shutdown: { value: 0 },
2025-07-02 10:53:03 +02:00
cooldown: { value: 0 },
2025-06-25 17:26:13 +02:00
machineCurve : { value: {}},
//define asset properties
uuid: { value: "" },
supplier: { value: "" },
category: { value: "" },
assetType: { value: "" },
model: { value: "" },
unit: { value: "" },
//logger properties
enableLog: { value: false },
logLevel: { value: "error" },
//physicalAspect
positionVsParent: { value: "" },
2025-07-01 15:25:07 +02:00
positionIcon: { value: "" },
2025-06-02 16:56:36 +02:00
2025-05-14 10:07:27 +02:00
},
2025-06-25 17:26:13 +02:00
inputs: 1,
outputs: 3,
inputLabels: ["Input"],
outputLabels: ["process", "dbase", "parent"],
icon: "font-awesome/fa-tachometer",
2025-07-01 15:25:07 +02:00
label: function () {
return this.positionIcon + " " + this.category.slice(0, -1) || "Machine";
2025-06-25 17:26:13 +02:00
},
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
oneditprepare: function() {
// wait for the menu scripts to load
const waitForMenuData = () => {
if (window.EVOLV?.nodes?.rotatingMachine?.initEditor) {
window.EVOLV.nodes.rotatingMachine.initEditor(this);
} else {
setTimeout(waitForMenuData, 50);
2025-05-14 10:07:27 +02:00
}
2025-06-25 17:26:13 +02:00
};
waitForMenuData();
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
// your existing projectsettings & asset dropdown logic can remain here
2025-07-24 13:15:33 +02:00
document.getElementById("node-input-speed");
document.getElementById("node-input-startup");
document.getElementById("node-input-warmup");
document.getElementById("node-input-shutdown");
document.getElementById("node-input-cooldown");
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
},
oneditsave: function() {
const node = this;
// save asset fields
if (window.EVOLV?.nodes?.rotatingMachine?.assetMenu?.saveEditor) {
window.EVOLV.nodes.rotatingMachine.assetMenu.saveEditor(this);
2025-05-14 10:07:27 +02:00
}
2025-06-25 17:26:13 +02:00
// save logger fields
if (window.EVOLV?.nodes?.rotatingMachine?.loggerMenu?.saveEditor) {
window.EVOLV.nodes.rotatingMachine.loggerMenu.saveEditor(this);
2025-05-14 10:07:27 +02:00
}
2025-06-25 17:26:13 +02:00
// save position field
if (window.EVOLV?.nodes?.rotatingMachine?.positionMenu?.saveEditor) {
window.EVOLV.nodes.rotatingMachine.positionMenu.saveEditor(this);
2025-05-14 10:07:27 +02:00
}
2025-07-02 10:53:03 +02:00
["speed", "startup", "warmup", "shutdown", "cooldown"].forEach((field) => {
const element = document.getElementById(`node-input-${field}`);
const value = parseFloat(element?.value) || 0;
console.log(`----------------> Saving ${field}: ${value}`);
node[field] = value;
});
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
}
2025-05-14 10:07:27 +02:00
});
2025-06-25 17:26:13 +02:00
</script>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
<!-- Main UI Template -->
<script type="text/html" data-template-name="rotatingMachine">
<!-- Machine-specific controls -->
<div class="form-row">
<label for="node-input-speed"><i class="fa fa-clock-o"></i> Reaction Speed</label>
<input type="number" id="node-input-speed" style="width:60%;" />
</div>
<div class="form-row">
<label for="node-input-startup"><i class="fa fa-clock-o"></i> Startup Time</label>
<input type="number" id="node-input-startup" style="width:60%;" />
</div>
<div class="form-row">
<label for="node-input-warmup"><i class="fa fa-clock-o"></i> Warmup Time</label>
<input type="number" id="node-input-warmup" style="width:60%;" />
</div>
<div class="form-row">
<label for="node-input-shutdown"><i class="fa fa-clock-o"></i> Shutdown Time</label>
<input type="number" id="node-input-shutdown" style="width:60%;" />
</div>
<div class="form-row">
<label for="node-input-cooldown"><i class="fa fa-clock-o"></i> Cooldown Time</label>
<input type="number" id="node-input-cooldown" style="width:60%;" />
</div>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
<!-- Asset fields injected here -->
<div id="asset-fields-placeholder"></div>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
<!-- Logger fields injected here -->
<div id="logger-fields-placeholder"></div>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
<!-- Position fields injected here -->
<div id="position-fields-placeholder"></div>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
</script>
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
<script type="text/html" data-help-name="rotatingMachine">
<p><b>Rotating Machine Node</b>: Configure a rotatingmachine asset.</p>
<ul>
<li><b>Reaction Speed, Startup, Warmup, Shutdown, Cooldown:</b> timing parameters.</li>
<li><b>Supplier / SubType / Model / Unit:</b> choose via Asset menu.</li>
<li><b>Enable Log / Log Level:</b> toggle via Logger menu.</li>
<li><b>Position:</b> set Upstream / At Equipment / Downstream via Position menu.</li>
</ul>
</script>