ccarner Posted April 1, 2014 Report Share Posted April 1, 2014 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 Quote Link to comment
lvb Posted April 1, 2014 Report Share Posted April 1, 2014 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 Quote Link to comment
ccarner Posted April 1, 2014 Author Report Share Posted April 1, 2014 (edited) 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".) Edited April 1, 2014 by ccarner Quote Link to comment
lvb Posted April 1, 2014 Report Share Posted April 1, 2014 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".) LabVIEWclassAsTestStandObjectRef.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. Quote Link to comment
ccarner Posted April 1, 2014 Author Report Share Posted April 1, 2014 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. Quote Link to comment
Jeff Posted April 2, 2014 Report Share Posted April 2, 2014 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! Quote Link to comment
ccarner Posted April 3, 2014 Author Report Share Posted April 3, 2014 Jeff, thank you very much for the useful information. That answers my question, and saves me a lot more headache trying to find out how to make it work! Chris Quote Link to comment
lvb Posted April 11, 2014 Report Share Posted April 11, 2014 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 Quote Link to comment
Aristos Queue Posted April 14, 2014 Report Share Posted April 14, 2014 > 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. Quote Link to comment
Thomas_ Posted December 17, 2014 Report Share Posted December 17, 2014 (edited) 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 December 17, 2014 by Thomas_ Quote Link to comment
Thang Nguyen Posted July 10, 2015 Report Share Posted July 10, 2015 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.