tools:logger_trace:start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tools:logger_trace:start [2018/01/12 11:11] – graf | tools:logger_trace:start [2026/04/13 12:17] (current) – ursgraf | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| When working with realtime applications you have to be careful when logging. The formatting of any output into an output stream takes time and usually cannot be done with the full speed of the control system or the safety system. However, when debugging a intricate control algorithm it might be desirable to study various signal values together with their timestamps as they are calculated in the control system. \\ | When working with realtime applications you have to be careful when logging. The formatting of any output into an output stream takes time and usually cannot be done with the full speed of the control system or the safety system. However, when debugging a intricate control algorithm it might be desirable to study various signal values together with their timestamps as they are calculated in the control system. \\ | ||
| - | For this purpose you can place [[eeros_architecture: | + | For this purpose you can place [[eeros_architecture: |
| + | |||
| + | In the EEROS library you will find a directory with examples. For this example | ||
| + | |||
| + | It has a simple control system with two trace blocks, each having a ring buffer lenght of 64. | ||
| <code cpp> | <code cpp> | ||
| class ControlSystem { | class ControlSystem { | ||
| Line 12: | Line 16: | ||
| trace1.getIn().connect(c.getOut()); | trace1.getIn().connect(c.getOut()); | ||
| trace2.getIn().connect(i.getOut()); | trace2.getIn().connect(i.getOut()); | ||
| - | trace1.start(); | + | trace1.enable(); |
| - | trace2.start(); | + | trace2.enable(); |
| } | } | ||
| Line 36: | Line 40: | ||
| </ | </ | ||
| - | ===== Starting | + | ===== Enabling |
| + | A trace block, though it will run by the control system, has to be enabled. If so, it will continously fill its trace buffer until it is disabled. This allows for tracing a given stream of signals. You could start tracing as soon as the safety system enters a certain safety level. You do this by starting the trace in the safety level action, see [[eeros_architecture: | ||
| + | If you read out such a trace buffer it will simply return a buffer starting with the most recently logged at the end of the buffer. If the trace buffer was not filled completely, the returned buffer is simply as long as the trace buffer was actually filled. \\ | ||
| + | A trace block has a given number of entries and is organized as a ring buffer. While running it fills new entries at the head and looses old entries at the tail. | ||
| + | ===== Concurrent Writing of Trace Data ===== | ||
| + | The example above shows how a trace buffer can be written to a file. This has to be done only after the executor stopped, because the writing usually takes a long time. If you wish to write a trace buffer to a file for further analysis while the application still runs, you can use a '' | ||
| + | <code cpp> | ||
| + | TraceWriter< | ||
| + | if (slRunning.getNofActivations() % (int)(30 / period) == 0) { // write to log file every 30s | ||
| + | tw.write(); | ||
| + | } | ||
| + | </ | ||
| + | The name of the trace file will be appended with the current date and time. | ||
tools/logger_trace/start.1515751867.txt.gz · Last modified: (external edit)
