Files
rotatingMachine/rotatingMachine.html

165 lines
5.9 KiB
HTML
Raw Normal View History

2025-10-14 13:52:39 +02:00
<!--
| S88-niveau | Primair (blokkleur) | Tekstkleur |
| ---------------------- | ------------------- | ---------- |
| **Area** | `#0f52a5` | wit |
| **Process Cell** | `#0c99d9` | wit |
| **Unit** | `#50a8d9` | zwart |
| **Equipment (Module)** | `#86bbdd` | zwart |
| **Control Module** | `#a9daee` | zwart |
-->
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",
2025-10-14 13:52:39 +02:00
color: "#86bbdd",
2025-06-25 17:26:13 +02:00
defaults: {
// 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-11-20 11:09:44 +01:00
movementMode : { value: "staticspeed" }, // static or dynamic
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-09-05 16:20:27 +02:00
hasDistance: { value: false },
distance: { value: 0 },
distanceUnit: { value: "m" },
distanceDescription: { 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"],
2025-10-14 13:52:39 +02:00
icon: "font-awesome/fa-cog",
2025-06-25 17:26:13 +02:00
2025-07-01 15:25:07 +02:00
label: function () {
return this.positionIcon + " " + this.category || "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-11-20 11:09:44 +01:00
const movementMode = document.getElementById("node-input-movementMode");
if (movementMode) {
movementMode.value = this.movementMode || "staticspeed";
}
2025-05-14 10:07:27 +02:00
2025-06-25 17:26:13 +02:00
},
oneditsave: function() {
const node = this;
2025-06-25 17:26:13 +02:00
// 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-11-20 11:09:44 +01:00
node.movementMode = document.getElementById("node-input-movementMode").value;
console.log(`----------------> Saving movementMode: ${node.movementMode}`);
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-11-20 11:09:44 +01:00
<div class="form-row">
<label for="node-input-movementMode"><i class="fa fa-exchange"></i> Movement Mode</label>
<select id="node-input-movementMode" style="width:60%;">
<option value="staticspeed">Static</option>
<option value="dynspeed">Dynamic</option>
</select>
</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>