node-red-contrib-opcua
Version:
A Node-RED node to communicate via OPC UA based on node-opcua library.
110 lines (98 loc) • 4.84 kB
HTML
<!--
Copyright 2016 Valmet Automation Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/javascript">
RED.nodes.registerType('OpcUa-Event',{
category: 'opcua',
color:"#3FADB5",
defaults: {
root: {value:"", required:true}, // ns=2;i=85 Server object to look through all objects under it
activatecustomevent: {value: false, required:true},
eventtype: {value:"", required:true},
customeventtype: {value:""},
name: {value:""}
},
inputs:1,
outputs:1,
align: "right",
icon: "opcuanodeLogo.png",
label: function() {
return this.name || "OPC UA Event";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function () {
var node = this;
try {
var inputActivateCustomEvent = $('#node-input-activatecustomevent');
var inputCustomEventTypeRow = $('#node-input-customeventtyperow');
var inputEventTypeRow = $('#node-input-eventtype-row');
adapt_input(); // initialize
inputActivateCustomEvent.change(adapt_input);
} catch (err) {
node.error(err);
}
function adapt_input() {
if (inputActivateCustomEvent.is(':checked')) {
inputCustomEventTypeRow.show();
inputEventTypeRow.hide();
}
else {
inputCustomEventTypeRow.hide();
inputEventTypeRow.show();
}
}
}
});
</script>
<script type="text/x-red" data-template-name="OpcUa-Event">
<div class="form-row">
<label for="node-input-root"><i class="icon-tasks"></i> Source node</label>
<input type="text" id="node-input-root" placeholder="i=2253">
</div>
<div class="form-row" id="node-input-activatecustomeventrow">
<label for="node-input-activatecustomevent"><i class="icon-tasks"></i> Custom event</label>
<input type="checkbox" id="node-input-activatecustomevent" style="width: auto">
</div>
<div class="form-row" id="node-input-customeventtyperow">
<label for="node-input-customeventtype"><i class="icon-tasks"></i> Event Type</label>
<input type="text" id="node-input-customeventtype" placeholder="ns=2;i=1234">
</div>
<div class="form-row" id="node-input-eventtype-row">
<label for="node-input-datatype"><i class="icon-tag"></i> Event Type</label>
<select type="text" id="node-input-eventtype" style="display: inline-block; vertical-align: middle; width:60%;">
<option selected disabled value="" >Choose a Event Type</option>
<option selected value="i=2041">BaseEvent (all)</option>
<option value="i=2052">AuditEvent</option>
<option value="i=2132">BaseModelChangeEvent</option>
<option value="i=2782">ConditionType</option>
<option value="i=3035">Event Queue Overflow</option>
<option value="i=11436">Progress Event</option>
<option value="i=2130">System Event</option>
</select>
</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="">
</div>
</script>
<script type="text/x-red" data-help-name="OpcUa-Event">
<p>Defines the OPC UA events that will be subscribed from the server.</p>
<p>The Source node defines the node where events are subscribed for.
The root Server node id is used, if all events of the server shall be processed.
If available, other specific node ids can be used for a subset of events.
Not using the root Server node might for example make sense in case of an aggregating server.</p>
<p>The Event Type defines what kind of events are subscribed. Events of the given Event Type and all subtypes are returned.
An event type can be selected in the dropdown field, or manually entered when marking the checkbox.
</p>
</script>