08-27-2019 06:29 PM - edited 08-27-2019 06:43 PM
Hi,
I'm new in LVOOP. I'm trying to understand a few concepts to change a code from using a lot of references and clusters to classes.
Please see attached picture for reference. I put everything in one pic.
My question is basic... I'm using the "VI from dynamic dispatch template" (Untitled 7) to read and write data from/to the main class control (Test.ctl) which includes a Ring and a Numeric control. I'm able to read the information from the Test.ctl, but not to write new values on it.
What is the correct way to overwrite the values on the main class control Test.ctl? This is private data, so I'm not sure if this can be overridden, and if not,
What is the main purpose of creating a write accessor?
Thanks,
08-27-2019 10:01 PM
The code you show in the image works probably as you expect it to - the current values are displayed in the indicators and then the values from the controls are written into the class data.
I suspect the problem comes from your watching the private data (test.ctl). That's the default value you see - not the value of any particular object.
This is a crucial concept with LabVIEW OOP (and OOP in other languages more generally). When you write your class (.lvclass, the files in that class (ctl, vi, etc)) you are effectively writing a template for objects of that class. The wires on a block diagram can be of a class type - they carry objects of that class. However, when you write the values into an object, you don't change the template - you change the object.
Each time you drop a block diagram constant for a class, you create a new copy of it (a new object is instantiated) with the default values (as you see in the .ctl private data - you can modify these the same way you change a VI's default values: change the value in the control; select the control; choose Edit > Make Current Values Default).
The training available at the top of the forum has more detail about this, but feel free to ask more questions 🙂
08-27-2019 10:18 PM - edited 08-27-2019 10:19 PM