Discussion:
Subpanel Data Read by Main VI?
(too old to reply)
DJDDA
18 years ago
Permalink
In the attached VI, I need a certain sub-VI to fire when the main VI closes. For the sub-VI to work, it needs to know the location of a physical device, and that location can be changed by an interface in one of the main VI's sub-VI's. Only one such sub-VI requires a termination condition like this right now, but there might be more later. The inc_dec sub-VI does not seem to be receiving the data from the HV sub-VI (I set it to play a sound if a specific non-default value appeared on the brown cluster wire, and the sound isn't playing).So, how am I supposed to do this to make it work?(I can post the sub-VI's if needed.)


CRATE FACE.vi:
http://forums.ni.com/attachments/ni/170/286417/1/CRATE FACE.vi
DJDDA
18 years ago
Permalink
Ugh, it's worse than I thought. The "Panel Close" event case for the HV sub VI--which does not fire when CRATE FACE closes, I tested by running it alone--works fine. However, in the CRATE FACE version attached to this post, inc_dec does not fire at all. This is especially frustrating because it did fire before the brown wire existed. Argh!Ideas?(Edit for missing words.)Message Edited by DJDDA on 11-26-2007 03:13 PM


CRATE FACE.vi:
http://forums.ni.com/attachments/ni/170/286434/1/CRATE FACE.vi


inc_dec voltage.vi:
http://forums.ni.com/attachments/ni/170/286434/2/inc_dec voltage.vi
Ben
18 years ago
Permalink
Speaking only for myself...
i only volunteer on this forum so I can't spend a lot of time looking into a problem. If the question is clear and i think i have an idea, i'll reply.
In the case of this question, I am OK with your title but you lost me after that.
Sure I could look at your code if I had the right version on this machine but I suspect I do not. That means I would have to go to another machine, down load....
Sorry but I don't have time for that.
So...
please imbed images of your code so we can reply by looking and save us having to poke.
Now I'm guessing;
Are you try to do inter-thread communications? If so look at my <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;view=by_date_descending&amp;message.id=240328#M240328" target="_blank">Action Engine Nugget</a>.
The next guess is that you are having trouble harnessing the data flow pardigm.
And as to your mini-follow Q I would guess "a" complicated by "d".
Trying to help,
Ben
PS: Watch how long it will take for Jim Kring to get an answer to <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;thread.id=286718&amp;jump=true" target="_blank">this Q</a> ! Message Edited by Ben on 11-27-2007 01:39 PM
DJDDA
18 years ago
Permalink
Okay, here are images. Thanks for the reply. (Edit to display images in post, and again to space them better.) Crate Face:<img src="Failed to load image: http://forums.ni.com/attachments/ni/170/286745/3/crateface1.gif"> 3002D:<img src="Failed to load image: http://forums.ni.com/attachments/ni/170/286745/1/3002D_1.gif"> inc_dec:<img src="Failed to load image: http://forums.ni.com/attachments/ni/170/286745/2/incdec1.gif"> Message Edited by DJDDA on 11-27-2007 02:34 PM


3002D_1.gif:
http://forums.ni.com/attachments/ni/170/286745/1/3002D_1.gif


incdec1.gif:
http://forums.ni.com/attachments/ni/170/286745/2/incdec1.gif


crateface1.gif:
http://forums.ni.com/attachments/ni/170/286745/3/crateface1.gif
Ben
18 years ago
Permalink
Hi DJ,
I recomended reading the help for the Insert VI and look at its examples. The examples will show you how to run your VI's in the sub-panel and show where and how to close the references.
RE: Globals I rarely if ever use globals (Globals are evil!). I generally use Action Engines to fill that need. I posted a link earlier to a Nugget I wrote on Action Engines.
The help and the Nugget say much more than I could with a quick reply. Please review those help files and links and post follow-up Q's if they don't answer your Q's.
Quick guess at why your event approach is not working.
The panel close event only files when the FP is closed. Since you have open refs to the VI's and the are running in the sub-panels, their FP are not closing so their Panel Close events never fire. But this is just a guess about what I thought you were TRYING to do. So either read the help on the Insert VI and the panel close event or stick with the method you reported that works.
Still trying to help!
Ben
PS The Examples for the "Insert VI" show you exactly what you need to do. Take a look, please.
DJDDA
18 years ago
Permalink
Ah, the examples were very helpful. I should have looked at them earlier. On the panel close events: It still does not appear that closing a VI with subpanels will fire off the Panel Close event for the sub VI's in said subpanels, but I'm not sure on that.I couldn't find Nuggets or Action Engines in the help files, but here is an updated VI with a global. It sometimes gives me an error when I close it--I don't know what that's about. >_>Edit: And I still don't understand why a global is evil.Message Edited by DJDDA on 11-28-2007 03:57 PM


crateface4.gif:
Failed to load image: http://forums.ni.com/attachments/ni/170/287100/1/crateface4.gif


crateface error.gif:
http://forums.ni.com/attachments/ni/170/287100/2/crateface error.gif
jrpe
18 years ago
Permalink
I think your question is actually a number of questions, all kind of wrapped together, which makes it a bit confusing.



DJDDA wrote:In the attached VI, I need a certain sub-VI to fire when the main VI closes.


you can use the event structure to capture either Panel Close? Or application close events. You can make the program ignore the close and instead run a subvi in the event before closing. Check out Event Conditional Stop.vi in the example finder under Events.
&nbsp;






DJDDA wrote:For the sub-VI to work, it needs to know the location of a physical device, and that location can be changed by an interface in one of the main VI's sub-VI's.



In the subvi that can change the location of the device, make sure that every time the location is changed, the value is stored in a functional global (not the same thing as a global!), or even better, like Ben was saying, an action engine. Then you can read from that action engine in your close subVI, so it will always know the location of the device.
&nbsp;





DJDDA wrote:Only one such sub-VI requires a termination condition like this right now, but there might be more later.


I really don't understand what this part means. What is the termination condition? That it needs to know where the device is? Or that it needs to execute when the panel is closed. If you need MORE termination conditions, that is easy, just add them into the event structure (Depending what they are), but if you mean that the same termination condition might apply to other subVIs, just duplicate your code.
&nbsp;





DJDDA wrote:The inc_dec sub-VI does not seem to be receiving the data from the HV sub-VI (I set it to play a sound if a specific non-default value appeared on the brown cluster wire, and the sound isn't playing).


I doubt I can open your .vi (since I have 7.0 and no one posts in 7.0 lol) so I cant specifically help you with this, however your method of debugging seems a bit excessively complicated. Instead of playing a sound, try either
&nbsp;&nbsp;&nbsp; - placing a probe on the brown wire (probes let you see what the value in the wire is during execution)
&nbsp;&nbsp;&nbsp; - use highlight execution to debug your program (the little lightbulb by the run button on the block diagram) and step through your program to find where it fails
&nbsp;&nbsp;&nbsp; - set a breakpoint in the code a little bit before the brown cluster wire occurs and once your program gets to there it will pause, then you can turn on highlight execution and step through to see if your program is behaving as expected.
&nbsp;
As to why globals are evil...you should read Ben's nugget, its quite good. I promise. haha actually all the nuggets are a good way to learn the finer points of labview (or even the bigger points). Basically with a global you can be writing and reading from it at the same time...which is not good. Other methods like functional globals and action engines prevent this from occuring.
&nbsp;
Hope that helps a little bit to answer your initial questions

Loading...