LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control not outputting the correct value

Solved!
Go to solution

Hello,

 

I have a producer consumer architecture with a queue to pass values. I want to push a new value onto the array using "Insert into Array" when a button is pressed, but when I do the previous value is being read the first time and the correct value on the second press.

 

I'm self taught and it's my first time using the queue so maybe something I'm not seeing/thinking about there?

 

Version 8 VI Attached.

 

Do this to see the problem:

1. Run
2. Click "Master Read"
3. Change "Value"
4. Click "Master Read"
5. Click "Master Read"

 

Any help is appreciated including block diagram critique.

 

Thanks!

0 Kudos
Message 1 of 11
(2,810 Views)

As far as I can tell, the code is doing exactly what you are telling it to. Each time you click the Read button the new version is inserted into the array at element 0 and the rest are pushed down. This happens first time and every time. What behavior are you wanting?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 11
(2,803 Views)

What I am seeing is:

 

Start:

Value = 0

Array = empty

 

Click Master Read

Value = 0

Array = 0

 

Change: Value = 1

 

Click Master Read

 

Value = 1

Array = 0,0 I would expect this to be Array = 1,0 as Value = 1 when I clicked Master Read

 

Click Master Read

 

Value = 1

Array = 1,0,0  I would expect this to be Array = 1,1,0 as Value = 1 when I clicked Master Read both times

0 Kudos
Message 3 of 11
(2,795 Views)

Yup, that's exactly what I am seeing...

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 11
(2,790 Views)

You're seeing what I expect to be seeing? but not what I am actually seeing?

0 Kudos
Message 5 of 11
(2,787 Views)

Just had a thought. Do your test again and after you change the value of the value input click outside the control somewhere before you click on the button. Does that make a difference?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 11
(2,783 Views)

Yes I saw what you were expecting.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 11
(2,781 Views)

"Just had a thought. Do your test again and after you change the value of the value input click outside the control somewhere before you click on the button. Does that make a difference?"

 

Yes now it works. But why?

0 Kudos
Message 8 of 11
(2,775 Views)
Solution
Accepted by topic author trilogy

It all depends on how you change the value of "Value". If you use the increment and decrement buttons it works as you expected.

 

If however, you type in a new value and click the button without clicking somewhere else first, it doesn't work - and here's why:

 

When you type in a value that modified value doesn't show up in the code untill the control loses "key focus". The problem is that clicking the button does cause the numeric input to lose key focus but only after the code has responded to the mouse up event.

 

To fix the problem put a property node in the mouse down event to set the numeric's KeyFocus property to false before the value is enqueued.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 11
(2,772 Views)

That works, I still find it strange (I'll have to go read up on key focus) but it works. Thank you!

0 Kudos
Message 10 of 11
(2,767 Views)