NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read and Write Attributes Using the API?

Solved!
Go to solution

I am attempting to access (read and write) attributes of the following:

 

SequenceFile

Sequence

Sequence Steps

 

When looking at the TestStand API documentation, the following functions are available:

 

PropertyObject

Properties

Attributes (Read Only)

HasAttributes (Read Only)

 

Methods

DisplayAttributesDialog

 

I attempted to use SetValString and GetValString commands using the Attributes reference, but it does not seem the data is stored within the file.

 

I cannot find the following information within the TestStand API:

  1. Where are attributes stored within a property object?
  2. How can they be accessed through the API?

 

Any advice or information is appreciated!

 

CLA, CTA
0 Kudos
Message 1 of 10
(6,230 Views)

Hi LVB,

 

You should be able to access your custom attributes for each sequence file, sequence, or step by following the Attributes reference with your custom attribute name. 

 

For example, Step.AsPropertyObject.Attributes.<attributename> should let you then read or set a particular value. I hope this helps!

Best Regards,
Swathi B
0 Kudos
Message 2 of 10
(6,187 Views)

Swathi,

 

Thank you for the response.  I am currently usting the method you suggested.  Upon further investigation, it appears that I can access the attributes.  However, the attributes are not saved wehn I call the SequenceFile.Save command.

 

What is the suggested method to make attributes persistant and store within the Sequence File?

 

 

Thanks!

CLA, CTA
0 Kudos
Message 3 of 10
(6,170 Views)

You are likely changing the run-time copy of the sequence rather than the edit-time copy.

0 Kudos
Message 4 of 10
(6,165 Views)

After some further testing, this only occurs when writing attributes to the SequenceFile object.  The Sequence and Step property object values are stored upon the SequenceFile.Save command.

 

 

  • Is it possible to write attributes to a SequenceFile?

 

The fact I cannot find a way to access this through the TestStand Sequence Editor makes me curious.  However, the help file says that all PropertyObjects should support attributes.

 

 

From the TestStand 4.2 New Features Help:

 

 

PropertyObject Attribute Support
You can now create attributes for TestStand PropertyObjects, such as variables, steps, and module parameters. Use attributes to store additional information, such as the author of a sequence, about a PropertyObject within a sequence file or type palette file.

When you copy a PropertyObject, TestStand adds the attributes stored on the PropertyObject to the new copy. You can create attributes for properties of a type. Attributes of type properties specify the default attributes when you create an instance of a type.

Every PropertyObject includes an Attributes property, which is an unstructured container that stores arbitrary data. Although an attribute can be any kind of data, you typically create a name-value pair to give an attribute a name and a data value.

Right-click a PropertyObject on the Variables pane and select Advanced»Edit Attributes from the context menu to launch the Attributes dialog box, in which you can create and edit attributes. PropertyObjects with attributes include an Edit Attributes button in the Name column of the Variables pane.

Steps with attributes include the word Attributes in the step description, and the General panel of the Properties tab on the Step Settings pane includes an Edit Attributes button.

 

 

 

CLA, CTA
0 Kudos
Message 5 of 10
(6,160 Views)
Solution
Accepted by topic author LVB

You need to increment the change count of the file after editing it or the sequence editor (or UI) won't know to refresh or mark the file as modified. Use sequenceFile.AsPropertyObjectFile().IncChangeCount().

 

SequenceFile attributes are stored on the SequenceFile.Data object, not the SequenceFile object. You can edit them on the advanced tab of the sequence file properties dialog.

 

Hope this helps,

-Doug

Message 6 of 10
(6,152 Views)

Thank you Doug!

 

I have attached my working code.

 

Is there any documentation that explains the structure of the SequenceFile object?  How did you know the Data object contained the attribute information?

 

CLA, CTA
Message 7 of 10
(6,131 Views)

I'm not sure if it's documented anywhere (I'll pass along the feedback that it probably should be), but if you set some attributes on a sequence file in the sequence editor using the Sequence File Properties dialog box, then expand the SequenceFile property in the variables view, you will see an attributes button next to the Data subproperty which indicates that it has attributes. If you click on the button you will see and be able to edit the attributes you added with the Sequence File Properties dialog box.

 

Hope this helps,

-Doug

0 Kudos
Message 8 of 10
(6,111 Views)
Message 9 of 10
(6,102 Views)

Roy, sing your link, I was able to locate this documentation in the NI TestStand help file under:

 

NI TestStand Supplemental Reference Help --> Sequence Context --> RunState Subproperties --> SequenceFile Object Subproperties

 

Doug, I still think this should be mentioned under the NI TestStand API Reference Help.  Possibly under new SubProperties category or a See Also in the SequenceFile object description along with a more verbose description of where the data exists within the object.

 

 

Thanks for the help everyone!

CLA, CTA
0 Kudos
Message 10 of 10
(6,098 Views)