eeros_architecture:control_system:available_blocks:switch
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| eeros_architecture:control_system:available_blocks:switch [2017/04/06 13:50] – [Auto Switching] graf | eeros_architecture:control_system:available_blocks:switch [2021/07/07 20:09] (current) – [Switch] ursgraf | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| A switch block allows to select one of several input signals to write to its output. The code below shows a switch with 3 inputs where the second input is selected. | A switch block allows to select one of several input signals to write to its output. The code below shows a switch with 3 inputs where the second input is selected. | ||
| <code cpp> | <code cpp> | ||
| - | | + | Switch< |
| - | sw.switchToInput(1); | + | sw.switchToInput(1); |
| </ | </ | ||
| You can also query the index of the selected input with | You can also query the index of the selected input with | ||
| <code cpp> | <code cpp> | ||
| - | | + | int index = sw.getCurrentInput(); |
| </ | </ | ||
| + | By calling | ||
| + | <code cpp> | ||
| + | setActiveLevel(safetySystem, | ||
| + | </ | ||
| + | the switch will only switch if the current safety level is equal or greater than the safety level set by this method. | ||
| ==== Auto Switching ==== | ==== Auto Switching ==== | ||
| It is possible to configure a switch in such a way, that if the selected input reaches a given level within a small margin the switch does switch automatically. For this purpose you have to specify a condition with | It is possible to configure a switch in such a way, that if the selected input reaches a given level within a small margin the switch does switch automatically. For this purpose you have to specify a condition with | ||
| <code cpp> | <code cpp> | ||
| - | | + | setCondition(T switchLevel, |
| </ | </ | ||
| - | where '' | + | where '' |
| Before the switching can take place the switch must be armed with | Before the switching can take place the switch must be armed with | ||
| <code cpp> | <code cpp> | ||
| - | | + | arm(); |
| </ | </ | ||
| The function | The function | ||
| <code cpp> | <code cpp> | ||
| - | | + | triggered(); |
| </ | </ | ||
| queries the state of the switch function. It will return '' | queries the state of the switch function. It will return '' | ||
| Line 28: | Line 33: | ||
| The switching might lead to a change in the safety level. In order to be able to trigger a safety event you have to register such an event beforehand. | The switching might lead to a change in the safety level. In order to be able to trigger a safety event you have to register such an event beforehand. | ||
| <code cpp> | <code cpp> | ||
| - | | + | registerSafetyEvent(SafetySystem* ss, SafetyEvent* e); |
| </ | </ | ||
| + | ==== Combining ==== | ||
| + | Switched can be combined. If switch 1 is combined with switch 2 and switch one changes its position then switch 2 will simultaneously change its position as well. To combine switches you have to call | ||
| + | <code cpp> | ||
| + | s1.combine(s2) | ||
| + | </ | ||
| + | where '' | ||
eeros_architecture/control_system/available_blocks/switch.1491479440.txt.gz · Last modified: 2017/04/06 13:50 by graf