mike5 Posted March 18, 2010 Report Share Posted March 18, 2010 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 Quote Link to comment
K-node Posted March 18, 2010 Report Share Posted March 18, 2010 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 Quote Link to comment
mike5 Posted March 18, 2010 Author Report Share Posted March 18, 2010 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 Quote Link to comment
K-node Posted March 18, 2010 Report Share Posted March 18, 2010 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 Quote Link to comment
jgcode Posted March 19, 2010 Report Share Posted March 19, 2010 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. Quote Link to comment
mike5 Posted March 19, 2010 Author Report Share Posted March 19, 2010 Yes, thank you all for the clarification. I think what got me confused is the fact that Context Help leads you (me, at least) to believe that the VI Ref is in fact pointing to lvclass. Mike Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.