From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-22-2014 12:49 AM
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
01-22-2014 10:44 AM
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
}
}
01-23-2014 02:25 AM
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.
01-23-2014 04:01 PM - edited 01-23-2014 04:09 PM
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.
01-23-2014 04:23 PM - edited 01-23-2014 04:26 PM
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);
01-26-2014 02:22 AM
Thanks a lot,
It works perfectly.