86 lines
1.8 KiB
C++
86 lines
1.8 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include <QSerialPortInfo>
|
|
#include <QDebug>
|
|
#include <QMutex>
|
|
#include "Qss.h"
|
|
#include "libmodbus/modbus.h"
|
|
#include <math.h>
|
|
#include <QTimer>
|
|
#include <QFileDialog>
|
|
#include "global.h"
|
|
#include <subform.h>
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
|
|
# pragma execution_character_set("utf-8")
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
, mStart(false)
|
|
, mConfig(nullptr) {
|
|
ui->setupUi(this);
|
|
auto list3 = QSerialPortInfo::availablePorts();
|
|
for(int i=0;i<list3.size();i++){
|
|
qDebug()<<list3[i].portName();//
|
|
ui->comboBox_2->addItem(list3[i].portName());
|
|
}
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::init_charts()
|
|
{
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_2_clicked()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
{
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_3_clicked()
|
|
{
|
|
if(this->mForms.contains(ui->lineEdit_2->text())){
|
|
QMessageBox::warning(this,"鍦板潃宸茬粡鐩戝惉","鍦板潃宸茬粡鐩戝惉");
|
|
return;
|
|
}
|
|
SubForm *p1 = new SubForm(ui->lineEdit_2->text());
|
|
qDebug()<<ui->lineEdit_2->text();
|
|
ui->tabWidget->addTab((QWidget*)p1,"设备地址:" + ui->lineEdit_2->text());
|
|
this->mForms[ui->lineEdit_2->text()] = p1;
|
|
|
|
|
|
if(nullptr == gAsyncData){
|
|
gAsyncData = new ASyncReadData(this);
|
|
connect(gAsyncData,&QSSASyncProcess::Done,[&](){
|
|
qDebug()<<"done";
|
|
});
|
|
|
|
gAsyncData->Start(new Config{
|
|
QString(ui->comboBox_2->currentText()),
|
|
ui->lineEdit_2->text().toInt(),
|
|
ui->lineEdit_3->text().toInt(),
|
|
});
|
|
}
|
|
gAsyncData->AddConfig( Config{
|
|
QString(ui->comboBox_2->currentText()),
|
|
ui->lineEdit_2->text().toInt(),
|
|
ui->lineEdit_3->text().toInt(),
|
|
});
|
|
|
|
}
|
|
|