07-04-2018 12:51 PM
Hello,
I am using a queued message handler architecture to run various processes in parallel. I would like to load multiple vi's onto the main vi's front panel using a subpanel. I used the Multiple VI's in a Subpanel example as a base. Attached is the PNG of my display loop (I'm not sure I can upload the whole project because it contains at least fifty subvis).
The display message queue is the input to a case selector and inside each case, the next vi to display is sent to the message queue. Each vi is listed in an enum array just as it is in the example.
However, I keep getting error 1000 with the run vi method. By watching the vi run with highlight execution, I see that the vi never goes into the while loop to get removed before the next one tries to get loaded.
Is there a better way of doing this? I really feel like this method is fundamentally wrong, I am just not sure which direction to go. Im still new to Labview so any pointers or advice would help!
Solved! Go to Solution.
07-04-2018 09:18 PM
@bbell wrote:
Hello,
I am using a queued message handler architecture to run various processes in parallel. I would like to load multiple vi's onto the main vi's front panel using a subpanel. I used the Multiple VI's in a Subpanel example as a base. Attached is the PNG of my display loop (I'm not sure I can upload the whole project because it contains at least fifty subvis).
To upload a Project with hundreds of VIs, compress the Folder that contains them all and upload the resulting single .ZIP file.
I've had no problem running 48 VIs and having pairs of them appear in two sub-Panels. Here are some questions that we could figure out for ourselves if you attached your entire Project, but which you should be able to answer --
Incidentally, I tend to run independent sub-VIs as Asynchronous sub-VIs using Start Asynchronous Call.
Bob Schor
07-05-2018 05:51 AM
Stopping the VI's with Abort is quite violent, you should send an Event or Queued message. As Bob mentions Start asychronous call can be a better choice, especially if you want to attach some inputs. (you can use Set Control Value, but all in all it's Messier).
/Y
07-05-2018 07:59 AM
Hi Bob,
Thanks a lot for your help.
-I only want one vi to show on one subpanel on the main vi at a time.
-I only want the vi to both start running and appearing when called. However, if I understand the code correctly, the vis are all running at the same time and only the chosen one is displayed. I changed the original example so that it aborts before the next one is loaded. I have simplified it into its own vi and attached it to give you a better understanding.
-Using asynchronous calling is good for when you do not need the results of the subvi immediately. However, some of the data from a vi will be needed for the subsequent vi running on the subpanel. Would I use an asynchronous call and collect option? Or global/shared variables? Or queues?
Thank you for your time, I really appreciate it
bbell
07-05-2018 08:36 AM
Hi Yamaeda,
Thank you for your time!
Could you give me a bit more insight on sending a Queued message to stop a vi in lieu of Abort vi? Would this message be sent from the vi itself or would it be sent in the event case (for example, when NEXT is pressed, the stop vi queued message would be sent?). In either case, what function would I use to actually stop the vi since the queued message tells the program what to do but not how, if I understand correct.
bbell
07-05-2018 09:09 AM
You can Have Your Cake and Eat It, Too! by taking advantage of "Message Queues" in your design. Without worrying about the Particulars of your tasks, here is what I would recommend:
This sounds more complex, but it is really simple, works really well, and even works in an Executable (without changing anything). There is a potential drawback (some might find this an advantage) -- my preferred method of handling Start Asynchronous Calls keeps all of the Tasks' code in memory, loading it when the Main VI runs, so if Memory is a precious commodity, this might be a consideration.
Bob Schor
07-05-2018 09:31 AM
@bbell wrote:
-I only want one vi to show on one subpanel on the main vi at a time.
-I only want the vi to both start running and appearing when called. However, if I understand the code correctly, the vis are all running at the same time and only the chosen one is displayed. I changed the original example so that it aborts before the next one is loaded. I have simplified it into its own vi and attached it to give you a better understanding.
-Using asynchronous calling is good for when you do not need the results of the subvi immediately. However, some of the data from a vi will be needed for the subsequent vi running on the subpanel. Would I use an asynchronous call and collect option? Or global/shared variables? Or queues?
You're correct in your interpretation, you'll start all 5 at once and then show and kill one at a time. Depending on what needs to happen and react in your main VI, it might work with simply dropping the called VI's as subVIs. Since you're using VI server i'll assume you'll need to have your main VI responsive and the other VI's need the dynamic call.
I like the proposed idea of HostToClient and ClientToHost queues. For now it probably is sufficient with a String data type to start of simple. Make a VI of each 'Obtain HTC queue' and 'Obtain CTH queue' so you can use it in all VI's easily.
With that solution you don't actually need any inputs on the subVI's, you'll Obtain the queues internally.
Now it's very easy to Control your subpanel'd VI, enqueue 'stop' to HTC in your main VI and dequeue and react to it in the sub-vi.
Look at Producer/consumer queue-example.
/Y