03-08-2018 06:42 AM
Does exist any easy (or even more complicated - programmatically) way to edit LVOOP object constant ?
03-08-2018 06:50 AM
Are you talking about the class private data?
Anyways, you have to use LV development environment to modify things like that...
Maybe this helps you.
03-08-2018 07:09 AM
Lets say I have LVOOP class. Its private data (ctl) has some implicit values, always the same for all instances.
I need some instances to have different values from app start. I'm looking for the most simple way to solve this.
Solution A: create some "init value" static method for every class. And initialize all instances after app start. So non- implicit values = input of "init" method. All init calls collected in some VI. However this solution needs init method for every class, a lot of wiring (for every instance). Complicated.
I wonder if is it possible to edit object constant directly in LV environment. I know I can copy non implicit object data and paste to another object constant. But I need some edit phase to change that data.
Any ideas?
03-08-2018 07:17 AM
You can define default values in the private data of a lvclass as the private data is a cluster.
Every instance of that class will start with those default values, but it is highly recommended to add some "init" methods to clearly define the values from a caller point of view. Otherwise you rely on crypting data values coming from "somewhere"....
03-08-2018 08:41 AM
03-08-2018 09:19 AM
Does it mean that private data are random? I dont think so. It should have implicit value, right?
I don't need general advice. I know all that. I'm looking for specific methods/ideas... how to edit these values during project editing.
03-08-2018 03:38 PM
@petrnowak wrote:
Does it mean that private data are random? I dont think so. It should have implicit value, right?
I don't need general advice. I know all that. I'm looking for specific methods/ideas... how to edit these values during project editing.
No, they're not random. When you drop an object on the BD or FP, the private data contained therein will be the default values in the class definition. Although it's easy enough to change that, you said you wanted "some" of the instances to have different values. The only way to do that is to with code that changes the values at runtime.
03-09-2018 08:28 AM
@petrnowak wrote:
Does it mean that private data are random? I dont think so. It should have implicit value, right?
I don't need general advice. I know all that. I'm looking for specific methods/ideas... how to edit these values during project editing.
Here's an example of how to do something like that with an XControl.
Note: Using LVOOP objects inside XControls comes with a yuge caveat:
Whenever you make any change to the class definition, you should open & resave all XControl components that reference that class. Failure to do so can result in a LV crash the next time you open any VI with an instance of that XControl.
03-09-2018 11:58 AM
Create a dummy VI where you bundle in all the values of the class that you would like, and create an indicator of the class. Run the vi, right click the indicator, and select data operations>copy data, then you can paste that class constant on the block diagram, and it will have the values you put in. It will also show up on the diagram with a black outline.
Note that this is a terrible practice, and you shouldn't do it. How are other developers (or you in 6 months) supposed to know what data is in the class? As others have suggested, create an init method where you can set the data you want, and you can see what data the class is being loaded with.
03-09-2018 03:21 PM
Well, you could use this (if you find it handy, put it in C:\...\National Instruments\LabVIEW xxxx\project\)
Run the program. Then click on an object (FP or BD). You will be able to see & edit the data inside the object.