01-27-2009 10:56 AM
I just want to add an example of a really easy way to communicate bi-directionally between a sequence and a UI without using station globals or sequence contexts:
Basically, post a synchronous (true for the synchronous parameter) UI Message from a step in the sequence, passing, for the ActiveX data parameter, a propertyobject (container) with variables containing all of the information you need to send to the UI as well as places to store information you want back from the UI. The UI can then use the PropertyObject API to access this container and knows that the thread in the execution will be blocked until the UIMessage is acknowledged or freed and therefore knows its access to the data is synchronous with respect to the sequence. After the postUImessage call returns the sequence knows that the UI is done updating the data it passed in so it can get back out any return values it needs.
Hope this helps,
-Doug
01-28-2009 04:53 AM
My application is different from the standard. Unfortunately, is a mix between parallel and batch model, hence I had to modify the process model and the Operator Interface. Let me do a consideration that are beyond the scope of this post: why developing batch and parallel model separately? I do not thing that my application is so strange. TS should offer a sequencial model and a "multi sockets" model that includes both batch and parallel.
However, in my model I do not run the "UUT Info dialog" of the modelsupport2.dll (also the modelsupport2.dll would deserve some considerations). In this case my Operator Interface must replicate some commands. I would like to use the same approach of the modelsupport2.dll to communicate the commands to TS (it seemed to me the easiest approach). For what I understood about the dll, it enqueues elements into the "DialogRequestQueue" (command + TestSocket) and changes TS variables in each different execution (like ContinueTesting) using the TS_PropertySetValxxx . Both commands should need the sequence context.
See the code below:
///////////////////////////
// Stop Button
///////////////////////////
// set continue flag to false
tsErrChkMsgPopup( TS_PropertySetValBoolean (testSocketData->testSocket,
&errorInfo, TEST_SOCKET_CONTINUE_TESTING, 0,
VFALSE));
or
///////////////////////////
// OK Button
///////////////////////////
// store serial number
errChk(TS_SetPropertyToCtrlVal (panel, testSocketData->ctrls[kTSCtrl_SerialNum],
testSocketData->testSocket,
TEST_SOCKET_UUT_SERIAL_NUM));
// change displayed state
testSocketData->currentState = kTSCState_Running;
errChk( RefreshTestSocketCtrls(parentPanel, testSocketIndex));
// tell controlling sequence to continue test socket execution
errChk( SendRequestToControllingSequence(panelData, CTRL_REQUEST_TEST_SOCKET_CONTINUE, testSocketIndex));
break;
Is the testSocketData->testSocket the sequence context?
What do you thing about this approach?
Thanks a lot for your interest.
01-28-2009 11:03 AM - edited 01-28-2009 11:05 AM
What is the UI taking the place of in your architecture? In the models, the dialog is shown by the controlling execution's thread. That thread also owns all of the modeldata, thus there is no synchronization needed to access it. "testSocketData->testSocket" is NOT the sequence context. That is the data structure that stores information about the testsocket. The data structure is ultimately created as a local variable in the controlling execution of the model (the same execution that displays the dialog). See Locals.ModelData.TestSockets[] in the Test UUTs sequence. The elements of that array at runtime are what modelsupport2.dll stores in testSocketData->testSocket. Every variable in TestStand is a PropertyObject, including, but not limited to, the sequence context.
If all you want to do is override the dialogs and substitute your own UI, there is a simpler way. Rather than using any of the code in modelsupport2.dll you can just override it by modifying the process model.
In the ParallelModel you can do this as follows:
Also, thank you for your feedback. I'm a bit unclear as to what you mean though. Please explain what you mean by a model that includes both batch and parallel. Do you mean running multiple batch model executions in parallel? You might not be aware, but you can already run multiple instance of the batch model at the same time. Do you still want the parallel model UI too? If so you could just make a mainsequence in your client sequence file that uses a sequence call step to launch a batch model set of executions (use single-pass in this case). Another alternative is to just run multiple instance of your executions using the batch model. There is no fixed limit in teststand, other than what your resources will allow, for the number of executions you can create at once.
Anyway, hope this information is helpful. Please let me know if you need more information.
-Doug
01-29-2009 09:58 AM
I appreciated very much your suggestions about the bacth /parallel model. I wrote a post about this argument time ago but it was not so profitable. I will deepen this topic because the solution I implemented works but is not very elegant.
Thanks a lot.
01-29-2009 11:15 AM - edited 01-29-2009 11:20 AM
Hi logatto,
You asked how to communicate LV-->TS with UIMessages. Here is how:
Another issue you bring up is that to use Queues requires a sequence context. This is actually incorrect. You can use queues and other TestStand synchronization primitives without a sequence context. Although the Enqueue and Dequeue methods of the Queue interface take a Sequence Context pointer, you can and should pass a NULL reference (use an uninitialize reference in LabVIEW for this I think) in the case in which you are not accessing them from the code module of an execution. The online help describes this somewhat if you look at the online help for Enqueue and Dequeue for that parameter. You can even create new synchronization objects or access existing ones by name without a sequence context. Use the Engine method Engine.GetSyncManager and the SyncManager API interface to do so (see the online help for more information).
I think I understand what your architecture is now. Certainly it is a good suggestion for us to consider supporting this specific case in a future version. In the meantime you might consider doing the following:
Anyway, hope this is helpful. Let me know if you need more details about any of this.
-Doug
01-30-2009 07:42 AM
Thanks Dug, I made many steps forward in communication between TS and LV. Now I have to metabolize your numerous suggestions. I need some days to complete the OI. Then I'll be back on the architecture. You gave me some ideas that I would like to deepen. I'll open a new post on "running multiple batch model executions in parallel".
Thanks.
Logatto.