LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write class data

Solved!
Go to solution

Hello,

I am looking for a solution to programatically write to the data of a LabVIEW class.
I want to create a method that reads an ini file and writes the data of the keys to the class data at runtime. The method should be flexible. So I do not want to code cases for the keys.
With normal clusters I would do this with vi server. I have not found a way to do this with classes.

 

I hope someone has a solution for this.

 

Thanks in advance.
D. Ackermann

0 Kudos
Message 1 of 17
(3,918 Views)

Are you referring to the set control value method of VI Server? You can set a class control value with VI Server but not the individual data members.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 17
(3,913 Views)

@DAckermann wrote:

Hello,

I am looking for a solution to programatically write to the data of a LabVIEW class.
I want to create a method that reads an ini file and writes the data of the keys to the class data at runtime. The method should be flexible. So I do not want to code cases for the keys.
With normal clusters I would do this with vi server. I have not found a way to do this with classes.

 

I hope someone has a solution for this.

 

Thanks in advance.
D. Ackermann


 

If I understand you correctly you are loking for a method to populate the private data of a class from an ini file. YOu would also like the approach to be flexible and allow you to easily adapt for child classes etc.

 

I had a similar desire when I switched to LVOOP. I never found a solution like using VI server functions to programatically put stuff in the right place.

 

This is "by design" since being able to "reach out and touch" the private data is a no-no.

 

But I have come to realize that what I thought I wanted was not really required once I started to figure out how to create my classes. Initially I was not decomposing my classes enough so I had humungous private data.

 

After properly decomposing the classes, the resulting classes only have a small set of values along with the classes of which they are composed. So adding new children is simple since there are only a small number of fileds to deal with. The componenet classes have their own methods to fill in themselves so...

 

I have lost all interest in trying to populate the private data programatically since "the need" is no longer there.

 

Alternatively...

 

You can write the

class data to file and LV is smart enough to unpack it into the proper class (evn if the class changes over time). Its hardly human readable but it should work.

 

Not what you wanted, I am sure.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 17
(3,907 Views)

Yes, I need to set the individual data members of the class somehow by name.

Is there any workaround?

0 Kudos
Message 4 of 17
(3,897 Views)

@DAckermann wrote:

Yes, I need to set the individual data members of the class somehow by name.

Is there any workaround?


Create access methods to those data memebers. As Ben stated above, this is by design in OOP programming. Nothing should have access to the internal data of a class unless it is through class methods.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 17
(3,895 Views)

Ooops, I did not see there was already a second reply.

 

In my projects I use ini files for configuration. I had a vi that would just put the ini file content in a cluster by vi server functions. So I only have to change the cluster and do not have to do any programming on the function that is loading the data. I am trying to rebuild this for the LVOOP class. But it seems not possible.

 

Thanks for your replies!

0 Kudos
Message 6 of 17
(3,893 Views)

@Mark_Yedinak wrote:

@DAckermann wrote:

Yes, I need to set the individual data members of the class somehow by name.

Is there any workaround?


Create access methods to those data memebers. As Ben stated above, this is by design in OOP programming. Nothing should have access to the internal data of a class unless it is through class methods.


 

If there was, Stephen would close that hole as soon as he learned about it.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 17
(3,891 Views)

Actually the data access would be through a class method. But this method would have to be able to reference the internal class data by name.

0 Kudos
Message 8 of 17
(3,888 Views)

A member method of the class can access the private data directly. Use and bundle/unbundle on the class wire wire to directly access the data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 17
(3,884 Views)

@DAckermann wrote:

Actually the data access would be through a class method. But this method would have to be able to reference the internal class data by name.


 

I still think I folow you and shared the same desire. I wanted to do something like what I explained in my Nugget on exploiting control references found here to LVOOP.

 

But as Mark and I have been saying, that type of access would break the "contract" the classes have with the data.

 

Ben

 

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 17
(3,881 Views)