@gapit/node-red-contrib-gapit-modbus
Version:
A Node-RED node witch reads Modbus registers based on gapit code JSON schema
102 lines (99 loc) • 3.39 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("gapit-modbus", {
category: "Gapit Nordics",
color: "#a6bbcf",
defaults: {
name: { value: "" },
host: { value: "" },
port: { value: "" },
deviceName: { value: "" },
deviceNameDbTag: { value: "" },
unitId: { value: "" },
gapitCode: { value: "" },
customTags: { value: "" },
},
inputs: 1,
outputs: 1,
icon: "file.png",
label: function () {
return this.name || "gapit-modbus";
},
oneditprepare: function () {
$("#node-input-gapitCode").typedInput({ type: "json", types: ["json"] });
$("#node-input-customTags").typedInput({
type: "json",
types: ["json"],
});
},
});
</script>
<script type="text/html" data-template-name="gapit-modbus">
<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="Name" />
</div>
<div class="form-row">
<label for="node-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-input-host" placeholder="127.0.0.1" />
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-globe"></i> Port</label>
<input type="text" id="node-input-port" placeholder="502" />
</div>
<div class="form-row">
<label for="node-input-deviceName"
><i class="fa fa-file-code-o"></i> Device name</label
>
<input type="text" id="node-input-deviceName" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-deviceNameDbTag"
><i class="fa fa-file-code-o"></i> Device name db-tag</label
>
<input type="text" id="node-input-deviceNameDbTag" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-unitId"
><i class="fa fa-ellipsis-h"></i> Unit id</label
>
<input type="text" id="node-input-unitId" placeholder="1" />
</div>
<div class="form-row">
<label for="node-input-gapitCode"
><i class="fa fa-file-code-o"></i> Gapit code</label
>
<input type="text" id="node-input-gapitCode" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-customTags"
><i class="fa fa-ellipsis-h"></i> Custom tags</label
>
<input type="text" id="node-input-customTags" placeholder="" />
</div>
</script>
<script type="text/html" data-help-name="gapit-modbus">
<p>
Triggered by any input. Reads modbus registers specified in the gapit code.
</p>
<p>all config can be specified in msg object.</p>
<p>Host => <code>msg.host</code></p>
<p>Port=> <code>msg.port</code></p>
<p>Device name => <code>msg.device_name</code></p>
<p>Device name db-tag => <code>msg.device_name_db_tag</code></p>
<p>Unit id => <code>msg.unit_id</code></p>
<p>Gapit code => <code>msg.gapit_code</code></p>
<p>Custom tags => <code>msg.custom_tags</code></p>
<p>
Outputs the result in <code>msg.gapit_results</code> and the buffer read
from modbus in
<code>msg.modbus_buffer</code>
</p>
<p>
Register types are specified in gapit code. Currently only supporting
holding registers. Diffrent regiser types will be added in later versjons.
</p>
<p>
Scaling function is set in the gapit code. If no scaling function is
specified General scaling will be used.
</p>
</script>