LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update controls with events

Solved!
Go to solution

 


@secr1973 wrote:

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


 

Here you don't need any of this here. Here's a quick attempt at simplification....

... see if it makes sense.

 

I assume this is a subVI and the input cluster is a connector...

 

 

 

Message 11 of 19
(1,641 Views)

 


@Omar II wrote:

-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


Okay, it is becoming clearer now.  So, if the event structure never timesout then it will just sit there and wait for one of the events to occur eventhough there may be more stuff in the while loop.  What if you have a state machine or something in series with a event structure, you would need it to timeout so that the state machine can run.  I am probably sounding pretty stupid...

 

0 Kudos
Message 12 of 19
(1,627 Views)

 


@altenbach wrote:

 


@secr1973 wrote:

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


 

Here you don't need any of this here. Here's a quick attempt at simplification....

... see if it makes sense.

 

I assume this is a subVI and the input cluster is a connector...

 

 

 


Yea, this is a subvi.  Thanks for the help.  I changed it a little bit to make it a little more what I want. I changed the exit button so that it would negate any of the changes that you did and then I added the itemnames property to update the list when you make a new device. 

 

0 Kudos
Message 13 of 19
(1,624 Views)

One option is the put the event structure in one (and only one) of your states. The state machine would then sit very quietly waiting for some input to fire an event. Then when does, send it to what ever state or states needed to handle that event. When done return to the event wait state and wait for the next state.

 

Be careful with state that take a long time to run. Your code will appear to be locked up while any long states are running. 

Omar
0 Kudos
Message 14 of 19
(1,617 Views)

 


@Omar II wrote:

One option is the put the event structure in one (and only one) of your states. The state machine would then sit very quietly waiting for some input to fire an event. Then when does, send it to what ever state or states needed to handle that event. When done return to the event wait state and wait for the next state.

 

Be careful with state that take a long time to run. Your code will appear to be locked up while any long states are running. 


Well, the reason I said that is because I have a subvi that runs a state machine to handle a bunch of steps by the user, so it may take a couple minutes.  The state machine will stay on a certain state and poll to see if something has happened to take it to the next state.  I have a event structure with a timeout of 1 next to the state machine mainly just to handle the Panel Close event.  That was the only way that I could see to do something like that.

 

0 Kudos
Message 15 of 19
(1,603 Views)

I cannot look at your code now, so these comments are based on the text in your posts.

 

Look at the Producer/Consumer design pattern.  It uses parallel loops to separate tasks which may operate at very different rates.  The user interface is often in the Producer loop while time consuming operations are in the Consumer loop.  If well planned the program is quite responsive to user inputs.

 

In general a loop with an event structure in it should not contain any code which takes longer to execute than the time allowed between any two user events.  I typically interpret this to mean that any code which takes more than ten of milliseconds to run is not placed in the loop with the event structure.

 

Lynn

0 Kudos
Message 16 of 19
(1,591 Views)

I like how you modified the vi but I now realize why I coded it different before.  Having a value change event for all of the controls made it so the save as new group button logged any changes immediately.  I want to be able to press the save as a new group button and have it save the current changes but discard any changes from the previous group.  Also when I press the save/exit it doesn't capture any new changes in the controls.  Does that make sense?

0 Kudos
Message 17 of 19
(1,562 Views)
Solution
Accepted by secr1973

 


@secr1973 wrote:

Also when I press the save/exit it doesn't capture any new changes in the controls.


 

Since changes in the controls are applied immediately in my code, the data in the shift regsiter is fully updated when you press save.

 

 


@secr1973 wrote:

Having a value change event for all of the controls made it so the save as new group button logged any changes immediately.  I want to be able to press the save as a new group button and have it save the current changes but discard any changes from the previous group.


All you probably need is an additional shift register that contains the current data in a cluster and gets updated with the control changes of the relevant values. In the other cases, you would then insert this cluster or ignore it, depending on the desired outcome.

 

Message 18 of 19
(1,556 Views)

That works great, thanks for the help.

0 Kudos
Message 19 of 19
(1,530 Views)