G#

cancel
Showing results for 
Search instead for 
Did you mean: 

Need easy Tutorials to Understand G#

Hi Everyone,

I am a beginner level programmer in labview. I have knowledge of workin in OOP Concept I know how to create objects and use them in Other languages like C#, Java, C++. I am trying to underdstand the  G#  like how to create objects and inheritance. I have gone through the help and know how to create a class in G# and methods need more help in understanding objects in G # how  to create them and use them.  going through examples in labview for a beginner like me does not help much. So if anybody could help me learn from beginner level that will be easier for me to sustain my new job

Thanks,

Bharath

Thanks & Regards,
Bharath Kumar
GCentral
0 Kudos
Message 1 of 16
(13,784 Views)

Hi,

Ok, if you know the concept of reference OO programing from other languages, the step to G# shouldn't be that big. Usually it is the OO programming itself that is the most difficult. If you have the knowledje of working with OO, then it should be more of a LabVIEW issue.

You have read the help I suppose, but try to check out the G# examples. Help->Find Examples and search for G#. You should have quite many "theoretical" examples, covering various aspects of G# OO implementation.

Maybe, not the answer you hoped for, but the best there is for now. I upload some examples I've used when having customer presentation of G#. Maybe they give you some clues.

Mattias

Message 2 of 16
(9,857 Views)

Hi,

Thanks for your help I am facing difficulty in the objects creation for the classes in G# is there only one object for a class or can we create as many as we want and you have Created an object of RS232 in the create method of  power supply class.

Plz help

Bharath

Thanks & Regards,
Bharath Kumar
GCentral
0 Kudos
Message 3 of 16
(9,857 Views)

Hi,

I'm not sure I understand your question, but of course you can create as many objects as you want. Just run the constructor as many times you need or place it in a loop. G# adds a nice feature that doesn't exist native in C# or Java and that is named objects, where you can lookup objects by name and easy create singletons or fewton implementation. The RS232 class is a named object.

However, if you take a look of the example (Help->Find Examples -> Search for G#) called G# - Creating and destroying named objects, you can play around a bit with object creation, also creating many objects of the same class.

/Mattias

0 Kudos
Message 4 of 16
(9,857 Views)

Hi,

The G# debugger could be useful to in real time see when an object is created and destroyed.
The G# debugger also show information about the object.

To turn it on select Tools->G# IDE->G# Debugger (from the menu bar in a VI).

Magnus

Message 5 of 16
(9,857 Views)

Hi,

Thanks for the reply i now know how to create a named object what i don't understand is that the inheritance how can you create object of one class in the create method of another class ?? . In the inheritance example Class super power supply is missing in the attachments. please give me a clear Idea of how inheritance works in the G# like some book or a document or something that could help and the scope of private util and what about the typedef  control used same as the class name and the class typedef control class attributes when is it used?? I know that the varibles are used in the  objectattributes typedef file.

I am sorry to ask so many questions but i am used to read from books and understand since I am not able to find any books on G# I get these doubts

Thanks again

Bharath

Thanks & Regards,
Bharath Kumar
GCentral
0 Kudos
Message 6 of 16
(9,857 Views)

Hi,

I tried to use the debugger when running the vi I can only see the trace but not the other option like objects tab and Active debug tab. please could you explain it in detail.

Thanks

Bharath

Thanks & Regards,
Bharath Kumar
GCentral
0 Kudos
Message 7 of 16
(9,857 Views)

Hi,

When you create a subclass, the create method will contain the create method of its base class that is correct. But this will not create a new object of the base class. As you can see, the reference is wired to the reference input of the base class create method. G# will sense this and not create a new object, just execute the constructor code in the base class. You could compare this to C#:

public class MyBaseClass

{

     public MyBaseClass()

     {

          // Any initialization code

     }

}

public class MySubClass:MyClass

{

     public MySubClass(): base() //This will call the base class constructor code.

     {

          // Any subclass initialization code.

     }

}

I'm not sure I understand your questions regarding the type defs etc., but I think you need to leard first how native LabVIEW classes without G# works first. The only tip I can give you is to study LabVIEW examples of native classes and the G# - CreateDestroy example. You can also in deep study the first three examples of the G#Demo I uploaded, it compares native and references based OO.

Sorry about the missing code in the examples. It shouldn't be there at all. I upload the correct version.

Mattias

0 Kudos
Message 8 of 16
(9,857 Views)

Hi,

If you press the Help button in the G#Debugger, the tabs are explained.

Objects - the objects allocated when the code is executing. Then execution is finished, no objects should remain. Put a break point in your code in the examples. The examples typically just creates, do some work and the destroys them.

Active Object - you must have your classes in a LV project. Click "Enable Active Debug", then you see all classes in the tree. You can then run constructor and methods one-by one without actually putting them in a main VI. This way you can test your methods "standalone". Usually you can't do that else, since the reference in is invalid without an object.

Mattias

0 Kudos
Message 9 of 16
(9,857 Views)

Hi,

what type of inheritance is followed is it hierarical or Multilevel ??

In polymorphism2.vi which is base class and which is child class how is it calling  agilent methods when power supply class method is called agilent and hameg is called. Like in java multilevel inheritance used likewise here?? and I have gone through the native objects in your example i have understood it.

Bharath

Thanks & Regards,
Bharath Kumar
GCentral
0 Kudos
Message 10 of 16
(9,857 Views)