07-29-2010 10:22 AM
i load an UI in SequenceFileLoad and close it in SequenceFileUnload.but i run sequence file,and find that the teststand is always running in SequenceFileLoad,exerpt for terminating it.how can i realize this function?
thanks
Solved! Go to Solution.
07-30-2010 01:23 AM
Hi,
Not sure what you are referring to. Are you saying that you are trying to launch a second TestStand?
07-30-2010 08:56 AM
a logdisplay panel is loaded by SequenceFileLoad,it will be unloaded by SequenceFileUnload ,during test,this UI is always working.my problem is if i load logdisplay panel, the teststand stop in SequenceFileLoad, and do not run mainSequence.
07-30-2010 09:10 AM
this my test program,
07-30-2010 10:13 AM
Your code module that brings up your UI in SequenceFileLoad needs to do so from a new thread. It then needs to return back to teststand immediately so that the load callback can complete. Your unload callback then needs to communicate some how with your UI, perhaps via SendMessage if it can get the window handle, in order to dismiss the UI and allow your newly created thread to exit. Ideally, to shutdown a new thread as safely as possibly, your code in the unload callback should wait for the thread to exit after telling it to exit before returning back to teststand. With the WIN32 sdk you can wait for a thread to exit by calling WaitForSingleObject() on the thread handle. Thread handles should be closed when you are done with them using CloseHandle otherwise you will leak them. It really depends on what programming language you are using for exactly how to do this. If you want advice on other alternatives, it might help to explain exactly what you are trying to do and why.
Hope this helps,
-Doug
08-01-2010 10:28 AM
thank you for your advice,but how can i return back to teststand,i think it is the key of problem.
by the way,i try to use thread to display panel,but the sequence is always running before quiting panel.
i know little about teststand.
08-02-2010 09:43 AM - edited 08-02-2010 09:46 AM
It depends on the programming language you are using. I meant creating the new thread in your code module, not in TestStand.
Another alternative that might be simpler if you don't want to deal with writing multithreaded code modules is to use a New Execution sequence call to call the sequence that displays your dialog and set the sequence call's wait for execution option to Dot Not Wait (in the advanced subpanel). That way the load callback execution will complete and your dialog's execution will still be running. You can even configure the sequence call to store the execution's reference in a station global or something so that you can access it later in your unload callback (i.e. you can call terminate on it and use a wait step to wait on it).
A downside of using an execution though is that TestStand restricts you from doing certain things (like modifying types) while an execution is running. So if those things are important you should probably use new threads directly in your code modules instead.
Hope this helps,
-Doug
08-02-2010 09:54 AM
thank you again.
i find use code as follow which can work out this problem.why? at the same time ,i can update the panel ,during test.
int __declspec(dllexport) __stdcall InitUIForDLL (CAObjHandle sequncetext)// load in SequenceFileLoad
{
/* Call this function from the appropriate place in your code */
/* to load and display startup panels. */
if ((panelHandle = LoadPanelEx (0, "panel.uir", PANEL, __CVIUserHInst)) < 0)
return -1;
DisplayPanel (panelHandle);
/* Uncomment this call to RunUserInterface or call it from elsewhere */
/* in your code to begin issuing user interface events to panels */
/* RunUserInterface (); */
return 0;
}
void __declspec(dllexport) __stdcall DiscardUIObjectsForDLL (CAObjHandle sequncetext)//load in SequenceFileUnload
{
/* Discard the panels loaded in InitUIForDLL */
if (panelHandle > 0)
{
DiscardPanel (panelHandle);
panelHandle = 0;
}
}
08-02-2010 10:24 AM
Those functions do not create a new thread, they just create a window in the current thread, but do not process messages (i.e. do not do RunUserInterface()) for it. TestStand execution threads do process window messages when they are idle, but you should not rely on that since a TestStand execution thread could be reused at any time by another execution and that other execution might not process window messages in that thread. That is why it's best to create your own thread for your UI that you will have full control over.
Or perhaps writing a custom UI or modifying one of the ones we ship might be a better alternative for you. TestStand ships with a User interface written in CVI with source code that you can modify. That would allow your UI panels to run in the main UI thread of the application rather than having to create a separate thread.
Hope this helps,
-Doug
08-03-2010 09:21 AM
yes,it just create windows,becasue test log will be displayed in it.
DLL + thread, i have no idea where can i create thread;
/*******************************************i can create thread as follow******************************************************************/
int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason,
LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
/* Place any initialization which needs to be done when the DLL */ CmtScheduleThreadPoolFunction (, , , );
/* is loaded here. */
if (InitCVIRTE (hinstDLL, 0, 0) == 0)
return 0;
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
/* Place any clean-up which needs to be done when the DLL */CmtWaitForThreadPoolFunctionCompletion (, , OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
/* is unloaded here. */
if (!CVIRTEHasBeenDetached ())
CloseCVIRTE ();
}
/* Return 0 to abort if initialization fails */
return 1;
}