LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Learn QMH with multiple loops

Solved!
Go to solution

Sorry, my question was how do you create the queue constant. Sorry for the confusion. But I'm trying what you said.

Thanks guys!

0 Kudos
Message 31 of 42
(1,307 Views)

Right-click on the reference output of the obtain queue primitive or on the reference wire and create a constant.

Message 32 of 42
(1,303 Views)

Thank you  very much Ravi! I got it now. it works!

0 Kudos
Message 33 of 42
(1,296 Views)

I have a new doubt. So as I said now I am working on OOP. I don't know whether to continue the thread or create a new one. But for now I will continue here. I have 4 classes. Data, Numbers, Strings and Booleans each have two data in its cluster. For Numbers, String and Boolean, you can imagine which one it is. But for Data, I wanted a generic data type. So I used two variants. Then I created a function Write Input for all classes, which is just entering input to the data in its clusters. But here comes the problem. Numbers, String and Boolean are child classes of the Data class. So my idea was to use the Write Input function from parent class itself in the main program and depending on the wiring it will execute the required one. That is, if I wire Numeric class to this, then I can give two numeric inputs and work accordingly. This was my attempt in learning inheritance. But the Write Input VI is giving an error that connector panes are different. Since I am using the same name Write Input in all classes, I need to use the same connector pane. This is the error 

"This VI doesn't match other VI's in the method, Connector Pane Terminal(s) are different. All VI's that implement a method of a LabVIEW class must match Connector Panes. To correct this, compare the Connector Pane of both this VI and the VI of an ancestor class that implements this method."

So is my thinking wrong. Where have I understood this wrong, or is it that my idea not possible, or I have to think of another idea to practice inheritance? I have attached the zip file for the project. Kindly let me know. 

0 Kudos
Message 34 of 42
(1,281 Views)

IMHO you should make a new thread with a proper topic, to attract other people, may learning or helping on that topic.

Make a link in both threads pointing to each other.

 

I'm trying to learn OOP, too, but not very effective 😞

0 Kudos
Message 35 of 42
(1,269 Views)

Since a child class overrides the parent, they must have the same connector pane. If you want different panes you must make it a non inherited method. Or you can use a common/general interface, like all of them having Variants as inputs which you in the functions convert as needed.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 36 of 42
(1,268 Views)

@govindsankar wrote:

I have a new doubt. So as I said now I am working on OOP. I don't know whether to continue the thread or create a new one. But for now I will continue here. I have 4 classes. Data, Numbers, Strings and Booleans each have two data in its cluster. For Numbers, String and Boolean, you can imagine which one it is. But for Data, I wanted a generic data type. So I used two variants. Then I created a function Write Input for all classes, which is just entering input to the data in its clusters. But here comes the problem. Numbers, String and Boolean are child classes of the Data class. So my idea was to use the Write Input function from parent class itself in the main program and depending on the wiring it will execute the required one. That is, if I wire Numeric class to this, then I can give two numeric inputs and work accordingly. This was my attempt in learning inheritance. But the Write Input VI is giving an error that connector panes are different. Since I am using the same name Write Input in all classes, I need to use the same connector pane. This is the error 

"This VI doesn't match other VI's in the method, Connector Pane Terminal(s) are different. All VI's that implement a method of a LabVIEW class must match Connector Panes. To correct this, compare the Connector Pane of both this VI and the VI of an ancestor class that implements this method."

So is my thinking wrong. Where have I understood this wrong, or is it that my idea not possible, or I have to think of another idea to practice inheritance? I have attached the zip file for the project. Kindly let me know. 


Hello @govindsankar , 

You have came across the intersection of a few core language concepts that are handled in a uniquely LabVIEW way. The core language topic are: 

 

1) data types

2) classes 

3) polymorphism 

 

Your choice of classes shadows built in LabVIEW data types and since in LabVIEW world, data types are primitives not classes it will be some work on your part to make a data type look and act like a class. Typically you would have an object that can be passed by wire, and as you extend the object, the child class/methods will override the parent methods but this has the soft requirement that the method inputs *should* be of the same data type (since LabVIEW is a static typed language) .

 

As you have noticed, this does not work when you have different data types as inputs. 

 

This is where polymorphism come in. You will need to make a generic base class object that all 'data type classes' inherit from. This base class will define the interface for the class and will have the 'write input' method. You will have to do a bit of a hack here and make the base class method a polymorphic VI that will accept the different data types, put the data in the correct class instance then you can pass the class wire out of that and apply your class methods to it. 

 

You can use the factory pattern to take in a data primitive and spit out an instantiated class object that is of the class that is determined by the input. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 37 of 42
(1,258 Views)
Solution
Accepted by topic author govindsankar

Hi Govind, we probably should have taken this discussion to another post, as suggested earlier. But I guess we can finish these thoughts and then please start a new post for any additional questions.

 

To expand on everything that @Jay14159265 already pointed out, here is some code based on your original example.

 

Instead of pair of numbers in a numbers class or pair of strings in a strings class, etc., I created a number class, a string class, etc. which closely matches with how we know and see these data types. The parent data class defines an Add method, with the child classes override. Number class just adds, string class concatenates. Both these classes have a To String override method.

 

The attached code shows Polymorphism, where an implementation is selected at edit time, and Dynamic dispatch, where an implementation is selected at run time.

 

Just some food for thought for your learning.

Download All
Message 38 of 42
(1,227 Views)

@Ravi, thank you. I think I got the idea. But now I have to do the same thing I did with QMH where I do a new program. Is there any website where I can find some questions to solve, questions with OOP and inheritance. Thank you. 

0 Kudos
Message 39 of 42
(1,179 Views)

Not a question/task, but this did helped me, especially where to click and find the basics.

https://www.linkedin.com/pulse/monthly-labview-reminder-2-object-oriented-part1-monaam-cld-cta-?trk=...

https://www.linkedin.com/pulse/monthly-labview-reminder-3-object-oriented-part2-monaam-cld-cta-

 

If you find a exercise, I would like to try it, too.

0 Kudos
Message 40 of 42
(1,169 Views)