tools:logger_trace:start
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tools:logger_trace:start [2017/05/08 15:30] – created graf | tools:logger_trace:start [2018/08/22 11:56] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Logging with a Trace Block ====== | ====== Logging with a Trace Block ====== | ||
- | The gain block allows | + | When working with realtime applications you have to be careful when logging. The formatting |
- | examples. | + | |
+ | For this purpose you can place [[eeros_architecture: | ||
<code cpp> | <code cpp> | ||
- | | + | |
+ | public: | ||
+ | ControlSystem() : c(0.1), trace1(64), trace2(64) { | ||
+ | i.getIn().connect(c.getOut()); | ||
+ | i.setInitCondition(Vector3{0, 1.0, 2.0}); | ||
+ | i.enable(); | ||
+ | trace1.getIn().connect(c.getOut()); | ||
+ | trace2.getIn().connect(i.getOut()); | ||
+ | trace1.enable(); | ||
+ | trace2.enable(); | ||
+ | } | ||
+ | |||
+ | Constant< | ||
+ | I< | ||
+ | Trace< | ||
+ | }; | ||
</ | </ | ||
- | The first template parameter denotes the input signal. The gain here is a 2x2-matrix. | ||
- | If a '' | + | An application can now run this control system. After stopping the executor you can output the content |
<code cpp> | <code cpp> | ||
- | | + | |
- | | + | std:: |
+ | file.open("/ | ||
+ | | ||
+ | Vector3* buf1 = controlSystem.trace1.getTrace(); | ||
+ | Vector3* buf2 = controlSystem.trace2.getTrace(); | ||
+ | for (int i = 0; i < controlSystem.trace1.getSize(); i++) file << timeStampBuf[i] << " " << buf1[i] << " " << buf2[i] << std:: | ||
+ | file.close(); | ||
+ | log.info() << "file written"; | ||
</ | </ | ||
- | Another useful operation | + | ===== Enabling and Disabling ===== |
+ | 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 | ||
+ | If you read out such a trace buffer it will simply return a buffer starting | ||
+ | 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> | <code cpp> | ||
- | | + | |
- | </ | + | |
- | The third template parameter specifies an element-by-element multiplication. Please beware of the fact that in this case input signal and gain matrix must be of the same dimensions. | + | |
+ | 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.1494250209.txt.gz · Last modified: 2017/05/08 15:30 (external edit)