LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

LVOOP Device class implementation. How should I start?

Hello everyone,

 

I am having some trouble lately trying to understand how to work in LVOOP. I did create some programs that used objects I designed before but they always used some tricks to get around what I really wanted. Also excuse me for using any term in a misleading way. I am really bad with those. I know I need to learn.

 

Currently I am so confused I no longer understand how to even start.

 

I want to simulate an object of oscilloscope for which I have a DLL. If someone is curious as to which oscilloscope it is HandyScope HS5 from TiePie. I programmed HandyScope HS3 (earlier model) to make a device called HS3 consisting of Generator (inherited from class CGenerator) and encapsulating two objects of class CBasicChannel. I would prefer to use multiple inheritance here and inherit two channels then use something along namespace to decide which data to acquire and set. This would allow me to use a single instance to set values of anything in handyscope. To show you what I mean and what I did I add ss2.JPGss3.JPGss4.JPG

 

I also wanted any class inside of my build to have a semaphore shared between inheriting classes... simply so no two methods would try to access DLL or data at the same time. After all I use it in parallel.

 

I thought I could inherit the class CBasicChannel twice with multiple inheritance and create classes CChannel1 CChannel2 then inherit them in main class. I know multiple inheritance creates problems in other languages but I am pretty bad at OOP design.

 

So how should I go in trying to simulate a virtual object of a real existing device? What if the device has several entities of the same thing inside? Like channels or sensors? How should I start to build it so it will look simple yet work properly? Should I use any of common design patterns (they get me really confused)?

 

An example would be appreciated. Especially at making a hierarchy. I tried turning inheritance upside down and inheriting from handyscope then creating objects of class "channel" and "generator" but I'd prefer to have a single entity? Or am I stupid for trying that?

 

I am really lost here. Thank you in advance for any replies.

0 Kudos
Message 1 of 4
(784 Views)

@Vitae wrote:

I tried turning inheritance upside down and inheriting from handyscope then creating objects of class "channel" and "generator" but I'd prefer to have a single entity? Or am I stupid for trying that?

 


Edit for those TL;DR readers (hopefully not the OP Smiley Wink ) - Make the main object encapsulate a parent class type object. Place in that private data an object of the child class.

 

It sounds like this is roughly the direction you should be considering (sorry!). LabVIEW doesn't allow multiple inheritance at all, but a trick which perhaps you've already used is to have a parent class object encapsulated in private data of another object, whilst actually placing child class objects in that data element.

 

To use an example with your channels and scope, you could consider a Scope class, containing an array of Channel classes. This Channel class can have multiple children, with types like ChannelType1 and ChannelType2.

 

Assuming you have a fixed number of channels, but that it is large enough to not want to have a separate data item for each channel in the Scope class data, you can have an InitializeScope function use 'Initialize Array' with a fixed number of channels, of the parent Channel class type. Then, when you want to configure one, you call a function like "Set Channel Type.vi" or similar, which takes a channel number (used to index the array inside the scope class) and an enum for the available types where a new object of type ChannelType1 is created by "Set Channel Type.vi" and if need be initialized, possibly by transferring some values from the previous entry at the same index.

 

You can also have this check that the index is in a suitable range (or use an enum for the channel index too), and that other values are sensible for initialization if needed.

Message 2 of 4
(684 Views)

Hello Vitae,

I'm searching in vain how to use my HS3 into Labview (and also Matlab).

Did you found examples on the net or did you develop your own set of functions?

Best regards.

Jean-Michel (Brussels, Belgium)

0 Kudos
Message 3 of 4
(488 Views)

 I skipped this project for some time (using HS5) and actually want to get back to it in several days.

 

Still I think you just want to start using HS3 right? There should be examples on the TiePie site how to do it. You can also leave me a personal message and I don't mind helping you setting it up in my free time. Maybe I will get a new idea from your fresh start.

 

I know HS3 like the back of my hand so...

0 Kudos
Message 4 of 4
(463 Views)