The code below should report several debug-lines in my LOG-viewer when I start the script from pmon, but also when I stop it via pmon.
Code: Select all
// Callback function to handle exitRequested event
void onExitRequested(string event, int exitCode) {
DebugN("Bye bye");
DebugN("Event: " + event);
DebugN("Exit Code: " + exitCode);
}
// Main function
main() {
// Connect to the exitRequested event
sysConnect("onExitRequested", "exitRequested");
DebugN("Script started");
// Keep the script running to test exit
while (true) {
// Optional: Add a sleep or wait here to prevent busy-waiting
delay(5); // Sleep for 1 second
}
}
Am I doing something wrong here?unknown user wrote:
Unexpected state, CtrlMgr, doConnectionClose, Lost Connection to Event Manager, exiting ...
I use the following version: WinCC 3.20 Patch 4