UNPKG

node-red-contrib-mobius-flow-dali

Version:

Node-RED nodes to work with MOBiUSFlow and DALI devices

292 lines (279 loc) 12.2 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 command generator"> <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-command" style="width: 160px;"><i class="fa fa-terminal"></i> Command Type</label> <select type="text" id="node-input-command" style="display: inline-block; width: 300px; vertical-align: middle;"> <option value='' disabled selected>Select a command...</option> <option value='224'>Rest</option> <option value='225'>Inhibit</option> <option value='226'>Re-Light / Reset Inhibit</option> <option value='227'>Start Function Test</option> <option value='228'>Start Duration Test</option> <option value='229'>Stop Test</option> <option value='230'>Reset Function Test Done Flag</option> <option value='231'>Reset Duration Test Done Flag</option> <option value='232'>Reset Lamp Time</option> <option value='233'>Store DTR as Emergency Level</option> <option value='234'>Store Test Delay Time High Byte</option> <option value='235'>Store Test Delay Time Low Byte</option> <option value='236'>Store Function Test Interval</option> <option value='237'>Store Duration Test Interval</option> <option value='238'>Store Test Execution Timeout</option> <option value='239'>Store Prolong Time</option> <option value='240'>Start Identification</option> </select> </div> <div class="form-row"> <label for="node-input-addressingMode" style="width: 160px;"><i class="fa fa-address-book"></i> Addressing Mode</label> <select type="text" id="node-input-addressingMode" style="display: inline-block; width: 300px; vertical-align: middle;" placeholder="Select Command Type"> <option value='short'>Short</option> <option value='group'>Group</option> <option value='broadcast'>Broadcast</option> </select> </div> <div id="shortAddressingMethod"> <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> <div id="addressing"> <div class="form-row"> <label id ="insLabel" for="node-input-address" style="width: 160px;"><i class="fa fa-list-ol"></i> Object Instance</label> <label id = "daliLabel" for="node-input-address" style="width: 160px;"><i class="fa fa-sitemap"></i> DALI Address</label> <input type="text" id="node-input-address" style="width: 300px;"> </div> </div> <hr> <div class="form-row"> <label for="node-input-name" style="width: 160px;"><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 command generator', { category: 'dali', color: '#88cc00', defaults: { name: {value: ''}, daliConnection: {value: "", required: true}, command: {required:true, value: '', validate:RED.validators.regex(/^[0-9]{3}$/)}, addressingMode: {required:true, value: 'broadcast'}, address: {required:true, value: '0001', validate: (v) => { let re; if (v === undefined || v === null) { return false; } else { if ($("#node-input-addressingMode").val() === undefined) { return true; } else if ($("#node-input-addressingMode").val() === 'short') { if ($("#node-input-selectionMethod").val() === 'ins') { re = /^([0][0]([0]([0-9]|[A-F])|[1-3]([0-9]|[A-F])))$/g; } else { re = /^([0-9]|([1-5][0-9]|[6][0-3]))$/g; } return re.test(v); } else if ($("#node-input-addressingMode").val() === 'group') { re = /^([0-9]|([1][0-5]))$/g; return re.test(v); } else { return true; } } }}, selectionMethod: {value: 'ins', required: true} }, inputs: 1, outputs: 0, icon: 'running-man.png', align: 'left', paletteLabel: 'dali send emergency command', label: function() { const commandLookup = { 224: 'Rest', 225: 'Inhibit', 226: 'Re-Light / Reset Inhibit', 227: 'Start Function Test', 228: 'Start Duration Test', 229: 'Stop Test', 230: 'Reset Function Test Done Flag', 231: 'Reset Duration Test Done Flag', 232: 'Reset Lamp Time', 233: 'Store DTR As Emergency Level', 234: 'Store Test Delay Time High Byte', 235: 'Store Test Delay Time Low Byte', 236: 'Store Function Test Interval', 237: 'Store Duration Test Interval', 238: 'Store Test Execuation Timeout', 239: 'Store Prolong Time', 240: 'Start Identification' } let connectionLabel; if (this.daliConnection !== '') { connectionLabel = getLabel(this.daliConnection); } if (commandLookup[parseInt(this.command)] !== undefined) { if (connectionLabel !== undefined) { return this.name||`${commandLookup[parseInt(this.command)]} - ${connectionLabel}`; } else { return this.name||`${commandLookup[parseInt(this.command)]}`; } } else { return this.name||`DALI Send Emergency Command`; } }, 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 displayLayout() { if($("#node-input-addressingMode").val() === 'broadcast') { $("#addressing").hide(); } else { $("#addressing").show(); } if($("#node-input-addressingMode").val() === 'group') { $("#insLabel").hide(); $("#daliLabel").show(); } if($("#node-input-addressingMode").val() === 'short') { $("#shortAddressingMethod").show(); updateSelectionLabel(); } else { $("#shortAddressingMethod").hide(); } } displayLayout(); $("#node-input-addressingMode").change(function() { displayLayout(); }); $("#node-input-command").change(function() { displayLayout(); }); function updateSelectionLabel() { if($("#node-input-selectionMethod").val() === 'ins') { $("#insLabel").show(); $("#daliLabel").hide(); } else { $("#insLabel").hide(); $("#daliLabel").show(); } } updateSelectionLabel() $("#node-input-selectionMethod").change(function() { updateSelectionLabel(); }); $("#circuit-busy-message-row").hide(); $("#circuit-failed-message-row").hide(); function doesMobiusServiceExist () { let srvc = $("#node-input-mobius").val(); if (srvc === '_ADD_') { $("#node-lookup-circuit").hide(); $("#circuit-message-row").show(); } else { $("#circuit-message-row").hide(); $("#node-lookup-circuit").show(); } } doesMobiusServiceExist(); $("#node-lookup-circuit").click(function() { $("#node-lookup-circuit").addClass('disabled'); $("#circuit-row").hide(); $("#circuit-busy-message-row").show(); $("#circuit-failed-message-row").hide(); let mobiusSrvc = $("#node-input-mobius").val(); let mobiusHID = $("#node-input-hid").val(); let mobiusSPID = "0032"; $.getJSON(`mservicediscover?mobius=${mobiusSrvc}&hid=${mobiusHID}&spid=${mobiusSPID}`,function(services) { $("#node-lookup-circuit").removeClass('disabled'); $("#circuit-busy-message-row").hide(); $("#circuit-row").show(); $("#node-input-circuit").autocomplete({ source: services, minLength: 0, close: function( event, ui ) { $("#node-input-circuit").autocomplete('destroy'); } }).autocomplete('search',''); }) .fail((err) => { $("#node-lookup-circuit").removeClass('disabled'); $("#circuit-busy-message-row").hide(); $("#circuit-row").show(); $("#circuit-failed-message-row").show(); }); }); } }); </script> <script type="text/html" data-help-name="dali emergency command generator"> <p>MOBiUS DALI Emergency Lighting Control Command Generator.</p> <h3>Configuration Page</h3> <dl class="message-properties"> <dt>DALI Connection <span class="property-type">connection</span></dt> <dd>The connection to an instance of the DALI circuit service representing the working DALI circuit.</dd> <dt>Command Type <span class="property-type">choice</span></dt> <dd>The DALI command to be generated.</dd> <dt>Addressing Mode <span class="property-type">choice</span></dt> <dd>The DALI addressing mode, short / group / broadcast.</dd> <dt>Selection Method <span class="property-type">choice</span></dt> <dd>The method to select DALI fittings.</dd> <dt>DALI Address / Instance <span class="property-type">number</span></dt> <dd>If DALI Address selection is used: Short addressing (0-63), Group addressing (0-15).</dd> <dd>If object instances selection is used: The Mobius object instance number (0001-003F).</dd> </dl> <h3>Input: </h3> <dl class="message-properties"> <dd>Any input message will trigger the node to generate the set command.</dd> </dl> <h3>Details</h3> <p>Generates DALI commands relating to emergency lighting control. Does not include DALI emergency querying.</p> <p align="center" style="color:#000080">iaconnects © 2020</p> <br> <p align="center" style="color:#000080">ER 2020</p> </script>