Update cookies preferences
Promotic

onAppStopBegin - event of the PmaRoot object

Description:
The event is triggered after the command for halting the application.
Parameters:
pMe(Object) Reference to the PmaRoot object where the event rises.
pEvent(Object) Reference to an object describing detailed information about the specific event.
pEvent.Type - (String) [for reading] Application stopping type.
"Stop" - Normal application stopping called by the Pm.AppStop(0) method or by closing the main application window. This normal application stopping can still be supressed by the confirmation window or in the PmaRoot.onAppStopBegin event.
"HardStop" - Stopping the application by calling the Pm.AppStop(1) method or by malfunction of internal component or licence. This application stopping cannot be supressed by a confirmation window or in the PmaRoot.onAppStopBegin event.
"Logoff" - Logging off the user logged in the Windows OS, see Pm.ShutDown(0, false) The applications will be terminated with confirmation dialog.
"HardLogoff" - Logging off the user logged in the Windows OS, see Pm.ShutDown(0, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
"Reboot" - Rebooting the computer with Windows OS, see Pm.ShutDown(1, false) The applications will be terminated with confirmation dialog.
"HardReboot" - Rebooting the computer with Windows OS, see Pm.ShutDown(1, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
"Shutdown" - Shutting down the computer with Windows OS, see Pm.ShutDown(2, false) The applications will be terminated with confirmation dialog.
"HardShutdown" - Shutting down the computer with Windows OS, see Pm.ShutDown(2, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
pEvent.Error - (Long) [for reading] If the value of the parameter is 0, then the application is stopped by the user (designer) command - i.e. by calling the Pm.AppStop method.
Otherwise (the value is no-zero), the application is stopped from the failure cause of some component (e.g. ActiveX object, etc.).
pEvent.Enabled - (Boolean) [for reading] Enable/disable normal application termination. The value of this parameter is preset to true. If the value of the property is true, then the normal application termination is enabled. If the value of the property is false, then the normal application termination is disabled. This way it is for example possible to enable/disable normal application termination conditionally or execute delayed termination, etc.
Note:
After the event Pma objects are deleted sequentially (the onStop event is triggered for each object) and finally the onAppStopEnd event is triggered.

Application termination can be disabled by "PmaRoot > Permissions > AppStop" permission.
See also:
- Pm.AppStop (method)
- Pm.ShutDown (method)
Example1:
Delays application stop so the designer "SaveConfigApp" method can finish its necessary procedures
JavaScriptSelect and copy to clipboard

function onTimeOut()
{
Pm.AppStop(1);   // will by called "onAppStopBegin" with pEvent.Type == "HardStop"
}

if (pEvent.Type == "Stop")
{
pEvent.Enabled = false;
pMe.Root.AddEventTimer(5000, 1, pMe.GetPathName(), onTimeOut);
pMe.Methods.SaveConfigApp();   // user method
}
Example2:
Opens the "PmForm" window with countdown to application stop. The application can be stopped immediately by confirmating the dialog.
JavaScriptSelect and copy to clipboard

var nSecStop = 15;   // number of seconds until the application stops
var oPmfTimeout;

function onTimeOut()
{
if (nSecStop <= 0)
{
Pm.AppStop(1);   // will by called "onAppStopBegin" with pEvent.Type == "HardStop"
}

oPmfTimeout.Value = "Application stops in " + nSecStop + " seconds";
nSecStop--;
}

function onViewClose(ev)
{
if (ev.CloseReason == "ok")
{
nSecStop = 0;
}
else
{
pMe.Root.RemoveEventTimer("StopOut", 0);
}
}

function onViewLoad(ev)
{
var oForm = ev.Form;
oForm.Title = "Application stop";

oForm.CreateItem("separ", "separ", "", "Subtype:space;TitlePos:no;BodyHeightIni:1;");

oPmfTimeout = oForm.CreateItem("string", "msg", "", "Subtype:static;TitlePos:no;Multiline:1;ValueHorzAlign:center;");
oPmfTimeout.Value = "Application stops in " + nSecStop + " seconds";
}

if (pEvent.Type == "Stop")
{
pEvent.Enabled = false;
pMe.Root.AddEventTimer(1000, 0, "StopOut", onTimeOut);

var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/form", "", "target:_blank;modal:1;");
oCreator.View.onLoad = onViewLoad;
oCreator.View.onClose = onViewClose;
oCreator.Open();
pMe.Methods.SaveConfigApp();   // user method
}
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.