| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include "widget.h"
- #include <QApplication>
- #include "dataupdatethread.h"
- #include "buttonclickthread.h"
- #include <QScreen>
- #include <QGraphicsScene>
- #include <QGraphicsView>
- #include "pdu_ctrl.h"
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- //窗口初始化
- pdu_Ctrl::instance();
- Widget w;
- qDebug()<<"widget End";
- QGraphicsScene *scene = new QGraphicsScene;
- QGraphicsView *gview = new QGraphicsView(scene);
- QGraphicsProxyWidget *g_proxy_widget;
- qDebug()<<"Widget-x:"<<w.size().width()<<"y:"<<w.size().height();
- qDebug()<<"get Screen Start";
- QScreen *desktop = QApplication::primaryScreen();
- QRect screen_info = desktop->geometry();
- qDebug()<<"get Screen End";
- // Rotation 90 degree
- g_proxy_widget = scene->addWidget((QWidget*)&w);
- g_proxy_widget->setRotation(0);
- // Set window size
- qDebug()<<"Reset Widget";
- w.resize(screen_info.width(), screen_info.height());
- qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
- /*
- QRect screen_info(0,0,128,64);
- w.resize(screen_info.width(), screen_info.height());
- */
- qDebug()<<"get Screen End";
- qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
- pdu_Ctrl::instance()->InitData(&w,g_proxy_widget,gview,screen_info.width(), screen_info.height());
- gview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- gview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- gview->setStyleSheet("border:none");
- gview->showFullScreen();
- qDebug()<<"x:"<<w.size().width()<<"y:"<<w.size().height();
- qDebug()<<"Modbus Thread start";
- QString appDirPath = QCoreApplication::applicationDirPath();
- pdu_Ctrl::instance()->strSqliteAddress=appDirPath+"/pdu_dat.db";
- pdu_Ctrl::instance()->ReadModbusInit();
- //============================线程开启====================================
- //数据更新线程
- DataUpdateThread thread_Update(nullptr);
- thread_Update.pwidget=&w;
- //QString appDirPath = QCoreApplication::applicationDirPath();
- //thread_Update.strSqliteAddress=appDirPath+"/pdu_dat.db";
- thread_Update.initShm();
- thread_Update.start();
- //GPIO更新线程
- qDebug()<<"GPIO Thread start";
- ButtonClickThread thread_Button(nullptr);
- thread_Button.InitConnect();
- thread_Button.start();
- //thread_Button.InitConnect();
- int ret=a.exec();
- //析构
- thread_Update.isRunStats=false;
- thread_Update.wait();
- thread_Button.isRunning=false;
- thread_Button.wait();
- pdu_Ctrl::distory();
- return ret;
- }
|