@pickdata/node-red-contrib-emod-simulator
Version:
eManager is an IoT controller designed with eMOD tech for monitoring, control and automation applications. The following nodes are pre-installed in all eMOD devices, although here we present a simulator to practice & test our modular industrial solution.
193 lines (187 loc) • 9.4 kB
HTML
<!--
Copyright (c) 2020,2021 PickData SL (https://www.pickdata.net/)
All rights reserved.
node-red-contrib-emod-simulator - The BSD 3-Clause License
-->
<script type="text/javascript">
RED.nodes.registerType('7AI+2PR-S-Config',{
category: 'config',
defaults: {
name: {value:""},
sampleRatePeriodMs: {value:500, required: false, validate:function(v) {return /^$|^[0-9]+$/.test(v) && parseInt(v) >= 100}},
pulseWidthMsR1: {value:0, required: false, validate:RED.validators.regex(/^$|^[0-9]+$/)},
pulseWidthMsR2: {value:0, required: false, validate:RED.validators.regex(/^$|^[0-9]+$/)},
modeI1: {value:"voltage"},
modeI2: {value:"voltage"},
modeI3: {value:"voltage"},
modeI4: {value:"voltage"},
modeI5: {value:"voltage"},
modeI6: {value:"voltage"},
modeI7: {value:"voltage"},
eventMode: {value:"poll"},
intervalMs: {value:1000, required: false, validate:function(v) {return /^$|^[0-9]+$/.test(v) && parseInt(v) >= 100}},
threshold: {value:1, required: false, validate:function(v) {return /^$|^[0-9]+$/.test(v) && parseInt(v) >= 1}},
lowLimit: {value:0, required: false, validate:RED.validators.regex(/^$|^[0-9]+$/)},
highLimit: {value:10, required: false, validate:function(v) {return /^$|^[0-9]+$/.test(v) && parseInt(v) >= 1}}
},
label: function() {
return this.name||"7AI+2PR-S-Config";
},
oneditprepare: function () {
let tabs = RED.tabs.create({
id: "node-config-input-ai7r2-tabs",
onchange: function (tab) {
$("#node-config-input-ai7r2-tabs-content").children().hide()
$("#" + tab.id).show()
}
})
tabs.addTab({
id: "ai7r2-AI-tab",
label: "Analog inputs"
})
tabs.addTab({
id: "ai7r2-R-tab",
label: "Relays"
})
}
});
function AI7R2SeventModeChanged() {
switch ($("#node-config-input-eventMode").val()) {
case "poll":
$("#intervalMs-row").hide();
$("#threshold-row").hide();
$("#lowLimit-row").hide();
$("#highLimit-row").hide();
break;
case "interval":
$("#intervalMs-row").show();
$("#threshold-row").hide();
$("#lowLimit-row").hide();
$("#highLimit-row").hide();
break;
case "threshold":
$("#intervalMs-row").hide();
$("#threshold-row").show();
$("#lowLimit-row").hide();
$("#highLimit-row").hide();
break;
case "within-range":
$("#intervalMs-row").hide();
$("#threshold-row").hide();
$("#lowLimit-row").show();
$("#highLimit-row").show();
break;
case "out-of-range":
$("#intervalMs-row").hide();
$("#threshold-row").hide();
$("#lowLimit-row").show();
$("#highLimit-row").show();
break;
}
}
</script>
<script type="text/html" data-template-name="7AI+2PR-S-Config">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<ul style="background: #fff; min-width: 600px; margin-bottom: 20px;" id="node-config-input-ai7r2-tabs"></ul>
</div>
<div id="node-config-input-ai7r2-tabs-content" style="min-height: 170px;">
<div id="ai7r2-AI-tab" style="display:none">
<div class="form-row">
<label for="node-config-input-sampleRatePeriodMs"><i class="fa fa-ellipsis-h"></i> Sample rate milliseconds</label>
<input type="number" id="node-config-input-sampleRatePeriodMs" placeholder="500" min="100" step="100">
</div>
<div class="form-row">
<label for="node-config-input-eventMode"><i class="fa fa-bars"></i> Working mode</label>
<select id="node-config-input-eventMode" onchange="AI7R2SeventModeChanged()">
<option value="poll">Poll</option>
<option value="interval">[Event] Time interval</option>
<option value="threshold">[Event] Value threshold</option>
<option value="within-range">[Event] Value within range</option>
<option value="out-of-range">[Event] Value out of range</option>
</select>
</div>
<div class="form-row" id="intervalMs-row" style="display: none;">
<label for="node-config-input-intervalMs"><i class="fa fa-arrows-h"></i> Interval period milliseconds</label>
<input type="number" id="node-config-input-intervalMs" placeholder="1000" min="100" step="100">
</div>
<div class="form-row" id="threshold-row" style="display: none;">
<label for="node-config-input-threshold"><i class="fa fa-minus"></i> Value change threshold</label>
<input type="number" id="node-config-input-threshold" placeholder="1" min="1">
</div>
<div class="form-row" id="lowLimit-row" style="display: none;">
<label for="node-config-input-lowLimit"><i class="fa fa-arrow-down"></i> Low limit value range</label>
<input type="number" id="node-config-input-lowLimit" placeholder="0" min="0">
</div>
<div class="form-row" id="highLimit-row" style="display: none;">
<label for="node-config-input-highLimit"><i class="fa fa-arrow-up"></i> High limit value range</label>
<input type="number" id="node-config-input-highLimit" placeholder="10" min="1">
</div>
<hr>
<h5>Input mode</h5>
<div class="form-row">
<label for="node-config-input-modeI1"><i class="fa fa-file-code-o"></i> Input 0</label>
<select id="node-config-input-modeI1">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI2"><i class="fa fa-file-code-o"></i> Input 1</label>
<select id="node-config-input-modeI2">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI3"><i class="fa fa-file-code-o"></i> Input 2</label>
<select id="node-config-input-modeI3">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI4"><i class="fa fa-file-code-o"></i> Input 3</label>
<select id="node-config-input-modeI4">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI5"><i class="fa fa-file-code-o"></i> Input 4</label>
<select id="node-config-input-modeI5">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI6"><i class="fa fa-file-code-o"></i> Input 5</label>
<select id="node-config-input-modeI6">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-modeI7"><i class="fa fa-file-code-o"></i> Input 6</label>
<select id="node-config-input-modeI7">
<option value="voltage">Voltage</option>
<option value="current">Current</option>
</select>
</div>
</div>
<div id="ai7r2-R-tab" style="display:none">
<h5>Pulse width milliseconds</h5>
<div class="form-row">
<label for="node-config-input-pulseWidthMsR1"><i class="fa fa-bolt"></i> Relay 0</label>
<input type="number" id="node-config-input-pulseWidthMsR1" placeholder="0" min="0">
</div>
<div class="form-row">
<label for="node-config-input-pulseWidthMsR2"><i class="fa fa-bolt"></i> Relay 1</label>
<input type="number" id="node-config-input-pulseWidthMsR2" placeholder="0" min="0">
</div>
</div>
</div>
</script>