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.

235 lines (186 loc) 8.88 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('7AI+2PR-S',{ category: 'emod', color: '#db777c', defaults: { name: {value:""}, modNumEnabled: {value: false}, modNum: {value: "1", validate:RED.validators.regex(/^$|^[0-9]+$/)}, modConfig: {value:"", type:"7AI+2PR-S-Config"} }, inputs:1, outputs:2, icon: "7AI+2PR.png", label: function() { if (this.name) return this.name; if (this.modNumEnabled && this.modNum && this.modNum != "1") return "7AI+2PR-S "+this.modNum; return "7AI+2PR-S"; }, outputLabels: ["Analog inputs","Relays"] }); function AI7PR2ModNumEnabledChanged() { if (document.getElementById("node-input-modNumEnabled").checked) { $("#modNum-row").show(); } else { $("#modNum-row").hide(); } } </script> <script type="text/html" data-template-name="7AI+2PR-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="AI7PR2ModNumEnabledChanged()"> </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="7AI+2PR-S"> <p>Connects to a 7AI+2PR eMOD module to manage the 7 analog inputs and 2 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>Set the input mode (current or voltage) for each analog input and also the working mode</li> <li>Get the input value for one or all inputs</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>Working modes:</b></h2> <p> <p>7AI 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] Time interval: module keeps notifying values of all inputs in a fixed time interval</li> <li>[Event] Value threshold: module notifies when the measured value in any input surpases the threshold from last notification</li> <li>[Event] Value within range: module notifies when the measured value in any input enters within a value range</li> <li>[Event] Value out of range: module notifies when the measured value in any input falls out of a value range</li> </ul> <p>2PR only can operate in <b>Poll mode</b>.</p> <p>This module has 2 output: one for the relays and the other for the analog inputs.</p> </p> <h2><b>Available functions for analog inputs </b>:</h2> <ul> <li><b>ai_get_one</b> (only in Poll mode): obtains the value of a single analog input.</li> <p></p> Examples: <p> <p>To obtain the value of a single analog input:</p> <code>{"ai_get_one": 3}</code> <p></p> <p>In this case, fourth analog input is configured as voltage and its value is 3.1 V:</p> <code>{"voltage": {"index": 3, "value": 3.1}}</code> </p> <li><b>ai_get_all</b> (only in Poll mode): obtains the value of all analog inputs.</li> <p></p> Examples: <p> <p>To obtain the value of all analog inputs:</p> <code>{"ai_get_all": "status"}</code> <p></p> <p>In this case, the first three inputs are configured as voltage and the rest as current. Each one has a different value:</p> <code>{"values": [{"voltage": {"index": 0, "value": 5.2}}, {"voltage": {"index": 1, "value": 3.2}} , {"voltage": {"index": 2, "value": 4.8}}, {"current": {"index": 3, "value": 0.3}}, {"current": {"index": 4, "value": 0.2}}, {"current": {"index": 5, "value": 0.4}}, {"current": {"index": 6, "value": 0.3}} ]}</code> </p> </ul> <h2><b>Available functions for relays</b>:</h2> <ul> <li><b>relay_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>{"relay_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>relay_get_all</b>: obtains the status of all relays.</li> <p></p> Examples: <p> <p>To obtain the status of all relays:</p> <code>{"relay_get_all": "status"}</code> <p></p> <p>In this case, only the first relay is activated:</p> <code>{"all_status": [true, false] }</code> </p> <li><b>relay_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>{"relay_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>{"relay_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>relay_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 deactivate the second:</p> <code>{relay_set: [true, false]}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[true,false]}</code> </p> <li><b>relay_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>{"relay_set_all": true}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[true,true]}</code> <p></p> <p>To deactivate all relays:</p> <code>{"relay_set_all": false}</code> <p></p> <p>Output tells us all relay status:</p> <code>{"all_status":[false,false]}</code> </p> </ul> </p> </script>