todd Posted September 16, 2011 Report Share Posted September 16, 2011 I wish I'd seen Michael's vishots about classes and instruments a few months ago. I've made it to that level of functionality and am looking for the next baby step of having multiple instruments to iterate over - just for init, status and cleanup functions. (Most of the actual instruments stream data. I put that into a queue as it arrives, and process that queue into an LV2/AE - though it seems a look at classes +| IPE may be in order, as long as the performance is there.) I'm playing around with an instrument class that has child classes of dmm, gpio, power supply, serial binary streaming device, etc. Each of those classes has a child class for specific devices - for example, dmm might have child classes: agilent 34401, simulated and custom. I saw someone use a "create" or "new" method somewhere on the forums, here, but I can't find it now. Basically, I want a case statemtent to return a "simulated" or "34401" class, but in a subvi. See the attachment. I apologize for not taking the time to post code. The blue circles error out as expected, since real instruments are not installed. The red one does not. All that's in the "get new class.vi" is that case statement. (I added the "base" class instrument in an attempt to use dynamic dispatching and class-casting. Of course I've learned better than that by reading the forums. I remember seeing an example of this in someone's code on the forums, here, but I can't find it. Anyone remember the link - or have any other feedback? Thanks, --Todd Quote Link to comment
jgcode Posted September 16, 2011 Report Share Posted September 16, 2011 Aside from VI Shots (as you already mentioned) there is a HAL example here that might help (pdf + code). Quote Link to comment
todd Posted September 16, 2011 Author Report Share Posted September 16, 2011 Ah, yes, thanks! That's a good one. They create four instruments from four children of class DSSP. If I put those constants in an array, and downcast them in a loop, the array of child classes appears as expected. What I'm hoping for is a way to placing the child constants in a sub VI instead of having them on the BD. Perhaps the sub VI would need to be reentrant so as to "create" each class instance. Thanks, again! Quote Link to comment
todd Posted September 16, 2011 Author Report Share Posted September 16, 2011 Turns out I can do the enum-to-case-to-class constant in a subvi, then upcast it in order to put it in a cluster or array. The goal is to keep the various specific instrument classes all combined, somewhere. It may turn out to be more overhead than necessary, though. 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.