LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create parallel loops at runtime

I need some while loops to run independently, with different timing, like parallel threads. If you know the number of loops this is easily done... just draw the loops not connected to each other. But i need the number and timing of loops to vary at runtime, being created and killed like threads.
What would be a good approach?
0 Kudos
Message 1 of 7
(3,384 Views)

The way I know how to solve that is to save your (sub)vi that include your loop as a template and call it at runtime with the vi-server vis.

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 7
(3,376 Views)
Open and run vi's dynamically, using the functions in the Application Control palette (Open VI Reference, Close Reference, Invoke Node), like in the attached example.
Stop the running vi by calling Abort VI or implementing code with sync objects (Occurrences, Notifiers, etc.).
If several vi need to do the same basic code, save a vi template (.vit): every time you open the template, a new instance will be loaded in memory.
Hope this helps.

Paolo

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 7
(3,375 Views)

"Snamprogetti" <x@no.email> wrote in message news:1148283609050-368369@exchange.ni.com...
I need some while loops to run independently, with different timing, like parallel threads. If you know the number of loops this is easily done... just draw the loops not connected to each other. But i need the number and timing of loops&nbsp;to vary at runtime, being created and killed like threads.
What would be a good approach?


Hi,


You should consider vi templates. You can start as many as you like with VI server.


Regards,


Wiebe.
0 Kudos
Message 4 of 7
(3,374 Views)
Thanks for the hints, i also found a document:
Design Patterns for implementing asynchronous processes in LabVIEW.pdf
which explains everything
0 Kudos
Message 5 of 7
(3,349 Views)
Can you provide a link for the pdf file that you found?  I searched NI's site and couldn't find it.

Thanks
0 Kudos
Message 6 of 7
(3,323 Views)
It is actually a LAVA file and should be here:
0 Kudos
Message 7 of 7
(3,306 Views)