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...
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.
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.
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.