GDS(Goop Development Suite)

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions about ClassName_New.vi in GOOP4 Type C

Solved!
Go to solution

Hi all, 

I am new to GOOP toolkit, and I start to study this framework. 
Here, I have a several questions about "ClassName_New.vi" which is created auotmatically by the framework. 


The black diagram of this vi is: 

 

Diagram of ClassName_New.png

 

I lists my questions in the followings: 

 

1. 

This access scope of this vi is protected. It is further warpped into "ClassName_Create.vi" which is public, and   "ClassName_Create.vi" is a constructor to instantiate an object. 

There is an "Object name" input of "ClassName_New.vi", but I have no ideal about when I should wire "name of object" to this input and for what reason I should. 

 

Is this a way to get the reference of an object by name string in any place of a project? 

 

2. 

When the "Object name" input is not empty string, "ClassName_New.vi" will create or look up the existing object which has the same name. From the black diagram of "ClassName_New.vi", we know that there is a "Single Element Queue" (SEQ) accompanied with a "named object", and the reference number of this object is stored in this SEQ, not only in wire. 

But I find that there is no explicit code in "Destroy.vi" to close the reference of SEQ. Does the framework intend to close the reference by garbage collection? or Should I create an "object name" attribute for explicitly closing the reference in "Destroy.vi". 

Thanks for your kind help

 

Godel Sung

0 Kudos
Message 1 of 7
(2,454 Views)
Solution
Accepted by topic author godel

Hi,
And welcome to the world of Objects :-).
BTW you can find the latest version from here: http://opengds.github.io/

So below you are looking at the Object By reference design (That means you're not copying the object if you split the wire).

The name of the object behaves as a Named Queue, but you need to create a Public method that's called e.g. GetObjectByName(<Name>).
But maybe you should look at the Singleton Class Template, this is using the named objects to make sure only one object of the class is created.
Normal Objects often don't use "Named Objects".

But it's always used in the Singleton Templates but you are right how do you destroy this 1 element queue.
So in the clean up you can get hold of this Named Queue and destroy it like this:

MikaelH_0-1652999120572.png

I.e. Use Force Destroy=True in Release Queue

For normal object I do use named queues for a RS232 Object, and I name it "COM1","COM2" so if multiple object of the same com ports get created they all refer to the same object, that means I can control the access to the com port.
There is a short presentation here: https://www.youtube.com/watch?v=Iv9mTiiyYzw
And a long here: https://www.youtube.com/watch?v=VWsOIsn8fSA

And more videos are currently being created.

Message 2 of 7
(2,428 Views)

Hi Mikae, 

Thanks for your detailed explaination. 

Godel

0 Kudos
Message 3 of 7
(2,422 Views)

Just so you know, there is one difference between getting an Object by name vs getting a Queue by name.
Every time run run the Obtain Queue, regardless if you're using a name or not, the reference number you get with always be different, even if you get a Queue by name that already exists.
(That's why you always need to release an obtained Queue, if won't destroy it until the last caller releases it).
But for the GOOP4's DVR design you will get the same reference number back if the object already exists.
To handle the Destroy/Release of the DVR, I normally create a Class Attribute called "Creators" which I increment inside Create and Decrement in Destroy, and only if the Creators=0 in Destroy, then I'll destroy the DVR.
Class Attribute can be added with the "Add Design Pattern" function.
Class Attribute are shared between all objects of one class

0 Kudos
Message 4 of 7
(2,418 Views)

Hi Mikae, 

Sorry for bothering you again. 
Here, I have another question about ClassName_New.vi to dicuss with you. 

 

In ClassName_New.vi, there are "Disabled" subdiagrams which call ClassName_New.vi recursively. 
I have no idea about the purpose of invoking ClassName_New.vi recursively to instantiate all its "Parent" classes, although these subdiagrams are disabled. 

 

Thanks for your help

 

Godel

0 Kudos
Message 5 of 7
(2,271 Views)

Hi Godel,
An excellent question.
This disable structure is just to make it easier to modify this VI by scripting when needed.
If you look at a Child class, you'll see that this disable structure's enable case have been changed and the VI we call there is the New VI of the Base class.
By having this Disable Structure there it make the scripting much easier.
Also when you use the function to modify the inheritance of a class (changing a base to a sub class or a Sub class to a base class), the scripting code becomes so much easier :-).

0 Kudos
Message 6 of 7
(2,234 Views)

Hi MikaeIH, 

Thanks for your kind reply. 
I totally understand the <ClassName>_New.vi in GOOP4. 

Godel 

0 Kudos
Message 7 of 7
(2,227 Views)