forked from RnD/measurement
updates for standaardisation
This commit is contained in:
124
measurement.html
124
measurement.html
@@ -9,9 +9,7 @@
|
||||
defaults: {
|
||||
|
||||
// Define default properties
|
||||
name: { value: "", required: true },
|
||||
enableLog: { value: false },
|
||||
logLevel: { value: "error" },
|
||||
name: { value: "", required: true }, // use asset category as name
|
||||
|
||||
// Define specific properties
|
||||
scaling: { value: false },
|
||||
@@ -31,6 +29,13 @@
|
||||
model: { value: "" },
|
||||
unit: { value: "" },
|
||||
|
||||
//logger properties
|
||||
enableLog: { value: false },
|
||||
logLevel: { value: "error" },
|
||||
|
||||
//physicalAspect
|
||||
physicalAspect: { value: "" },
|
||||
|
||||
},
|
||||
|
||||
inputs: 1,
|
||||
@@ -54,11 +59,11 @@
|
||||
// Wait for the menu data to be ready before initializing the editor
|
||||
waitForMenuData();
|
||||
|
||||
// --------------- Initialize the dropdowns and other specific UI elements -------------- this should be derived from the config in the future (make config based menu)
|
||||
// THIS IS NODE SPECIFIC --------------- Initialize the dropdowns and other specific UI elements -------------- this should be derived from the config in the future (make config based menu)
|
||||
// Populate smoothing methods dropdown
|
||||
const smoothMethodSelect = document.getElementById('node-input-smooth_method');
|
||||
const options = window.EVOLV?.nodes?.measurement?.config?.smoothing?.smoothMethod?.rules?.values || [];
|
||||
console.log("Smoothing methods options:", options);
|
||||
|
||||
// Clear existing options
|
||||
smoothMethodSelect.innerHTML = '';
|
||||
|
||||
@@ -92,8 +97,13 @@
|
||||
success = window.EVOLV.nodes.measurement.assetMenu.saveEditor(this);
|
||||
}
|
||||
|
||||
// Validate logger properties using the logger menu
|
||||
if (window.EVOLV?.nodes?.measurement?.loggerMenu?.saveEditor) {
|
||||
success = window.EVOLV.nodes.measurement.loggerMenu.saveEditor(node);
|
||||
}
|
||||
|
||||
// Save basic properties
|
||||
["name", "smooth_method"].forEach(
|
||||
["smooth_method"].forEach(
|
||||
(field) => (node[field] = document.getElementById(`node-input-${field}`).value || "")
|
||||
);
|
||||
|
||||
@@ -106,17 +116,11 @@
|
||||
(field) => (node[field] = parseFloat(document.getElementById(`node-input-${field}`).value) || 0)
|
||||
);
|
||||
|
||||
node.logLevel = document.getElementById("node-input-logLevel").value || "info";
|
||||
node.enableLog = document.getElementById("node-input-enableLog").checked;
|
||||
|
||||
// Validation checks
|
||||
if (node.scaling && (isNaN(node.i_min) || isNaN(node.i_max))) {
|
||||
RED.notify("Scaling enabled, but input range is incomplete!", "error");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -124,48 +128,30 @@
|
||||
<!-- Main UI -->
|
||||
|
||||
<script type="text/html" data-template-name="measurement">
|
||||
|
||||
<!-- Node Name -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="node-input-name"
|
||||
placeholder="Measurement Name"
|
||||
style="width:70%;"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Scaling Checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-scaling"
|
||||
><i class="fa fa-compress"></i> Scaling</label
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-scaling"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
><i class="fa fa-compress"></i> Scaling</label>
|
||||
<input type="checkbox" id="node-input-scaling" style="width:20px; vertical-align:baseline;"/>
|
||||
<span>Enable input scaling?</span>
|
||||
</div>
|
||||
|
||||
<!-- Source Min/Max (only if scaling is true) -->
|
||||
<div class="form-row" id="row-input-i_min">
|
||||
<label for="node-input-i_min"
|
||||
><i class="fa fa-arrow-down"></i> Source Min</label>
|
||||
<label for="node-input-i_min"><i class="fa fa-arrow-down"></i> Source Min</label>
|
||||
<input type="number" id="node-input-i_min" placeholder="0" />
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="row-input-i_max">
|
||||
<label for="node-input-i_max"
|
||||
><i class="fa fa-arrow-up"></i> Source Max</label>
|
||||
<label for="node-input-i_max"><i class="fa fa-arrow-up"></i> Source Max</label>
|
||||
<input type="number" id="node-input-i_max" placeholder="3000" />
|
||||
</div>
|
||||
|
||||
<!-- Offset -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-i_offset"
|
||||
><i class="fa fa-adjust"></i> Input Offset</label>
|
||||
<label for="node-input-i_offset"><i class="fa fa-adjust"></i> Input Offset</label>
|
||||
<input type="number" id="node-input-i_offset" placeholder="0" />
|
||||
</div>
|
||||
|
||||
@@ -181,20 +167,14 @@
|
||||
|
||||
<!-- Simulator Checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-simulator"
|
||||
><i class="fa fa-cog"></i> Simulator</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-simulator"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
<label for="node-input-simulator"><i class="fa fa-cog"></i> Simulator</label>
|
||||
<input type="checkbox" id="node-input-simulator" style="width:20px; vertical-align:baseline;"/>
|
||||
<span>Activate internal simulation?</span>
|
||||
</div>
|
||||
|
||||
<!-- Smoothing Method -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-smooth_method"
|
||||
><i class="fa fa-line-chart"></i> Smoothing</label>
|
||||
<label for="node-input-smooth_method"><i class="fa fa-line-chart"></i> Smoothing</label>
|
||||
<select id="node-input-smooth_method" style="width:60%;">
|
||||
</select>
|
||||
</div>
|
||||
@@ -202,61 +182,19 @@
|
||||
<!-- Smoothing Window -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-count">Window</label>
|
||||
<input
|
||||
type="number"
|
||||
id="node-input-count"
|
||||
placeholder="10"
|
||||
style="width:60px;"
|
||||
/>
|
||||
<input type="number" id="node-input-count" placeholder="10" style="width:60px;"/>
|
||||
<div class="form-tips">Number of samples for smoothing</div>
|
||||
</div>
|
||||
|
||||
<!-- Optional Extended Fields: supplier, cat, type, model, unit -->
|
||||
<hr />
|
||||
<div class="form-row">
|
||||
<label for="node-input-supplier"><i class="fa fa-industry"></i> Supplier</label>
|
||||
<select id="node-input-supplier" style="width:70%;"></select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-category"><i class="fa fa-sitemap"></i> Category</label>
|
||||
<select id="node-input-category" style="width:70%;"></select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-assetType"><i class="fa fa-puzzle-piece"></i> Type</label>
|
||||
<select id="node-input-assetType" style="width:70%;"></select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-model"><i class="fa fa-wrench"></i> Model</label>
|
||||
<select id="node-input-model" style="width:70%;"></select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-unit"><i class="fa fa-balance-scale"></i> Unit</label>
|
||||
<select id="node-input-unit" style="width:70%;"></select>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<!-- Asset fields will be injected here -->
|
||||
<div id="asset-fields-placeholder"></div>
|
||||
|
||||
<!-- loglevel checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-enableLog"
|
||||
><i class="fa fa-cog"></i> Enable Log</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-enableLog"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
<span>Enable logging</span>
|
||||
</div>
|
||||
<div id="logger-fields-placeholder"></div>
|
||||
|
||||
<div class="form-row" id="row-logLevel">
|
||||
<label for="node-input-logLevel"><i class="fa fa-cog"></i> Log Level</label>
|
||||
<select id="node-input-logLevel" style="width:60%;">
|
||||
<option value="info">Info</option>
|
||||
<option value="debug">Debug</option>
|
||||
<option value="warn">Warn</option>
|
||||
<option value="error">Error</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Position fields will be injected here -->
|
||||
<div id="position-fields-placeholder"></div>
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user