Aggregate using join node


I am looking for any suggestions as to whether my approach to aggregating xml could be improved. Firstly, in a plc i am formatting data in xml and sending it out a tcp/ip socket. In my node-red app I am using the join node to aggregate the xml node (which could span multiple buffers).

first, i created my own aggregation function to capture the complete node. Then it occurred to me the join node should be able to do this. But for the join node to work i still have to set the msg.complete property in an upstream function. (just putting it out there but maybe a good feature on the join node would be to have a endsWith condition??)

my upstream function node to set the complete param contains the following...

msg.complete = msg.payload.endsWith('</Root>')

Hi, I've not really considered your aggregation method as I can't really get round why you have taken the approach of building XML in the PLC instead of obtaining values in node-red & building the XML their.

I'm certain you have good (or legacy) reasons but I'll ask anyway...

What is the PLC you're communicating to? Perhaps there is a node that will reduce the need to do any ladder for the TCP socket Comms & XML building.

As it stands, any changes would needing to be done in PLC. I understand that can be desirable but also, I know if the PLC only has basic string functions, it's quite a task.


Thanks for the reply.

I guess it is a unconventional approach but i have found building xml in the plc to be extremely flexible with respect to event logging. I am not using this approach this to poll variables but rather log events and telegrams from the plc.

The log buffer (array of char) i am using in the plc is 32k and quite often the length i am using for the send request will span multiple buffers when receiving in node-red. I generally buffer events for say 250ms in the plc and then send.

If i reduce my send size so that i do not have to aggregate on the node-red size I will loose capacity

The PLC is s7-1500 and in addition to the sockets i do use s7 connection to poll some data.

(I noted your parser yesterday, looks good and i look fwd to testing it out)

No bother. I was unsure if you were unaware of other options available - seems you're perfectly up to speed.

Quick note / question, why not use MQTT (the s7-1500 has some FBs for doing MQTT). Not sure if there are any JSON FBs but if you did it this way, your node-red code would be hugely simpler.

no reason really, i am not that familiar with MQTT. Yes, i think there are some JSON blocks coming packaged with V16 which will take a look at.

Oh well in that case, it's time to have a play.

Mqtt is so easy & takes care of connection issues, lightweight, has things like QoS built in and you don't have to look for end of stream, no parsing of data.

So many benefits compared to developing your own Comms channel.

Have a look at this - see how simple it can be.
Linking 2 or more instances on a local network

Don't forget, MQTT is pretty much a defacto protocol in IIoT - good to have in your toolbox. And, once you "get it" you can realise so much potential.

Phew, I've done my sales pitch for today.

Thanks for your comments. Yes i agree, it is well overdue for me to create my MQTT hello world.

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