UNPKG

@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.

156 lines (128 loc) 5.57 kB
<!-- 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('10DI-S',{ category: 'emod', color: '#db777c', defaults: { name: {value:""}, modNumEnabled: {value: false}, modNum: {value: "1", validate:RED.validators.regex(/^$|^[0-9]+$/)}, modConfig: {value:"", type:"10DI-S-Config"} }, inputs:1, outputs:1, icon: "10DI.png", label: function() { if (this.name) return this.name; if (this.modNumEnabled && this.modNum && this.modNum != "1") return "10DI-S "+this.modNum; return "10DI-S"; } }); function DI10SModNumEnabledChanged() { if (document.getElementById("node-input-modNumEnabled").checked) { $("#modNum-row").show(); } else { $("#modNum-row").hide(); } } </script> <script type="text/html" data-template-name="10DI-S"> <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-modConfig"><i class="fa fa-cog"></i> Config</label> <input type="number" id="node-input-modConfig" placeholder="0"> </div> <div class="form-row"> <label for="node-input-modNumEnabled"><i class="fa fa-check"></i> Enable module number</label> <input type="checkbox" id="node-input-modNumEnabled" style="max-width:30px" onchange="DI10SModNumEnabledChanged()"> </div> <div class="form-row" id="modNum-row" style="display: none;"> <label for="node-input-modNum"><i class="fa fa-microchip"></i> Module number</label> <input type="number" id="node-input-modNum" placeholder="1" min="1"> </div> </script> <script type="text/html" data-help-name="10DI-S"> <p>Connects to a 10DI eMOD module to manage the 10 digital inputs individually or jointly.</p> <p> <p>It allows to manage the following functionalities on the module:</p> <p></p> <ul> <li>Configure module parameters</li> <li>Poll input status for one or all inputs</li> <li>Poll pulse counter for one or all inputs</li> <li>Reset pulse counters</li> </ul> </p> <p></p> <p> <h2><b>Working modes:</b></h2> <p> <p>10DI eMOD module can operate in two different ways: <b>Poll mode</b> and <b>Event mode</b>.</p> <p></p> <p>In <b>Poll mode</b>, user starts the flow and asks for data when he needs it.</p> <p>In <b>Event mode</b> user configures certain condition when he wants to be notified and it is the module that notifies him when it has been met.</p> <p>Module can operate in the following working modes:</p> <p></p> <ul> <li>Poll</li> <li>[Event] Input value change: module notifies when a digital input changes</li> <li>[Event] Pulse count change: module notifies when the pulse counter surpases the threshold from last notification</li> </ul> </p> <h2><b>Available functions</b>:</h2> <ul> <li><b>get_one</b> (only in Poll mode): obtains the status or pulse count of a single digital input.</li> <p></p> Examples: <p> <p>To obtain the status of a single digital input:</p> <code>{"get_one": {"index": 3, "mode": "status"}}</code> <p></p> <p>In this case, fourth digital input is in high state:</p> <code>{"status": {"index": 3, "value": true}}</code> <p></p> <p>To obtain the pulse count of a digital input:</p> <code>{"get_one": {"index": 3, "mode": "pulse_count"}}</code> <p></p> <p>In this case, pulse count of fourth digital input is 15:</p> <code>{"counter": {"index": 3, "value": 15}} </code> </p> <li><b>get_all</b> (only in Poll mode): obtains the status or pulse count of all digital inputs.</li> <p></p> Examples: <p> <p>To obtain the status of all digital input:</p> <code>{"get_all": "status"}</code> <p></p> <p>In this case, only fourth digital input is high state:</p> <code>{"all_status": [false, false, false, true, false, false, false, false, false, false] }</code> <p></p> <p>To obtain the pulse count of all digital input:</p> <code>{"get_all": "pulse_count"}</code> <p></p> <p>Function returns following pulse counts:</p> <code>{"all_counters": [0, 5, 10, 2, 23, 5, 71, 3, 0, 0] }</code> </p> <li><b>reset_pulse_count</b>: resets one or all inputs.</li> <p></p> Examples: <p> <p>Resets the ninth input:</p> <code>{"reset_pulse_count": 8}</code> </p> <p> <p>Resets all input:</p> <code>{"reset_pulse_count": "all"}</code> </p> </ul> </p> </script>