LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatic save of LVOOP class default value

Solved!
Go to solution

Hi!

 

I've been stuck on this littel issue for some time now, maybe I can't see the wood for trees, maybe my intention is utopic Smiley Very Happy

 

Here is what I want to do: retrieve class default value from an existing *.lvclass (no prob so far), modify it in some sort of configuration programme and then save back the default value to this (or another) *.lvclass file.

The only intended editing is about changing the default value, not more, not less.

 

I have tried some VI server magic but failed (LabVIEW crashed) Smiley Sad

 

Any suggestions?

 

Cheers

Oli

 

0 Kudos
Message 1 of 5
(3,223 Views)

The similar thing has been discussed here, and the same reasoning should apply for LVOOP as to why dynamically changing the default value is not possible.

 

http://forums.ni.com/t5/LabVIEW/Programmatically-set-the-default-of-a-control/td-p/1656554

 

I would implement some sort of a constructor VI which conditionally sets a initial data using case structures. If the initial data should be determined outside of the process, use FILE I/O to read data to initialize with. You can save a class object data into string using "Flaten to String" function and read it back by "Unflatten from String".

 

Hope it helps 🙂

SK

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 2 of 5
(3,196 Views)

Well, I do understand this issues for controls, but I'm sill struggling to transfer this to the LVOOP issue.

 

Here's what I used to understand about loading class default values:

I'm able to load a class default value dynamically from disk as long as inheritance is set right (--> PlugIn Architecture).

So lets say I have a parent class A which has two children B1 and B2. So using the Get LV class default value.vi I'm able to load classes dynamically and cast it to class A (To More Generic Class). This way I can also load Class_B1.lvclass and Class_B2.lvclass and use dynamic dispatch.

Now, if B1 and B2 have basically the same class private data (let's say a Boolean) that only differs in default value (true/false) I have a similar case for loading as what I'd like to do for saving.

Having said that: maybe my intention should be be better described as modifying an existing class default value and save it as a new class.

 

I guess there is a reason why NI did not implement the saving part... just need to understand why Smiley Wink

 

Oli

0 Kudos
Message 3 of 5
(3,174 Views)
Solution
Accepted by topic author Oli_Wachno

Hello Oli

With some, as you named it: "VI Server magic", it is possible to edit class default data and save it as the same/new class. However, there are at least three major problems:

  • This is not possible in run-time engine, as it requires scripting functions available only during development
  • If you want to save modified class as new class, it would require to copy all the VIs and controls that belong to this class
  • It is simply unefficient.

So before we'll go further, could you explain more thoroughly, why would you want to to that? If you only want to have two classes, that are exactly the same but differ only in some data fields default values, this is absolutely not a good idea and not a good software design. And relying on default values might generally lead you to unexpected behaviour of your program sometime in the future, when you'll decide to change these defaults.

0 Kudos
Message 4 of 5
(3,163 Views)

The more I'm thinking about this, the more I think you're right.

First of all, I was completely missing the aspect of run time support for what I wanted to do... I tried to get around the usage of some kind of configuration file, but it seems I won't be able to. Anyway, that's life Smiley Very Happy

 

But... if anyone tries to achieve something similar like me: http://lavag.org/files/file/65-lvclass-api/ is a good hint

 

Regarding the question for the use case: initially, I wanted to build a model for sth like a test socket, that holds data, like for example test sequence (again here a class), which can be configured quite conveniently by the user.

The goal was to use as much of LVs API as possible.

 

Ok, let's continue with the config file approach.

 

Thanks for your help guys!

 

Oli

 

 

0 Kudos
Message 5 of 5
(3,154 Views)