mikakaraila / node-red-contrib-opcua

A Node-RED node to communicate OPC UA. Uses node-opcua library.
Other
209 stars 195 forks source link

Extended OPC UA Events #410

Closed MarekS4P closed 1 year ago

MarekS4P commented 2 years ago

Hello @mikakaraila,

I am trying to use OPC UA Events, but there are "only" default types: image image

I have a OPC UA Server with custom events, which extends the BaseEventType. In this case, I will get only the known fields of the BaseEventType. All the event extensions are suppressed. Here is a screenshot with an event hierarchy in UAExpert OPC UA Client: image

Is it possible to discover the OPC UA Root Node for all events and select only relevant values? Here is an example of selecting events in UAExpert: image

Or do I need to modify the opcua-basics.js file?

mikakaraila commented 2 years ago

It should work with BaseEvent if event type is done correctly and event notifier is notifying events to server it "should" work.

mikakaraila commented 2 years ago

There was Lady from Siemens and she made some event extension. I´m not sure if it is available from the nodered.org flows.

MarekS4P commented 2 years ago

Yes, it is basically working, but there are not all the data in the returned Node-RED message object. I am missing extended values of extended events. All known BaseEventType values are presented.

UAExpert received event details with all values: image

Two message objects from Node-RED with the identical EventId "0xf58e368ac5fe1144b5dd2c14645733b7", but only with BaseEventType values: image

mikakaraila commented 2 years ago

There's own definition for event fields. I will check if it can be extended somehow.

mikakaraila commented 2 years ago

In principle it should be enough to inject to client node correct message with eventTypeId and eventFields and eventFilter. Can you find out your event TypeId and event Fields?

Inject node and these are needed inside msg connected to client node with "Action EVENTS": msg.topic = node.root; // example: ns=0;i=85; msg.eventFilter = eventFilter; msg.eventFields = basicEventFields; msg.eventTypeIds = node.eventtype; // example: ns=0;i=10751;

You can debug it this way, Debug node above A & C node: image

MarekS4P commented 2 years ago

I tried it but without success. I extended msg but Node-Red throws an exception.

Code: msg.topic = "ns=4;s=38000404"; msg.eventTypeIds = "i=2041"; msg.eventFilter.selectClauses.push( { "typeDefinitionId": "ns=0;i=2041", "browsePath": [ { "namespaceIndex": 4, "name": "InjectionUnitCycleParameters_1/4:TransferSpecificPressure" } ], "attributeId": 13, "indexRange": "NumericRange:<Empty>" }); msg.eventFields.push("4:InjectionUnitCycleParameters_1/4:TransferSpecificPressure"); return msg;

Exception: image

I did the same by extending the opcua-basics.js file function "module.exports.getBasicEventFields = function ()" with "4:InjectionUnitCycleParameters_1/4:TransferSpecificPressure".

I restarted Node-Red and I had the new value in the msg: image

It looks better, but this is also not working. Maybe it is because there is a composite BrowsePath "4:InjectionUnitCycleParameters_1/4:TransferSpecificPressure" created from two parts: "4:InjectionUnitCycleParameters_1" and "4:TransferSpecificPressure". Is this supported? If not, how can I declare it properly?

simon0168 commented 1 year ago

Hello @MarekS4P I also work with an OPC UA server (EUROMAP77) with node red, and I can't get the events.. Have you found the solution in the meantime ?

MarekS4P commented 1 year ago

Hello @simon0168, yes, I have a solution for the node-red-contrib-opcua version 0.2.270 with NodeJs14 and Node-RED 2.2.2 You have to edit the mentioned opcua-basics.js file. For example the TransferSpecificPressure value will be declared like this: ["4:InjectionUnitCycleParameters_1", "4:TransferSpecificPressure"]

Koseng commented 1 year ago

Hi guys, don't know exactly what you are doing, but meanwhile there is support for custom events out of the box. You will automatically get all fields of the event. (it worked some time ago, did not recheck).

image

Just click custom event, and add the node-id of the event-type. For standard opc ua events i=xx is enough for real custom one you need the namespace as well. Like for example ns=2;i=55.

MarekS4P commented 1 year ago

Hi @Koseng, thank you for your comment. This is a new feature that I did not have. We used one year ago the node-red-contrib-opcua@0.2.270 This is how the old configuration window looks like: image

I will try it with the last version 0.2.305 and provide feedback.

MarekS4P commented 1 year ago

Hi guys, I can confirm that the new feature works. Now it is possible to define an own Event Type direct in Node-RED and no opcua-basics.js file modifications are needed. image

Received event: image

simon0168 commented 1 year ago

Thanks @Koseng @MarekS4P. I couldn't try custom event because Node-RED crashes when I use it, maybe it's because I tried to reach wrong or non-existent nodes.. I will try at work tomorrow.

Koseng commented 1 year ago

@MarekS4P great that it works. Yeah it was implemented not too long ago.

simon0168 commented 1 year ago

Hello @MarekS4P & @Koseng, I tried this:

Hi guys, I can confirm that the new feature works. Now it is possible to define an own Event Type direct in Node-RED and no opcua-basics.js file modifications are needed. image

Received event: image

But in my payload I just have the message "New cycle" without CurrentLotName, CushionVolume etc., here is my payload: { "payload": { "EventId": "0xb20be6cc6a7e364c9401d8345bc413b0", "_EventId": { "dataType": "ByteString", "arrayType": "Scalar", "value": [178,11,230,204,106,126,54,76,148,1,216,52,91,196,19,176] }, "EventType": "ns=4;i=7116", "SourceNode": "ns=4;s=38621799", "SourceName": "IMM_KRAUSSMAFFEI_38621799", "Time": "2023-05-10T08:47:04.910Z", "ReceiveTime": "2023-05-10T08:47:05.176Z", "Message": { "locale": null, "text": "New Cycle" }, "Severity": 100 }, "topic": "ns=4;i=7116", "_msgid": "754864e6784a9102" }

In UaExpert if I want to retreve all "cyclic" informations I have to manually tick "SimpleEvents" in Event View and then Apply. Then With every NewCycle Event comes all informations I need (CushionVolume, CushionStroke, etc..).

Is there a way in nodeRED to "tick" SimpleEvent..?

yayitazale commented 12 months ago

Hi guys, I can confirm that the new feature works. Now it is possible to define an own Event Type direct in Node-RED and no opcua-basics.js file modifications are needed. image

Received event: image

Can you share the flow and tell me witch versions are you using? I have the same event type but no success to read anything.

MarekS4P commented 11 months ago

Hi @yayitazale, I tested it with node-red-contrib-opcua@0.2.305 and Node-RED 2.2.2. I do not have the test flow anymore.

yayitazale commented 11 months ago

Hi @yayitazale, I tested it with node-red-contrib-opcua@0.2.305 and Node-RED 2.2.2. I do not have the test flow anymore.

Thanks, finally with the help of Mika we make it.