NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create data type programatically

Hello,
 
we are writing a custom sequence editor that will generate TestStand sequence. I can populate the generated TS sequence sequence with steps using primitive arguments like Boolean, String, Number. Our test methods also use structures and I am having problem with programatically creating custom data type that matches C# struct similarly as one would do in SeqEdit.exe
 
I am assuming that there is something to do with Engine.NewDataType() and create new container, but then where to add the returned PropertyObject for it to be a type in the current sequence with a name?
 
Roman
0 Kudos
Message 1 of 4
(3,580 Views)
 

Hi,

You can try this example, http://zone.ni.com/devzone/cda/epd/p/id/3606 

I know its a version 2.01 but it should still apply.

There is a CVI version and probably a labVIEW version on the NI website.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 4
(3,574 Views)
Ray, that's great. This pointed me to right direction, thank you!
 
In case someone else needs this; The example worked fine from TestStand, but not from C# :
 PropertyObjectFile[] typeFiles = MyEngine.GetTypePaletteFileList();
 PropertyObjectFile typeFile = typeFiles[0];
 TypeUsageList typeList = typeFile.TypeUsageList;
 string whyNotValid = typeList.ValidateNewTypeName(name, false, out isValidName);
 if (!isValidName)
  return null;

 PropertyObject newType = MyEngine.NewPropertyObject(PropertyValueTypes.PropValType_Container, false, "", 0);
 newType.NewSubProperty("MyNum", PropertyValueTypes.PropValType_Number, false, "", 0);
 newType.SetValNumber("MyNum", 0, 123.0);
 newType.NewSubProperty("MyStr", PropertyValueTypes.PropValType_String, false, "", 0);
 newType.SetValString("MyStr", 0, "AA");
 newType.Name = name;
 typeList.InsertType(newType, 0, TypeCategories.TypeCategory_CustomDataTypes);
 typeFile.IncChangeCount();
 typeFile.SaveFileIfModified(false);
 
SetValNumber and SetValString threw an exception on non-existing sub-property so I added the red lines.
 
There is one feature not mentioned in example - If you want to have the type in the sequence file instead of INI type files, it also works like this
 
 PropertyObjectFile typeFile = MySequenceFile as PropertyObjectFile;
 
Message 3 of 4
(3,558 Views)

That's great, thanks for the feedback

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 4
(3,553 Views)