Jump to content

Property of Controls in parallel loops


Recommended Posts

Hi,

First of all, I would have to say I'm absolutely new to LabVIEW.

With that in mind, I've created a listbox control and intend to change the listbox's "ItemNames" property as means of controlling what appears on the listbox.

However, I have event cases in two different, parallel while loops both adding items to the array of string by reading from one ItemNames property, appending to the array, and then writing back to another ItemNames property node.

It seems however that any updates made to the property in one loop does not update the property in the other loop, which makes me feel like that there are 2 local variables in both loops affecting the listbox.

I'm pretty sure there is a more elegant way to do this, but I've been confounded for quite a while now.

Any help is appreciated, thank you very much.

cheers

Link to comment

QUOTE

However, I have event cases in two different, parallel while loops...

That's a problem. Why do you have two different event structures? Best bet is to restructure your program to eliminate the second one. Regarding your specific question it sounds like you might have branched something and one of the loops is operating on a copy. Beyond that I'd have to see your block diagram to see what you are doing.

Link to comment

As said, the most likely source of your problem is a race condition caused by working on the same resource (the list of strings) in two places without locking it, but without seeing the code it's impossible to tell for sure. The solution is either to lock it or to handle it in a single loop.

The more generic solution would be to disconnect the display from the underlying data and logic. For example, you can have one loop and a cluster of your data which is passed through a shift register. One of the elements in that cluster would be the array of names or the data needed to build that array. Your logic would actually operate on that data (by unbundling and bundling by name) and you then call a display state which will translate the data into your display. You can see some examples if you search for "state machines" or look at some of the templates you get when you select File>>New.

There are links to some tutorials here.

Link to comment

I now see the problem with more than one event structure.

The thing is, I'm trying to introduce some modularity in my program.

In my case, I'm trying to get the code relating to several numeric controls and a waveform graph contained inside a tab of a tab control to be as separate as possible from the rest of the code. The reason behind this is because I'm trying to make the software as easy to modify as possible for someone else, where he could just add a block of code himself to create an extra tab without messing about with the rest of the code apart from a few wire connections.

On another question, is it possible to have the various controls and indicators such as LEDs as part of a sub-VI? I.e., can I define a sub-VI with a proper user interface, and that add it into my main VI and have it shown on the main VI's front panel (not as a new window)?

I've attached my (horrible) code alog with this post.

There are two while loops. The one on top controls for numeric controllers which contains values that are inter-related, which is why I've used an event structure to change the values of the other 3 numeric controllers when one of them changes. Any changes in the numeric controllers also change the waveform 'Preview'.

The top while loop is my attempt at modularising the code related to the cotents iof the first tab in the front panel, which is the 4 numeric control, waveform graph and a single button. But this obviously has turned out to be trouble.

Only the tab labeled "Linear" has any functional code in it. The button labeled "Linear" add a line in the listbox in the following format: lin(initial diameter, gradient, length).

Again, I apologise for the messy code and unclear questions. I'm very new to LabVIEW and am still struggling to cope with it. All help is very much appreciated.

cheers

Link to comment

QUOTE(minority @ Feb 23 2008, 11:49 PM)

See sub-panels in the example finder.

QUOTE

Well that is certainly true (sorry ;) )

Do you have your monitor in portrait mode?

In the main event you have 4 times the same code, that is not modularizing. Put the mathscript in a subVI, and learn the LabVIEW code that is representing this (shouldn't be too hard).

post-2399-1203882418.png?width=400

In such a case you could consider locals, the use of the cluster is not clear. And if you want to use clusters type-def them.

The array building is useless, you can just use 'concatenate array'.

QUOTE

Only the tab labeled "Linear" has any functional code in it. The button labeled "Linear" add a line in the listbox in the following format: lin(initial diameter, gradient, length).

Use format into string for such an action:

post-2399-1203881579.png?width=400

Is there still a specific reason that there is a second event structure?

For storing of the items in the listbox you could use a shift register.

Ton

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.