no message
parent
5eeda7ab66
commit
e0f929fab3
13
global.h
13
global.h
|
@ -49,23 +49,26 @@ public:
|
|||
}
|
||||
void AddConfig(Config *c){
|
||||
if(nullptr != c){
|
||||
mMux.lock();
|
||||
for(auto itr = mConf.begin();itr != mConf.end();
|
||||
itr++){
|
||||
if (c == *itr){
|
||||
mMux.unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->mConf.append(c);
|
||||
mMux.unlock();
|
||||
}
|
||||
}
|
||||
void Run(void *v) override{
|
||||
|
||||
// 读取1
|
||||
float x = 0;
|
||||
while(mRuning){
|
||||
int count = 0;
|
||||
|
||||
int it = 0;
|
||||
for(;it < mConf.size();
|
||||
it++){
|
||||
for(int it = 0;it < mConf.size();it++) {
|
||||
auto itr = mConf.at(it);
|
||||
uint16_t dat[10] = {0};
|
||||
mMod = modbus_new_rtu(itr->com.toStdString().c_str(),
|
||||
|
@ -79,7 +82,6 @@ public:
|
|||
|
||||
for(auto s = 0;s < itr->req.length();s++){
|
||||
|
||||
|
||||
QThread::msleep(1000);
|
||||
int ret = modbus_read_registers(mMod,itr->req[s].addr,itr->req[s].len,dat);
|
||||
|
||||
|
@ -103,7 +105,8 @@ public:
|
|||
}
|
||||
modbus_close(mMod);
|
||||
}
|
||||
QThread::msleep(1000*pcom->rate);
|
||||
qDebug()<<"keep alive";
|
||||
QThread::msleep(100);
|
||||
}
|
||||
// 读取2
|
||||
}
|
||||
|
|
|
@ -60,30 +60,28 @@ void MainWindow::on_pushButton_clicked()
|
|||
|
||||
void MainWindow::on_pushButton_3_clicked()
|
||||
{
|
||||
if(this->mForms.contains(ui->lineEdit_2->text())){
|
||||
QMessageBox::warning(this,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>","<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
SubForm *p1 = new SubForm(ui->lineEdit_2->text(),
|
||||
ui->comboBox->currentText().toInt(),
|
||||
ui->lineEdit_2->text().toInt());
|
||||
qDebug()<<ui->lineEdit_2->text();
|
||||
ui->tabWidget->addTab((QWidget*)p1,"<EFBFBD>豸<EFBFBD><EFBFBD>ַ:" + 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->AddConfig(new Config{
|
||||
// QString(ui->comboBox_2->currentText()),
|
||||
// ui->lineEdit_2->text().toInt(),
|
||||
// ui->lineEdit_3->text().toInt(),
|
||||
// });
|
||||
qDebug()<<"hello world";
|
||||
gAsyncData->Start(nullptr);
|
||||
|
||||
}
|
||||
if(this->mForms.contains(ui->lineEdit_2->text())){
|
||||
QMessageBox::warning(this,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>","<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
SubForm *p1 = new SubForm(ui->comboBox_2->currentText(),
|
||||
ui->comboBox->currentText().toInt(),
|
||||
ui->lineEdit_2->text().toInt());
|
||||
qDebug()<<ui->lineEdit_2->text();
|
||||
ui->tabWidget->addTab((QWidget*)p1,"address:" + ui->lineEdit_2->text());
|
||||
this->mForms[ui->lineEdit_2->text()] = p1;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
diff a/mainwindow.cpp b/mainwindow.cpp (rejected hunks)
|
||||
@@ -79,6 +79,11 @@
|
||||
|
||||
}
|
||||
|
||||
+// gAsyncData->AddConfig(new Config{
|
||||
+// QString(ui->comboBox_2->currentText()),
|
||||
+// ui->lineEdit_2->text().toInt(),
|
||||
+// ui->lineEdit_3->text().toInt(),
|
||||
+// });
|
||||
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@
|
|||
<widget class="QComboBox" name="comboBox_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
|
|
10
subform.cpp
10
subform.cpp
|
@ -27,13 +27,17 @@ SubForm::SubForm(QString addr,int baurate,int device_addr)
|
|||
mModel->setHorizontalHeaderLabels(QStringList() << "寄存器地址" << "返回值"<<"读取时间");
|
||||
ui->tableView->setModel(mModel);
|
||||
|
||||
mConfig = new Config;
|
||||
mConfig->addr = device_addr;
|
||||
mConfig->com = *com;
|
||||
|
||||
connect(pTimer,&QTimer::timeout,[=](){
|
||||
static float sd = 0;
|
||||
if(gAsyncData == nullptr)
|
||||
return;
|
||||
CapData *z = new CapData;
|
||||
|
||||
int ret = gAsyncData->TakeLast((*com).toInt(),&z);
|
||||
int ret = gAsyncData->TakeLast(device_addr,&z);
|
||||
if(ret == 0){
|
||||
mSeries1->append(sd,z->val1);
|
||||
|
||||
|
@ -60,10 +64,8 @@ SubForm::SubForm(QString addr,int baurate,int device_addr)
|
|||
pTimer->start(100);
|
||||
qDebug()<<QDateTime::currentDateTime().toString();
|
||||
ui->lineEdit_2->setText(addr);
|
||||
gAsyncData->AddConfig(this->mConfig);
|
||||
|
||||
mConfig = new Config;
|
||||
mConfig->addr = device_addr;
|
||||
mConfig->com = *com;
|
||||
}
|
||||
|
||||
void SubForm::on_pushButton_clicked() {
|
||||
|
|
Loading…
Reference in New Issue