Issue with opcua and s7 -> OPCServer in node red with many tags

Hello,

I am using:
node-red-contrib-s7
node-red-contrib-opcua

currently I am struggling with a flow to create many tags (approx. 800).
I am using OPCUA-IIoT-Inject->OPCUA-IIoT-Server-ASO->OPCUA-IIoT-Sver to create the folders and tags in the OPCServer. => This is working good but is quite huge (1603 nodes in total).

Now I need to read data from S7 (RFC1006), I've created S7-Endpoint where all the Variables of S7 are defined "Endpoint"->"Name".
Then I've created nodes for each variable as a "s7 in" in mode "single" so that I could use a function for each node afterwards to transform the msg from "s7 in" to a msg for a OPCUA-IIoT-Write node.

The function is defined:

msg.topic = ""
msg.nodetype ="inject"
msg.injectType = write
msg.addressSpaceItems = [
    {"name":"","nodeId":"ns=1;s=OPCTAGNAME_E352","datatypeName":"Boolean"}
]
	
msg.valuesToWrite = [
    msg.payload.S7Endpoint_E352
]
return msg;

This solution results into a too big flow which I can not deploy.

Now usually I do not like to build it in this way, normally I would use loops or so to reduce everything but I am new to NodeRed.
Anyways the "documentation" does not help me identifying which object is in msg for "S7 in" when I used mode "ALL" or mode "All, one per message".

The issue is that I need to set the datatypeName for OPCUA Server for the specific tag.

I.e. I could create multiple S7 endpoints for each data type, then create a node for "S7 In" for the datatype and set this to mode "ALL". But then I am lost, how can I transform the msg to OPCUA Server for all of the variables which are contained in msg of "S7 in"? I also need to set the S= to the OPCTAGNAME but this could be the same as the name of the "S7 in" variable (if I can extract it from input msg)

Regards
Joerg

Better solution is to transform S7 msg to OPC UA msg, I mean no need to create individual nodes for each possible variable.
I expect you have used browse to get the whole address space, but I need some draft flow as an example what you want to do. I am not 100% sure that I got your idea correct.

Well, when I started I used a macro to generate NodeRedNodes to inject folders and variables to the NodeRed OPC UA server. This resulted in 1400 Nodes.
The same I thought I had to do to inject values from S7 to OPCUAServer. But that was not possible with my provided system.
At this time I used the examples provided by my vendor of the system and it sorted out to be not very reliable.

So I started new and used OPC UA flex server. There I could write source code to create the folders and variables and bind the variables of OPC UA to flow variables. This resulted in less NodeRedNodes as well as in a faster startup of the OPC UA server.

Then I used three S7 in (basically to divide the process variables, message and error variables). Each S7 in node uses mode "ALL". I've learned that the msg object contains KeyValue pairs for each variable defined in S7in. So in the following function I just write to the appropriate flow variable using msg.VARIABLENAME.value where VARIABLENAME is the name of the variable defined in S7in.

Tomorrow I am going to test this in production environment as I only have a S7 there to test.

Regards
Joerg

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.