NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Editing template window programmatically

Hello,

I have a vi which is using the UI controls.  It is going to be used for end user editing of a series of sequences, which will only use a subset of step types.  I have the insertion a palette correctly displaying all of our step types in the step types window, and all the statically defined template steps we have.   I now want to temporarily populate a template folder at run time, the contents of which will be a series of instances of a particular step type that whose properties are particular to the UUT under test at the time, so the  user can more easily set up that uut.

I am looking at the UI InsertionPalette control methods and properties, and the ConnectInsertionPalette methods/properties, but nothing is jumping out.  I see where I can get a reference to pages, then item, but the properties available after that are extremely limited, and don't seem to have what I need.  Is there a way to dynamically edit the templates window using the UI controls somehow?

I am already to the point of having a sequence dynamically defined which has all the instances contained in it, I just want to put that in the templates window, in a folder.

 

Thanks

David Jenkinson

0 Kudos
Message 1 of 5
(2,474 Views)

Hi David,

 

You are right, the UI Controls API does not expose all of the same functionality for the Insertion Palette that is available from context menus and manual manipulation. Future versions of TestStand may have expanded functionality for these and other similar controls, the developers are aware of this requested feature.

 

Luckily, you still should be able to accomplish dynamic template insertion. By accessing the TemplateFile PropertyObjectFile you can get access to the Data PropertyObject member of this PropertyObjectFile. The Data PropertyObject has a Root SubProperty which is the template information. 

 

From here, you can clone and insert what ever steps, variables, and sequence property objects that you desire into this Templates List.

 

Keep in mind that you can force these changes to the TemplateFile to be saved to disk by calling the IncChangeCount() method on the TemplateFile object.

 

In order to refresh the InsertionPalette you can post the UIMsg_RefreshWindows UIMessage using the PostUIMessageEx method.

 

Putting the following code in a statement step may help get you started:

 

Locals.fileref = RunState.Engine.GetTemplatesFile(0),
Locals.data =Locals.fileref.AsPropertyObjectFile.Data,
//make changes here,
Locals.fileref.AsPropertyObjectFile.IncChangeCount(),
RunState.Thread.PostUIMessageEx(UIMsg_RefreshWindows,0,"",Nothing,True)

 

If you are not quite sure what to start editing, visualizing the Data PropertyObject may help with this. Setting a breakpoint after executing the above series of expressions will allow you to look at the Data in the TemplateFile PropertyObjectFile using the watch view. Here is what it looks like for me, with 1 step template:

 

 

The three SubProperties here match the three default folders in the Templates List section of the Insertion Palette Pane; you can see the matching step template in the Steps folder:

 

 

 

I hope this helps!

Message Edited by Evan P. on 11-21-2008 04:28 PM



Evan Prothro
RF Systems Engineer | NI

Download All
Message 2 of 5
(2,413 Views)

David,

 

Attached is a sample sequence (TestStand 4.0.x) exhibiting the behavior you desire. I am curious of your particular use case, do you mind explaining what you are doing that dynamically generated templates are necessary?

 

On the surface it sounds like a better option might be using custom step types instead of templates (See introduction paragraph here in the Reference Manual for use cases of each). This would, in most cases, be a more robust solution for giving users a straightforward way to edit properties and parameters for commonly used steps. The "Edit Substep" is a powerful way to give sequence developers and testers easy access to testing parameters and setup while protecting the integrity of your structures and step types.

 

It is of course possible your situation warrants using templates instead of custom step types. Either way, this is good information for other TestStand users to be aware of that are looking at these concepts. 

 

Developer Zone Reference Manual : (See Chapter 13: Custom Step Types, page 13-4 in particular has information on Edit Substeps)

Developer Zone Tutorial: Creating Configurable Test Steps in TestStand

Developer Zone Tutorial: How Do I Make a Custom Step Type?

Message Edited by Evan P. on 11-24-2008 10:38 AM



Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 3 of 5
(2,381 Views)

Evan,

Thanks for the info.  I'll give that a try ASAP.

 

Yes we have made extensive use of the edit substep feature.  And yes it does provide for the end user to customize step type instances, and is in fact one way in which they could ( and do ) customize the step types in our current application.  The reason I want to additionally populate the template view with several custom instances of a particular step type, is just the amount of button clicks one has to go through to go through the edit substep vs. just dragging pre-defined instances from the template view.  It is only in the interest of test setup time, and ease of test setup, while still maintaining the ability to customize through the edit substep.  

 

I'll post on this forum when I get a chance to try this out (gotta finish up something else first).

 

Thanks again for the info.

 

Dave

 

 

0 Kudos
Message 4 of 5
(2,361 Views)

David,

 

Thanks for curbing my curiosity, sounds like a good use case.

 

While on the subject of substeps - an "OnNewStep" Custom substep can be a good way to give added usability to sequence developers. The TestStand Sequence Editor and User Interfaces calls any custom substep named "OnNewStep" each time you create a new step of that type.

 

Have a good Thanksgiving!



Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 5 of 5
(2,343 Views)