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.

177 lines (143 loc) 6.05 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('8SR-S',{ category: 'emod', color: '#db777c', defaults: { name: {value:""}, modNumEnabled: {value: false}, modNum: {value: "1", validate:RED.validators.regex(/^$|^[0-9]+$/)}, modConfig: {value:"", type:"8SR-S-Config"} }, inputs:1, outputs:1, icon: "8SR.png", align: 'right', label: function() { if (this.name) return this.name; if (this.modNumEnabled && this.modNum && this.modNum != "1") return "8SR-S "+this.modNum; return "8SR-S"; } }); function SR8SModNumEnabledChanged() { if (document.getElementById("node-input-modNumEnabled").checked) { $("#modNum-row").show(); } else { $("#modNum-row").hide(); } } </script> <script type="text/html" data-template-name="8SR-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="SR8SModNumEnabledChanged()"> </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="8SR-S"> <p>Connects to a 8SR eMOD module to manage the 8 relays individually or jointly.</p> <p> <p>It allows to manage the following functionalities on the module:</p> <p></p> <ul> <li>Set the pulse width for each relay</li> <li>Activate or deactivate one, some or all relays</li> <li>Get the current relays status</li> </ul> </p> <p></p> <p> <h2><b>Available functions:</b></h2> <ul> <li><b>get_one</b>: obtains the status of a single relay.</li> <p></p> Examples: <p> <p>To obtain the status of the relay 0:</p> <code>{"get_one": 0}</code> <p></p> <p>In this case, the response tells us that relay 0 is deactivated:</p> <code>{"status": {"index":0, "value":false}}</code> </p> <li><b>get_all</b>: obtains the status of all relays.</li> <p></p> Examples: <p> <p>To obtain the status of all relays:</p> <code>{"get_all": "status"}</code> <p></p> <p>In this case, the first and fourth relays are activated:</p> <code>{"all_status": [true, false, false, true, false, false, false, false] }</code> </p> <li><b>set_one</b>: activates or deactivates a single relay. On completion of action, input message with result is sent to output port.</li> <p></p> Examples: <p> <p>Activates relay 0:</p> <code>{"set_one": {"index": 0, "value": true}}</code> <p></p> <p>Output tells us that relay 0 is activated:</p> <code>{"status": {"index":0, "value":true}}</code> </p> <p> <p>Deactivates relay 0:</p> <code>{"set_one": {"index": 0, "value": false}}</code> <p></p> <p>Output tells us that relay 0 is deactivated:</p> <code>{"status": {"index":0, "value":false}}</code> </p> <li><b>set</b>: activates or deactivates some relays. On completion of action, input message with result is sent to output port.</li> <p>Parameters:</p> <ul> <li>An 8-element array of one among the following:</li> <ul> <li>true: activates relay</li> <li>false: deactivates relay</li> <li>null: does not change the status of the relay</li> </ul> </ul> <p></p> Examples: <p> <p>Activate the first and fourth relays and deactivate the eighth:</p> <code>{"set": [true, null, null, true, null, null, null, false]}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[true,true,true,true,false,true,false,false]}</code> </p> <li><b>set_all</b>: activates or deactivates all relays. On completion of action, input message with result is sent to output port.</li> <p></p> Examples: <p> <p>To activate all relays:</p> <code>{"set_all": true}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[true,true,true,true,true,true,true,true]}</code> <p></p> <p>To deactivate all relays:</p> <code>{"set_all": false}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[false,false,false,false,false,false,false,false]}</code> </p> </ul> </p> </script>