LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
sofub

VI-server reference "pane"> array of references on elements from the frontpanel

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

By using the VI-server reference "pane" > you will obtain a array which contains a reference for each used element. This VI-server reference can be wired in any sub-VI, to check for example the state (value) of a element. Into the respective sub-VI the array function "Array Index" can be used to check the value of the element. Everything will work fine, until you put another element into your frontpanel. At this point, LabView change the order of the reference array. Now the user wish to have a function, to edit the reference number of each element (like "Change order of elements in cluster"). The problem remains, even if the new element will be deleted.

6 Comments
AristosQueue (NI)
NI Employee (retired)

I do not understand the problem as described. Can you post some images showing the sequence of editing steps as well as the code that doesn't work any more?

sofub
Member

screen01.JPGi i mean that i have a frontpanel with some elements as shown abowe and there is a control STOPP. To get the state of this control, i use the VI -server reference PANE, which contains a array with references on all elements from frontpanel:

 

screen02.JPG

 

in my example the STOPP control has got allways the index 21 in the obtain array of all elements from frontpanel. If i will insert now a new control in my frontpanel, the order of all references in the array from frontpanel is changed ! I'm missing a editor to set the Index of the controls by hand.

tst
Knight of NI Knight of NI
Knight of NI

The editor does exist (in the Edit menu->Set Tabbing Order, I don't know what it is German, so you'll need to translate this and the rest of this post as well). The tabbing order is what controls the order of the Controls[] property.

 

However, it's not something that I would suggest using.

 

First, you can read the value of the control a lot more easily if you create a property node which is directly linked to the control (by right clicking the control and selecting Create>>Property Node). This will get around your basic issue.

 

Second, reading the value of controls by using the value property is generally a bad idea as it has bad performance. A local variable (right click>>Create>>Local Variable) is better in terms of performance, but it also has a problem of race conditions - when you access the same value in multiple places in your code you risk having outdated values and bugs which are hard to find.

 

This is an important aspect of working with LabVIEW, so I suggest you try looking at some of these tutorials.


___________________
Try to take over the world!
sofub
Member

The editor that you mean (Set Tabbing Order) does exist, that's right, but the index that you can change there has nothing to do with the index of the array of references on the elements from frontpanel ! In my example i show that i use the Index 21 to get the state of the STOP button, but after you insert any new control in the frontpanel, the index 21 didn't match the STOPP button anymore.

 

As next you suggest to use a property node from the STOPP button -> this is not working in a SubVI !

 

Your second suggestion contains the idea, to use a local variable to read the value of the control -> i try this with a global variable, but there i also have the problem, that the reading of the value from the control, will happen only if the application is processing the main block diagram, during the application is processing any SubVI's, i can press the STOPP-button, but the global variable didn't contain the new value !

 

As next i will check you link with "these tutorials", but before i'll do that, i want to explain what the support department from NI suggest for fixing this issue: i should create a while loop, where i should check the mentioned array of references on controls from frontpanel for the name (in my case: STOPP), and stop the loop by matching the capture, so i have then the index for the STOPP control, even if the order of references in the array has been changed. This solutions works, but i don't realy like it, because it has also has a bad performance, but at the moment i have no better solution.

tst
Knight of NI Knight of NI
Knight of NI

 


 

The editor that you mean (Set Tabbing Order) does exist, that's right, but the index that you can change there has nothing to do with the index of the array of references on the elements from frontpanel

 


 

 

You're right. The tabbing order does control the order of the Controls[] property, but only the one which belongs to the panel. The one which belongs to the pane is affected by the Z order of the objects, for some reason. I don't know why this is so, but it was probably an oversight.

You can control this by using the reorder button in the toolbar to move the controls to the back or front, but again, this is not a good idea.

 

You are correct that if you create a property node it can't be used in a subVI, but you can use it if you create a reference to the control, then pass the value of that reference to the subVI. Like I said, though, this is not a good way of doing something like this.

 

A global variable is better, but it also has the race condition issue. The issue you ran into can be solved by separating the UI code from the application code, but this isn't the place to discuss this. The tutorials should hopefully provide more details on this.

 


___________________
Try to take over the world!
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.