Jump to content

Cannot create "Strictly typed VI Ref" to a class


Recommended Posts

I'm trying to recreate Factory pattern provided by NI (Aristos Queue if I'm not mistken), but I've tried everything and I cannot create a Strictly typed VI Rev to a lvclass. Can someone please explain to me how to do that? I'm using LV 2009.

Thanks in advance, Mike

Link to comment

Mike5,

This link will describe many of the design patterns...

http://decibel.ni.co...t/docs/DOC-2875

In particular it has a zip file with an implementation of the factory method. While it does not create a static VI reference since a class is really not a VI, it uses the path of the class and converts it using the Get LV Class Default Value VI. This implementation is interesting because it does not load the desired class into memory until the Load By Enum VI is called (this VI is part of the project).

There are alternate ways to get the Factory to understand what classes it can create rather than an enumeration. Perhaps it could have a registration method where some other VI tells it to add a class path to its list - creating something like a name-value pair (probably implmented as two arrays - one with name, the other with path). The name would be something your application would use to tell the Factory to create. The value would be the path to the class. Alternately, if memory does not concern you, you can give the Factory an instance (rather than a path) of the classes it creates. The Factory would simply return the entry in its list based on the name it used to look up. Remember that as a data flow language, the class the factory got out of its list is an independent copy (unless you start using data value references in the class's private data). More on the DVR when you get to that point - there was an earlier thread on that subject.

I hope this helps.

Kurt

Link to comment

Mike5,

This link will describe many of the design patterns...

http://decibel.ni.co...t/docs/DOC-2875

In particular it has a zip file with an implementation of the factory method. While it does not create a static VI reference since a class is really not a VI, it uses the path of the class and converts it using the Get LV Class Default Value VI. This implementation is interesting because it does not load the desired class into memory until the Load By Enum VI is called (this VI is part of the project).

There are alternate ways to get the Factory to understand what classes it can create rather than an enumeration. Perhaps it could have a registration method where some other VI tells it to add a class path to its list - creating something like a name-value pair (probably implmented as two arrays - one with name, the other with path). The name would be something your application would use to tell the Factory to create. The value would be the path to the class. Alternately, if memory does not concern you, you can give the Factory an instance (rather than a path) of the classes it creates. The Factory would simply return the entry in its list based on the name it used to look up. Remember that as a data flow language, the class the factory got out of its list is an independent copy (unless you start using data value references in the class's private data). More on the DVR when you get to that point - there was an earlier thread on that subject.

I hope this helps.

Kurt

Thanks, I was looking at the Factory_UsingVIs.zip , which is referenced from a PDF with the same contents as your link. This one somehow creates that Strictly typed VI Ref which the Context Help then shows that is is really a reference to a lvclass. And that I could not recreate. I'll look at your example as well, thanks.

And, yeah, I do use DVR in the class private data.

Miha

Link to comment

Miha,

Ah, I see what you are trying to do. I have never used this approach yet. To get close to what is there...

I added the Open VI Reference function to my block diagram

I right clicked on the type specifier node and selected Create Constant.

I then right clicked on the newly created constant and selected Select VI Server Class. From that submenu selected Strictly Typed VIs.

Listed in that was Generic Plugin.lvclass, this was not in my project, but I added one later and the constant turned red.

Sorry, this sounds very non-technical, but perhaps it will get you farther.

Kurt

Link to comment

I'm trying to recreate Factory pattern provided by NI (Aristos Queue if I'm not mistken), but I've tried everything and I cannot create a Strictly typed VI Rev to a lvclass. Can someone please explain to me how to do that? I'm using LV 2009.

Thanks in advance, Mike

Hi Mike

You can also just browse to a path on a VI Refnum constant to get want you want.

post-10325-126896621385_thumb.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.