NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of TS_EnginePostUIMessage

Hello,
 
I am trying to send a UI message to a custom user interface.
I don't want to be dependend of the thread (or sequence context) therefore I don't want to use TS_ThreadPostUIMessage(..);
 
TS_EnginePostUIMessage seems to fit better, but I am not really sure how to use the thread and execution parameter.
The help says:

executionParam As Execution

[In] Specifies the execution to pass with the message.

threadParam As Thread

[In] Specifies the thread to pass with the message.

Do I have to pass a correct execution and thread object with the parameters? Or are these parameters optional?

 

 

0 Kudos
Message 1 of 11
(4,886 Views)

You can pass NULL references for these parameters if you don't want to use these parameters.

 

Allen P.

NI

0 Kudos
Message 2 of 11
(4,863 Views)
 
Hello AllenP,
 
thanks for your reply.
 
How can I pass a "NULL reference for these parameters" in TS_EnginePostUIMessage?
 
I have already tried:
1.)TS_EnginePostUIMessage(engine, &errorInfo, NULL, NULL, MY_CUSTOM_MSG, 0, "", NULL, VTRUE);
-> I get a CVI compile error message : "Type error in argument 3 to 'TS_EnginePostUIMessage': found 'pointer to void' expected 'TSObj_Execution'." and the same for argument 4
 
2.)
TSObj_Execution tsThreadObj = NULL;
 TSObj_Thread tsExecObj = NULL;
TS_EnginePostUIMessage(engine, &errorInfo, tsExecObj, tsThreadObj, MY_CUSTOM_MSG, 0, "", NULL, VTRUE);
-> compiler error message: "Operands of = have illegal types 'TSObj_Execution' and pointer to void." and the same for the thread object.
 
3.)
TSObj_Execution tsThreadObj = 0;
 TSObj_Thread tsExecObj =0;
TS_EnginePostUIMessage(engine, &errorInfo, tsExecObj, tsThreadObj, MY_CUSTOM_MSG, 0, "", NULL, VTRUE);
-> I get a error message during runtime of my dll : "User-defined error code. [Error Code: -2147467261] No description available."
This error code is defined in winerror.h and means:
   //
   // MessageId: E_POINTER
   //
   // MessageText:
   //
   //  Invalid pointer
   //
  #define E_POINTER                        _HRESULT_TYPEDEF_(0x80004003L)
 
First I thought the engine reference passed to this function is not valid, but the message is received correctly by my user interface (and the appropriate actions are done). So it seems that the thread and execution object is not valid, that might be true because it is 0 in this case.
 
4.)
In order to find out the right way to pass a "NULL reference" to this function I have also use with a TestStand ActiveX/COM step and played around with the parameters. By passing "Nothing" to the two parameters it seems to work, the TestStand help says, that NULL used in CVI is the correct substitution for "Nothing" in TestStand but it doesn't work -> 1.)
 
 
 
0 Kudos
Message 3 of 11
(4,841 Views)
One more information:
 
I also tried:
TS_EnginePostUIMessage(engine, &errorInfo,(TSObj_Execution) NULL, (TSObj_Thread) NULL, MY_CUSTOM_MSG, 0, "", NULL, VTRUE);
-> I get again a error message during runtime of my dll : "User-defined error code. [Error Code: -2147467261] No description available."
 
Strange to say that my sequence runs without any error message inside the sequence editor, but the sequence editor doesn't react on my custom UI message of course.
 
Can it be a problem, that the user interface is using the applicationMgr:
HRESULT CVICALLBACK ApplicationMgr_OnUserMessage(CAObjHandle caServerObjHandle, void *caCallbackData, TSUIObj_UIMessage  uiMsg)
{
   enum TSEnum_UIMessageCodes event;
 
   tsErrChk( TS_UIMessageGetEvent (uiMsg, &errorInfo, &event));
 
   switch (event)
  ....
....
}
 
Maybe the engine the ApplicationMgr uses is another than the engine of the sequence editor?
 
                   
0 Kudos
Message 4 of 11
(4,826 Views)

MaWie -
COM reference types in CVI are of type CAObjHandle, which are defined as:

typedef int          CAObjHandle;

I would suggest passed the number zero (0) instead of NULL. NULL  is defined as:

#define NULL    ((void *)0)

which is why you get the pointer type mismatch error.

So typically you would define a variable like this:

CAObjHandle thread = 0;

Message Edited by Scott Richardson on 09-18-2006 09:43 AM

Message Edited by Scott Richardson on 09-18-2006 09:43 AM

Scott Richardson
https://testeract.com
0 Kudos
Message 5 of 11
(4,814 Views)
Thank you for your reply.
 
I have already tried to pass a CAObjHandle variable defined with 0 to the function, look at my message from 09-17-2006 05:09 AM  numeration 3.).
I get this error number mentioned that means that the pointer is invalid (winerror.h). I am quit sure that the engine reference is valid, because the appropiate actions are done (passing an activeXparam).
 
It is strange that this error will not occur if I start my sequence from the sequence editor but from my custom operator interface.
 
 
 
0 Kudos
Message 6 of 11
(4,806 Views)

MaWie -
Sorry about that. Sending the zero value would be the correct way to do it. So it appears that sending the zero values for the custom UI message are resulting in an internal error inside the Application Manager control.

  1. What version of TestStand are you using?
  2. Can you try the UIMessage Event instead? You will have to get the UIMessage object and get the Event property to determine the UIMessageCodes value.
Scott Richardson
https://testeract.com
0 Kudos
Message 7 of 11
(4,796 Views)

MaWie -
When you debug the DLL, on what line does the error message "User-defined error code occur"? Can you even hit a breakpoint if you set it at the top of the event callback?

Scott Richardson
https://testeract.com
0 Kudos
Message 8 of 11
(4,795 Views)

MaWie -
I had some more time to look at this. I could not duplicate the problem in our current source code for TestStand. It appears that the problem occured in TestStand 3.5. The error appears to be internally to TestStand UI controls. The error occurs after you process the message. The error also occurs even when you use the generic UIMessage event; however, if you set cancel for the message, the UI controls do not process it and the error does not occur.

HRESULT CVICALLBACK ApplicationMgr_OnUIMessage (CAObjHandle caServerObjHandle,
                              void *caCallbackData,
                              TSUIObj_UIMessage  uiMsg,
                              VBOOL *cancel)
{
 int error = 0;
    enum TSEnum_UIMessageCodes event;
 
    tsErrChk( TS_UIMessageGetEvent (uiMsg, &errorInfo, &event));
    if (event >= 10000)
    {
     //process the message here
     *cancel = VTRUE;
    }
   
Error:  
    return 0;
}

Scott Richardson
https://testeract.com
0 Kudos
Message 9 of 11
(4,780 Views)
Thanks for your efforts, Scott Richardson.
 
Unfortunatly the maintainer of the source code of our operator interface is not at office this week,
therefore I will try to include your code snippet next week and tell you if it solves this issue.
 
At the moment I do a very dirty workaround in order to post the UI message with TS_ThreadPostUIMessage
and looking forward to implement your solution.
 
 
 
 
 
 
0 Kudos
Message 10 of 11
(4,760 Views)