From 125df34c3c2375ca423e5bfd0d5fed7ce2744a9a Mon Sep 17 00:00:00 2001 From: wu bobo Date: Sat, 24 Sep 2022 18:53:39 +0800 Subject: [PATCH] Add files via upload --- README.md | 4 ++-- recorder.cpp | 2 +- recorder.h | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 52f701b..c752303 100644 --- a/README.md +++ b/README.md @@ -42,5 +42,5 @@ MemberFuncPtr(T* pobj) 1. On Windows, segmentation fault will be produced when the thread created by `Frontend` exits. Use `Frontend::run()` instead of `Frontend::open()` (which creates a new thread for `Gtk::Application::run()`) on Windows, especially if you need to do necessary things after the window is closed by the user. 2. The record process can be interrupted by the environment, this causes missing of data and unsmooth curves on the graph. It works very well on XFCE, and is acceptable on GNOME and KDE, but the unsmooth effect can be significant on Windows that the delay can sometimes exceed 20 ms. 3. Limited by software timer accuracy, it is IMPOSSIBLE for `Recorder` to keep its data sampling frequency higher than 10 kHz (0.1 ms interval). The higher the frequency, the lower the stability. -4. `Recorder` is not capable of loading a block of data at once. In this case, it can still be used to show data: do not call `Recorder::start()`, but load data into each buffer manually, then call `Recorder::set_axis_x_range()` to refresh the graph. In case of the amount of data in the buffers are not equal, that of the buffer for the first variable makes sense. To avoid writing invalid non-zero data into the CSV file, call `CircularBuffer::erase()` for each buffer after calling `Recorder::clear()`. -5. It has not been migrated to `gtkmm-4.0`, partly because the repository of newest distributions of Debian and Ubuntu has not provided this version of the library. +4. `Recorder` is not capable of loading a block of data at once. In this case, it can still be used to show data: do not call `Recorder::start()`, but load data into each buffer manually, then call `Recorder::refresh_view()` to refresh the graph. In case of the amount of data in the buffers are not equal, that of the buffer for the first variable makes sense. To avoid writing invalid non-zero data into the CSV file, call `CircularBuffer::erase()` for each buffer after calling `Recorder::clear()`. +5. It has not been migrated to `gtkmm-4.0`, partly because newest distributions of Debian and Ubuntu has not provided this version of the library. diff --git a/recorder.cpp b/recorder.cpp index f650d02..c25cbbd 100644 --- a/recorder.cpp +++ b/recorder.cpp @@ -512,7 +512,7 @@ void Recorder::refresh_loop() if (this->redraw_interval > 200) check_time_interval = 200; check_time_interval *= 1000; //us - this->set_axis_x_range(); + this->refresh_view(); steady_clock::time_point t_last_refresh = steady_clock::now(); while (this->flag_recording) { diff --git a/recorder.h b/recorder.h index eb2d00f..c5ba52c 100644 --- a/recorder.h +++ b/recorder.h @@ -187,6 +187,8 @@ class Recorder: public Gtk::Box bool open_csv(const std::string& file_path); //note: comments will not be loaded bool save_csv(const std::string& file_path, const std::string& str_comment = Empty_Comment); //note: comment is unstandard + void refresh_view(); //call this function if data has been loaded into the buffers manually + bool set_interval(float new_interval); //interval of reading current values (ms). it sets index unit (multipier) to interval (s) bool set_redraw_interval(unsigned int new_redraw_interval); //set manually if a slower redraw rate is required to reduce CPU usage @@ -216,6 +218,8 @@ class Recorder: public Gtk::Box void set_option_anti_alias(bool set); //font of x-axis, y-axis values are not influenced. default: false }; +using RecordView = Recorder; + inline bool Recorder::is_recording() const { return this->flag_recording; @@ -304,6 +308,11 @@ inline AxisRange Recorder::axis_y_range(unsigned int index) const return this->areas[index].get_range_y(); } +inline void Recorder::refresh_view() +{ + this->set_axis_x_range(); +} + inline bool Recorder::set_axis_x_range(unsigned int range_width) { AxisRange range(0, range_width);