NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Stack Navigation

Hi,
 
I want to go navigate trough my call stack starting from the very top level like this: Runstate.Root.Runstate -> going down to where my execution is actually running ...
 
How can I do this?
 
Thanks,
0 Kudos
Message 1 of 10
(5,884 Views)

Hi,

The top level is actual the level that is currently executing. the next level is the caller and soon

for example

you are currently in a subsequence called from MainSequence which has been called from Test UUTs

therefore level 2 is your SubSequence found by using RunState. Using NameOf(RunState.Sequence) would give you the name of your SubSequence.

Level 1 is your MainSequence and you would use RunState.Caller.RunState. Using a statement like NameOf(RunState.Caller.RunState.Sequence) in you SubSequence would give you the name of the caller ie MainSequence and level 0 will be the Test UUTs sequence and you would use RunState.Caller.RunState.Caller.RunState.

There is a property that indicates the RunState level call CallStackDepth. When CallStackDepth == 0 then RunState.Caller doesn't exist.

Hope this hepls

Regards

Ray Farmer

Regards
Ray Farmer
Message 2 of 10
(5,871 Views)

Thank you Ray,

I was wondering if there is a way to do it from top to bottom (Runstate.Root.Runstate...) instead of from bottom to top (Runstate.Caller.Runstate.Caller. etc)

Do you know if this is possible???

Thanks again

 

0 Kudos
Message 3 of 10
(5,869 Views)
Hi,
 
Using the RunState.CallStackDepth, create a loop and appended to the lookup string n number of 'Caller.RunState' to get to the bottom.
 
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 10
(5,860 Views)

Hello all,

 

I found this forum thread while searching for some related information. I just want to post this help document on RunState.Thread.GetSequenceContext as a future reference for others that run into this problem. 

 

Cheers,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 5 of 10
(5,274 Views)

Hello, 

 

Here, in VB.Net, a reccursive function which allows to find the sequence callStack, even for parallel sequence call ...

The idea is to find the caller of the caller ... of the caller reccursivly !

 

Public Shared Function getCallStack(  ByVal sequenceContext As NationalInstruments.TestStand.Interop.API.SequenceContext) As String

 

   Dim result As String = ""
   Dim frameId As Integer = 0
   Dim caller As NationalInstruments.TestStand.Interop.API.SequenceContext = Nothing

 

   result = sequenceContext.Sequence.Name

   caller = sequenceContext.Caller

 

   Do
        If caller Is Nothing Then
            Exit Do
        End If

 

        result = caller.Sequence.Name & "\" & result

        caller = caller.Caller
    Loop

 

    Return result 

 

End Function

 

Manu.net
0 Kudos
Message 6 of 10
(5,140 Views)

You can also do (C# syntax):

 

int callstackSize = mainContext.Thread.CallStackSize;

 

string callstackstring = "";

 

for (int i= 0; i < callstackSize; i++)

{

    int frameid;

    SequenceContext currentStackItem = mainContext.Thread.GetSequenceContext(i, out frameId);

 

    if (i > 0)

        callstackstring+=  "\n";

 

    callstackstring+=  currentStackItem.CallStackName;

}

 

Hope this helps,

-Doug

0 Kudos
Message 7 of 10
(5,130 Views)

Hello,
I develop an application operator of testsrand in c#, and I etulise the order dowry Net, I want to get  the current sequence execution in a listview in c#
I do not arrive introduced the code
RunStat.CallStack in my code
here my code

 

private void btnStart_Click(object sender, EventArgs e)

{

affichageDeroulementTest.Clear();

 

// Execution de Programmme

myExecution = myEngine.NewExecution(mySqFile,

"Test UUTs", mySqFile.GetModelSequenceFile(out sDummyString), false, 0, null, null, null);

 

 

 

}

 

 

Please

it is somebody can help me has recovers the sequence in the course of execution

thank you;

0 Kudos
Message 8 of 10
(4,948 Views)

As seen in this link, GetModelSequenceFile will get the process model sequence file of "mySqFile," so I'm not sure if that's what you are wanting based on your description:

http://zone.ni.com/reference/en-XX/help/370052G-01/tsapiref/reftopics/sequencefile_getmodelsequencef...

 

This also is quite an old thread and I'm not sure how related your question is to the original post, so you might get more visibility on a new thread!

Michael Keane
National Instruments
0 Kudos
Message 9 of 10
(4,912 Views)

Thank you KeaneSensesSmiley Indifferent

0 Kudos
Message 10 of 10
(4,808 Views)