07-04-2012 05:54 AM - edited 07-04-2012 05:56 AM
Hello,
I am making a VI library that does reading from NI Hardware, no matter how many devices you use.
However, many NI hw devices do not support multiple independent devices in one software task, so I have to work with array of tasks created programmaticaly based on the measurement settings.
I would like all my VIs utilize the event structure so I can control the easily, therefor I want to do my readings event based, using the "Every N samples acquired into buffer" event. I did the registration like this :
If you open the VI, you can see that the event structure offers 8 ?! task events for task 0 - 7. I tried to use this with 2 independent devices, and it works, but the whole code seems very unusual so I want to ask if this is the correct way to do it.
07-04-2012 10:15 AM - edited 07-04-2012 10:16 AM
Your code actually has 9 events registered 0 to 8.
This comes from the "Array to cluster" conversion which MUST have a fixed size cluster. Default is 9. If you KNOW how many channels you want to register events for, this will work otherwise you will need to think up another way of doing things.
Shane
PS Aside from that it looks ok at first glance.
07-04-2012 11:39 AM - edited 07-04-2012 11:42 AM
So it should work up to to 9 devices, right ? You wrote I have to know the number of channels, but the channel number for each task is not relevant I think...
Thanks for reply.
07-05-2012 02:21 AM - edited 07-05-2012 02:22 AM
My point was that even if your input array of tasks is 1000 in size, you'll only have registered the events for the first 9. The "Array to Cluster" conversion sets the dynamically-sized array (1000) to a fixed-size cluster (here it is 9). You will lose the registration information for the other 991 tasks.
Simply change the settings of the +Array to Cluster" (By right-clicking on its icon) and set the number higher. This will be your upper limit of tasks to be monitored.
I don't know if there's a correlation between task and device but the code seems limited by the maximum number of tasks only. If these can be from ANY device, then it should work for you.
Shane.
07-05-2012 04:08 AM - edited 07-05-2012 04:09 AM
Ok, thanks for the answer.
Would it be better to code this using the AsyncCall of clones that would each work with one device but different parameters. I was thinking about passing some event control reference so I can control these clones, distinguish between collected data by parameters passed, like Dev1 / Dev2 etc.. And if the user decides to change the configuration and add more channels from other devices, I would stop the clones from running and call them again with different parameters from some wrapper VI.
I have never used the CallAsync function so this is just all in my head. Is it possible to do it so ?
07-05-2012 08:13 AM - edited 07-05-2012 08:14 AM
I did it like this :
This is the case of the wrapper VI that gets the slave VI clones running. I would like to know, what am I supposed to do with the reference to that VI, I was not able to pass it into it as an parameter, so I did it like this and I want to close it as the VI is supposed to end. Maybe I should just keep it in the wrapper VI and Close it as I get notified that the slave clone VI was closed. I do not know...
This whole setup looks very unlabview.
07-05-2012 08:54 AM
Doesn't look very unLabVIEW to me... Looks more modern than most code I'm working with right now.
I don't know aht's travelling over the Queues so it's hard for me to comment but parallel launching VIs and collecting the data ona queue should be the right kind of thing.
I have too little experience with DAQ to know if there's a catch anywhere, sorry.
Shane.
07-05-2012 09:31 AM - edited 07-05-2012 09:32 AM
Thank you,
but what about that reference ? I am very confused about it, when is it supposed to be closed ? Once all VIs are done or within every VI clone termination ? I know this is a common hard2find memory leak. Is it the same as I get from "this VI reference" constant ? I chcecked all the examples and it seems to be supposed to be closed once all the VIs are terminated... So I think that what I posted is somewhat wrong.
07-05-2012 01:34 PM
You mean the reference fed into the Asynchronous call? I think LV takes care of them itself as long as they are no longer being referenced.
Shane.