Interrupt the Shutdown Process
There are two methods to interrupt the shutdown process. Note that neither can be used to delay a shutdown caused by time-limited trial license by more than ten minutes.
Method 1:
Any module declared in AppRoot.SRC as a member of the class (SHUTDOWN_HOOK) will run automatically during the shutdown process. Such a module may be used to write extra information to disk or perform any other task before the shutdown process completes.
Method 2:
If you add a module named "VAMStopAppCheck" to your application, you can interrupt the shutdown process to prompt for confirmation or to give the operator time to perform some task before proceeding with the shutdown. For example, when the TraceViewer is shut down, it will check whether logging is still enabled and if so, ask the operator whether to continue logging.
This does not apply to shutdowns initiated by a low UPS. Those are considered to be both time-sensitive and critical and therefore will not be delayed by a VAMStopAppCheck module.
If adding this module to a script application, define it in the AppRoot.src file of the application. If adding it to a VTScada application, the module must be in it's own file, which is declared in the AppRoot.SRC file. (Note - it should be declared on its own, not within any of the module classes.)
It is sufficient that the module be declared in the AppRoot.SRC file in order for the VAM to call it upon shut-down. This will happen when the user tries to stop the application by using the stop button in the VAM or by stopping the VAM itself. The VAM will not automatically call VAMStopAppCheck when the user closes the application by clicking the X in the corner of the title bar. Script applications can trap for this method of closing the application, but VTScada applications are not.
VAMStopAppCheck should be declared with two parameters:
- OKStopPtr - a pointer to be set. When *OKStopPtr is set to 1, the application may stop.
- VTSExit - a Boolean. If TRUE, VTScada is being shutdown. If FALSE, only the application is being stopped.
The general structure of the module will display a dialog to the operator, and wait for a response before continuing.
Example:
< {============================== VAMStopAppCheck ========================} { Module called by VAM when Stop button is pressed. Setting OKStopPtr } { to 0 tells the VAM not to stop the app. Setting it to 1 allows it to } { stop. } {=======================================================================} VAMStopAppCheck ( OKStopPtr { Pointer to set: 1 if ok to stop, 0 if not ok }; VTSExit { Flag - TRUE if VTScada wants to exit; false if app is just being stopped. Default is false. }; ) [ Close { TRUE if user chooses to stop the app }; CloseDialog Module { Presents dialog to user getting confirmation for app stop. }; ] Check [ If 1 Wait; [ { User has attempted to stop the application. Show the close dialog. } CloseDialog(&Close); ] ] Wait [ If Valid(Close); [ IfElse(Close, *OkStopPtr = 1; { Else } *OkStopPtr = 0; ); Slay(); { In either case, this module is finished. } ] ] > < {=============================== CloseDialog ==========================} { Launched module presents a dialog to the user when the application } { is stopped } {======================================================================} CloseDialog ( AskExitResultPtr { Pointer to set the result }; ) [ AskExitResult { The user's choice }; ] CloseDialog [ AskExitResult = System.4BtnDialog(\System\Question_Icon, "Yes", "No", Invalid, Invalid, "Continue shutdown?", Invalid, Invalid, 1, 0, 1, "Continue with shutdown?", Invalid, Invalid, Invalid, 2, Invalid, Invalid); If Valid(AskExitResult); [ *AskExitResultPtr = AskExitResult == 1 ? 1 : 0; Slay(); ] ] >