LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create object in labview 8.5

hi all ,  i am new to labview object oriented programming, i have some questions on using classes and objects. basically i am from computer science back ground , i know very well about object oriented programming concepts and all. with the help of GOOP Development Suite i created class which contains methods. and data members. i think i am somewhat confortable with GOOP tool.
 
In C++, we just create a object and call the methods in the class  through object. here i am still searching how to create a object and how to link those with classes.
 
Please any of you help / guide me in how to create object, and multiple instance(object) of class 
if any of you having tutorial on object oriented programing material , please share to me.
 
Expecting you help...
 
Thanks in advance
 
Ram
0 Kudos
Message 1 of 11
(5,853 Views)
When you say GOOP Development Suite I'm assuming you're referring to Endevo's GOOP Development Suite, as opposed to LabVIEW's built-in OOP? If that's the case I would have thought they would have provided you with adequate documentation on how to use it as well as with examples.

You may want to take a look at this: LabVIEW Object-Oriented Programming FAQ.

You can also take a look at Tomi's video.
0 Kudos
Message 2 of 11
(5,830 Views)

hi thanks for ur relpy, yes i am using endevo GOOP Development Suite, Help files provided by endevo is not so detailed.

for example , they just gave how to create class, template class, add method , template method, edit icon only. i need to know how to create object & multiple object (instance) and how to call the methods in the class access through object, and all.

wants to know about object refnum ? is it necessary ?

Thanks for your support

Ram

 

0 Kudos
Message 3 of 11
(5,811 Views)

Hi,

 

Please find attached some demo code. It is two simple Counter classes. One is built using a plain lvclass and the other is built using a GOOP3 class, i.e. an lvclass extended to have a reference.

 

Open and run the ByValueApp.vi and the ByRefApp.vi. This will show you the difference in the two approaches and also how to create new by reference objects and modify the object data.

 

For those who haven't installed our GOOP Development Suite but still wants to check out the the example. Save the attached _goop3.llb in this folder:

C:\Program Files\National Instruments\LabVIEW 8.5\vi.lib\addons

 

The example code is in LV8.5

 

Thanks,

Jan Klasson

Endevo

Download All
0 Kudos
Message 4 of 11
(5,789 Views)

Ehhh for some reason the _goop3.llb seems to have been renamed to _goop31.llb during upload. Rename it to _goop3.llb when downloading.

 

Jan

0 Kudos
Message 5 of 11
(5,788 Views)

hi jank,   thanks for your support, i downloaded the shared sample, in some of the VIs are read protected, in sense, block diagrams are not able to open , it is asking password to show the content, especially in Creating instance VI (GOOP_Counter_New.vi).

is that GOOP_Counter_New.vi is Built-in function ? if soo.. guide me to achieve the same. if not .. tell me what to do next...

i coundn't able to add those utlities by right click on classes in Project explorer window and add those utilities as file.i am getting some error on doing this.

Thanks

Ram 

0 Kudos
Message 6 of 11
(5,751 Views)

Hi,

 

XX_New.vi is created by our tool and is password protected. How to create the code:

1. Decide what type of class to create. Native LV class (by value), Endevo GOOP 3 (by reference) or OpenG (by reference, BSD licensed).

2. Select the type of class in "Class Provider Options": "Tools->GOOP->Class Provider Options...", or click on the green tool button. Make your choice in "Current class provider to use".

3. Now you are ready to create a class. First create a project, or open your existing. (also open the help maual "Tools->Main Help", the "Create New Class" section.

4. Right click on "MyComputer" and select "New->GOOP Class". The wizard will guide you through two dialogs. First the Create Class Dialog and then the class icon dialog. The class icon dialog allows you to define a common header for the class VIs and also set color preferences for Public/Protected/Private. Click on the question mark in the upper right corner of the Create Class Dialog to get context help for the dialogs.

5. Now you should have a new class in your project.

 

Add method VIs:

1. Right click on the xx.lvclass you just created and select "GOOP->Add Method". (check the main help manual section: Create New Method)

2. Now you have the "Create Method Dialog" open (activate the context help by clicking on the question mark). This dialog allows you to define the method name (= the Class VI name), the method icon, the Method Template (affects the block diagram layout: read data, write data or read and then write data). "Method Type" allows you to select if the method should be a standard method or if you like to override a parent class (dynamic dispath) method or if you like to create a method which only reads/writes a selected data field (attribute) of the class, i.e. a "Property Method". You can also define visibility of the method and select method location (our tool adds Protected/Private project folders to the class).

 

Edit data of the class.

If it is a native class, i.e. a by value class: Open the "Class Name".ctl and edit the cluster.

If it is an Endevo GOOP 3 class (by reference): Open the "ClassName".lvclass/Protected/ObjectAttributes.ctl (from LV project explorer) and edit the cluster

If it is an OpenG class (reference class): Opent the "ClassName".lvclass/Definitions/Data/ObjectPrivateData_"ClassName".ctl and edit the cluster.

 

Hope this helps,

Jan

0 Kudos
Message 7 of 11
(5,742 Views)

hi jank, thanks.............

with the help of that XX_New.vi file only, we are creating multiple instances. is it right?

whenever loop executes, one instance will be create....is it right?

In the previously post, you just mentioned about ..... how to create class & method .. right .. thats not my question.

i want to know how that XX_New.vi is creating instances at every iteration, how the objects are handled and maintained in the project.  

if possible share the content of the XX_New.vi block diagram in picture format.

what my requirement is ; Totally i have 10 Test units, i have to test all the units using one method, that test should  be applicable to all the units, input parameters only vary. Here i need to create multiple instances to run the method Test() in the C_Test class.

Below C++ code help you understand the same.

 

Class C_Test

{

Test();

}

obj1.Test(unit 1);

obj2.Test(unit 2);

obj3.Test(unit 3);

.

.

.

obj10.Test(unit 10);

 

Hope you understand what i am expecting!

i know i am in very beginning stage..... help me !

Thanks

Ram

0 Kudos
Message 8 of 11
(5,733 Views)

Hi,

 

Ok, perhaps I should spend more time reading the question than replying to  it:-).

Second try:

In the counter (by ref) example there is only one (1) object created. The obj ref is passed back with the shift reg in the loop.

 

When you want a new object you call XX_Create.vi. This corresponds to the C++ constructor. The Destroy.vi is the destructor.

Call XX_Create.vi 10 times and you have 10 objects which you must later delete using Destroy.vi.

 

The XX_New.vi is a help method "malloc" which simply allocates memory for a new object which is thereafter initialized. If you look in the Create.vi block diagram you see that it first calls new.vi and thereafter calls XX_GetAttributesToModify.vi and XX_SetModifiedAttributes.vi, these two help VIs reads out all object data in a cluster, locks the object, and after your modifications XX_SetModifiedAttributes.vi writes the data back.

So, in your program you normally use Create and Destory to create and initialize new instances and remove them.

 

When you use inheritance Destroy acts as a virtual destructor (it is a dynamic dispath VI). Create calls its parent class Create to ensure data is properly intialized throughout the inheritance hierarchy.

Thanks,

Jan

0 Kudos
Message 9 of 11
(5,721 Views)

And about the input parameters. For example you can simply add controls to the XX_Create.vi to take whatever initialization data you like to provide to the object.

 

By convention we never add controls to Destroy (just as C++). The Destructor shouldn't depend on parameters to do its job.

 

Jan

0 Kudos
Message 10 of 11
(5,719 Views)