NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I receive default UIMessages?

I use TestStand 3.5 ,Parallel Model, and LabWindow/CVI 8.0.
There are lots of posts which instructed users to utilize PostUIMessageEx and user-define messages to notify OI so that the OI can take
proper action after receiving events. It did work for user-defined message(>10000) if I use TSUI__ApplicationMgrEventsRegOnUIMessageEvent()
to register my message handler.
 
Yet I never receive any default UI Messages( Message ID = 1 ~ 37) via my message handler. On the other hand, the NI Teststand UI control library
 has provide a set of functions, such as: TSUI__ApplicationMgrEventsRegOnStartExecution(), I guess it maps to UIMsg_StartExecution (id=10).
 Am I correct ?
 But not all of the default UI messages has a corresponding function call. For example , UI_TileWindows
There is a C# sample:
private void axApplicationMgr_UIMessageEvent(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_UIMessageEventEvent e)
{
 switch (e.uiMsg.Event)
 {
  case UIMessageCodes.UIMsg_TileWindows:  // tile the windows the message specifies    
   TileWindows(GetForms(e.uiMsg));
   break;
  case UIMessageCodes.UIMsg_CascadeWindows: // cascade the windows the message specifies
   CascadeWindows(GetForms(e.uiMsg));
   break;
 }
}
 
It looks like it takes the same approach with my CVI program, i.e, use TSUI__ApplicationMgrEventsRegOnUIMessageEvent() to register a event handler.
But the difference is ,the C# sample can receive the TileWindow event, but my program can't.
Do I mistaken anything?
 
Moreover, in the parallelmodel.seq , there are several messages will be posted:
UIMsg_ModelState_Initializing,
UIMsg_ModelState_BeginTesting,
UIMsg_ModelState_TestingComplete,
UIMsg_ModelState_PostProcessingComplete,
UIMsg_TileWindows,
UIMsg_ModelState_Waiting
 
Can they be received on an Opertaor Interface?
If yes ,who is the message receiver? Application manager or execution view manager?
If there is any sample code provided, it woule be very appreciated.
 
Thank you
0 Kudos
Message 1 of 4
(4,002 Views)
Cipher,

I just tried this out in CVI and I did not see any problems capturing the TileWindows event.  I modified the Simple OI that ships with TestStand.  I included a line to register the UIMessageEvent callback function.

errChk( TSUI__ApplicationMgrEventsRegOnUIMessageEvent(gMainWindow.applicationMgr,       ApplicationMgr_OnUIMessageEvent, NULL, 1, NULL));

The function is defined as:

HRESULT CVICALLBACK ApplicationMgr_OnUIMessageEvent (CAObjHandle caServerObjHandle,
                              void *caCallbackData,
                              TSUIObj_UIMessage  uiMsg,
                              VBOOL *cancel)
{  
    char buffer[256];
   
    enum TSEnum_UIMessageCodes eventCode = 0;
   
    TS_UIMessageGetEvent (uiMsg, NULL, &eventCode);
   
    if (eventCode == 23)     // Tile Windows UI Message
    {    sprintf(buffer, "%s\0", "Tile Windows");
        TS_EngineDisplayMessageBox (gMainWindow.engine, NULL, "Tile Windows Message", buffer,
                                TS_MsgBox_Custom, 0, 0, NULL);
    }
   
    return 0;
}

If I have the ProcessModel selected as the Batch or Parallel Process Model and then execute a Sequence, then eventually I receive and can capture the TileMessage event.  Anything you can capture in C# is also capturable in CVI.

Let me know if you have any specific questions.

Tyler T.
0 Kudos
Message 2 of 4
(3,990 Views)

Hi, Tyler:

I try your sample code, and it did work in my CVI environment if I follow the same procedure to modify the simple OI.
But it still did not work in my own. Finally, I found the root cause until I use a compare-file program to compare the 2 projects.

I mis-recognize UIMessageEvent with UserMessageEvent, that's why I can get my UserMessagse events but not the UIMessage event.
As the ExecutionView Manage only has OnUserMessage event, I thought Application manager may use this event to receive both UI and User messages. 
Anyway, I can keep going for my program.

 

Thank you very much.

 

 

0 Kudos
Message 3 of 4
(3,975 Views)
Cipher,

Awesome!  Yes, the difference between the UserMessage event and UIMessageEvent is that UserMessage will only receive messages with event codes of 10,000 or above.  These event codes are designated as custom event codes for the TestStand user.  The ApplicationMgr should always be used to receive UI Message Events.

Let me know if you have any specific questions.

Tyler Tigue
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,962 Views)