NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Find test socket index

Hi All,

I 'll try to explain better my needs.

I'm using simple GUI example of c# and I need for each event of "DisplayExecution" that occured what is the test socket index that referenced to it.

 

Please show me from which object should I get it.

 

private void axApplicationMgr_DisplayExecution(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_DisplayExecutionEvent e)

{

 

}

Tnx,

Liran

0 Kudos
Message 1 of 6
(5,202 Views)

DisplayExecution is not a good event for that because the socket is set in parallel in another thread, so it would be a race condition to access it from that event.

 

You should be able to use the UIMsg_ModelState_Initializing event, but there is a problem with that, which we will fix in a future release. Instead, you can use UIMsg_ModelState_BeginTesting:

 

void CTestExecDlg::UIMessageEventApplicationmgr(LPDISPATCH uiMsg, BOOL* cancel)
{
    UIMessagePtr message = uiMsg;
    
    if (message->Event == UIMessageCodes::UIMsg_ModelState_Initializing)
    {
        int socketIndex = (int)message->GetNumericData();
        // this doesn't work, but will be fixed in a future release
    }

    if (message->Event == UIMessageCodes::UIMsg_ModelState_BeginTesting)
    {
        int socketIndex = (int)message->GetNumericData();
    
        // this works, but note that you will get the message again for each UUT.
        // if socketIndex < 0, then it is not a test socket execution
    }
}

0 Kudos
Message 2 of 6
(5,179 Views)

Hi James,

Maybe you know how to get the number of test sockets before start executing the batch by code.


I understand that it contains in "ModelData.ModelOptions.NumTestSockets" but how should I get it programmatically.

 

 

0 Kudos
Message 3 of 6
(5,160 Views)

You could call ReadModelOptionDefaults in ModelSupport2.dll (see http://forums.ni.com/t5/NI-TestStand/Get-the-Number-of-test-sockets-by-code/m-p/2710969#M44191). You can pass the function an empty container. When it returns, the container will contain a NumTestSockets numeric sub-property you can access with PropertyObject.GetValNumber.


 

 

0 Kudos
Message 4 of 6
(5,140 Views)

Assuming you are needing this in a C++ executable, you can avoid the need to link with modelsupport2.dll and the cvi runtime engine by just doing the following:

 

      // This assumes that TestStandModelModelOptions.ini already exists.

        IEnginePtr engine = mApplicationMgr->GetEngine();
        PropertyObjectPtr container = engine->NewPropertyObject(PropValType_Container, VARIANT_FALSE, "", PropOption_NoOptions);
        _bstr_t modelOptionsPath = engine->GetTestStandPath(TestStandPath_Config) + "\\TestStandModelModelOptions.ini";
        container->ReadEx(modelOptionsPath, "ModelOptions", RWOption_NoOptions, ConflictHandler_UseGlobalType);
        int numberOfSockets = (int)container->GetValNumber("NumTestSockets", PropOption_NoOptions);

 

 

0 Kudos
Message 5 of 6
(5,135 Views)

Thanks a lot,

It works perfectly.

0 Kudos
Message 6 of 6
(5,104 Views)