Jump to content

Compelling introductory examples of OO LabVIEW?


Recommended Posts

I'm teaching an introductory programming course using LabVIEW to 30 college freshmen, as part of a comparison study of text based vs. graphical programming. To match curricula, I need to include two days of object oriented programming. There are lots of great examples of how to do this, but I need to find a compelling example that shows why it is used. Is there some simple application that involves solving a real world problem, that becomes much easier, or much more obvious when OO concepts are applied to the solution? I'm drawing a blank, and have posed the question to several colleagues, and have them puzzled as well.

Stuart

Link to comment

Using OO to mitigate the problems that arise when hardware is obsoleted before the system that needs that hardware goes obsolete:

http://zone.ni.com/devzone/cda/epd/p/id/6307

(There are two examples attached to this document... use hal_version_2.zip, as that's the one that has been recently revised. We're leaving the old one up as reference just for a short while in case people are still using that as a reference example.)

You might also hunt around for one of the "creating a framework that 3rd parties can plug into" examples.

Link to comment

I'm teaching an introductory programming course using LabVIEW to 30 college freshmen, as part of a comparison study of text based vs. graphical programming. To match curricula, I need to include two days of object oriented programming. There are lots of great examples of how to do this, but I need to find a compelling example that shows why it is used. Is there some simple application that involves solving a real world problem, that becomes much easier, or much more obvious when OO concepts are applied to the solution? I'm drawing a blank, and have posed the question to several colleagues, and have them puzzled as well.

Stuart

The project I am currently working on processes and displays data in specified ways.

The User determines what and how data is calculated as well as what will be displayed.

Initially the "User" was a person. There for several dialog vis were created to extract the needed information before the application could continue.

The project has expanded and the user is not always available to enter in the information.

In one case the program will extract the needed information form a file.

In another case the information will be queried from a PLC.

Extracting data from each of the different sources requires very different methods

User: Ask user using dialog vis

File: Find Open and read data.

PLC: Setup connection read tags

To solve this problem I created a parent "Data Source" Class

and 3 children User, File, PLC,

Later if another data source is requested I simple add another child

The "Get Data" method is overwritten by each child using dynamic dispatch.

Hope this helps spark and idea for you

Mark

Link to comment
  • 2 weeks later...

The project I am currently working on processes and displays data in specified ways.

The User determines what and how data is calculated as well as what will be displayed.

Initially the "User" was a person. There for several dialog vis were created to extract the needed information before the application could continue.

The project has expanded and the user is not always available to enter in the information.

In one case the program will extract the needed information form a file.

In another case the information will be queried from a PLC.

Extracting data from each of the different sources requires very different methods

User: Ask user using dialog vis

File: Find Open and read data.

PLC: Setup connection read tags

To solve this problem I created a parent "Data Source" Class

and 3 children User, File, PLC,

Later if another data source is requested I simple add another child

The "Get Data" method is overwritten by each child using dynamic dispatch.

Hope this helps spark and idea for you

Mark

Thanks for the good ideas with this. I'd thought of the plug-in architecture myself, but not the obsolete hardware challenge or the multi-access point problem. These are still a bit above the level of non-programmers learning LabVIEW in a 10-week class, although the plug-in and multi access point can probably be simplified enough to work as problems.

Thanks again,

Stuart

Link to comment

Hi Stuart:

One use for a plugin/OOP architecture is debugging/logging. I have a VI that I sprinkle around in my code that logs messages and errors to a text file. I think a lot of programmers have something like that, and I think your students can understand the value.

So if you make it object oriented, it's much easier to change the way it behaves, like I have a version that emails me when there is an error. You could also use it to post status messages to a web page, or put up certain error codes in dialog boxes. But all the code that calls this logging VI has no need to know how it works. If I distribute the code, I just have to distribute the base class, and the user can ignore it or write their own descendants of the class to meet their own needs.

For this implementation, I keep the object in a global, so that I don't have to pass the lvclass wire through all though hundreds of routines that call it.

Jason

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.