forked from RnD/rotatingMachine
137 lines
4.7 KiB
HTML
137 lines
4.7 KiB
HTML
<!-- 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
|
||
name: { value: ""}, // use asset category as name ?
|
||
|
||
// Define specific properties
|
||
speed: { value: 1, required: true },
|
||
startup: { value: 0 },
|
||
warmup: { value: 0 },
|
||
shutdown: { value: 0 },
|
||
cooldown: { value: 0 },
|
||
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: "" },
|
||
positionIcon: { value: "" },
|
||
|
||
},
|
||
inputs: 1,
|
||
outputs: 3,
|
||
inputLabels: ["Input"],
|
||
outputLabels: ["process", "dbase", "parent"],
|
||
icon: "font-awesome/fa-tachometer",
|
||
|
||
label: function () {
|
||
return this.positionIcon + " " + this.category.slice(0, -1) || "Machine";
|
||
},
|
||
|
||
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);
|
||
}
|
||
};
|
||
waitForMenuData();
|
||
|
||
// your existing project‐settings & asset dropdown logic can remain here
|
||
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")
|
||
|
||
},
|
||
oneditsave: function() {
|
||
const node = this;
|
||
// save asset fields
|
||
if (window.EVOLV?.nodes?.rotatingMachine?.assetMenu?.saveEditor) {
|
||
window.EVOLV.nodes.rotatingMachine.assetMenu.saveEditor(this);
|
||
}
|
||
// save logger fields
|
||
if (window.EVOLV?.nodes?.rotatingMachine?.loggerMenu?.saveEditor) {
|
||
window.EVOLV.nodes.rotatingMachine.loggerMenu.saveEditor(this);
|
||
}
|
||
// save position field
|
||
if (window.EVOLV?.nodes?.rotatingMachine?.positionMenu?.saveEditor) {
|
||
window.EVOLV.nodes.rotatingMachine.positionMenu.saveEditor(this);
|
||
}
|
||
|
||
["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;
|
||
});
|
||
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<!-- 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>
|
||
|
||
<!-- Asset fields injected here -->
|
||
<div id="asset-fields-placeholder"></div>
|
||
|
||
<!-- Logger fields injected here -->
|
||
<div id="logger-fields-placeholder"></div>
|
||
|
||
<!-- Position fields injected here -->
|
||
<div id="position-fields-placeholder"></div>
|
||
|
||
</script>
|
||
|
||
<script type="text/html" data-help-name="rotatingMachine">
|
||
<p><b>Rotating Machine Node</b>: Configure a rotating‐machine 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> |