i've write a flow with 3 Modbus connection; each Modbus connection retrive an array data each of 95 elements. Then i've link out these 3 array to other flow.
On flow "data", i've use link IN
Now, how i can read each elements of each array?
- array 1 = [1, 2, 3, 4, 5, 6 ....]
- array 2 = 10, 20, 30, 40, 50, 60 ...]
- array 3 = [100, 200, 300, 400, 500, 600 ...
I need a function to retrive the therd element of each array [3, 30, 300]
Thanks to everyone for any advice
Do you need all 3 values at the same time or just the 3rd value of the data passing through?
If you need them all at the same time and need the value of all 3 third elements in a new array as you wrote (
[3,30,300]) then you will need to join the data from your three nodes so that you can access all three arrays at once. Then it will be a simple case of ...
msg.payload = [msg.payload.SQ1, msg.payload.QF1, msg.payload.QF2]
See this article in the cookbook for an example of how to join messages into one object.
PS, if you intend on converting all the modbus INT16 values into nicely named strings/bools/floats/int32s etc, you might want to look at buffer-parser.
but if SQ1, QF1 and QF2 don't raise data togheter, function terminate witha a error?
Is possible "Try / Catch" error inside function code??
Thats what the join node is for - read/watch the link I posted.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.