LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with a subvi in a subpanel

Solved!
Go to solution

Hi,

 

I'm creating an application whereby I have a main program running three subvi's with their front panels visible in subpanels on the main program. 

 

I want the main program to be able to send some data to the subvi's for initiation parameters where each message to each subvi would be different and a common shutdown etc.  (this will be a cluster of initialization parameters and a Boolean shutdown ctl)

 

I'm sure it's probably subjective, however what's the "best" way to transfer this data into or out of a subvi, without the access to the connector pane?  I've currently tried both Global Variables and the Ctrl Val.Set method and not sure what the benefits of one over the other is? Or is there a better solution overall - I've heard people talk of notifies over globals, but not sure how this could be implemented without the connector pane?

 

Thanks for your time,

 

Mark

0 Kudos
Message 1 of 12
(7,413 Views)

Hi Holroyd,

  Actually, you cannot use notifiers in your case,because to use notifiers definitely you have to create terminal  and thus you have use connection pane for that.

Please try functional global variable to transfer data to subvi.

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 12
(7,403 Views)

If you have the "Control val set" approach figured out, use that.

 

The code I posted in this message may be of interest to you. It was intended to be a Nugget on Docking someday but I never got around to writting the Nugget.

 

Ben

 

PS: Note: I did not say anything bad about globals (this time).

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 12
(7,400 Views)
Solution
Accepted by topic author Holroyd

I generally use queues and notifiers when dealing with subpanels.  You can obtain a reference to a queue or notifier without using the connector pane by wiring the name terminal on the obtain function.  I sometimes destroy the queue to force an error in the subpanel to make it exit through an error state.  controlvalue.set is good for setting initial values before the subpannel is run, and could be used for infrequent control changes. Be aware that controlvalue.set accesses the UI thread and is comparatively very slow compared to passing data through a queue or notifier.  If setting many values at once use the 'defer panel updates' property (set it to true during the changes) to significantly improve the performance.

Michael.

Message 4 of 12
(7,392 Views)

You do not need the connector pane in order to share a notifier or queue between VIs; you just need to assign them the same name.  This is one appropriate use of named queues.  It is also possible to use the CtrlVal.Set method to set a queue refnum value, and then you have a queue shared between VIs.

Message 5 of 12
(7,387 Views)

@RiversDaddy wrote:

"Be aware that controlvalue.set accesses the UI thread and is comparatively very slow compared to passing data through a queue or notifier.  If setting many values at once use the 'defer panel updates' property (set it to true during the changes) to significantly improve the performance."


 

Thank you all for your responses, its much appreciated!

 

So presumably this means that the contolvalue.set would also create an event for the value change of a control? I'll give the 'defer panel updates' a shot too and see how much of a difference it makes.

Ben, The docking example looks very interesting and is something I'd be interested to read more about.  I'll spend a few hours (days) trying to figure out how it works but would look forward to reading your Nugget (if you ever get around to it that is).

 

So the general consensus seems to be that controlvalue.set is a good method for anything that’s not "urgent", and a queue / notifier (named) can be used for passing data in / out quickly?  I think I'll remove my gobal and replace it with a Notifier in this that case.

 

Thanks again for all your replies, I'll give it all a go and see what happens!!

 

Cheers,


Mark

 

0 Kudos
Message 6 of 12
(7,363 Views)

Hi,

I am please you are happy with the explanations given.  Unfortunately controlvalue.set will not trigger an event in the sub panel though. If you need to fire events then one idea is to pass the main vi the specific control references and use the value(signaling) property.  Alternatively you could do something with user events.  See this: http://decibel.ni.com/content/docs/DOC-14216

You may find it useful.

All the best,

Michael.

0 Kudos
Message 7 of 12
(7,336 Views)

After a bit of playing and testing, I believe that the named Queue and Notifer option seems to work best for me and ended up passing some initialisation data through the Queue too. 


Thanks for all the replies, they were all very helpful and I'm sure they will come in handy for a later project!


Mark

0 Kudos
Message 8 of 12
(7,276 Views)

@nathand wrote:

You do not need the connector pane in order to share a notifier or queue between VIs; you just need to assign them the same name.  This is one appropriate use of named queues.  It is also possible to use the CtrlVal.Set method to set a queue refnum value, and then you have a queue shared between VIs.


 

Doesn't this break the dataflow paradigm?

0 Kudos
Message 9 of 12
(7,284 Views)

Yes it does break dataflow.  But you cannot pass data between parallel loops or subvi's following dataflow.  If you are accessing queues by name you do have to make sure you know where your data is coming from, especially where you have multiple writers to a queue from sepperate subvi's.

Michael.

Message 10 of 12
(7,280 Views)