0

I am trying to automate the handler equipment(a robot picks a chip and put it onto a hardware platform) with the following requirement:

1.There are 6 sites for the handler , once handler puts a device onto that site, handler will return an errorcode:

code1 for ready to test, code2 for error, and if in process no code have returned.

2.There is a master PC that controls the handler operation, and the communication b/w master and site PCs are using Staf

3.I need to use that code to run some tests(which already implemented and working properly). Handler puts the device in a FIFO order, first site returns code first, and last site returns code last.

4.The Site PC is acting passively, which master PC will determine when to run and how to run the tests. Site PC will only know if handler is ready then execute the tests.

So my question would be: In this case, for the site-PCs(Windows based with perl and .net enabled), is busy waiting method better or is the wait condition mechanism suits better:

For example: the sample code would be:

void runTestonSite()
{
    for(;;)
    {
        if(returnCode == code1)
        {
            testStart(arg1,arg2,arg3);
        }
    }
}

or is there any better way to do this kind of task?

#include <boost/thread.hpp>

void getReturnCode() { 
    // do stuff
}

void RunTestOnSite() { 
    // do stuff
}

int main (int argc, char ** argv) {
    using namespace boost; 
    thread thread_1 = thread(getReturnCode);
    thread thread_2 = thread(RunTestOnSite);

    // do other stuff
    thread_2.join();
    thread_1.join();
    return 0;
}

Please advise, thanks

4

0 回答 0