UNPKG

node-red-opcua-otmr

Version:
72 lines (69 loc) 3.01 kB
<script type="text/javascript"> RED.nodes.registerType('opcua-otmr', { category: 'function', color: '#77BFC7', defaults: { name: { value: "" }, endpoint: { value: "", required: true }, port: { value: 4840, validate: RED.validators.number(), required: true }, nodeIds: { value: "", required: true }, operation: { value: "read", required: true }, dataType: { value: "" } }, inputs: 1, outputs: 1, icon: "node-red/parser-xml.svg", label: function() { return this.name || "opcua-otmr"; }, oneditprepare: function() { $('#node-input-name').val(this.name); $('#node-input-operation').val(this.operation); $('#node-input-endpoint').val(this.endpoint); $('#node-input-port').val(this.port); $('#node-input-nodeIds').val(this.nodeIds); $('#node-input-dataType').val(this.dataType); }, oneditsave: function() { this.name = $('#node-input-name').val(); this.operation = $('#node-input-operation').val(); this.endpoint = $('#node-input-endpoint').val(); this.port = $('#node-input-port').val(); this.nodeIds = $('#node-input-nodeIds').val(); this.dataType = $('#node-input-dataType').val(); if (!this.endpoint || !this.port || !this.nodeIds) { RED.notify("Endpoint URL, Port, and Node IDs are required fields.", "error"); return false; } } }); </script> <script type="text/html" data-template-name="opcua-otmr"> <div class="form-row"> <label for="node-input-name">Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-operation">Operation</label> <select id="node-input-operation"> <option value="read">Read</option> <option value="write">Write</option> </select> </div> <div class="form-row"> <label for="node-input-endpoint">Endpoint</label> <input type="text" id="node-input-endpoint" placeholder="opc.tcp://hostname"> </div> <div class="form-row"> <label for="node-input-port">Port</label> <input type="text" id="node-input-port" placeholder="4840"> </div> <div class="form-row"> <label for="node-input-nodeIds">Node IDs</label> <input type="text" id="node-input-nodeIds" placeholder="NodeID 1, NodeID 2, ..."> </div> </script> <script type="text/html" data-help-name="opcua-otmr"> <p>This node communicates with an OPC UA server. You can choose to read or write values from specified Node IDs.</p> <p>For write mode, send a simple value in <code>msg.payload</code> (e.g., <code>42</code> or <code>"ON"</code>), and the node will use the configured Node ID and Data Type.</p> </script>