From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update controls with events

Solved!
Go to solution

I am trying to make a settings editor window that has multiple groups of settings that can be edited and saved.  The settings are loaded and saved to a array of clusters.  The window uses a shift register to store all the changes and then you can save them all at once when ready.  The problem I am seeing is if I change a value and leave the cursor in the control and then select a new group it won't read that new value.  I understand that you should put the control that you want to read in the same event but the problem is I would like to be able to read from that control with more than one event and it makes sense to have the control outside the event structure.  I attached a sample vi of what I am trying to accomplish.  I am fairly new to labview and am learning as I go, so any help would be appreciated. Thanks

0 Kudos
Message 1 of 19
(3,883 Views)

Adding a value change event will register the new value even if you leave the cursor in the field.

 

Ben64

0 Kudos
Message 2 of 19
(3,868 Views)

The problem is that your controls are in front of the event structure. This means they get read immediately at the start of the loop iteration and when the event fires, the stale value is read from the tunnel. The terminals need to be inside the associated event case.

 

You don't need any of the signaling properties. Keep the timeout in a shift register and set it to zero in all events that need to followup with an update. Do the final update in the timeout case and set the timeout to -1 there.

 

Currently, you don't use the timeout except to idly spin the loop evert millisecond. no need for that!

0 Kudos
Message 3 of 19
(3,866 Views)

I have no idea what you are talking about.  The indicator seems to update whenever you go and pick a new device, and the controls also update with the data for the device that was just picked.

 

Perhaps you can give us step by step instructions on how to replicate what you are getting and explain clearly how that is different from what you want.

0 Kudos
Message 4 of 19
(3,865 Views)

The problem is that the control read is before the event structure and therefore the value is read before the event is fired.

The value is read and the "old" data is stored in the input tunnel of the event structure. So when you change the Max Force but leave the cursor in the control and click save changes our code uses the old data that was sitting in the input tunnel of the event structure and not the new value that you just changed.

 

The 1ms timeout does not help with this.

 

Try creating a do nothing event for Max Force, Deflection and serial number to force an value change when the cursor leaves the control due to one of the save button being clicked. The loop will loop around read the changed value before "Save .." event.

 

I hope the order of the events will be the change value of the data input controls before the change value event of the Save buttons.

 

Omar
0 Kudos
Message 5 of 19
(3,857 Views)

The controls are outside the event structure because I need to read the controls from multiple events.  I thought that when a event gets triggered it does everything in the while loop and event structure.  Bens fix of adding a value change event for each control fixes the problem but to me it seems like a work around. 

 

Having a settings editor window seems like a pretty common function in programs, is it the architecture of it that is causing the problem or is it similiar to something that you have seen before.  Because I am new to labview and programming in general it is hard for me to know that I am doing it correctly and that I am not overcomplicating things.  Thanks for you help.

0 Kudos
Message 6 of 19
(3,836 Views)

"I thought that when a event gets triggered it does everything in the while loop and event structure."

 

NO only half right. It only does what is in the event structure. What is in the while loop BEFORE the event structure is done BEFORE the event is fired. So when the event happen the input tunels has as altenbach put "stale" data.

Omar
0 Kudos
Message 7 of 19
(3,828 Views)

Hey alenbach, can you please elaborate some more on the event timeout and the signaling properties?  I guess I never really understood the event timeout very well. What is the difference between using -1 and zero? Thanks

0 Kudos
Message 8 of 19
(3,810 Views)

-1 (or wire nothing) means NEVER timeout. Sit there and do nothing until another event fires. I this case I some times just delete the timeout event.

 

0 means do not wait between events but to constancely fire the time out event (not good)

 

Somewhere inbetween is when you need some event to happen when nothing else happens after some amount of time. Most times I do not have a timeout event.s

Omar
0 Kudos
Message 9 of 19
(3,800 Views)

Writing to the property 'value (signaling)' will trigger a value change event (identical to a user interaction to a control), while a write to the value property or a local variable is not triggering this event.

 

Felix

0 Kudos
Message 10 of 19
(3,783 Views)