eeros_architecture:safety_system:usage
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| eeros_architecture:safety_system:usage [2016/11/03 16:43] – graf | eeros_architecture:safety_system:usage [2017/01/28 17:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== | 
| - | The safety system | + | Every EEROS system can have exactly one safety system. As a first step you have to define your safety properties as described in [[eeros_architecture: | 
| <code cpp> | <code cpp> | ||
| - |  | + | MySafetyProperties safetyProperties; | 
| + | SafetySystem safetySys(safetyProperties, | ||
| </ | </ | ||
| - | The central attribute of the safety system | + | The executor will later run the safety system | 
| - | The most important function is its run method. This method is called periodically by a high priority thread. Here's how it works: | ||
| <code cpp> | <code cpp> | ||
| - | void SafetySystem:: | + | // Create and run executor | 
| - | + | auto& | |
| - |  | + | executor.setMainTask(safetySys); | 
| - |  | + | |
| - | + | ||
| - | // 2) Read inputs | + | |
| - | for(auto ia : level-> | + | |
| - | if(ia != nullptr) ia-> | + | |
| - | } | + | |
| - | + | ||
| - | // 3) Execute level action | + | |
| - | if(level-> | + | |
| - | + | ||
| - | // 4) Set outputs | + | |
| - | for(auto oa : level-> | + | |
| - | if(oa != nullptr) oa->set(); | + | |
| - | } | + | |
| - | } | + | |
| </ | </ | ||
| + | |||
| ===== Changing the Safety Level ===== | ===== Changing the Safety Level ===== | ||
| - | The only possibility to change the safety level is through the method // | + | The central attribute of the safety system is its // | 
| + | The only possibility to change the safety level is through the method // | ||
| + | Triggering an event can be done by | ||
| + | * the safety system itself (as a level action or by checking an critical input) | ||
| + | * the control system through a special '' | ||
| + | * the sequencer | ||
| - | ====== Safety System Usage ====== | + | An event can be triggered by the control | 
| - | Since the safety | + | <code cpp> | 
| + | safetySys.triggerEvent(safetyProperties.seStartRunning); | ||
| + | </ | ||
| + | Please make sure to declare a safety event public if triggered by the control system or the sequencer. Private event can be triggered solely by the safety system itself. | ||
| - | Sometimes you need to fire an event e.g. swInitDone: | ||
| - | <code c> | ||
| - | safetySys.triggerEvent(swInitDone, | ||
| - | </ | ||
| - | The C-style definition in class // | ||
| - | <code c> | ||
| - | void triggerEvent(uint32_t event); | ||
| - | </ | ||
| - | ===== Watchdog Output ==== | ||
| - | The last thing to do, is to set an watchdog output, which will be toggled on every execution of //run()//. This can easily be done with: | ||
| - | <code c> | ||
| - | SystemOutput< | ||
| - | safetySys.setWatchdogOutput(watchdog); | ||
| - | </ | ||
| - | ===== Setting Up The System ===== | ||
| - | Before the safety system can be started, you have to define the entry level: | ||
| - | <code c> | ||
| - | safetySys.setEntryLevel(off); | ||
| - | </ | ||
| - | |||
| - | Finally assign the safety system as the main task of the executor, so that the //run()// method will be called periodically (every millisecond, | ||
| - | <code c> | ||
| - | executor.setMainTask(safetySys); | ||
| - | </ | ||
eeros_architecture/safety_system/usage.1478187782.txt.gz · Last modified: 2016/11/03 16:43 by graf
                
                