02-06-2012 02:04 PM
I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port. I thought this would be a good time to start using Classes. I created a GPIB class which contains member data of: Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do. I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware. This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture.
However, in other applications (without classes) I typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction. My queue data is a cluster of an "action" enum and a variant to pass data. Is it OK to use this pattern with classes? I created a vi and it works fine and attached is a png (of 1 case) of it.
Are there any problems doing it this way?
02-07-2012 01:24 PM
Hello Jterosky,
I don't see a problem with doing it this way. It should work the same with classes.
02-07-2012 03:00 PM
@JTerosky wrote:
I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port. I thought this would be a good time to start using Classes. I created a GPIB class which contains member data of: Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do. I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware. This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture.
However, in other applications (without classes) I typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction. My queue data is a cluster of an "action" enum and a variant to pass data. Is it OK to use this pattern with classes? I created a vi and it works fine and attached is a png (of 1 case) of it.
Are there any problems doing it this way?
Including the error cluster as part of the private data is something I have never seen done and ... well I'll have to think about that one.
Ben
02-08-2012 07:56 AM
I included the error cluster because it contains information specific to the object and I thought (maybe incorrectly...I'm new at using classes) that all data specific to the object should be kept within the object. Also, since I use the class wire to maintain dataflow that I didn't need the error wire for that purpose....aaahhhh...but what if I want to establish dataflow between vis of different classes...like a signal generator and a power meter? Then I would need to have the error cluster external to the class so that dataflow can be maintained between functions of different classes.
I think that I just convinced myself to pull the error cluster out of the object.
02-08-2012 08:17 AM
Socratic method at work.
Ben
02-08-2012 09:37 PM
Thank you both for your comments.
02-09-2012 07:39 AM
No problem. You made me think. That is a good thing.
Since you are just starting off on the LVOOP path, you may want to view the images I have collected in my LVOOP Albumn. Some of those images have links back to the original thread where they were posted.
They may give you some ideas and inspiration.
Ben