tools:logger_cs:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tools:logger_cs:start [2017/12/21 13:52] – graf | tools:logger_cs:start [2018/05/31 10:30] – [Log in the Same Task] graf | ||
---|---|---|---|
Line 13: | Line 13: | ||
This will output the output of a chosen block once per second. The lambda function is necessary so that the periodic task knows what to do, though it actually does nothing, as the function is empty. \\ | This will output the output of a chosen block once per second. The lambda function is necessary so that the periodic task knows what to do, though it actually does nothing, as the function is empty. \\ | ||
For more complete examples see '' | For more complete examples see '' | ||
+ | |||
+ | |||
+ | ===== Log in the Task of the Time Domain ===== | ||
+ | It is also possible to add the logging to the monitors of one of the currently running task of the control system. This could be done as follows: | ||
+ | <code cpp> | ||
+ | double period = 0.001; | ||
+ | eeros:: control:: | ||
+ | eeros:: | ||
+ | perCS.monitors.push_back([& | ||
+ | static int ticks = 0; | ||
+ | if ((++ticks * period) < 1) return; | ||
+ | ticks = 0; | ||
+ | log.info() << controlSystem.myBlock.getOut().getSignal(); | ||
+ | }); | ||
+ | |||
+ | // and further down the code | ||
+ | executor.add(perCS); | ||
+ | </ | ||
+ | Please note that you usually want the logging to happen at a much smaller frequency than the time domain. For this, you have to reduce this frequency as shown in the example above. | ||
===== Log in a Subsequent Task ===== | ===== Log in a Subsequent Task ===== | ||
Line 24: | Line 43: | ||
Now, the logging will be done after the control system task has finished running. | Now, the logging will be done after the control system task has finished running. | ||
- | ====== Log in the Same Task ====== | ||
- | It is also possible to add the logging to the monitors of one of the currently running task of the control system. This could be done as follows: | ||
- | <code cpp> | ||
- | TimeDomain td(" | ||
- | Periodic perCS(" | ||
- | eeros:: | ||
- | perLog.monitors.push_back([& | ||
- | log.info() << controlSystem.myBlock.getOut().getSignal(); | ||
- | }); | ||
- | |||
- | // and further down the code | ||
- | executor.add(perLog); | ||
- | </ |
tools/logger_cs/start.txt · Last modified: 2018/05/31 10:32 by graf