LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel test

Solved!
Go to solution

I'm trying to create an application to calibrate UUTs, the calibration is OK, now i make some change to my prog to make 2 parallel tests in one panel.

I create two threads where i put the code to test UUT.

In my "Start_Function_Callback" call the two thread like that:

int CVICALLBACK Start_Test (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
 
 int result0,     result1;
switch (event)
{
case EVENT_COMMIT:
while (1)
CmtNewThreadPool(2,&handle);
CmtScheduleThreadPoolFunction (handle , test1ThreadFunction,0, &functionId);
CmtScheduleThreadPoolFunction (handle , test2ThreadFunction,0, &functionId2);
}
}
 
return 0;
}

 

While the user click on the start-button the test start, two panel (like popup) apprears where the user puts the serial number for each DUT.

After that the test start for the two DUTs.

I give 5second for the first test and 10seconds for the second one.

The problem is that the test is not in parallel mode, supposed that after 5seconds the first panel appears to put the serial for an other UUT in the first position but nothing happen until the second thread ends (after 10seconds).

Please what should i modify in my code to make parallel tests?

Thanks a lot.

0 Kudos
Message 1 of 9
(4,794 Views)

I would be surprised such a code works!

Your neverending loop continuously starts threads saturating the pool in a few runs.

Try spawining the threads and then exiting the callback: your program will sit in RunUserInterface () while the threads run independently.

 

You should experimenting the multithreading with a simple conceptual but working framework just to understand how things work. I am thinking to a simple UI that launches the threads; thread functions can simply ask for S/N and then wait for a few seconds, again and again until a stop thread condition is found.

This will help you also to understand how to stop that mechanism.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 9
(4,778 Views)

Thanks for your answer Roberto,

Im beginner in labwindows and multithreadding, i like to make this test in parallel.

Have you any example or a modification that should i do?

 

thanks.

0 Kudos
Message 3 of 9
(4,776 Views)

In my UI when the user click on the button "start", the first panel appear to put the serial for the first UUt then the second panel appears to put the second serialand the test start.

0 Kudos
Message 4 of 9
(4,773 Views)

Please any help, i'm blocked !!!

Spoiler
😞 
0 Kudos
Message 5 of 9
(4,743 Views)

Hello xmouth, have you already coded something? Can you posta the framework I told you so that we can discuss on some tangible code?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 9
(4,732 Views)

Hello, 

I don't know how to start?

Should i add a "while loop"? But i think that is not the good solution.

Really i can't found a solution, when surfing in the net, i found that the real solution for parallel test is multithreadding, i make two thread but can't run them in parallel mode, here is the biggest problem.

Have you any solution or idea?

In my UI, the prog still waiting until the user puts the serial then start testing, but how can i launch the two thread at time?

That's my question.

Please help me !!!

0 Kudos
Message 7 of 9
(4,726 Views)
Solution
Accepted by topic author xmouth

I have several ideas but I doubt you can understand the real complexity of a multithreading paradigm before a serious study on the subject.

Anyway, attached you can find a simple skeleton of what you can do: it does really nothing but advance a pair of progress bar and ask for serial numbers, but is multithreaded and handles proper start/stop/dispose of threads.

 

Fully understanding it will need you to read the chapter on multithreading in the help: you'll find it in Programmer Reference >> Creating Multithreaded Applications.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 9
(4,717 Views)

Thanks a lot Roberto, i do it now, just i make a condition to repeat the test and to make parallel tests.

Now i have to manage the popup , and block the second test until the user puts the serial number.

 

I'm really thankful.

🙂

0 Kudos
Message 9 of 9
(4,710 Views)