LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing a Front Panel SubVI Automatically During Execution

I do exactly as you state and use a separate VI for the "Screen Pause" activity (shown in first two attachments). We have 6i at work, I'll look into the panel window -> state property feature, but I don't think it exists with our version...thanks!

PS. I'm looking into the PNG file type, for the moment this is what I have.

0 Kudos
Message 11 of 17
(1,652 Views)
That's odd.  This is my standard way to close a VI dialog.  I never got around to using the methods, although they are the "preferred" way to close a front panel now.  However, some things will keep the property from working. 
  • An input error.  If you wire an error into it and the error is TRUE, it will not execute (this is generally true of all properties and methods).  I usually place it on the block diagram exactly as you see in the picture above, with no connections, for this reason.  Note that this will not stop your VI from executing if it still has active code (the VI will stay in memory, running, until it has finished, although there are run-time engine exceptions to this).
  • If you are stepping through your code, this will not work.  If you have the block diagram open, the front panel will always be open.
Hope this helps.
0 Kudos
Message 12 of 17
(1,649 Views)
If you want to generate a PNG, the easiest way is the following:
  1. Make the window you want a screenshot of active.
  2. Hit Ctrl-PrtScn to copy the bitmap to the clipboard.
  3. If you haven't done so already, open a bitmap editor.  Paint comes with all Windows OSes and can be found in the Accessories menu.
  4. Paste the bitmap into the editor (Ctrl-V or Edit->Paste)
  5. If you can, convert to 256 colors (Paint won't do this easily, but most other bitmap editors will.  I use GIMP because it is free and powerful, although it does have a steep learning curve).
  6. Crop if you need to.
  7. Save as a PNG file (use compression level 9 if you have a choice - this is usually the default).  In Paint, this is the last save option.  Note that if you don't have XP or Vista, Paint does not support PNG.
After you have done it a couple of times, it becomes second nature.  Do not use JPEG format for LabVIEW block diagrams.  JPEG is a lossy format that distorts text and leaves halos around edges.  A 256 color PNG is usually smaller than the JPEG for LabVIEW diagrams, anyway.

If you want to embed a picture in the text of your response, it is a two step procedure.
  1. Post your reply with the picture as an attachment.  This copies it to the NI servers.
  2. Edit your reply and add the picture.  You can get its URL by clicking on the attachment (make sure you launch to another window or tab).  Use the yellow picture icon for easy embedding (or edit the html directly, if you are more comfortable with that).
0 Kudos
Message 13 of 17
(1,643 Views)
I posted the above comment before I read your last one.  If you are trying to close the front panel of a VI different from the one the method/property is in, you need to wire a VI reference to it.  If you do not wire in the VI reference, the VI reference is to the VI the method/property is in, not to the top-level VI.
0 Kudos
Message 14 of 17
(1,639 Views)

The only other thing that I can think of is to create a global variable.  Have your background VI set the value of the global to indicate when it has completed.  Have your foreground "pause" VI monitor the value of the global, and stop when it has been set.

 

Jim

Jim

LV 2020
0 Kudos
Message 15 of 17
(1,632 Views)

DFGray,

Thanks for your excellent description in relation to the PNG format generation. I will also try your "VI reference" idea very soon.

Sincerely,

Dan

0 Kudos
Message 16 of 17
(1,629 Views)
There are many ways you can accomplish this task, but passing the VI reference to the subVI is probably the easiest.  Some examples of other ways, with editorial comments (reader warning, professor mode engaged Smiley Wink)
  1. Create a user event and pass it to the subVI.  If you have an event structure in your main VI (if you have a UI, you should), this is pretty easy, since it will use functionality (close or abort) that is already there.
  2. Create a queue and use a producer-consumer architecture to handle the event.  The producer is in the subVI, the consumer in the main VI.  The queue reference can be passed to the subVI or created there, if it is a named queue.  If your main VI uses a queue-driven state machine architecture, this ends up being almost identical to method 1.
  3. Create a thread-safe reference object containing a boolean and use a polling loop in the main VI to determine when the boolean goes TRUE, signalling a quit.  With the plethora of other, non-polling, methods available, this should only be used when the architecture is very simple.  Fortunately, it is relatively simple to convert to methods 1 or 2, if need arises.  Commonly used thread-safe reference objects are constructructed from uninitialized shift registers or single-element queues (my current favorite).  For more information, search this forum using such keywords as "action engine", "labview 2 global", "shift register global", or "single element queue".
  4. Use a non-thread-safe reference object (e.g. global, shared variable, datasocket variable) as in 3.  This is only appropriate if you can guarantee there will only be one writer.  LabVIEW is an inherently multi-threaded environment, so race conditions become a major issue very quickly if you have multiple readers/writers and unlocked data.
Take-home message: if your main VI does not have any cleanup tasks, use a passed VI reference to close it.  If it does, methods 1 or 2 above are more appropriate.  If you have any questions about any of the above, please ask.
0 Kudos
Message 17 of 17
(1,607 Views)