Jump to content

Choose a class control with an enum, in a sub vi

Recommended Posts

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?




Link to comment

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!

Link to comment

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.

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.

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.