diff options
| -rw-r--r-- | main.cpp | 98 |
1 files changed, 60 insertions, 38 deletions
@@ -8,17 +8,18 @@ #include "QmlCustomPlot.h" -#include <iostream> +// #include <iostream> // #include <execution> -int main( - int argc, char *argv[]) +int main(int argc, char* argv[]) { // qputenv("QT_SCALE_FACTOR", "1.5"); QApplication app(argc, argv); qDebug() << qgetenv("QT_QUICK_CONTROLS_MATERIAL_VARIANT"); + qDebug() << static_cast<unsigned>(-1); + auto font = app.font(); // font.setPointSize(font.pointSize() / 1.5); app.setFont(font); @@ -106,7 +107,6 @@ int main( profileAutoRestartTimer.setInterval(500); profileAutoRestartTimer.setSingleShot(false); QObject::connect(&profileAutoRestartTimer, &QTimer::timeout, [&]() { - qDebug() << "SEND PROFILE REQUEST"; manager->get(profileRequest); }); @@ -136,14 +136,16 @@ int main( // t.start(); if (reply->error()) { - // qDebug() << "replyFinished with error:" << reply->errorString(); - // qDebug() << "url was:" << reply->request().url(); + // qDebug() << "replyFinished with error:" << + // reply->errorString(); qDebug() << "url was:" << + // reply->request().url(); reply->deleteLater(); return; } - if (reply->url().toString().endsWith("pixels")) { + if (reply->url().toString().endsWith("pixels")) + { // qDebug() << "got pixels"; ++pixelsPacketCounter; const auto ra = reply->readAll(); @@ -151,7 +153,8 @@ int main( auto json = doc.object(); auto jsonPixels = json["pixels"].toArray(); auto encoderPosition = json["encoderPosition"].toInteger(); - auto measurementCounter = json["measurementCounter"].toInteger(); + auto measurementCounter = + json["measurementCounter"].toInteger(); auto timestampUs = json["timestampUs"].toInteger(); // y_profile.clear(); @@ -212,21 +215,25 @@ int main( jsonLines.cbegin(), jsonLines.cend(), lines.begin(), - [](const auto &jsonLine) -> QLineF { + [](const auto& jsonLine) -> QLineF { const auto jsonPoints = jsonLine.toArray(); const auto jsonPoint0 = jsonPoints.at(0).toArray(); const auto jsonPoint1 = jsonPoints.at(1).toArray(); - return {{jsonPoint0.at(0).toDouble(), - jsonPoint0.at(1).toDouble()}, - {jsonPoint1.at(0).toDouble(), - jsonPoint1.at(1).toDouble()}}; - }); + return { + {jsonPoint0.at(0).toDouble(), + jsonPoint0.at(1).toDouble()}, + {jsonPoint1.at(0).toDouble(), + jsonPoint1.at(1).toDouble()} + }; + } + ); // lines.append({{6,780},{38,787}}); - auto pixelsCustomPlot - = engine.rootObjects().first()->findChild<QmlCustomPlot *>( - "pixelsCustomPlot"); + auto pixelsCustomPlot = + engine.rootObjects().first()->findChild<QmlCustomPlot*>( + "pixelsCustomPlot" + ); if (!pixelsCustomPlot) { @@ -242,27 +249,40 @@ int main( // 38 787 engine.rootContext()->setContextProperty("max_diff", max_diff); - engine.rootContext()->setContextProperty("max_diff_idx", - int(max_diff_idx)); + engine.rootContext()->setContextProperty( + "max_diff_idx", + int(max_diff_idx) + ); engine.rootContext()->setContextProperty("min_diff", min_diff); - engine.rootContext()->setContextProperty("min_diff_idx", - int(min_diff_idx)); + engine.rootContext()->setContextProperty( + "min_diff_idx", + int(min_diff_idx) + ); engine.rootContext()->setContextProperty("avg_diff", avg_diff); - engine.rootContext()->setContextProperty("median_diff", - median_diff); - engine.rootContext()->setContextProperty("encoderPosition", - encoderPosition); - engine.rootContext()->setContextProperty("measurementCounter", - measurementCounter); - engine.rootContext()->setContextProperty("timestampUs", - timestampUs); + engine.rootContext()->setContextProperty( + "median_diff", + median_diff + ); + engine.rootContext()->setContextProperty( + "encoderPosition", + encoderPosition + ); + engine.rootContext()->setContextProperty( + "measurementCounter", + measurementCounter + ); + engine.rootContext()->setContextProperty( + "timestampUs", + timestampUs + ); manager->get(pixelsRequest); pixelsAutoRestartTimer.start(); prev_y_profile = y_pixels; - } else if (reply->url().toString().endsWith("profile")) { - qDebug() << "GOT PROFILE"; + } + else if (reply->url().toString().endsWith("profile")) + { ++profilePacketCounter; auto json = QJsonDocument::fromJson(reply->readAll()).object(); auto jsonProfile = json["profile"].toObject(); @@ -290,24 +310,24 @@ int main( profileGraph->setData(x_profile, y_profile); // pixelsGraph->setData(x_profile, y_profile); - qDebug() << "SEND PROFILE REQUEST1"; manager->get(profileRequest); profileAutoRestartTimer.start(); - qDebug() << "START PROFILE TIMER"; - } else { + } + else + { qDebug() << "unknown reply type"; } reply->deleteLater(); - // qDebug() << "reply processed for" << t.nsecsElapsed() / 1000 << "(us)"; + // qDebug() << "reply processed for" << t.nsecsElapsed() / 1000 << + // "(us)"; } ); manager->get(pixelsRequest); pixelsAutoRestartTimer.start(); - qDebug() << "SEND PROFILE REQUEST2"; manager->get(profileRequest); // profileAutoRestartTimer.start(); @@ -318,7 +338,8 @@ int main( // for(int x = -640; x < 640; ++x) // { - // double y = double(QRandomGenerator::global()->bounded(0, 80000)) / 100.; + // double y = double(QRandomGenerator::global()->bounded(0, 80000)) + // / 100.; // // x_profile << x; // y_profile << y; @@ -332,7 +353,8 @@ int main( &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, - Qt::QueuedConnection); + Qt::QueuedConnection + ); engine.loadFromModule("eurydice", "Main"); return app.exec(); |
