Access to RunState in C#

Hello to everyone,
I am using TestStand 2010 SP1 and Visual C# 2008.
In C# I use the TestStand API (NationalInstruments.TestStand.Interop.API).
I have a step in TestStand where I pass all the context to the C# code (NationalInstruments.TestStand.Interop.API.SequenceContext MyContext)
I know how to access to the StationGlobals, Locals, ... through these methods: MyContext.StationGlobals.GetValBoolean("BoolExample", 0);
My problem is:
For example, in TestStand I can access to a variable (that is a step of a subsequence) called RunState.SequenceFile.Data.Seq[0].Main.[0]
but I don't know how access to this part of the RunState... and also others...
Thanks to all of you.
Much thanks for your time and dedication!

Either:
myStep = MyContext.SequenceFile.GetSequence(0).GetStep(0, StepGroup_Main);
or
myStep = MyContext.AsPropertyObject().GetPropertyObject("RunState.SequenceFile.Data.Seq[0].Main.[0]", 0) as NationalInstruments.TestStand.Interop.API.Step;
Hope this helps,
-Doug

Similar Messages

  • Unknown variable or property name 'ReportFilePath'. Error accessing item 'Runstate.Root.Locals.ReportFilePath'. in TestStand

    Hi all.
    I was using Teststand 4.2 up to last week and upgraded to TS 2013. In 4.2 I was using the following to get the location of the teststand report:
    Runstate.Root.Locals.ReportFilePath
    but with TS 2013 this no longer works.. is the following error:
    Unknown variable or property name 'ReportFilePath'.
    Error accessing item 'Runstate.Root.Locals.ReportFilePath'. in TestStand - Get Property Value (String).vi->
    I've tried the following now with no success:
    RunState.Root.Report.Location
    So my question is how can I get the location (path) of the report file during test programmatically please?
    Please find enclosed a screenshot of the report config:
    Solved!
    Go to Solution.
    Attachments:
    TS_ReportConfig.png ‏42 KB

    Shashidhar,
    Thanks for your help! With your tips, I finally got it to work. For anyone else trying to modify report names based on user input after the sequential process model sets the file name path I will re tell what I did:
    Edit the Ni_RerportGenerator.seq plugin found in C:\Program Files (x86)\National Instruments\TestStand 2014\Components\Models\ModelPlugins\
    You go into this file and add the step higlighted in Blue at that same location. Please see the expression I typed in the expression box. Setting Parameters.ReportOptions.NewFileNameForEachUUTStatus to true forces re-evaluation of the report name at the end of the sequentialmodel.seq.
    Then you add a FileGlobal in the sequenatialmodel.seq. I called my FileGlobal ReportFileName
    Then I added an expression in my test sequence that modified the the new FileGlobal I created:
    Finally I updated the report options (Go to Cofigure>Report Options > Report File Pathname and under File/Directory Options select "Specify Report File Path by Expression" and I entered my expression. It appears that you can disregard the evaluated report file path error (box below) because your pathname won't be generated until run-time.
    This worked well for me hopefully it will for others. 
    Thanks,
    Marco

  • How do I access RunState via the C interface?

    I'm utilzing TestStand by controlling it via a C++ program and TestStand as a COM module.  I haven't been able to find how to access the RunState property.  Thanks.
    -G-

    Hey Grasshopper,
    I'm not certain, but it sounds like you are building a User Interface in C++ to operate your sequences, much like the one you can find at C:\Program Files\National Instruments\TestStand 3.1\OperatorInterfaces\NI\Full-Featured\C++ using MFC.  If this is the case, then the way to get access to the RunState property is by utilize UIMessages.  You should be able to do a search on the forums or in the Developer Zone and find some more information and sample code about UI Messages, but in a nutshell, you'll send a message to the User Interface that you are building by utilizing the ActiveX adapter (Action Step) in a TestStand sequence (The Method is PostUIMessageEx and can be found in the Thread class).  When you send the data you will want to send ThisContext via the ActiveX parameters.  You will then use the ApplicationMgr Control in your UI to register the UserMessage event and then create a function to be called when this event does occur.  In this function, you can get the Sequence Context from the ActiveX parameter and at that point can handle it just like any other code module to get and set items within your locals, runstate, or whatever you want.  That should give you a start, let me know if you into major issues.
    Adam B. 

  • How to get selected sequence in a file

    Hello,
        I can get the selected sequence file by accessing the RunState.InitialiSelection.SelectedFile property. However, if i want to get the name of the sequence that was selected in this sequence file, then how can i get that?
    Thanks,
    Regards,
    Aparna

    Hello,
       Sorry, i saw this thread a little late. My question is still the same. The solution that you gave actually gives me the display name of the sequence file. But i wanted the name of the sequence that was opened withtin the sequence file. Here is what i have.
    A sequence file named TestExport.seq has two sequences  - MainSequence and SecondSequence. I open up the sequence file and open the SecondSequence in that file. But i dont know how to get this information about the sequence that is selected within the file. I have an external dll, in which i am passing the sequence file name as RunState.InitialSelection.SelectedFile. But i do not know how to get the sequence name that was actually opened in that file. Because i actually want to get the sequence context of the sequence within the file. The code that i have looks like this:
    public ExportDlg(SequenceFile seqFile)
                InitializeComponent();
                SequenceContext seqContext = seqFile.NewEditContext();
                engine = seqContext.Engine;
                object outParam = System.Type.Missing;
                this.seqContext = engine.NewEditContext(seqFile.GetSequence(0).AsPropertyObject(),System.Type.Missing,out outParam);
    seqFile.GetSequence(0) - gives me the context of the first sequence which is MainSequence. But if i have opened the SecondSequence, i need the context for that. And to get this, i need the sequence name "SecondSequence" somehow.
    RunState.InitialState.SelectedSequences is an array of containers. Although i can see the sequence name during executing, i do not know how to get the name of the container my external dll .
    Please help,
    Thanks,
    Regards,
    Aparna

  • Main Sequence Result

    I need know the main sequence result (pass, fail, error) in the postuut sequence to control my test handler. How can I determine the main sequence result in the postuut sequence? 

    Hey Jimbo50,
    I assume when you are talking about the MainSequence result, you are referring to whether the MainSequence passed, failed, terminated, etc.  The PostUUT callback in the default NI Sequential Process Model already tests for these different results.  They can be accessed from RunState.Sequence.Main["MainSequence Callback"].Result.Status.
    Again I would highly recommend looking at the default PostUUT callback because I believe it is testing exactly what you are looking for.  Hope this helps!
    Message Edited by Patrick P. on 04-05-2007 10:14 AM
    Pat P.
    Software Engineer
    National Instruments

  • Accessing properties like "Runstate.​LoopIndex" in sub-sequen​ces...

    OK.  I know you can grab individual properties and pass them as parameters (which is what I am doing), but I was wondering how I might do it more elegantly...
    I have a Top level sequence that calls a Test routine, and I set the Looping property of that routine.  This in turn calls a sequnce "Report" that passes the loop status back to the Interface.
    I tries to pass the RunState object down to my sub-sequence.  But there is no "AsRunState" function, so I can't seem to access it's properties.
    Looks like I am passing down the 4-5 properties individually.
    Anyway, is there a way to do this? 
    Solved!
    Go to Solution.

    Well, in that case there are a couple options.
    You could use RunState.Caller.Runstate.Caller.Runstate.LoopIndex​, where you reference "Runstate.Caller" for as many levels back up the list you need to go. This is somewhat kludgey if you don't know how many levels you need to traverse.
    If you know that you're starting from the MainSequence, then Runstate.Main.LoopIndex will give you what you want - you should be able to see almost everything in the runtime of the MainSequence from here.
    Passing ThisContext as a parameter also worked - I experimented with both methods and got the same results for the LoopIndex value.
    The above being possible, it remains to be seen whether or not this is a good idea to implement... use at your own risk!
    Is this what you're looking for?
    -Jack

  • Accessing the elements in the Runstate.S​equence.Ma​in array

    I want to change the "Record Result" property of a step on the fly. I thought I could use the function TS_SetValPropertyBoolean for this. As a lookup string I used "Runstate.Sequence.Main[i].RecordResult" but this caused a run-time error. I found that there is a step property RecordResult from Programmer's Help. Runstate.Sequence.Main is an array of containers and the elements of the array are the steps of the main sequence. TestStand prefers to use ...Main["Step Name"] but since I have hundered of steps to manipulate I prefered to use the indices in a loop instead of writing a line of code for each step.
    How can I do this operation in a "compact" way? I just want to turn on/off the result recording of some steps
    at run-time.
    I think I made my problem clear.
    Any comments, suggestions welcome.
    Thanks in advance..
    Eren

    Hi Eren,
    you've got the right idea, you just need to evaluate the string you're passing.
    You can actually do it in a statement -
    Evaluate("RunState.Sequence.Main["+Str(Locals.Step​Index)+"].TS.NoResult")
    You could even set this step to loop, and use the Runstate.Loopindex instead of Locals.StepIndex as above - the Locals.StepIndex is just a variable I created for demonstration, and I fixed it to a value of the index of the step I wanted to turn result collection off for. - NOTE set this to a TRUE to run OFF result collection for the step.
    Since in your example, the "i" is embedded in a string, TestStand can't work out what it evaluates to.
    If you wanted to do this from say CVI, then format the string you're using to do the same function as calling Eval
    uate in TestStand, i.e.
    Fmt(lookupString,"Runstate.Sequence.Main%[%d%].TS.​NoResult",i); (think I got the square brackets specified correctly.)
    Hope this helps
    Sacha
    // it takes almost no time to rate an answer

  • Can't access results dynamically because of callback API

    LV6 TS1 - posted a question a week ago about accessing the step results to display immediately on a step failure. Ray kindly pointed me in the right direction where the TS example used RunState.PreviousStep.Result.etc to access the various data. I thought I was saved, but........I use a SequenceFilePreStep to post a UI message. This is a subsequence, so by the time I try to grab this resultant data, of the previous step I am mired in the SequenceFilePreStep subsequence, so the RunState.PreviousStep object is invalid. How can I get the Result.ReportText, .Limits etc?

    Hi ET,
    Just a small demo sequence to show how you might achieve what you what.
    Step through the sequence to get a idea whats
    going on
    Regards
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    previousstepresult.zip ‏26 KB

  • RunState results not updating

    Hello All,
    I am having a problem with RunState.PreviousStep.Result.PassFail variable. It is continue to read as fail when the previous step was shown as pass on the screen. I also get the same problem when accessing the Result.PassFail using the step ID instead of previous step.
    Why is the variable wrong? What can I do to fix it? Thanks.
    Solved!
    Go to Solution.

    I suspect the problem is that your pass/fail step is looping and the final status is not directly reflected by the property you are checking. You should use the precondition builder (the buttons near the precondition expression) for the precondition expression instead. It has predefined preconditions for things like a particular step passing or failing. It checks the Result.Status of the step rather than the property you are currently looking at.
    -Doug

  • Error -17501 in Teststand3.1 when accessing SelectedSteps

    If I try to query the property SequenceContext.SelectedSteps, I'm getting the errorcode -17501 (Unexpected Operating System Error).
    This happens only in Teststand 3.1 not in Teststand 2.0.1.
    I tried Labview6.1 and 7.1, but it returns always the same error.
    Attachments:
    GetSelectedSteps31.vi ‏35 KB

    LVFan -
    Starting in TestStand 3.0, we had to support vtable access to our COM API, so the entire API was touched. It appears that internally when returning arrays for the sequence context, we incorrectly validate the type of the elements and we throw an error when the type appears to be incorrect. It appears this problem occurs in 3.0 and 3.1.
    A workaround is to use the property object interface, i.e. call
    object = context.AsPropertyObject()
    stepArray = object.GetPropertyObject("RunState.InitialSelection.SelectedSteps", 0)
    Thank you for bringing this to our attention.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • How do I access the groups selected in DisplayNewUserDialog?

    I am developing a user manager for a deployment so that the production floor manager can add users as they are trained. I modified the simple OI to add a button "Manage users", which is implemented as a VI.
    I have this pretty much working except when I add a user using the DisplayNewUserDialog, I don't see any way to access the groups that can be selected in the dialog. Selecting a group in the dialog apparently does nothing. I save the user object that gets passed back from the dialog and that "sticks". But the group selection doesn't stick nor do I see any way to access the selection. Using the DisplayEditUserDialog on the same user object does properly save selected group membership(s) without having to make an extra call.
    I see that in the example CreateDeleteUsers.seq, there is a step "Add User to Group" which looks up the group by the name selected by the user. To paraphrase the steps:
    Add new user: RunState.Engine.UsersFile.UserList.SetPropertyObjectByOffset(0, 0x1, Locals.User)
    Add user to group (sets privileges): RunState.Engine.GetUserGroup(Locals.GroupName).Members.SetValStringByOffset(0, 0x1, Locals.User.AsUser.LoginName)
    I don't see how I can programmatically retrieve that group name ("Locals.GroupName" above) from the dialog box, nor from the user object that is returned from the dialog box. Is this a bug?
    Solved!
    Go to Solution.

    Update: I misunderstood the dialog somewhat. It allows you to copy privileges from a group, not select the group itself (although I still didn't see any evidence that the copied privileges stick either).  Since I want to put a newly added member in the "Operator" group, I will have to train the floor supervisors to first add the user and then edit (using the edit dialog) to add the user to the correct group. I'm kind of happy with the VI. Here are some screen shots:
    The current user cannot delete himself. If he has admin privileges, he can add and edit.
    Users with admin privileges can select from the list of users (alphabetized) and add, delete, or edit.
    Users without admin privileges can only change their own record, and only their password within that record.

  • Client fileglobal access by process model

    I have the same question as posted in knowledge base article:
    http://digital.ni.com/public.nsf/allkb/f970e072b4b41ef786256e30007505b2
    However, the stated solution in the knowledge based article appears to be unavailable for TestStand1.03.
    Basically I'm trying to access the fileglobals of a client from within the process model.  The only appearent path is the RunState.ProcessModelClient.Data.FileGlobalDefaults but this is just the default states of the client's variables.  I need the actual runtime copies.
    {section from the knowledge based article}
    Configuration for first step
    Object Reference: RunState.Execution
    Automation Server: NI Teststand API 3.0 (1.0)  TestStand API 1.0
    Object Class: Execution
    Action: Call Method
    Method: GetFileGlobals    (option is not available,  there is GetModelSequenceFile, GetSequenceFile, GetStates, and GetThread)
    Parameters
    Return Value: Locals.FileGlobals
    sequencefileParam: RunState.ProcessModelClient
    I'm actually using a CVI Dll to access the variables.  I'm passing in "ThisContext" and then using:
    CAObjHandle      SeqContextHandle = ThisContext passed from teststand
        tsErrChk(TS_PropertyGetValString(SeqContextHandle, &errorInfo, "FileGlobals.SoftwarePN",0,&pszKeyName));
    This works great for accessing the FileGlobals of the process model, but not for the fileglobals of the client.
    Maybe there is a different ObjHandle to get to the client, but I don't know where it is.

    Hi,
    Not sure if this is available in version 1.03, but have you tried setting the SequenceFile properties to use the same fileglobals for each execution. This maybe your only option if available.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How to get the Runstate variable of an external sequence called from the Client Sequence through Sequencecall?

    Hi,
               I need to change the runtime high and lo limit values of all the tests of the client sequence file before running it. My sequence file is having a SequenceCall which calls an external sequence. Can anyone tell me how to change/access the High and lo limit values of the external sequence test steps?
    Thanks,
    Jeyan

    Doug,
              I used the property loader method but I could not load the limits of any sub sequence call calling an external sequence file.
    I took the FlowRate_test.seq example from the NI Example folder "C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 4.2.1\Examples\PropertyLoader\LoadingLimits\LimitsFromExcelFile\UsingCVI". I created a sequence called PumpTest.seq in the same folder path. I then moved the Pump Test step from the FlowRate_test.seq to the PumpTest.seq. Now created a sequence call in the FlowRate_test.seq and called the PumpTest.Seq as the module path. When I execute the FlowRate_test.seq , I get the error as shown below:
    Attached is the Flowrate_Test.seq and the PumpTest.seq which should be there in the folder path "C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 4.2.1\Examples\PropertyLoader\LoadingLimits\LimitsFromExcelFile\UsingCVI".
    Let me know whether I am doing something wrong in this method. 
    My idea is to alter the runstate variable High and Low of Pump Test in the PumpTest.seq and then run the Flowrate_Test.seq.
    Attachments:
    PumpTest.seq ‏6 KB
    FlowRate_test.seq ‏11 KB

  • Where can I find RunState.Caller.Locals.UUT.SerialNumber?

    Hi guys,
    I was looking at an example with RunState.Caller.Locals.UUT.SerialNumber. The example compares a scanned serial numbers format to pass/fail.
    But I dont understand this RunState.Caller.Locals.UUT.SerialNumber variable. Where it come from?

    Hi
    RunState.Caller means that it comes from the calling Sequence
    and RunstateCaller.Locals means that you are a accessing the "Local" Variables of this Sequence
    Hope this helps
    Juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=

  • How to access Subsequences/callees properties?

    Is there any method to access properties or variable directly from caller to callee, without using parameter and global variable?

    Hi km9394,
    Yes, RunState.SequenceFile.Data.Seq[0] (this is usually the MainSequence).
    Therefore if you ahave a sequencefile with two sequencecalls eg MainSequence and SubSequence. Then the expression called somewhere in MainSequence
    'RunState.SequenceFile.Data.Seq[1].Locals.MyBoolean = True' will set the local boolean in SubSequence.
    I have attached an example. In the MainSequence a step changes the value of Locals.MyResult in SubSequence from 10 to 16.
    But once this has been changed it will always be set to 16. I haven't changed the ChangeCount so thats why the editor doesn't think the sequencefile has been changed.
    Hope this helps
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    Debug_Example7.seq ‏30 KB

Maybe you are looking for

  • Installing iTunes (Friend's problem)

    Hi there everyone. i have a problem with someone that is haveing trouble installing iTunes. I have already tryed the StandAlone for him/her but they reply with some message's this is the person's problem. (This was posted by him/her) This morning my

  • Increase Query timeout in Dashboard

    Hi,                     When we add  a query through query browser in dashboard after certain time the connection gets timed out if the system is idle . Normally we can increase time out for webi reports but where could we increase the time for the B

  • Drop on tree node

    hi i want to enable drag 'n' drop for a tree. it works mostly as expected, but it it is not possible to drop a node on another node which has no children. to make this possible, i had to set has_children to true for every node, even if the node has n

  • Sed rules to java regex

    Hi, what is the connection between sed regex rules and java regex rule. Is there an easy way to convert sed to java? or do i have to learn sed?.... Thanks

  • PLEASE help with 24p editing mixed with 29.97

    Hello--I am a newbie to all of this 24p editing. I shot a zombie movie last summer and have a MESS with the footage. Half was shot in 24p advanced mode on the Panasonic AGDVX100a with a 16:9 anamorphic lens, and half shot at 4:3, 29.97 with a Sony DV