martti:
Dynamically launch your sub-vi. This is the way to do what you want
to do. When you dynamically launch, tell it not to wait for execution
to complete and tell it to auto close vi references. You can
communicate between the main vi and the dynamically launched vi using
queues, notifiers, occurrences, and lastly but least reliably globals.
You will need to make sure that you don't try to dynamically launch an
already running dynamically launched sub-vi or if it is acceptable you
will need to use VI templates (VITs) so that you can have multiple
simultaneously running dynamic sub-vis. To do this you could use an
acquire semaphore to prevent launching a VI until the already launched
VI releases that semaphore.
You can use a queue, notifier, etc. to tell the dynamically launched
VI to abort or vice versa for the dynamically launched VI to kill the
main program if you want or you can simply close the main VI from it's
front panel and the dynamically launched VI will continue on it's own
until it finishes.
Douglas De Clue
LabVIEW developer
ddeclue@bellsouth.net
martti wrote in message news:<3D353506.5D1D1181@spam.for.me>...
> Hi!
>
> The solution to a user interface for "emergency stop" is the following.
>
> First of all you need to have the main.vi and sub.vi running in different
> threads. This
> is an execution system option: Instead of "same as caller" you should
> select for the sub.vi execution option "other2" or some name like that (I
> don't have LV in this machine.)
> Now that the main.vi and sub.vi run independently you should update the
> emegency_stop global variable state to that of the button during each
> circulation of the main.vi.
> while loop. Remember to add some time delay (wait until next 30?
> milliseconds multiple) in the main.vi while loop to leave proper
> processor time for your sub.vi.
> Then in your sub.vi place cleverly one or more emergency_stop read so
> that your
> sub.vi responds (exits) fast enough to the pressing of the emergency_stop
> button in the main.vi.
> Now your sub.vi reacts on the stop button pressing in the main.vi.
>
> So, the general solution to a control panel problem is multi-threading +
> global variables.
>
> One more thing, you should use local variables to initialize and to
> reinitialize after pressing of the stop button. Otherwise the user can
> initiate some double-click
> based problems or some other exotic failures in the program stopping.
> Also use error-in error-out interfaces to your sub-vi to make sure that
> your
> vi starts execute at the exactly right execution order like, first I do
> this
> then I do that and then I go to sub.vi
>
> Best Regards,
> Martti
> Oulu, Finland
>
> Mariannne wrote:
>
> > Thanks for the answer.
> >
> > But it doesn't quite work as I wanted it to. My main.vi also has a
> > while-loop.
> > I added a while-loop to main.vi in your example and wired the
> > stop-button also to the termination-symbol of this loop. Now the stop
> > button only seems to restart the sub.vi, and occasionally stopping
> > it.. What shall I do ?