Jump to content

Storing LabVIEW class objects in TestStand object reference variables


Recommended Posts

Hi,

 

First time post. I find this forum very helpful for finding answers to LabVIEW questions. Hopefully someone can help me out.

 

This webpage confirms that I can do what the topic title says, but it doesn't say how. Does anyone know how to do this?

 

http://zone.ni.com/reference/en-XX/help/370052M-01/tslabview/infotopics/class/

 

"You can store LabVIEW class objects in TestStand object reference variables."

 

Thanks,

Chris

Link to comment

In the TestStand Variables view, insert an "Object Reference" variable.  One thing to keep in mind, this terminology is confusing because it only stores a "copy" of the data in the variable (since LVOOP is by value).  You must pass this variable in and out of all methods of the class.

 

An example on the NI website:

TestStand Using LabVIEW OOP Truck Example

Link to comment

Thanks for your quick reply lvb.

 

Is there a way to explicitly set a LabVIEW class to a TestStand object reference variable, using LabVIEW code? I.e., something like the attached diagram? (Note, I've run this code, but the object reference ends up being "Nothing".)

 

post-50511-0-31699100-1396381312_thumb.p

Edited by ccarner
Link to comment
Thanks for your quick reply lvb.

 

Is there a way to explicitly set a LabVIEW class to a TestStand object reference variable, using LabVIEW code? I.e., something like the attached diagram? (Note, I've run this code, but the object reference ends up being "Nothing".)

 

attachicon.gifLabVIEWclassAsTestStandObjectRef.png

 

What exactly are you trying to accomplish with this code?  Typically, you want to be reading and writing variables related to a sequence or sequence file (Locals, FileGlobals, StationGlobals).  I would suggest using the TestStand - Set Property Value with the SequenceContext from the execution.

Link to comment

I have a custom interface for TestStand sequence execution, written in LabVIEW. I have custom data in my custom UI (living in a LabVIEW class instance) that I want a TestStand sequence to be able to access. What I was hoping to do was pass my LabVIEW class instance to the sequence as a TestStand object reference, and have the TestStand sequence call class-specific VI's to read/write the data.

 

As for your suggestion, how does using the SequenceContext differ from using the Execution object? They're both TestStand PropertyObjects.

Link to comment

I wanted to do the same thing; but I had a discussion with some TS developers who told me this is not possible.  What we need is to have PropertyObject.SetValVariant work for a LabVIEW object, or perhaps have a method something like PropertyObject.SetValLabVIEWObject, The only way to pass a LabVIEW object between TestStand and LabVIEW is through the VI's connector pane.  NI suggested posting on the TestStand feature request page.  I have been meaning to do that, but I haven't gotten around to it.  If you post a suggestion, I will vote for it! ;)

Link to comment
  • 2 weeks later...

As a work-around, there are a few things you could do:

 

1. Use a LabVIEW Queue to send the class between the sequence and the UI callback

2. Use Flatten/Unflatten string with "binary" strings in TestStand

 

-Brian

Link to comment

> PropertyObject.SetValVariant

 

This would be possibly technically impossible to ever implement.

 

The TestStand sequence is just that -- a sequence. The reference object that it has is a meta-dataflow -- the value is set when it comes out of LabVIEW and then can be read again by passing it back into LabVIEW. It maintains the same invariant of an immutable reference object because the value in the reference cannot be changed in parallel code. It is not a by-reference shared object; it is just a way of "branching a wire" from one LV call to the next", and just as you cannot set the value of one branch of a LV wire from another branch, you cannot modify the value of the object in the reference. So the value in the object reference is immutable between calls.

 

We have a technology that lets you do the shared-reference. If you want that, put your object in a Data Value Reference and then have TestStand pass the DVR value to different VI calls.

Link to comment
  • 8 months later...

I do use SetValVariant to set LabView objects to predefined object reference variables in TestStand. It works! I don't do this within LabView but in TestStand itself. But since both use the TS API it should make no difference. I don't know why OP's example does not work, maybe because he also tries to create the object reference variable per API. I use TestStand / LabView 2012.

Edited by Thomas_
Link to comment
  • 6 months later...

I do use SetValVariant to set LabView objects to predefined object reference variables in TestStand. It works! I don't do this within LabView but in TestStand itself. But since both use the TS API it should make no difference. I don't know why OP's example does not work, maybe because he also tries to create the object reference variable per API. I use TestStand / LabView 2012.

Thomas, 

Could you please take a screenshot of the part where you do this in TS?

 

Regards,

Thang Nguyen

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.