LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass data between panels

Solved!
Go to solution

Say I have a numeric slide on one panel. When I move the slider I need the value to be updated on another panel.

 

How can I do this?

 

Both panels are loaded as top level windows.

 

It seems like I read something about using queues to pass data between panels but I can't seem to find where I read that.

0 Kudos
Message 1 of 10
(4,972 Views)

Why not installing a callback on the numeric, trap EVENT_VALUE_CHANGE and update accordingly the control on the other panel?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 10
(4,966 Views)

Thanks for the reply.

 

I do have a callback installed for the slider. I'd rather not constantly poll a variable in panel1 unless there's no other option.

 

Ideally, panel2 would notify panel1 that there is data ready. Then panel1 would read it. Coming from the C# world I'm used to

using delegates and events.

 

EDIT: I may have found the answer with QueueUserEvent and GetUserEvent

 

0 Kudos
Message 3 of 10
(4,964 Views)

I do not understand your comment on "poll continuously".

If you want to reduce the number of events, trap EVENT_COMMIT on the slider, which is fired only once after the user has finished moving the slider.

 

This is an event: if the user does not moves the slider, then no event is generated and no code is executed.

 

Using GetUserEvent can be tricky, as it returns every commit event generated on the user interface, that is, also events fired from controls other than the slider.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 10
(4,956 Views)

Can I install a callback in panel1 for a control on panel2 (the slider)?

 

In other words, Can I catch the slider's EVENT_VAL_CHANGE in panel1?

0 Kudos
Message 5 of 10
(4,954 Views)

Callbacks are installed on the controls you want to trap events for. They can also be installed on the panels the controls are on, but I don't remember an easy way to have a panel be warned of an event in another panel.

Do you have a specific reason to reject a callback on the slider?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 10
(4,952 Views)

What I basically need is a multithreaded DAQ application.

 

I know C but this is the first time I've used CVI. I'm trying to experiment with the best way to get data from the DAQ thread to the main thread.

 

So far I've found that I can use Async timers and a thread pool. Those are both acceptable. I was just experimenting with other ways.

 

 

0 Kudos
Message 7 of 10
(4,949 Views)

Found what I needed.

 

Even though the slider is on panel2, I needed to install the slider's callback in panel1.c.

 

Maybe this isn't good coding practice though?

 

At least it works.

0 Kudos
Message 8 of 10
(4,945 Views)
Solution
Accepted by topic author WayneS1324

One basic concept that differentiate CVI from other languages is that there is no relation between a panel and a specific source file. I mean, you do not need to put functions related to one panel in a specific source file: they may be spread over multiple source files; at the other hand, you could have one source file only which collects callbacks for all panels in your application. What drives callback execution are panel handles and control IDs. (An effect of this paradigm is, you could have one callback installed on controls located on different panels).

For this reason, there is no problem in putting the slider callback in panel1.c. Besides it, you could call the source file in any other way.

 

Coming to the core of your problem, a multithreaded DAQ application is really different from a single-threaded user interface application.

Putting data acquisition functions in a separate thread can be beneficial for your application as they are not prone to suffer from user interface happenings.

CVI additionally supplies you with different methods of passing data between threads; the most powerful in DAQ applications is probably a Thread Safe Queue.

I suggest you to look at Programmer Reference >> Creating Multithreaded Applications chapter in the help,where the fundamentals of multithreading programming are explained and informations are given on all the instruments CVI includes.

If you want to discuss about this scenario, I suggest yu to start a new thread, as it has no relation with the original question with which you started this discussion.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 9 of 10
(4,937 Views)

Thanks for the reply.

 

I've got the multithreaded part down pretty good. No issues there.

 

The original issue arose from coming from object oriented C# to C. Using OOP was so ingrained in me, I had to train myself to use C.

 

It's becoming easier now. Thanks!

0 Kudos
Message 10 of 10
(4,910 Views)