NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Step Type Execution

I've made a custom step type which calls a .NET module. In the Properties>>SubSteps tab I added an Edit type which opens a dialog for the user to enter parameters when they edit that step type. Then I added a Post-stpe type which I thought was what gets called when the step is actually executed in a sequence. When I run a sequence that uses one of these types, the edit dialog pops up again, then only after I close the edit dialog does the post-step run. I assume I read something wrong because I thought the edit step type should only get called when one is editing the custom step type in the sequence editor prior to actually running the sequence that uses that step.
0 Kudos
Message 1 of 10
(4,539 Views)

I actually copied the hp34401A custom step type example that comes with Test Stand and changed the parameters to use my functions and it works OK. I guess there is some setting somewhere I need to dig out.

 

Next I wanted to make the step type with .NET modules. But, I get an error when I try to edit it in the Sequence editor. It says it is not a .NET object. I created a pre-step in which I create in instance of that object and assign it to a Station global but apparently this isn't the way to do it. Any idea on how to do would be appreciated.

0 Kudos
Message 2 of 10
(4,528 Views)
John,
 
Just so we're on the same page, here's what I think you're trying to do:
 
In the pre-step substep, you would like to create a new .NET object, and assign it's reference to a station global.
Then in that step's module, you want to use that station global's reference to call methods or access properties of that object?
 
If this is the case, then remember that your object will not be created until the sequence begins to run.  So when you edit your module, the station global does not have a valid reference to a .NET object yet.  So even though you will get an error at edit time, if you have everything set up correctly, the station global will get the correct reference at runtime, and the module should run correctly.
 
If this is not the case, and you get errors at runtime, could you describe in a little bit more detail what you  are trying to accomplish, or perhaps post an example of the step that is having trouble?
Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 3 of 10
(4,471 Views)

Josh,

   I think the issue is with the Edit step. Before the custom step type ever runs in a sequence the desire is to be able to edit parameters via some custom mechanism. i.e. one of the main reasons for creating a custom step type is to override and customize the parameter enter\select functionality. When a user adds a step, usually the next thing he or she does is immediately right click and select to edit it and enter parameters. When one of these custom steps is added and you try to 'edit' it, here is where the problems start. If, as you say, the .NET object will not get instantiated until the sequence is actually run, you will never be able to access it and call its functions at edit time. I guess that's why all the examples I've seen use calls to C\C++ style dlls so no objects are involved.

   Clearly the problem stems from my misunderstanding of when a .NET object can and\or will be created in custom steps in Test Stand. It just seemed logical to me that one should be able to force creation of an object in a pre-step but I now know that isn't true. However, there has to be some step or event (possibly when the Test Stand environment loads for example) in which I can create any .NET objects I want to use in custom steps. Maybe I'll look into that. If it turns out to be too much trouble to do so, I will stick to doing things via direct C\C++ dll function calls. Most of our .NET modules are just wrappers of multiple C\C++ dlls anyways. If you have any more info or I'm mistaken in my thinking please let me know. Thanks again.

 

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

John,

I think I understand what you need to do now.

The problem here is that the 'pre-step' only happens before the step is executed, not before it is edited.  So when we try to edit it, we get these errors.

What you can use instead is a custom sub-step called "OnNewStep".  This custom substep will be called whenever an instance of the custom substep is created.  In your "OnNewStep" substep, you can check for the existance and validity of your object, and if it does not yet exist, create it.

You can find a little bit more information about OnNewStep here:
http://digital.ni.com/public.nsf/allkb/D94132BADCCAAD7D862572AE00741915?OpenDocument



Message Edited by Josh W. on 11-29-2007 05:05 PM
Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 5 of 10
(4,460 Views)
If you store your .NET object as a station global during edit time, save your sequence, the next time you open the sequence editor, the reference will be invalid.  What are you trying to accomplish by storing it here?  There might be a better way to do this.

Allen P.
NI
0 Kudos
Message 6 of 10
(4,454 Views)

Allen,

   I'm simply trying to use .NET objects in my custom step types. But, because you can't use an object until you ceate an instance of it, my delema is when and how to create them so they will be active prior to editing a step

0 Kudos
Message 7 of 10
(4,435 Views)
If you specify a .NET step in your post step, there is a checkbox that allows you to create a module then.  Is there a problem you were having in doing that?

Allen P.
NI
0 Kudos
Message 8 of 10
(4,430 Views)
I checked the "Create Object" box but I did so in the pre-step. But, as we've been discussing, it appears that this creation is not happening because when I add one of these customs steps to a sequence and try to edit it I get an error saying there is no valid .NET object. Unless my thiking is skewed, logic tells me any instantiation of an object would need to be do prior to the edit step so that is why I assumed it needed to be done in a "pre" step. But, it aperently this isn't the case. Maybe you know of some other steps that I may be missing that need to be taken for this to happen? Thanks in advance.
0 Kudos
Message 9 of 10
(4,427 Views)
You shouldn't need to use a PostSubstep and a PreSusbtep if you are just trying to create the object in the PreSubstep (unless you were intended on having users specify a code module too).  What do you have specified in your object reference for your PreSubstep and PostSubstep?  You need to point it to the same object reference if you are creating in the pre and using it in the post.  If you just use a post, you can create it and not store it anywhere and it will have a lifetime of the step.

Allen P.
NI
0 Kudos
Message 10 of 10
(4,425 Views)