LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call an event case

Dear All,

  I was previously from code based programming.

Can you show me what can I do to trigger a Button(B1) value change event by another Button(B2) event?

 

Thank you 

0 Kudos
Message 1 of 6
(4,618 Views)

Hi Vincent,

 

Kindly check the attached VI. It may help you.

 

Regards,

NitzZ

(Give kudos to good Answers, Mark it as a Solution if your problem is Solved;))

Message 2 of 6
(4,606 Views)

Nitz showed you in the example how to do it. LabVIEW front panel controls have all a "Value(Signalling)" property you can use to modify the value of a control AND cause an according event to be triggered, if the control is registered for an event. It's in my humble opinion one of the only two valid cases where the Value property should be used at all. The other is for initialization of front panels. Any other use of the Value property I consider abuse.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 6
(4,599 Views)

Remember your sequence of events in Labview is different from procedural programming.  

 

In a procedural language you would press Button2 and inside that handler call the Button1 handler and run the Button1 code.  After the Button1 code completes you would return and finish the rest of the Button2 logic.

 

So something like : 

 

Button2_Handler()

{

   // Start running Button2 stuff

 

   // Call Button1 logic and perform all of Button1 stuff

   Button1_Handler();

 

   // Finish Button2 stuff

}

 

Button1_Handler()

{

    // Do Button 1 stuff

}

 

In Labview you press Button2 and inside that handler you make the request for Button1 to be run, finish the Button2 handler, and then the Button1 handler will be called.

 

In a procedural language this would look something like :

 

Button2_Handler()

{

   // Start running Button2 stuff

 

   // Request Button1 logic to be performed but don't run it yet

   runButton1Handler = true;

 

   // Finish Button2 stuff

}

 

Then inside some polling routine:

 

while(true)

{

  if(runButton1Handler == true) 

  {

      Button1_Handler()

      {

           // Do Button 1 stuff

      }

 

      // Clear button 1 logic flag so it doesn't keep running inside poll routine

      runButton1Handler = false;

  }

}

 

This was tricky for me to learn since I also came from a procedural background.

Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 4 of 6
(4,078 Views)

Another caveat -- Button 1 (the one you want to use with Value (Signal) property) cannot have a Latch mechanical action.  If you try to programmatically set the value of a Latched Boolean, you will get either a Compile Time (= Broken Arrow) or Run Time (= Error Message) error.

 

Bob Schor

Message 5 of 6
(4,055 Views)

@Bob_Schor wrote:

Another caveat -- Button 1 (the one you want to use with Value (Signal) property) cannot have a Latch mechanical action.


That's where this idea would help. 😄

0 Kudos
Message 6 of 6
(4,042 Views)