UNPKG

node-red-contrib-omron-fins

Version:

OMRON FINS Ethernet protocol functions 'Read' and 'write' for communicating with OMRON PLCs from node-red

162 lines (149 loc) 7.38 kB
<!-- MIT License Copyright (c) 2019, 2020, 2021 Steve-Mcl 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/javascript"> RED.nodes.registerType('FINS Fill', { category: 'OMRON', color: '#0090d4', defaults: { name: { value: "" }, connection: { type: "FINS Connection", required: true }, addressType: { value: "str" }, address: { value: "", required: true, validate: RED.validators.typedInput("addressType") }, valueType: { value: "num" }, value: { value: "0", required: true, validate: RED.validators.typedInput("valueType") }, countType: { value: "num" }, count: { value: "1", required: true, validate: RED.validators.typedInput("countType") }, msgPropertyType: { value: "str" }, msgProperty: { value: "payload", required: true, validate: RED.validators.typedInput("msgPropertyType") }, }, inputs: 1, outputs: 1, inputLabels: "Trigger request", outputLabels: "Write result", align: "right", icon: "write.png", label: function () { var addrOK = this.addressType == "str" && this.address != ""; var valOK = this.valueType == "num" && this.value != ""; var cntOK = this.countType == "num" && this.count != ""; var value = this.valueType == "num" ? this.value : "?" var count = this.countType == "num" ? this.count : "?"; var dynLabel = "FINS Fill"; if(addrOK && valOK && cntOK) { dynLabel = `Fill: ${this.address}, ${value}, ${count} WD${count > 1 ? "s" : ""},` } return this.name || dynLabel; }, oneditprepare: function () { var node = this; function setupTypedInput(varName, types, def) { let varSel = '#node-input-' + varName; let typeSel = varSel + 'Type'; let varVal = node[varName]; let typeVal = node[varName + 'Type']; if (typeVal == null || typeVal === 'none') { typeVal = def; } else if (typeVal === 'string') { typeVal = "str"; } else if (typeVal === 'number') { typeVal = "num"; } $(typeSel).val(typeVal); $(varSel).typedInput({ default: def, typeField: $(typeSel), types: types }); return $(varSel).typedInput('type', typeVal); } setupTypedInput('address', ["str","msg","flow","global"], 'str'); setupTypedInput('value', ["num","msg","flow","global"], 'num'); setupTypedInput('count', ["num","msg","flow","global"], 'num'); setupTypedInput('msgProperty', ["msg"], 'msg'); } }); </script> <script type="text/html" data-template-name="FINS Fill"> <div class="form-row"> <label style="width:120px;" for="node-input-name"><i class="icon-tag"></i> <span data-i18n="fill.label.name"> Name</span></label> <input style="width:70%" type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label style="width:120px;" for="node-input-connection"><i class="icon-globe"></i><span data-i18n="fill.label.connection"> Connection</span></label> <input style="width:70%" type="text" id="node-input-connection"> </div> <div class="form-row"> <label style="width:120px;" for="node-input-address"><i class="fa fa-envelope"></i> <span data-i18n="fill.label.address"> Address</span></label> <input type="hidden" id="node-input-addressType"> <input style="width:70%" type="text" id="node-input-address" placeholder=""> </div> <div class="form-row"> <label style="width:120px;" for="node-input-value"><i class="fa fa-ellipsis-h"></i> <span data-i18n="fill.label.value"> Value</span></label> <input type="hidden" id="node-input-valueType"> <input style="width:70%" type="text" id="node-input-value" placeholder=""> </div> <div class="form-row"> <label style="width:120px;" for="node-input-count"><i class="fa fa-sort-numeric-asc"></i> <span data-i18n="fill.label.count"> Count</span></label> <input type="hidden" id="node-input-countType"> <input style="width:70%" type="text" id="node-input-count" placeholder=""> </div> <div class="form-row"> <label style="width:120px;" for="node-input-msgProperty"><i class="fa fa-sign-out"></i> <span data-i18n="fill.label.msgProperty"> Output property</span></label> <input type="hidden" id="node-input-msgPropertyType"> <input style="width:70%" type="text" id="node-input-msgProperty" placeholder="payload"> </div> </script> <script type="text/html" data-help-name="FINS Fill"> <p>Fill consecutive 16 bit WORD values in an OMRON PLC using FINS protocol</p> <h3>Foreword</h3> <dl class="message-properties"> <dd> Example flows have been included to help you get started. Click the hamburger menu <a class="button" href="#"><i class="fa fa-bars"></i></a>, select <b>import</b> then <b>examples</b> (or press <kbd>ctrl+i</kbd>) </dd> </dl> <h3>Properties</h3> <dl class="message-properties"> <dt class="required">Connection<span class="property-type">FINS Connection</span></dt> <dd>The PLC connection</dd> <dt class="required">Address<span class="property-type">string</span></dt> <dd>PLC WORD Memory Address. Depending on the PLC Type selected in the connection, the address will use the PLC standard addressing format. Some examples... <ul> <li>CIO2000 - Core IO WORD 2000</li> <li>D100 - Data Memory WORD 100</li> <li>E0_200 - Extended Data Memory Bank 0, WORD 200</li> <li>H10 - Holding Relay WORD 10</li> <li>W500 - Work Area WORD 500</li> <li>A600 - Auxiliary Area WORD 600</li> <li>T50 - Timer 50 PV</li> <li>C50 - Counter 50 PV</li> </ul> </dd> <dt class="required">Value<span class="property-type">number | number[] | bool | bool[] | string</span></dt> <dd>Value to fill in the PLC Address[count] specified</dd> <dt class="required">Count<span class="property-type">string</span></dt> <dd>The number of PLC Memory addresses to fill with the specified value</dd> </dl> <h3>Output</h3> <p> Upon success, the SID (Sequence ID) will be sent in <code>msg.payload</code>. This should be a number between 1 and 254. <br> Additional details are sent in <code>msg.fins</code> - use a debug node set to "show complete message" to inspect the available properties. </p> </script>