User Tools

Site Tools


getting_started:tutorials:stoppingsystem

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:tutorials:stoppingsystem [2016/11/04 17:06] grafgetting_started:tutorials:stoppingsystem [2017/09/24 16:39] (current) – removed graf
Line 1: Line 1:
-====== Shutting down a System ====== 
-How does a robot control system properly shut down? In general it does not stop. Pressing an emergency button might switch to a emergency safety level. However, in a system under development it is often desirable to end an application. That usually means to switch to a specific safety level where the necessary steps for a well controlled stopping of the application takes place. Only after this happened the executor stops running and returns control to the main program, which then stops as well. \\ 
-The following example shows how this can be accomplished. The code can be found in [[getting_started:tutorials:safetysystem|]]. First of all you have to define a signal handler which handles all kind of signals, among them the ''SIGINT'' signal which is sent by pressing ''Ctrl-C''. 
-<code cpp> 
-#include "MySafetyProperties.hpp> 
-#include <signal.h> 
  
-void signalHandler(int signum) { 
- SafetySystem::exitHandler(); 
-} 
- 
-int main() { 
-  signal(SIGHUP, signalHandler); 
-  signal(SIGINT, signalHandler); 
-  signal(SIGQUIT, signalHandler); 
-  signal(SIGKILL, signalHandler); 
-  signal(SIGTERM, signalHandler); 
-  signal(SIGPWR, signalHandler); 
- 
-  ... 
-   
-  // Create and initialize safety system 
-  double period = 1; 
-  MySafetyProperties ssProperties; 
-  SafetySystem safetySys(ssProperties, period); 
-  
-  ...  
-} 
-</code> 
- 
-<code cpp> 
-exitFunction = [&](SafetyContext* privateContext) { 
-  privateContext->triggerEvent(seShutDown); 
-}; 
-</code> 
- 
-<code cpp> 
-SafetyEvent seShutDown; 
-</code> 
getting_started/tutorials/stoppingsystem.1478275612.txt.gz · Last modified: 2016/11/04 17:06 by graf