From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-09-2014 11:54 PM
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
02-10-2014 03:51 AM
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
02-11-2014 05:04 AM
02-11-2014 05:22 AM
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
02-11-2014 05:35 AM
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
02-12-2014 11:57 PM
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
02-12-2014 11:59 PM
02-13-2014 01:43 AM
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
02-13-2014 01:51 AM
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
02-13-2014 05:59 AM
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