LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to trigger value change in event structure

Solved!
Go to solution

First, as I said, you need to appropriately configure the sub-vi properties and appropriately code the UI of your sub vi. You have to uncheck "Open front panel when called" in the vi properties or the VI is called twice. The sub vi must handle its own UI. Here is a rough example of the code. I am attaching your modified sub vi.

 

c (mod).png

 

Second, the main vi must be configured to correctly call the sub-vi. You have to make sure that it will not be called twice before it is being closed. This task is up to you to you. For example, if you click the fire button twice without closing the sub vi, an error is generated (notice that you just have to close the error window and the sub vi and it will keep going). One way to solve the problem is to set the window property of the sub vi as modal. The main vi will keep running but you won't be able to access it until you close the sub vi. I have modified your main vi (that is also attached). Code is shown below.

 

 

fire (mod).png

 

 

Marc Dubois
Download All
0 Kudos
Message 11 of 23
(2,024 Views)

Thank you so much for the solution.. It help me understand a lot about event structure and sub vi.. But I have another question, in your main vi using control to the event, if I waant to use indicator to trigger the event, how should I link the fire indicator to the event? If I used local variable, there will be error.. thank you again..

0 Kudos
Message 12 of 23
(1,998 Views)

Sorry please ignore the previous threat, i not sure why I can't delete the threat. As the attached below, I want the indicator to trigger the event instead of using control, but the error pop up when run. Any solution for this?  thank you so much.

Download All
0 Kudos
Message 13 of 23
(1,979 Views)

Anyone please? 

0 Kudos
Message 14 of 23
(1,970 Views)

@yee0722 wrote:

As the attached below, I want the indicator to trigger the event instead of using control, but the error pop up when run.


What error?  I don't understand what you mean by the indicator triggering the event.  You are currently causing an event on the indicator.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 15 of 23
(1,966 Views)

hi thanks for your reply, ya I'm using I want the indicator to trigger on the event and show a pop up sub-vi when "fire" button is pressed. But I don't know how to link the indicator to trigger the subvi.  I got error as the attached image. 

0 Kudos
Message 16 of 23
(1,959 Views)

As I said, you cannot call the sub vi twice. You get the error because the sub vi is called while already running. The reason is because you selected "Latch until released" instead of "Latch when released" or "Latch when pressed" for the mechanical action of "Fire 2".

Marc Dubois
0 Kudos
Message 17 of 23
(1,950 Views)

opps... Sorry.. Now only I know the trouble bring by latch... Sorry still blur in Lbview.. Thanks finally its solved. thank you so much...!!

0 Kudos
Message 18 of 23
(1,945 Views)

Hi sorry for asking question about event structure again, now I got another question, which if I change the "fire 2"control button to something as below figure.. It doesn't have the mechanical action because it is not a control.. How should I correct it? 

 

Another about similar question, attachment 2 (capture 6) is part of my project.. I use local variable indicate the both flame boolean and overtemp boolean, I want the sub vi pop up when both the boolean is true.. It seems getting complicated. Sorry and thanks again. 

Download All
0 Kudos
Message 19 of 23
(1,935 Views)

The user event loop is designed for just that, managing user events. You can add some programmed events using dynamic events or using property nodes like you did but this is not, by a long shot, the best way to go. To have a user interface and be able to trigger programmatically triggered events, I would suggest that you look at the producer-consumer design pattern. Here is one example: https://decibel.ni.com/content/docs/DOC-2145.

 

One problem I see with your vi's is that the event is probably triggered several times when the condition is met. As I said several times before, if the event is triggered more than once while the sub vi is opened, an error is generated. You can add a test in the event case to check if the sub vi is already open, and not call it if already opened, but this is going down the wrong path. Have a look at the producer-consumer design pattern, or altenatively, a simple state-machine pattern.

Marc Dubois
0 Kudos
Message 20 of 23
(1,923 Views)