04-24-2014 01:39 PM
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.
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.
04-25-2014 02:18 AM - edited 04-25-2014 02:25 AM
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..
04-25-2014 03:44 AM
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.
04-25-2014 07:12 AM
Anyone please?
04-25-2014 07:32 AM
@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.
04-25-2014 07:40 AM
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.
04-25-2014 07:53 AM
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".
04-25-2014 08:00 AM
opps... Sorry.. Now only I know the trouble bring by latch... Sorry still blur in Lbview.. Thanks finally its solved. thank you so much...!!
04-25-2014 09:28 AM
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.
04-25-2014 09:45 AM
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.