In a previous blog post called ‘Sequence Call Step Type vs. Sequence Adapter’ I showed how one can couple the Action Step Type with the Sequence Call Adapter to create a Sequence Call Step that does NOT return a ‘Passed’ status upon completion. Feel free to to read my previous blog post if you are wondering why I would want to do such a thing. However, for this post I do want to remind you that the reason this could not be done with simply using the Sequence Call Step Type is because of the fact that the Status Expression is defaulted to either return ‘Passed’ or ‘Failed’ as shown in the Figure below.
Now lets say that you decide to make this a best practice in your organization and want to ensure that all developers going forward will utilize the new coding standards and be consistent with their coding practices when using Sequence Calls. An ideal way to achieve this is by creating a Custom Step Type. In this blog post, I am going to expand on a previous blog post to demonstrate how to get started creating Custom Steps. In this case, to create a custom Sequence Call Step Type such that it does NOT return a ‘Passed’ status upon successful completion.
In order to do this I need to first access the Types window by clicking the Types icon as shown in Figure 2 or I can simply hit (CTRL+T).
Your screen should now look similar to that shown in Figure 3.
Now under the Type Palettes tree, highlight the MyTypes.ini and notice the ability on the right to create custom Step Types and Date Types. For this post, all I am going to worry about is the Step Types. So next, where it says <Right click to insert Type>, I am going to do just that and select ‘Insert Step Type’. Next, we need to name our new Step Type and for this example I will call it something crazy original like ‘CustomSequenceCall’. Note that the name cannot have any spaces or start with a number. Unfortunately, we aren’t done yet as there is still a little configuration left to go.
Once we have inserted a new Step Type we now need to configure it such that it will have the behavior we expect it to. In order to do this, we need to right-click on ‘CustomSequenceCall’ and select Properties to pull up the Properties window as shown in Figure 4 below.
At first glance, this dialog can be a little overwhelming but remember that the power of TestStand is the configurability and be rest assured that the majority of these options will be rarely used as you will see whenever we configure this step.
So on the General tab, we are first presented with the ability to select an Icon. Clicking on the ‘Designate an Icon’ checkbox will allow you to select from the combo box one of several options of Icons that TestStand comes with. Note however that a lot of Icons already have a specialized meaning in TestStand and that sometimes it might be better to create your own. If that is the case, the Icon files can be located in your Program Files>>National Instruments>>TestStand Ver##>>Components>>Icons folder. Once you have an Icon selected, next we are given the ability to define the ‘Default Step Name Expression’. This field accepts a String value representing what you want the Step Name to default to whenever you insert it into a sequence. I’ll demonstrate with images a little later, but for now note I am going to type in “New Sequence Call”.
The next field is called ‘Step Description Expression’. This field accepts a String value representing the text you want displayed under the description column in the Sequence Editor. Once again, it is easier for me to demonstrate with images a little later, but for now I will enter the string “My New Step”. Normally all of these fields would be named something similar, but for this example I want to differentiate between them so you can see exactly where each is used.
Finally, we have the ability to ‘Designate an Adapter’. If nothing is selected here, the developer has the ability to select any adapter during script development. For our example, I want to restrict the user to only be able to use the Sequence adapter. My final configuration for the General tab can be seen in Figure 5 below.
Once we have the General tab configured we now need to jump to the Menu tab to create an ‘Item Name Expression’. This field accepts a String value representing the text you want displayed whenever you right-click on the Sequence Editor and select a Step to insert into your sequence. For our example I will create another unique String called ‘Custom Sequence Call’. Our Menu tab should now be configured like that shown in Figure 6 below.
Default Expressions Tab
The final tab I want you to take a look at is the Default Expressions tab as shown in Figure 7 below. Nothing needs to be changed here, however this is the major difference between the default Sequence Call Step Type as shown in Figure 1 and our new Custom Step. Now whenever we insert our new step it will no longer override the Step.Result.Status to ‘Passed’.
We now have our Step Type fully configured and are ready to use it to create sequences. Click ‘OK’ to exit out of the Properties window and go to the Sequence Editor. Now right-click to insert your new Step and notice that your new step should be selectable on the menu with the ‘Item Name Expression’ text you defined under the Menu tab as well as the Icon you selected under the General tab as shown in Figure 8.
So next lets go ahead and select our Step Type to insert it into our script. The first thing that should stick out is that the Step immediately gets named what we defined in the ‘Default Step Name Expression’ and the description for the Step gets set to what we defined in the ‘Step Description Expression’ under the General tab. This is demonstrated below in Figure 9. Figure 10 shows that under the Step Properties->General option, the Type is set to CustomSequenceCall and the Adapter is set to Sequence. Now you should be able to see the direct correlation of all the properties we configured and where they get used.
Finally I created a really quick script that executes my step and shows the Step.Result.Status upon successful completion. The results are shown in Figure 11 and as you can see my new Custom Sequence Call now returns a Status of ‘Done’. Yay!
Now say you are super stoked about your new Custom Step and want to make sure all your Test Racks come equipped with it. Under the Type Palettes window, you have the option of saving your changes. You should notice an asterisk ‘*’ next to MyTypes.ini. If you decide to save your changes, TestStand will update the corresponding MyTypes.ini file. This file is located in the Users>>Public>>Public Documents>>National Instruments>>TestStand Ver###>>Components>>TypePalettes. You can simply take a copy of the modified .ini file and copy it into the appropriate location on your other Test Racks.
Secondly, if you are having trouble coming up with proper names for the different String fields under the Custom Step Types Properties dialog. Navigating to the NI_Types.ini directory and viewing a similar Step Type configuration is always a good idea. For example, in our case, since we essentially wanted to modify the pre-existing Sequence Call Step Type, we could have configured our Step to look like the regular Sequence Call Step Type shown in Figure 12 below.
In conclusion, Custom Steps are another powerful tool that TestStand has to offer. They offer a unique way to make both major and minor modifications to the predefined suite of Steps that NI has to offer. You should now feel comfortable getting started with creating Custom Steps and don’t hesitate to contact your nearest NI Field Service Rep or Alliance Partner (hint hint) if you ever need some extra help.