UNPKG

node-red-contrib-mobius-flow-dali

Version:

Node-RED nodes to work with MOBiUSFlow and DALI devices

205 lines (194 loc) 8.92 kB
<!-- Copyright (C) 2020, IAConnects Technology Limited All Rights Reserved ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS, IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW. DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED FROM IACONNECTS TECHNOLOGY LIMITED. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <script type="text/html" data-template-name="dali addressing"> <div class="form-row node-input-groups-container-row"> <label for="node-input-groups-container"><i class="fa fa-bars"></i> Connections</label> <ol id="node-input-groups-container"></ol> </div> <hr> <div class="form-row"> <label for="node-input-addrTimeoutTime"><i class="fa fa-clock-o"></i> Addressing Timeout</label> <input type="text" id="node-input-addrTimeoutTime" placeholder="Timeout in ms"> </div> <div class="form-row"> <label for="node-input-scanTimeoutTime"><i class="fa fa-clock-o"></i> Scanning Timeout</label> <input type="text" id="node-input-scanTimeoutTime" placeholder="Timeout in ms"> </div> <hr> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name"> </div> </script> <script type="text/javascript"> RED.nodes.registerType('dali addressing', { category: 'dali', color: '#ffd11a', defaults: { name: {value: ''}, addrTimeoutTime: {value: 45000, required:true, validate:RED.validators.number()}, scanTimeoutTime: {value: 30000, required:true, validate:RED.validators.number()}, groups: {value:[{con: null, exp: '0'}]} }, inputs: 1, outputs: 1, outputLabels: ['Addressing Response'], icon: 'dali-icon.png', align: 'left', paletteLabel: 'dali addressing', label: function() { return this.name||`DALI Addressing`; }, labelStyle: function() { return this.name ? 'node_label_italic':''; }, oneditprepare: function() { var node = this; $('#node-input-groups-container').css('min-height', '300px').css('min-width', '450px').editableList ({ addButton: "add", removable: true, sortable: true, addItem: function (container, i, group) { container.css({ overflow: 'hidden', whiteSpace: 'nowrap' }); // Add a default group if it does not exist if (!group.hasOwnProperty("exp")) { group = {con: null, exp: '0'}; } var row = $('<div>Circuit:</div>').appendTo(container); var conField = $('<select/>',{ class: "node-input-group-con", style: "width:328px; margin-left: 10px; text-align: center;" }).appendTo(row); RED.nodes.eachConfig((n) => { if (n.type === 'dali-connection') { console.log(n.name); conField.append($("<option></option>").val(n.id).text(n.name)); } }); var row2 = $('<div>Expected Number of Devices:</div>').appendTo(container); var expField = $('<input/>',{ class: "node-input-group-exp", type: "text", style: "width: 174px; margin-left: 22px; margin-top: 5px; margin-bottom: 5px; text-align: left;", pattern: "^([0-9]|([1-5][0-9])|([6][0-3]))$" }).appendTo(row2); // Populate the new stat conField.val(group.con); expField.val(group.exp); } }); // If no stat exists, create a default one if (!node.groups) { node.groups = [group = {con: null, exp: '0'}]; } // Populate list with all saved filters for (let i = 0; i < node.groups.length; i++) { console.log(node.groups[i]); let group = node.groups[i]; $("#node-input-groups-container").editableList('addItem', group); } }, oneditresize(size) { var rows = $("#dialog-form>div:not(.node-input-groups-container-row)"); var height = size.height; for (var i = 0; i<rows.size(); i++) { height -= $(rows[i]).outerHeight(true); } var editorRow = $("#dialog-form>div.node-input-groups-container-row"); height -= 4 * ((parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")))); $("#node-input-groups-container").editableList('height',height); }, oneditsave: function() { let groups = $("#node-input-groups-container").editableList('items'); let node = this; node.groups = []; groups.each(function (i) { var group = $(this); let con = group.find(".node-input-group-con").val(); let exp = group.find(".node-input-group-exp").val(); node.groups.push({con: con, exp: exp}); }); } }); </script> <script type="text/html" data-help-name="dali addressing"> <p>MOBiUS DALI Addressing Node. (Node is typically used with addressing dashboard)</p> <h3>Configuration Page</h3> <dl class="message-properties"> <dt>Configure Connections <span class="property-type">connection</span></dt> <dd>Allows for configuration of DALI cricuits.</dd> <dt>Connections <span class="property-type">list</span></dt> <dd>Allows for all DALI circuit connections to be added to node.</dd> <dt>Timeout <span class="property-type">list</span></dt> <dd>Set timeout to stop any process if process take longer than the set timeout.</dd> </dl> <h3>Input: </h3> <dl class="message-properties"> <dd>Any input message will trigger the node. Function depends on input topic.</dd> <hr> <h4>Topics (<code>msg.topic</code>)</h4> <dt>daliScan <span class="property-type">string</span></dt> <dd>To perform scan process</dd> <dt>daliAddress <span class="property-type">string</span></dt> <dd>To perform full addressing process</dd> <dt>daliAdd <span class="property-type">string</span></dt> <dd>To add any unaddressed devices on a circuit</dd> <dt>daliSwap <span class="property-type">string</span></dt> <dd>To swap short address of two device on a circuit</dd> <dt>daliDelete <span class="property-type">string</span></dt> <dd>To delete short address of a device on a circuit</dd> <hr> <h4>Payloads (<code>msg.payload</code>)</h4> <h5>All Payloads</h5> <dt>payload.daliCircuitID<span class="property-type">string</span></dt> <dd>Should contain the three character hex string representing the service ID of the DALI circuit (e.g. '023').</dd> <h5>For swap only</h5> <dt>payload.data<span class="property-type">array</span></dt> <dd>Shoud contain array of the two short addresses to be swapped (0 - 63 each element).</dd> <h5>For delete only</h5> <dt>daliDelete<span class="property-type">number</span></dt> <dd>Should contain short address to be deleted (0 - 63).</dd> </dl> <h3>Output</h3> <dl class="message-properties"> <dt>payload.numberOfDevices<span class="property-type">number</span></dt> <dd>The number of devices following a scan or addressing process.</dd> <dt>payload.expectedNumberOfDevices<span class="property-type">number</span></dt> <dd>The expected number of dali devices on the circuit.</dd> <dt>payload.devices<span class="property-type">object</span></dt> <dd>Array of devices following a scan or addressing process.</dd> </dl> <h3>Details</h3> <p>Peforms DALI circuit scanning, addressing, partial addressing, addresses swaps and address deletions. If a given function takes too long to complete (likely caused by a bad connection to the dali master), the function will time out. Following an addressing or scanning process, the node can perform device type querying (also subject to a completion timeout). </p> <p align="center" style="color:#000080">iaconnects © 2020</p> <br> <p align="center" style="color:#000080">ER 2020</p> </script>