Jump to content

Sharing data amongst VIs


Recommended Posts

Hello everyone,

I have created a multiple-window application consisting of lots of independently running VIs. Each window receives data via a queue or notifier and process it in different ways.

The example image below shows an issue that crops up a lot and I am not sure if I am solving it the right way. My method works perfectly but it doesn't seem very efficient...

Within the main application there is a class which maintains a list of the active channels. That list is stored in a single-element queue. The children have access to a class member 'Get Channel List' which previews the data on the queue at any time. I use the class constant to hold the queue type and queue name just to be tidy - as you can see I do not pass any class wires in or out.

This works fine, but if I want to keep polling this list then it means each time I am having to have the overhead of trying to create the queue, finding out that it already exists so just getting the reference, then previewing the element (okay I could use event rather than poll but you see the point). I use DVR & In Place Element Structure in another case and I have the same issue there - I store the DVR in a queue in the same way.

I just wanted to check if what I have done is considered good or bad practice or whether there is a nicer way of doing this?

Thank you,

Martin

post-13935-0-13643600-1309418473_thumb.p

Link to comment

First, it should be pointed that you have an uncontrolled memory allocation, because each call to Obtain Queue creates a new reference to the queue.

Second, if I understand what you want correctly, the easiest way is a VI which looks like this:

post-1431-0-38651200-1309434628_thumb.pn

At first call it generates the SEQ (or DVR, in this example, because it has some advantages), then it just returns the same reference on every subsequent call. This doesn't handle a case where the queue was destroyed, so if you want to handle that, you can check the reference coming out of the feedback node for an error and generate a new one if there is an error (which would also happen on first call).

Link to comment

Crikey, thanks very much Yair for the post, I hadn't realised that a new reference was called each time (I now see it is written in the help, I just hadn't read it).

I am busy implementing your proposed method at the moment...

Thank you,

Martin

Link to comment

Crikey, thanks very much Yair for the post, I hadn't realised that a new reference was called each time (I now see it is written in the help, I just hadn't read it).

I am busy implementing your proposed method at the moment...

Martin, why aren't you using a global variable? I mean, you are using a global variable, just one that is a lot more complex than the built-in version, but appears to have the same functionality.

I suppose if you have multiple places modifying the channel list the queue will act as a semaphore (mutex) but you could just use a semaphore for that.

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
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.