2015-01-23 14:34:10 +01:00
|
|
|
|
|
|
|
<script type="text/x-red" data-template-name="rbe">
|
|
|
|
<div class="form-row">
|
2015-07-14 22:03:07 +02:00
|
|
|
<label for="node-input-func"><i class="fa fa-wrench"></i> <span data-i18n="rbe.label.func"></span></label>
|
2015-01-23 14:34:10 +01:00
|
|
|
<select type="text" id="node-input-func" style="width:74%;">
|
2015-07-14 22:03:07 +02:00
|
|
|
<option value="rbe" data-i18n="rbe.opts.rbe"></option>
|
2017-04-14 22:38:42 +02:00
|
|
|
<option value="deadbandEq" data-i18n="rbe.opts.deadbandEq"></option>
|
2015-07-14 23:01:08 +02:00
|
|
|
<option value="deadband" data-i18n="rbe.opts.deadband"></option>
|
2017-04-14 22:38:42 +02:00
|
|
|
<option value="narrowbandEq" data-i18n="rbe.opts.narrowbandEq"></option>
|
2016-02-02 14:39:37 +01:00
|
|
|
<option value="narrowband" data-i18n="rbe.opts.narrowband"></option>
|
2015-01-23 14:34:10 +01:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row" id="node-bandgap">
|
2015-07-14 23:01:08 +02:00
|
|
|
<label for="node-input-gap"> </label>
|
2017-04-14 22:38:42 +02:00
|
|
|
<input type="text" id="node-input-gap" data-i18n="[placeholder]rbe.placeholder.bandgap" style="width:95px;">
|
|
|
|
<select type="text" id="node-input-inout" style="width:54%;">
|
2016-03-21 01:01:50 +01:00
|
|
|
<option value="out" data-i18n="rbe.opts.out"></option>
|
|
|
|
<option value="in" data-i18n="rbe.opts.in"></option>
|
|
|
|
</select>
|
2015-01-23 14:34:10 +01:00
|
|
|
</div>
|
2016-02-02 14:39:37 +01:00
|
|
|
<div class="form-row" id="node-startvalue">
|
|
|
|
<label for="node-input-start"><i class="fa fa-thumb-tack"/> <span data-i18n="rbe.label.start"></span></label>
|
|
|
|
<input type="text" id="node-input-start" data-i18n="[placeholder]rbe.placeholder.start" style="width:71%;">
|
|
|
|
</div>
|
2015-01-23 14:34:10 +01:00
|
|
|
<div class="form-row">
|
2015-07-14 22:03:07 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"/> <span data-i18n="rbe.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]rbe.label.name" style="width:71%;">
|
2015-01-23 14:34:10 +01:00
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/x-red" data-help-name="rbe">
|
2017-04-14 22:38:42 +02:00
|
|
|
<p>Report by Exception node - only passes on data if the payload has changed.</p>
|
|
|
|
<p>It can also block until the value changes by a specified amount - deadband modes.</p>
|
|
|
|
<h3>Inputs</h3>
|
|
|
|
<dl class="message-properties">
|
|
|
|
<dt>payload
|
|
|
|
<span class="property-type">number | string | (object)</span>
|
|
|
|
</dt>
|
|
|
|
<dd>RBE mode will accept numbers, strings, and simple objects. Other modes must provide a parseable number.</dd>
|
|
|
|
<dt class="optional">topic <span class="property-type">string</span>
|
|
|
|
</dt>
|
|
|
|
<dd>if specified the function will work on a per topic basis.</dd>
|
|
|
|
</dl>
|
|
|
|
<h3>Outputs</h3>
|
|
|
|
<dl class="message-properties">
|
|
|
|
<dt>payload
|
|
|
|
<span class="property-type">as per input</span>
|
|
|
|
</dt>
|
|
|
|
<dd>If triggered the output will be the same as the input.</dd>
|
|
|
|
</dl>
|
|
|
|
<h3>Details</h3>
|
|
|
|
<p>In RBE mode this node will block until the <code>msg.payload</code> is
|
|
|
|
different to the previous one. </p>
|
|
|
|
<p>In Deadband modes the incoming payload must contain a parseable number and is
|
|
|
|
output only if greater than + or - the band gap away from a previous value.</p>
|
2015-07-14 22:03:07 +02:00
|
|
|
<p>Deadband also supports % - only sends if the input differs by more than x% of the original value.</p>
|
2017-04-14 22:38:42 +02:00
|
|
|
<p>In Narrowband mode the incoming payload is blocked if it is more than + or - the band gap
|
2016-02-02 14:39:37 +01:00
|
|
|
away from the previous value. Useful for ignoring outliers from a faulty sensor for example.</p>
|
2017-04-14 22:38:42 +02:00
|
|
|
<p>Both Deadband and Narrowband allow comparison against either the previous valid output value, thus
|
|
|
|
ignoring any values out of range; or the previous input value, which resets the set point, thus allowing
|
2016-03-21 01:01:50 +01:00
|
|
|
gradual drift (deadband), or a step change (narrowband).</p>
|
2016-02-12 14:14:12 +01:00
|
|
|
<p><b>Note:</b> This works on a per <code>msg.topic</code> basis. This means that a single rbe node can
|
2017-04-14 22:38:42 +02:00
|
|
|
handle multiple different topics at the same time.</p>
|
2015-01-23 14:34:10 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2015-07-14 22:03:07 +02:00
|
|
|
RED.nodes.registerType("rbe", {
|
2015-01-23 14:34:10 +01:00
|
|
|
color:"#E2D96E",
|
|
|
|
category: 'function',
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
|
|
|
func: {value:"rbe"},
|
2016-02-02 14:39:37 +01:00
|
|
|
gap: {value:"",validate:RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)},
|
2016-03-21 01:01:50 +01:00
|
|
|
start: {value:""},
|
|
|
|
inout: {value:"out"}
|
2015-01-23 14:34:10 +01:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2015-07-14 23:10:18 +02:00
|
|
|
icon: "rbe.png",
|
2015-01-23 14:34:10 +01:00
|
|
|
label: function() {
|
2017-04-14 22:38:42 +02:00
|
|
|
var ll = (this.func||"").replace("Eq","")||"rbe";
|
|
|
|
return this.name||ll||"rbe";
|
2015-01-23 14:34:10 +01:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
//$( "#node-input-gap" ).spinner({min:0});
|
2016-03-21 01:01:50 +01:00
|
|
|
if ($("#node-input-inout").val() === null) {
|
|
|
|
$("#node-input-inout").val("out");
|
|
|
|
}
|
2015-01-23 14:34:10 +01:00
|
|
|
$("#node-input-func").on("change",function() {
|
|
|
|
if ($("#node-input-func").val() === "rbe") {
|
|
|
|
$("#node-bandgap").hide();
|
|
|
|
} else {
|
|
|
|
$("#node-bandgap").show();
|
|
|
|
}
|
2016-02-02 14:39:37 +01:00
|
|
|
if ($("#node-input-func").val() === "narrowband") {
|
|
|
|
$("#node-startvalue").show();
|
|
|
|
} else {
|
|
|
|
$("#node-startvalue").hide();
|
|
|
|
}
|
2015-01-23 14:34:10 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|