07-20-2016 04:07 AM - edited 07-20-2016 04:09 AM
Hello,
I remember a few years ago I have seen an example for what I try to do now, but I just cannot find it. I have some idea which way to go, but I would ask first the advanced coders here.
Scenario: i need to monitor some bit flags from a TCP/IP stream, and a useful VI is the "Boolean Crossing PtByPt.vi" for this. However, I have many channels which I need to monitor for "rising edge" independently. If I had just a very few channels, I could go in the following not too elegant static way (see below, the Case structure needs to be setup manually for all elements).
I know the proper solution involves some dynamic VI call technique, but I would like to ask your opinion how to do it properly, and efficiently? Thanks very much!
Solved! Go to Solution.
07-20-2016 05:41 AM - edited 07-20-2016 05:43 AM
Have you seen this page here? http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/asynchronous_vi_calls/
Specifically, read the last two bullet points - if you open a single reference and then it will run the VI as reentrant. If you open the reference multiple times, it's preallocated so each call (reference) should retain it's own memory space.
For an example - look at the second diagram at this link: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/acbr_call_and_collect/
07-20-2016 07:05 AM
Do you think this way is OK?
07-20-2016 07:18 AM
That should work, but I don't see the advantage of the asynchronous call for this purpose.
The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.
07-20-2016 07:31 AM
Thanks, you are right, more simple!
07-20-2016 07:37 AM
@dan_u wrote:That should work, but I don't see the advantage of the asynchronous call for this purpose.
The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.
Oh yes, I sometimes forget that you can do synchronous calls - I tend to use asynchronous more commonly (for launching multiple instances of a UI VI) so I didn't think about it.
07-20-2016 07:40 AM
Talking about simple, a simple "Greater?" primitive with the old array as comparison will result in the same thing. No need for a for loop or multiple instances of subVIs.
07-20-2016 07:45 AM
@Sam_Sharp wrote:
@dan_u wrote:That should work, but I don't see the advantage of the asynchronous call for this purpose.
The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.
Oh yes, I sometimes forget that you can do synchronous calls - I tend to use asynchronous more commonly (for launching multiple instances of a UI VI) so I didn't think about it.
Yes, the async call is convenient for "handlers" or UI VIs that keep running for a while. I'm not sure how much overhead it would cause for a simple case like this where synchronous call seems the ideal solution.
07-20-2016 07:50 AM
Haha, well, I could call my solution a kind of "advanced Rube Goldberg"?
But for sure it was good to learn/clarify the usage method of this kind of dynamic call. For the actual code, your simple "Greater?" function with a shift register (or feedback node) is just superior 😄
07-20-2016 08:09 AM