LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between Class private data and Controls (Typedef etc) in lv.class

Solved!
Go to solution

Dear All,

 

What is the use case of creating controls, Cluster(type def) etc. inside of class if class already  have private data as a cluster by default.

 

Thanks

0 Kudos
Message 1 of 9
(3,714 Views)

@LV_COder wrote:

What is the use case of creating controls, Cluster(type def) etc. inside of class if class already  have private data as a cluster by default.


If you want to use clusters or enums that are inside of the private data cluster, it still boils down to the same use for a type def: If you update the type def, everywhere it is used gets updated.  This includes constants, controls, and indicators that are part of the class methods or outside of the class.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,683 Views)

Hello,

 

In my experiences I use cluster in classes for grouping data.

One cluster for A group, second cluster for B group etc...

But if you don't have a lot of data in the class, cluster seems pointless.

 

Another reason to have cluster in class is if you already have data formed in that same cluster format.

Then it is easier to write and

 

I don't see any other reasons.

But I don't count my self as an expert, there might be some other reasons.

BR,

Jakob

0 Kudos
Message 3 of 9
(3,682 Views)

Please find the image attached, in the image what is the use for creating separate Stop typedef if we already have message.ctl. I have seen in some project that there is separate typedef.

 

Thanks

0 Kudos
Message 4 of 9
(3,671 Views)

Please find the image attached, in the image what is the use for creating separate Stop typedef if we already have message.ctl. I have seen in some project that there is separate typedef.

 

Thanks

Class Control.PNG

0 Kudos
Message 5 of 9
(3,670 Views)

I misunderstood the question in the first question.

 

Typdef are usefull like already meantioned by user .

With another words:

When you are building up a LOOP program you would (usually) have one same indicator in multiple VI's and classes.

If your are predicting that you will often do some modification to that same indicator through the process of programming, it is best to use typedef. You crate that typedef in your project, than you apply it to your class, VI and SUB VI's. Later, when you need to modify that indicator (typedef), you do it only once, and all the indicators/controls in class, VI and SUBVI's are updated.

 

You can still do it without typedef, but you would have to modify every indicator/controls in your class, VI and SUBVI's individually.

Hope that solves your mystery.

 

BR,

Jakob

0 Kudos
Message 6 of 9
(3,659 Views)

The <myclass>.lvclass:myclass.ctl file contains the private data of a class. This is always private, and can only be used by VIs that are members of the class. Other VIs (not in the class) can access this data only through accessor methods (Read A.vi, Write B.vi, etc).

 

The control you highlighted in your image (for example, myclass.lvclass:someOtherControl.ctl) is a member of the class (myclass). It can have an access scope just like a VI (private, public, protected or community) and can be used by other VIs/classes according to that setting. Often these are placed in the class to allow more restrictive settings than public to be used, but even when public they can be placed in the class to indicate the primary user of the control, etc.

 

Also, a class can have only one private data control, and as you've seen, can have many member controls. These can be used, as was described by others, to define typedefs, clusters of settings or parameters, or reference types (along with others).


GCentral
Message 7 of 9
(3,626 Views)
Solution
Accepted by topic author LV_COder

@LV_COder wrote:

Please find the image attached, in the image what is the use for creating separate Stop typedef if we already have message.ctl. I have seen in some project that there is separate typedef.

 

Thanks

Class Control.PNG


I'm left to assume that Stop Typedef.ctl is defining an enum.  So in this case, you need the enum defined in one place so you don't have to update it everywhere.  The private data cluster does not do this for you as all of the controls, indicators, and clusters will be separately defined.  It would be just like having an enum in a cluster and you tried to bundle the enum into the cluster.  Unless that enum is a type def, you will get coercion dots and possibly wrong results.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 9
(3,603 Views)

To add: If you want to use e.g. Enums as inputs to a public method the enum also needs to be public and then it's logical to have a public type def'd enum in the class.

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(3,586 Views)