LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Control Values by Index Function only works for a running VI?

Solved!
Go to solution

I have never used Set Control Values by Index Function before so I decided to benchmark it against two other ways to set front panel controls, using the invoke node Ctrl.Val.Set and using property nodes for Value. But if the VI whose controls I am trying to set is not running I get error 1000 saying "The VI is not in a state compatible with this operation." When I run the VI whose controls I am trying to set I don't get an error. So does this VI truly only work if the VI is running? I can't set the values before I call the VI to run dynamically?

0 Kudos
Message 1 of 13
(4,440 Views)

I see no point in setting value for control when it is in edit mode (unless you are trying to set a default value). Also the Set Control value by index is introduced in 2013 version only.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 13
(4,432 Views)

It is in the 2014 version as well. Also you might want to set the values before running the VI if you are calling a VI dynamically but want to avoid a race condition by running it and then setting control values.

0 Kudos
Message 3 of 13
(4,427 Views)

As I said unless you set the control value as default it will be cleared once the execution starts. If you want to pass a value to a VI which you want to call dynamically you can do so by using Call by reference primitive,

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 13
(4,409 Views)

I may be misunderstanding you, but you can create a VI reference set the values using either the invoke node Ctrl.Set.Value or property node for the value property and then run it and you won't lose those values. They don't change back to default.

0 Kudos
Message 5 of 13
(4,405 Views)

@LJHerskowitz wrote:

I may be misunderstanding you, but you can create a VI reference set the values using either the invoke node Ctrl.Set.Value or property node for the value property and then run it and you won't lose those values. They don't change back to default.


you're absolutely correct. this is how it works. you only get the default value when the VI is brought into memory

 

now, if the VI is used as a subVI, and the fp control is wired to the connector pane, it will take the default value if the terminal is unwired in the parent VI.

 

I assume that you're not using this as a subVI and that you're dynamically launching it via VI server and interracting with it by reference.

0 Kudos
Message 6 of 13
(4,399 Views)

Yes soupy. I call the VI dynamically and set the controls before running it. But it looks like the Set Control by Index doesn't work if the VI is not running. Is that correct? If it is why?

0 Kudos
Message 7 of 13
(4,395 Views)

Yes. As said the VI is loaded into the memory and stays Idle when you open the VI dynamically and thats why the control values are not chaning. I was in a wrong impression. '

Regarding the Set Control Value by Index you can set  the only during the run mode as explained here.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 8 of 13
(4,386 Views)
Solution
Accepted by topic author LJHerskowitz

i'd question why you're doing it this way in the first place.

 

a little background. this feature was added to address the problem that writing to front panel items by reference is roughly a 1000 times slower than writing to the terminal. i believe this feature operates by writing directly to the transfer buffer. it still ends up being slower than writing to the terminal, but only about 10 times slower.

 

My company is making use of this new feature. We needed it because we were updating thousands of front panel values on the same VI by reference and labview couldn't keep up (yes, probably could have worked around it in a different way, but there are more details than that...). If your'e not updating thousands of items, you probably shouldn't be using this feature. The performance savings will not be worth the extra development effort it takes.

 

it probably doesn't work because the transfer buffer doesn't exist when the vi is not running

0 Kudos
Message 9 of 13
(4,380 Views)

Thanks for the information on how it works. I was only playing with this feature. I have never used it before so I wanted to see which method is the fastest. But I see that it doesn't work the way I expected.

0 Kudos
Message 10 of 13
(4,374 Views)