smithtek-node-red-meter
Version:
Adds record function to node-red
207 lines (175 loc) • 6.85 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("Smithtek-Metering", {
category: "Smithtek Metering",
color: "#B9B6B8",
defaults: {
name: {
value: "",
},
recordType: {
value: "time",
},
saveto: {
validate: function (val) {
return val !== "";
},
},
savetoType: {
value: "global",
},
start: {
value: 1,
},
startType: {
value: "num",
},
stop: {
value: 0,
},
stopType: {
value: "num",
},
multiplier: {
value: 1,
},
},
inputs: 1,
outputs: 1,
icon: "smithtek.png",
paletteLabel: "Meter Controller",
label: function () {
return this.name || "Smithtek-Metering";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
var flowType = {
value: "flow",
label: "flow",
hasValue: true,
};
var globalType = {
value: "global",
label: "global",
hasValue: true,
};
$("#node-input-recordType").change(function () {
if ($(this).val() === "time") {
$(".form-row-recordTypeTime").show();
$(".form-row-recordTypeUnit").hide();
} else {
$(".form-row-recordTypeTime").hide();
$(".form-row-recordTypeUnit").show();
}
});
$("#node-input-saveto").typedInput({
default: this.savetoType || "global",
typeField: $("#node-input-saveto"),
types: [flowType, globalType],
});
$("#node-input-start").typedInput({
default: this.startType || "num",
typeField: $("#node-input-start"),
types: ["str", "num", "bool"],
});
$("#node-input-stop").typedInput({
default: this.stopType || "num",
typeField: $("#node-input-stop"),
types: ["str", "num", "bool"],
});
},
oneditsave: function () {
this.startType = $("#node-input-start").typedInput("type");
this.stopType = $("#node-input-stop").typedInput("type");
this.savetoType = $("#node-input-saveto").typedInput("type");
},
});
</script>
<script type="text/x-red" data-template-name="Smithtek-Metering">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-saveto"><i class="icon-tag"></i> Data Store:</label>
<input type="text" id="node-input-saveto" placeholder="variable name">
</div>
<div class="form-row">
<label style="width: 360px !important;"><h5><strong>Select Meter Type</strong></h5></label>
</div>
<div class="form-row">
<label for="node-input-recordType">Meter Type</label>
<select id="node-input-recordType">
<option value="time">Run Hours</option>
<option value="unit">Totalizer</option>
</select>
</div>
<div class="form-row form-row-recordTypeTime">
<label style="width: 360px !important;"><h5><strong> Configure the command that will trigger the node to start recording hours/totalizer</strong></h5></label>
</div>
<div class="form-row form-row-recordTypeTime">
<label for="node-input-start"><i class="icon-tag"></i> Signal Start</label>
<input type="text" id="node-input-start" placeholder="start">
</div>
<div class="form-row form-row-recordTypeTime">
<label for="node-input-stop"><i class="icon-tag"></i> Signal Stop</label>
<input type="text" id="node-input-stop" placeholder="stop">
</div>
<div class="form-row form-row-recordTypeUnit">
<label style="width: 360px !important;"><h5><strong> Configure the multiplier </strong></h5></label>
</div>
<div class="form-row">
<label style="width: 360px !important;"><h5><strong>Example : When using the totalizer,If the water flow meter outputs 1 pulse for 10 litres, enter the value 10. Every pulse received</strong></h5></label>
</div>
<div class="form-row form-row-recordTypeUnit">
<label for="node-input-multiplier"><i class="icon-tag"></i> Multiplier:</label>
<input type="text" id="node-input-multiplier" placeholder="1">
</div>
</script>
<script type="text/x-red" data-help-name="Smithtek-Metering">
<p>This is a multi function node for
A: Recording run hours. this could be a machine, device, pump,motor,
B: Totalizer that can convert pulses into totals.This could be a water flow meter, energy meter.</p>
<p><strong>Run Hour</strong><br/></p>
<h3>Data Store</h3>
<dl class="message-properties">
<p>Choose a name for your data store. The data store will save your run hour or totalized values to either Global,Flow context stores
These can also be called using other nodes within the work flow</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Bool, Number, String</span>
</dt>
<p>Signal Start. Choose a data type and value. Your trigger must match these properties</p>
<p>Signal Stop. Choose a data type and value. Your trigger must match these properties</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Number</span>
</dt>
<p>The output will show the current run hour value in seconds. This will also be saved to the Data Store</p>
<p><strong>Totalizer</strong><br/></p>
<h3>Data Store</h3>
<dl class="message-properties">
<p>Choose a name for your data store. The data store will save your run hour or totalized values to either Global,Flow context stores
These can also be called using other nodes within the work flow</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Number</span>
</dt>
<p>The node will take any number value and multiply it by the setpoint multiplier</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Number</span>
</dt>
<p>The output will show the current totalized value. This will also be saved to the Data Store</p>
<dl class="message-properties">
<dt>Contact
</dt>
<h3>info@smithtek.com.au</h3>
<a href="https://www.smithtek.com.au/" target="_blank">Visit Smithtek</a>
</script>
</script>