main.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "widget.h"
  2. #include <QApplication>
  3. #include "dataupdatethread.h"
  4. #include "buttonclickthread.h"
  5. #include <QScreen>
  6. #include <QGraphicsScene>
  7. #include <QGraphicsView>
  8. #include "pdu_ctrl.h"
  9. int main(int argc, char *argv[])
  10. {
  11. QApplication a(argc, argv);
  12. //窗口初始化
  13. pdu_Ctrl::instance();
  14. Widget w;
  15. qDebug()<<"widget End";
  16. QGraphicsScene *scene = new QGraphicsScene;
  17. QGraphicsView *gview = new QGraphicsView(scene);
  18. QGraphicsProxyWidget *g_proxy_widget;
  19. qDebug()<<"x:"<<w.size().width()<<"y:"<<w.size().height();
  20. QScreen *desktop = QApplication::primaryScreen();
  21. QRect screen_info = desktop->geometry();
  22. // Rotation 90 degree
  23. g_proxy_widget = scene->addWidget((QWidget*)&w);
  24. g_proxy_widget->setRotation(0);
  25. // Set window size
  26. w.resize(screen_info.width(), screen_info.height());
  27. qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
  28. pdu_Ctrl::instance()->InitData(&w,g_proxy_widget,gview,screen_info.width(), screen_info.height());
  29. gview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  30. gview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  31. gview->setStyleSheet("border:none");
  32. gview->showFullScreen();
  33. qDebug()<<"x:"<<w.size().width()<<"y:"<<w.size().height();
  34. qDebug()<<"Thread start";
  35. QString appDirPath = QCoreApplication::applicationDirPath();
  36. pdu_Ctrl::instance()->strSqliteAddress=appDirPath+"/pdu_dat.db";
  37. pdu_Ctrl::instance()->ReadModbusInit();
  38. //============================线程开启====================================
  39. //数据更新线程
  40. DataUpdateThread thread_Update(nullptr);
  41. thread_Update.pwidget=&w;
  42. //QString appDirPath = QCoreApplication::applicationDirPath();
  43. //thread_Update.strSqliteAddress=appDirPath+"/pdu_dat.db";
  44. thread_Update.initShm();
  45. thread_Update.start();
  46. //GPIO更新线程
  47. ButtonClickThread thread_Button(nullptr);
  48. thread_Button.InitConnect();
  49. thread_Button.start();
  50. //thread_Button.InitConnect();
  51. int ret=a.exec();
  52. //析构
  53. thread_Update.isRunStats=false;
  54. thread_Update.wait();
  55. thread_Button.isRunning=false;
  56. thread_Button.wait();
  57. pdu_Ctrl::distory();
  58. return ret;
  59. }