LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

class data member accessor in parallel with main program

Here's the deal... if I can describe it. Should be no need to post a vi... should be a simple problem.

 

I have several images on the main front panel. When one image is clicked, it begins to flash. I'm doing this with a parallel while loop. I'm swapping the image loaded from disk with an empty picture twice a second. I see my image for 500ms, and then an empty image for 500ms. When its clicked a second time, the flashing stops and the image from disk is displayed.

 

Everything works great, but I want to convert it to OOP. For the learning experience if nothing else.

 

What I'd like to do is keep all image control inside of the class. Everything is fine until I need an image to flash.

 

So... my question is this... can I execute a data accessor in parallel with the main program? In its own thread? This way I can flash the image with a while loop while allowing the rest of the program to go on about its merry way.

 

 

I'm pretty sure now that I have thoroughly confused anyone reading this. I could throw together a quick vi to demonstrate.

 

The question seems simple though... can I run a member function(vi) of a class in parallel with the main program?

0 Kudos
Message 1 of 3
(2,517 Views)

The short answer to your last question is yes. Class member VIs are no different from any other VIs, so you can run them in parallel to other code.

 

That said, there are a couple of points to make:

 

  1. This does not at all seem to be a good application for OOP. It sounds like you have some pretty simple UI code, so there's no need to make a class out of it.
  2. LV class data is by-value, just like the other native data types in LV - if you branch a wire you will get two copies of the object. I don't know if this is relevant in your case, but it's something to be aware of when you want to do something in parallel.

I suggest you look through some of the LVOOP training material available on line to get a feel for where it might be better suited.


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,501 Views)
Thanks for the reply. I just gave an example... the program its self is more complicated. I was planning on using a singleton for the class. That way I don't have to Worry about having copies of it. This is more for learning lvoop. The program doesn't *need* oop.
0 Kudos
Message 3 of 3
(2,497 Views)