11-21-2011 08:13 AM
Taggart,
I would be interested in an example of using Subpanels with LVOOP. I am working on a project with tabs and subpanels, and would like to see how you do the dynamic dispatching with a class. I have just started learning LVOOP and your suggestions sound like they would work nicely with the project I am currently on.
11-21-2011 08:40 AM
Unfortunately I don't think I have any code I can post. But I can try and explain it a little better. Maybe that would help. This is a pretty generic description. There are lots of variations possible depending on your exact needs.
First I would create a parent class called something like UI Module Parent.lvclass.
The parent class would have 3 methods.
The first one would be an "initialize" method which would be dynamic dispatching. This would allow all the child classes to initialize as needed.
The second method would be a "load" method which is static. This would contain all the code for loading the module into the subpanel. So each child class would have a "Main UI.vi" or some similar name in the same directory as the .lvclass file. This method would just find the path of the object passed in and then use vi server to run the vi and load it into the subpanel. Before it runs it it would pass it a copy of the object.
The third method would be to "unload" method which is also static. This vi would stop the "Main UI.vi" and then unload it from the subpanel.
By making the load and unload methods static, then child classes don't have to worry about any of those details. All they simple have to do is provide a "Main UI.vi" Any data you need to pass to the "Main UI.vi" you can pass as private data of the object since the load method passes a copy of the object before it uses vi server to run the vi.
Some synchronization is often useful. For example you can use an occurence to verify that the "Main UI.vi" has launched correctly. simply bundle the occurence into the parents private data. Then when the "Main UI.vi" runs have it fire the occurence. The load can pass an error if it doesn't recieve the occurence. For unloading I often put a user event in the parents private data. Then when I unload I fire the user event and then wait for an occurence to tell me it unloaded succesfully (if you want to get fancy you can make the datatype of the event an occurence and pass it that way).
Aside from that the "Main UI.vi" just simply runs in its own thread and has an event structure for processing user interaction. It will have to have some mechanism for interacting with the rest of your programs (perhaps queues or user events). You can pass those refnums in when you initalize the object.
As far as an example I would look on lava in the code repository. There was some kind of active object demo that showed how to launch a process asynchronously and it had some synchronization. Basically you would be doing the same thing except you would be sticking that vi inside a subpanel.
Hope that helps. I know you said you are new. If any of the terms I used or anything else doesn't seem to make sense, please ask.
Sam
11-21-2011 09:05 AM
Here is the link to the example on lava. Again, the demo just shows how to launch a parallel process. But you can simply take that and have the parallel process be a UI module and add to the launching method an input for a subpanel and have the launch method load the parallel process into a subpanel and viola!
http://lavag.org/files/file/95-by-ref-active-object-framework/