11-20-2012 12:59 PM
Steve,
You have to be careful when using the method you suggested which is to do the calls within the Event Structure itself. I did not look at your code, but I am familiar with people's misfortunes at using this style. In other words, I've had to debug many people's programs who were not careful about the fact that the program was held inside the event structure; which caused the program not to respond to operator selections.
Ray,
Thank you for the feedback on something you did not look at.
Given the following block diagram, please identify the “program” inside the event structure.
steve
11-20-2012 03:48 PM
You are triggering a user event inside the event structure? 😮
And I would assume that you have event structures inside the sub-vi?!? 😮 😮
Yikes..
11-20-2012 05:13 PM
@Ray.R wrote:
You are triggering a user event inside the event structure? 😮
And I would assume that you have event structures inside the sub-vi?!? 😮 😮
Yikes..
I don't see any issues with the way Steve is using events. I regularly fire events from within an event structure. I have not run into any issues doing so. Why do you claim generating a user event within an event structre is problematic?
11-20-2012 06:27 PM
It is an unusual approach, where you need to be careful that the sub-vi's event structure does not cause a deadlock.
If it is well implemented there is no problem.
I recall a post on these forums where the person had created such a deadlock. Maybe I get jumpy when I see such implementations on the forum.. 😄
11-21-2012 05:50 AM
Ok, back to the Original Posters issues ...
What was not mentioned in this example:
Your sub vis can not be located on your block diagram (you are dynamically opening them).
The path to the subvis must be relative to the main vi if you need to build an exe. (Expect path issues until you figure it out)
LabVIEW does not know these subvis exist so when building applications you have to manually include them in the build specification.
You need to create code to close each subvi.
Would you like to Profile your code? Sorry - Dynamically called vis don't show up (as of LV2010 anyway).
Several of these items are reasons why I try to stay away from Dynamically calling vis.
But even saying all that, they can be made to work and do provide one benefit: They free up memory when you close them.
steve
11-21-2012 07:54 AM
There are many ways to implement the solution. He has been presented a few.
That's the beauty of life: choices.
I did not mean to knock down your suggestions. I was merely stating observations from years of helping others in this forum. And you are correct in stating that there are caveats to the solution I offered. There was no indication that the OP wanted to build an executable. I did not realize that this had to become a p***ing contest.
11-21-2012 08:22 AM
I was able use the open VI reference > Run VI method to do what I needed. I'm not to comfortable with user events yet, so I didn't get to explore that option.
It seems like this should be easier to do though...
01-30-2013 01:23 PM
So I have something similar that I am trying to do but I get the same error when I try to call the same VI a second time. The subVI pops up with a progress bar on it that goes from 0 to 100 and it displays the number of seconds left as defined by the user's input (the example just has a constant). In any case once it counds down to zero it ends the loop in the subVI and closes the front panel. Then as you can see below in the code I have been using to call it - I close the references. Now I can't figure out why it is still running after doing this. The front panel of the subVI will not close until it gets out of the while loop and the only things after that are a close front panel method and a close reference. Then the VI should stop running I would think since there is no more code for it to run.
Below is an example of the code I am trying to use to call the subVI.
01-30-2013 04:23 PM
Actually as I've been trying to figure this out I noticed that if I run the main VI with highlight execution on there is no error, but when I run it without highlight execution there is. What would cause that?
01-30-2013 04:37 PM
What is the error?