LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating class members programmatically

Solved!
Go to solution

Hey folks.

 

I have written some code to update some class member VIs. Since the class locks, if you try to modify them directly, I am creating some temporary files and then copy them to the right location, overwriting the old files. This works apart from one detail. If you open the modified files in the project, Labview tells me, that the class owns these items, but the VIs don't excpect to belong to a class. Now I am asking myself, what I need to do to solve this issue. I was trying to open the class and make the VIs part of the class, but this does not work, since the class locks. Any ideas what to do?

 

Thanks.

 

Update LV class.png

 

EDIT:

To prevent confusion due to improper description, here is the error message Labview throws when openening one of the edited VIs in the class:

 

DrPolzPhotonics_1-1714748709439.png

 

0 Kudos
Message 1 of 5
(216 Views)

Instead of using "This Application", try using the attached VI.  The app ref it returns will live in a completely different memory space.

0 Kudos
Message 2 of 5
(188 Views)
Solution
Accepted by topic author Dr.Polz.Photonics

Hi,

 

What are you trying to update with your class members exactly?

It seems the file copy/replace and adding to the class is already a complicated workaround to something that could be done simpler.

 

Also, what locks your class is the fact that you have one of its constants on the block diagram of your executing script:

raphschru_0-1714771207254.png

Either:

 - Provide the class path directly (without using a class constant/control);

 - Use property "Library" of the VI class to access the owning library directly (which is actually a class);

 - Search through all project descendents an item which has the same name as your class (using "Get All Descendents" of the ProjectItem class)...

 

But we could be much more helpful if you stated exactly what you want to achieve.

 

Regards,

Raphaël.

0 Kudos
Message 3 of 5
(166 Views)

Hi Raphaël,

 

thanks for your reply. A little more context for you, as wished.

I have a class to control devices, which is based on a dictionary and drop down menues for easy function access. The functions will change in future or elements will be added. So I decided to code an VI to update the neccessary code via VI scripting, to make SW maintenance easier in the future. This works fine so far, except saving the files as part of the class to modify. The code which updates the class members is in a separate .lvlib to prevent interference. However, as you already pointed out using the class object locks the class.

 

What I actually wanted to achieve, is not being forced to hard code the path to the class. So I was looking for a way to dynamically load the path to the class.

 

As far as I understand your suggestions, the VI modifying the class members would have to be a member of the class themselves?

 

Cheers,

Jens

0 Kudos
Message 4 of 5
(69 Views)

Hi Raphaël,

 

I just realized that the library property is what I want. I can use that on the class member VI, whose reference I am retrieving anyway. Thanks for your thoughts.

 

Cheers,

Jens

0 Kudos
Message 5 of 5
(56 Views)