LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exiting a LabVIEW Application

Hi,
Need help to implement the graceful exit subroutine for my application.


High level architecture of the application is attached here.

"A" is a central controlling entity invokes (Dynamic Call) the AXx (yellow oval). AXx further invokes AXXx (blue oval) and so on  (Whenever required, it's not shown in figure). These represents the application level/ GUI in architecture.

 

D1 through D7(green rectangle) are LabVIEW VIs, which deals with Device Drivers (MAX)/ DLLs/ Low level device drivers etc. D1 - D7 are invoked by AXx/AXXx and don't communicate with "A". Data transfer between D1- D7 and AXx is achieved using various means like Queues, LV2Gs etc. The synchronization between various layers is achieved using Events.

 

When it is required to Exit the application, I wish that the VIs should execute a proper Exit subroutine (Closing the references/ releasing memories of Hardware devices/ closing ports etc. Of course this is for the particular vis). The stop process is initiated from "A" only. As D1- D7 are not controlled by "A", finding difficulty while implementing the Application exit subroutine.

 

Can any one help me in identifying/ implementing such methodology?

 

Notes: Almost all the VIs in application are employing Hybrid design pattern (Combination of State machine and Event architecture).

I don't want to Exit the application directly from A.....Before the application could Exit, need to ensure few things which needs graceful shutdown/ exit subroutine to be executed.

0 Kudos
Message 1 of 4
(3,150 Views)

I have also an architecture with dynamic VIs. You need to define an event "Stop" for each of the VIs. Also you need to define an "Ended" event which will be thrown when the shutdown task of the VI is finished.

In your example A would send "Stop" to AXx. AXx would send "Stop" to D1 .. D7. D1 .. D7 will answer with "Ended". When all "Ended" events have received AXx then AXx would send "Ended" to A. A will then stop executing and leaving the application.

Message Edited by waldemar.hersacher on 09-23-2009 02:01 PM
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 4
(3,135 Views)

Hi Waldemar,

Thanks for the reply.

 

Whatever procedure you explained seems to be OK for normal scenarios. But just consider the scenario, where in Axn has encountered an error and is not able to communicate with D1- D7. "A" is responsible for health monitoring of Axn level modules. As soon as "A" come to know that error in Axn, I want all the Vis to be stopped. Since Axn is already erroneous (stopped)....it won't be able to communicate with D1-D7.

 

How do I proceed in this scenario?

0 Kudos
Message 3 of 4
(3,080 Views)

You have two solutions:

1: Change the error handling in Axn so that it wont stop in case of an error. It will act on "Stop" and "Ended" but ignore all other commands. The worst case here is that you will lose the references to the user defined events or queues. But I never got that on queues. I do not use user defined events in this scenarios.

 

2: You have to create direct channels from A to D1-D7. In this case you need to collect the references from Axn for all the loaded VIs. Althoug you need to give information to D1-D7 where they will send there "Ended" respond.

 

We implement the first solution. All the VIs are running until they get an explicit "Stop" during application shutdown. In the case of an unrecoverable error they will change their state to "erronous" but respond to the "Stop" .

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 4
(3,048 Views)