UNPKG

node-red-contrib-mobius-flow-dali

Version:

Node-RED nodes to work with MOBiUSFlow and DALI devices

167 lines (159 loc) 7.28 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 emergency query process"> <div class="form-row"> <label for="node-input-daliConnection" style="width: 160px;"><i class="fa fa-globe"></i> DALI Connection</label> <select type="text" id="node-input-daliConnection" style="display: inline-block; width: 300px; vertical-align: middle;"></select> </div> <div id="nocons-message-row" class="form-row" style="color:#ff0000" align="center"> <p>Please use the DALI connection manager node <br/> to add a new DALI connection.</p> </div> <hr> <div class="form-row"> <label for="node-input-selectionMethod" style="width: 160px;"><i class="fa fa-hand-pointer-o"></i> Selection Method</label> <select type="text" id="node-input-selectionMethod" style="display: inline-block; width: 300px; vertical-align: middle;"> <option value='ins'>By Object Instance</option> <option value='addr'>By DALI Address</option> </select> </div> <div class="form-row"> <label id ="insLabel" for="node-input-addresses" style="width: 160px;"><i class="fa fa-list-ol"></i> Object Instances</label> <label id = "daliLabel" for="node-input-addresses" style="width: 160px;"><i class="fa fa-sitemap"></i> DALI Addresses</label> <input type="text" id="node-input-addresses" style="width: 300px;"> </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" style="width: 300px;"> </div> </script> <script type="text/javascript"> function getLabel(conNode) { return RED.nodes.node(conNode).name } RED.nodes.registerType('dali emergency query process', { category: 'dali', color: '#88cc00', defaults: { name: {value: ''}, daliConnection: {value: "", required: true}, selectionMethod: {value: 'ins', required: true}, addresses: {required:true, value: '0001-003F', validate: (v) => { let re; switch ($("#node-input-selectionMethod").val()) { case 'ins': re = /^(([0]{2}([0-3]([0-9]|[A-F])))([-]([0]{2}([0-3]([0-9]|[A-F])))|))((|[,](|[ ])((([0]{2}([0-3]([0-9]|[A-F])))([-]([0]{2}([0-3]([0-9]|[A-F])))|))))+)$/g; return re.test(v); break; case 'addr': re = /^(([0-9]|[1-5][0-9]|[6][0-3])([-]([0-9]|[1-5][0-9]|[6][0-3])|))((|[,](|[ ])((([0-9]|[1-5][0-9]|[6][0-3])([-]([0-9]|[1-5][0-9]|[6][0-3])|))))+)$/g; return re.test(v); break; } return true; }} }, inputs: 0, outputs: 1, outputLabels: ['Response'], icon: 'running-man.png', align: 'left', paletteLabel: 'dali emergency response inject', label: function() { let connectionLabel; if (this.daliConnection !== '') { connectionLabel = getLabel(this.daliConnection); } if (connectionLabel !== undefined) { return this.name||`DALI Emergency Response Inject - ${connectionLabel}`; } else { return this.name||`DALI Emergency Response Inject`; } }, labelStyle: function() { return this.name ? 'node_label_italic':''; }, oneditprepare: function () { let node = this; RED.nodes.eachConfig((n) => { if (n.type === 'dali-connection') { $("#node-input-daliConnection").append($("<option></option>").val(n.id).text(n.name)); $("#nocons-message-row").hide(); } }); $("#node-input-daliConnection").val(node.daliConnection); function updateSelectionLabel() { if($("#node-input-selectionMethod").val() === 'ins') { $("#insLabel").show(); $("#daliLabel").hide(); } else { $("#insLabel").hide(); $("#daliLabel").show(); } } updateSelectionLabel() $("#node-input-selectionMethod").change(function() { updateSelectionLabel(); }); } }); </script> <script type="text/html" data-help-name="dali emergency query process"> <p>MOBiUS DALI Query Response Processor.</p> <h3>Configuration Page</h3> <dl class="message-properties"> <dt>Selection Method <span class="property-type">choice</span></dt> <dd>The method to select DALI fittings.</dd> <dt>Addresses / Instances <span class="property-type">number</span></dt> <dd>The list of DALI short addresses (0-63) or Mobius object instances (0001-003F).</dd> </dl> <h3>Output</h3> <ol class="node-ports"> <dl class="message-properties"> <dt>payload.daliCircuitID <span class="property-type">number</span></dt> <dd>The circuit ID of the DALI circuit.</dd> <dt>payload.daliAddress <span class="property-type">number</span></dt> <dd>The DALI address of the responded device.</dd> <dt>payload.commandCode <span class="property-type">number</span></dt> <dd>The DALI command code.</dd> <dt>payload.commandName <span class="property-type">string</span></dt> <dd>The DALI command name.</dd> <dt>payload.responseData <span class="property-type">object</span></dt> <dd>The query response data. The format of the object depends on the query type.</dd> </dl> </ol> <h3>Details</h3> <h4>Overview</h4> <p>Injects a dali query response from any short address within the specified range into the flow.</p> <h4>Address Range</h4> <p>Short address range to be input in any valid format involving commas and dashes e.g. ( 0-63 ) or ( 0,1 ) or ( 0, 1, 10-20 ). Examples involving any address < 0 or > 63 are invalid. examples starting or ending in a comma or dash are invalid e.g. ( ,1 ) or ( 1, 2, ) or ( 1, 2, 3-5, 8- ). Any example containing letters, symbols or further punctuation are invalid. The same principle applies to instance selection e.g. (0001-0005, 0008) etc.</p> <p align="center" style="color:#000080">iaconnects © 2020</p> <br> <p align="center" style="color:#000080">ER 2020</p> </script>