NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Link between num socket and threadId

Solved!
Go to solution

Hello,

 

As said in the object, I wonder if there is any relation between threadId and the UUT position (socket) ? 

 

Regards,

 

FranckH

0 Kudos
Message 1 of 5
(115 Views)

I guess I don't understand why you need to correlate them.  Sockets can have more than one thread.  Besides, at any point during the execution you can grab either (Thread.Id or RunState.TestSockets.MyIndex).  So correlating them doesn't make sense.

 

Maybe if you explain the need a little more there might be a better way to accomplish what you want.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 5
(87 Views)

I'm getting location from output message:

 

case UIMessageCodes.UIMsg_OutputMessages:

    OutputMessages outMsg = e.uiMsg.ActiveXData as OutputMessages;
    OutputMessages appOutputMessages = _engine.NewOutputMessages();
    outMsg.CopyMessagesToCollection(appOutputMessages);
    outMsg.Clear();
    foreach (OutputMessage outputMessage in appOutputMessages)
    {
         foreach (Location location in outputMessage.ExecutionLocations)

 

From this location, I could get a thread id:

 

location.ThreadId

 

So I was wondering if I could get Num Socket from this information ?

 

 

Meanwhile, I've successfully implemented a complex but functionnal solution:

 

case UIMessageCodes.UIMsg_OutputMessages:

(...)

foreach (Execution item in _appMgr.Executions)
{
    if (item.NumThreads > 0)
    {
         PropertyObject seqContextPO = item.GetThread(0)?.GetSequenceContext(0, out int frameId).AsPropertyObject();
         int testSocket = Convert.ToInt32(seqContextPO.GetValNumber("RunState.TestSockets.Count", 0));
         List<Execution> socketState = new List<Execution>();

         for (int Iindex = 0; Iindex < testSocket; Iindex++)
         {
             socketState.Add(seqContextPO.GetValVariant("RunState.Root.Locals.ModelPluginConfiguration.RuntimeVariables.PerSocket[" +                          Iindex.ToString() + "].Execution", 0) as Execution);

             if (socketState[Iindex].Id == location.ExecutionId)
             {
                 iSoc = Iindex;
             }
         }
    } 
}

 

With iSoc the socket index. Maybe there is a more straightforward solution, but I can't find any.

 

Regards,

 

FranckH

 

0 Kudos
Message 3 of 5
(80 Views)
Solution
Accepted by topic author FranckH

PropertyObject seqContextPO = item.GetThread(0)?.GetSequenceContext(0, out int frameId).AsPropertyObject();
int iSoc = Convert.ToInt32(seqContextPO.GetValNumber("RunState.TestSockets.MyIndex", 0));

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 5
(71 Views)

Thank you !

0 Kudos
Message 5 of 5
(59 Views)