UNPKG

node-red-contrib-vscp

Version:

A collection of VSCP (Very Simple Control Protocol) nodes

204 lines (192 loc) 7.38 kB
<!-- /////////////////////////////////////////////////////////////////////////// // event2value.html // // This file is part of the VSCP (https://www.vscp.org) // // The MIT License (MIT) // // Copyright © 2020-2021 Ake Hedman, Grodans Paradis AB // <info@grodansparadis.com> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // --> <script type="text/html" data-template-name="event2value"> <div class="form-row"> <label style="margin-left: 100px; width: 70%"> <input type="checkbox" id="node-input-btransparent" placeholder="" style="width: 20px; margin: -4px 0 0 0;" /> Transparent </label> </div> <div class="form-row"> <label style="margin-left: 100px; width: 70%"> <input type="checkbox" id="node-input-btopayload" placeholder="" style="width: 20px; margin: -4px 0 0 0;" /> Measurement to payload </label> </div> <div class="form-row"> <label style="margin-left: 100px; width: 70%"> <input type="checkbox" id="node-input-bvalue2payload" placeholder="" style="width: 20px; margin: -4px 0 0 0;" /> Value to payload </label> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/html" data-help-name="event2value"> <dd>A node that convert VSCP measurement event objects to a measurement value. The unit, sensor index and original event is preserved. </dd> <dd> Measurements are present on the output under the msg.measurement tag. Full VSCP event data will still be in msg.payload. </dd> <dd> The measurement tag have the following content <pre> { value: 1234 unit: 123; sensorindex: 123, index: 123 zone: 123 subzone: 123 } </pre> When index/zone and subzone is not available for the measurement they will be set to zero. </dd> <dd> If the Transparent checkbox is checked all event are feed to the outputs regardless if they are measurement events or not. If it is not checked only measurement event will be feed to the output. </dd> <dd> If Measurement to payload checkbox is checked all the measurement object is placed in the payload. This is the standard format for VSCP JSON data. If it is not checked the measurement object is placed at the message top level. </dd> <h3>Inputs</h3> <dl class="message-properties"> <dd> One input is available and is a <b>VSCP event object</b> or a VSCP <b>event on string</b> form. </dd> <dt class="optional">payload <span class="property-type">object</span></dt> <dd> A VSCP event object typically looks likes this <pre> { vscpHead: 3, vscpClass: 10, vscpType: 6, vscpGuid: "FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:01", vscpsizeData: 4, vscpsizeData: [0x89,0x82,0xFE,0xDC] } </pre> <ul> <li> <b>vscpHead</b> - The VSCP event header</li> <li> <b>vscpClass</b> - The VSCP class for the event. Value must be in the range 0-511</li> <li> <b>vscpType</b> - The VSCP type for the event. Value must be in the range 0-255</li> <li> <b>vscpsizeData</b> - Number of data bytes. Value must be in the range 0-8. </li> <li> <b>vscpData</b> - An array, a comma separated list or a buffer with data bytes. Set to null if no data. Max eight bytes.</li> <li> <b>vscpTimestamp</b> - A micro second timestamp. Can be left out and will be set to an appropriate default if it is.</li> <li> <b>vscpDateTime</b> - An ISO time object set to UTC time. Can be left out.</li> <li> <b>vscpObid</b> - Event object id. Used by some software and can be left out.</li> </ul> </dd> <dt class="optional">payload <span class="property-type">string</span></dt> <dd> A VSCP event on string form <pre> "vscpHead,vscpClass,vscpType,vscpObId,vscpDateTime,vscpTimeStamp,vscpGuid,vspData" </pre> <dd> See meaning of each part above. vscpObId, vscpTimeStamp and vscpDateTime can be left out. Data is just a comma separated list of values. </dd> </dl> <h3>Outputs</h3> <dl class="node-ports"> <li> <dl class="message-properties"> <dt>payload <span class="property-type">number</span></dt> <dd> For a measurement event msg.measurement will be added to the msg object. The msg.payload will hold the original event. </dd> <dd> If The transparent checkbox is checked all events will be let trough and will be available on the output. If not only measurement events will be present. </dd> <dd> If the value to payload checkbox is checked the msg.payload will be set to the value. msg.event will hold the original event with the added measurement tag. </dd> </dl> </li> </dl> </script> <script type="text/javascript"> RED.nodes.registerType('event2value',{ category: 'vscp', color: '#ffe033', defaults: { name: {value:""}, btransparent: { value: false }, btopayload: {value: true}, bvalue2payload: { value: false } }, inputs:1, outputs:1, icon: "arrow-in.png", label: function() { return this.name||"event2value"; } }); </script>