UNPKG

node-red-contrib-simatic-opcua-event

Version:

A node-red node to communicate with Siemens PLC S7-1500 or any other basic opc ua server. Based on "node-red-contrib-opcua"-Nodes.

48 lines (37 loc) 1.65 kB
/** 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. **/ module.exports = function (RED) { "use strict"; var opcua = require('node-opcua'); var opcuaBasic = require('./BasicOPCUA'); function OpcUaEventNodeSimatic(n) { RED.nodes.createNode(this, n); this.root = n.root; // OPC UA item nodeID this.eventtype = n.eventtype; // eventType this.name = n.name; // Node name var node = this; node.on("input", function (msg) { // var baseEventTypeId = "i=2041"; // var serverObjectId = "ns=0;i=2253"; // All event field, perhaps selectable in UI var basicEventFields = BasicOPCUA.getBasicEventFields(); var eventFilter = opcua.constructEventFilter(basicEventFields); msg.topic = node.root; // example: ns=0;i=85; msg.eventFilter = eventFilter; msg.eventFields = basicEventFields; msg.eventTypeIds = node.eventtype; // example: ns=0;i=10751; node.send(msg); }); } RED.nodes.registerType("OpcUa-SimaticEvent", OpcUaEventNodeSimatic); };