LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview buttons are triggered only after rerun the vi

I have a vi actually to behave like a control panel.

i created each action with a button.

for example:

Lockbutton, unlockbutton...

 

when run the vi, i click on lockbutton, it locks.

then after it locks, when click on unlock button, no value is parsing at unlock button.

 

what's is wrong with my vi?

 

help me..

0 Kudos
Message 1 of 11
(1,205 Views)

Hi toyan,

 

The simple answer is due to dataflow.  When you hit run on your VI the LockBut and UnlockBut states are read - their values are passed into your case structure, and we never go back to look at those controls again.

 

If you hit "Highlight Execution" and watch the code, you will see it happening.

 

It looks as though you have different actions to perform based on a user event (i.e. clicking a button on the front panel).  I would look into using an event structure to handle your front panel interaction.  There is also no need to create the "Terminate Main Panel" notifier in each case structure, just wire the Notifier Refnum into each from your first "Obtain Notifier".


Regards,

Peter D

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

Hi Peter,

So i need to change instead of using case structure of each button, i use event structure?

 

about the notifier refnum, how to determine it?

each case would have its own refnum?

 

0 Kudos
Message 3 of 11
(1,184 Views)

instead of using case structure of each button, i use event structure?

 


Yes - that will make things easier to manage.  I would do some reading on it before you jump in, you may decide to use a producer/consumer with events should you require that the FP remain responsive when performing a time intensive operation.

 


about the notifier refnum, how to determine it?

each case would have its own refnum?

 


For this I just meant you can fork the wire for the Refnum.  Something like this:

 

value.png


Regards,

Peter D

0 Kudos
Message 4 of 11
(1,181 Views)

ohh..i guess i need to dig up more on event structure.

i have no idea how to.

 

any good example of it?

thanks Peter. 

0 Kudos
Message 5 of 11
(1,178 Views)

For the producer consumer with events this is probably a good place to start.

 

Application Design Patterns: Producer/Consumer - http://www.ni.com/white-paper/3023/en

 

I'd try to setup a basic VI where you have a couple of boolean controls, and you use those to launch two dialog boxes.  If you get the hang of sending a command in a queue, and having the consumer do 'something' - you'll have a pretty powerful architecture to work with.

 

Smiley Happy


Regards,

Peter D

0 Kudos
Message 6 of 11
(1,169 Views)

Hi Peter,

i can't open the link..

0 Kudos
Message 7 of 11
(1,147 Views)

Hi Peter,

I would have minimum 10 buttons on the Panel.

as i see example of event structure, so for 10 buttons i may have 10 'Event Data' as below?

 

eventStructure.jpg

0 Kudos
Message 8 of 11
(1,143 Views)

Hi Peter,

I think i manage to do it as attached.

0 Kudos
Message 9 of 11
(1,138 Views)

That is the correct way to do it.

 

One more thing. You can remove the Timeout event, as you have not wired anything to the timeout port.

You can also remove the 25 ms wait you have, as the loop time is controlled by the Event structure.

 

Last thing, you don't need the small sequence structures, just let the thing happen in parallel.

0 Kudos
Message 10 of 11
(1,124 Views)