16 _dummy_notification =
new QAction(
this);
18 connect(_dummy_notification, &QAction::triggered,
this, [
this]() {
19 QMessageBox::warning(
nullptr,
"Dummy Notifications",
20 QString(
"%1 notifications").
arg(_notifications_count),
23 if (_notifications_count > 0)
25 _notifications_count = 0;
26 emit notificationsChanged(_notifications_count);
30 _notifications_count = 0;
31 for (
int i = 0; i < 150; i++)
33 auto str = QString(
"data_vect/%1").arg(i).toStdString();
35 param.A = 6 * ((double)rand() / (double)RAND_MAX) - 3;
36 param.B = 3 * ((double)rand() / (double)RAND_MAX);
37 param.C = 3 * ((double)rand() / (double)RAND_MAX);
38 param.D = 20 * ((double)rand() / (double)RAND_MAX);
39 _parameters.insert({ str,
param });
40 auto& plotdata = dataMap().addNumeric(str)->second;
43 dataMap().addStringSeries(
"color");
46 auto tcGroup = std::make_shared<PJ::PlotGroup>(
"tc");
47 tcGroup->setAttribute(
TEXT_COLOR, QColor(Qt::blue));
49 auto& tc_default = dataMap().addNumeric(
"tc/default")->second;
50 auto& tc_red = dataMap().addNumeric(
"tc/red")->second;
52 tc_red.setAttribute(
TEXT_COLOR, QColor(Qt::red));
59 _thread = std::thread([
this]() { this->loop(); });
66 if (_thread.joinable())
95 std::lock_guard<std::mutex> lock(mutex());
97 using namespace std::chrono;
98 static auto initial_time = high_resolution_clock::now();
100 duration_cast<duration<double>>(initial_time.time_since_epoch()).count();
102 auto now = high_resolution_clock::now();
103 std::string colors[] = {
"RED",
"BLUE",
"GREEN" };
106 duration_cast<duration<double>>(now - initial_time).count() + offset;
108 for (
auto& it : _parameters)
110 auto& plot = dataMap().numeric.find(it.first)->second;
117 auto& col_series = dataMap().strings.find(
"color")->second;
118 col_series.pushBack({ stamp, colors[(count / 10) % 3] });
120 auto& tc_default = dataMap().numeric.find(
"tc/default")->second;
121 tc_default.pushBack({ stamp, double(count) });
123 auto& tc_red = dataMap().numeric.find(
"tc/red")->second;
124 tc_red.pushBack({ stamp, double(count) });
135 auto prev = std::chrono::high_resolution_clock::now();
138 if (count++ % 200 == 0)
140 _notifications_count++;
141 emit notificationsChanged(_notifications_count);
143 std::this_thread::sleep_until(prev + std::chrono::milliseconds(20));