优化mqtt重连,开入开出界面
This commit is contained in:
parent
332756c8eb
commit
d32e5bfb55
1
.gitignore
vendored
1
.gitignore
vendored
@ -54,3 +54,4 @@ deploy/
|
||||
*.pb.cc
|
||||
|
||||
|
||||
realtimeform - 副本.cpp
|
||||
|
||||
10
Backup.cpp
10
Backup.cpp
@ -34,8 +34,14 @@ void CBackup::on_pushButton_confirm_clicked()
|
||||
QMessageBox::information(this,tr("提示"),tr("请选择导出文件路径!"));
|
||||
return;
|
||||
}
|
||||
backup_path = backup_path + "\\config\\";
|
||||
copyDirectory(QCoreApplication::applicationDirPath() + "\\config\\", backup_path);
|
||||
#ifdef Q_OS_WIN32
|
||||
backup_path = backup_path + "\\config\\";
|
||||
copyDirectory(QCoreApplication::applicationDirPath() + "\\config\\", backup_path);
|
||||
#endif
|
||||
#ifdef Q_OS_LINUX
|
||||
backup_path = backup_path + "/config/";
|
||||
copyDirectory(QCoreApplication::applicationDirPath() + "/config/", backup_path);
|
||||
#endif
|
||||
QFile file(backup_path+"macbackup");
|
||||
if (!file.open(QIODevice::ReadWrite)) {
|
||||
qWarning("Couldn't open file for writing.");
|
||||
|
||||
@ -1016,22 +1016,14 @@ void CBoardSetting::on_pushButton_Init_clicked()
|
||||
// g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
||||
// g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json");
|
||||
customLogMessageHandler(QtDebugMsg,"初始化机组板卡配置信息推送完成!");
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
#ifndef NO_FILTER
|
||||
>>>>>>> font
|
||||
QJsonObject sendData;
|
||||
sendData["cmd"] = "111";
|
||||
QNetworkRequest req;
|
||||
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
||||
req.setUrl(sUrl);
|
||||
g_NetMgr->PostJson(req,sendData);
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
#endif
|
||||
>>>>>>> font
|
||||
putJson();
|
||||
|
||||
}
|
||||
|
||||
@ -68,9 +68,6 @@ CChannelList::CChannelList(QWidget *parent) :
|
||||
ui->comboBox_operate->addItem("通道");
|
||||
ui->comboBox_operate->addItem("带通滤波");
|
||||
|
||||
|
||||
ui->comboBox_operate->addItem("带通滤波");
|
||||
ui->comboBox_operate->addItem("通道");
|
||||
//--2 创建表格项
|
||||
// QStringList workingConditionName;
|
||||
// workingConditionName<<tr("工况1")<<tr("工况2")<<tr("工况3");
|
||||
@ -79,12 +76,9 @@ CChannelList::CChannelList(QWidget *parent) :
|
||||
#ifdef QT_DEBUG
|
||||
initReadConfig();
|
||||
#endif
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#ifdef NO_FILTER
|
||||
initReadConfig();
|
||||
#endif
|
||||
>>>>>>> font
|
||||
|
||||
}
|
||||
|
||||
@ -180,10 +174,7 @@ void CChannelList::iniConnect()
|
||||
connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(itemChangedSlot(QStandardItem*)));
|
||||
|
||||
connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#ifndef NO_FILTER
|
||||
>>>>>>> font
|
||||
QJsonObject sendData;
|
||||
sendData["cmd"] = "97";
|
||||
QJsonArray chan_list;
|
||||
@ -196,10 +187,7 @@ void CChannelList::iniConnect()
|
||||
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
||||
req.setUrl(sUrl);
|
||||
g_NetMgr->PostJson(req,sendData);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#endif
|
||||
>>>>>>> font
|
||||
}
|
||||
|
||||
void CChannelList::createItem(QStringList filename)
|
||||
@ -659,12 +647,8 @@ void CChannelList::on_pushButton_open_clicked()
|
||||
}
|
||||
}
|
||||
putJson();
|
||||
<<<<<<< HEAD
|
||||
}else if(ui->comboBox_operate->currentText() == "带通滤波"){
|
||||
=======
|
||||
}else if(ui->comboBox_operate->currentText() == "带通滤波")
|
||||
{
|
||||
>>>>>>> font
|
||||
QJsonArray channleList;
|
||||
for (int i = 0; i < model->rowCount(); i++) {
|
||||
QModelIndex indexCheck = model->index(i,0);
|
||||
@ -728,10 +712,7 @@ void CChannelList::on_pushButton_refresh_clicked()
|
||||
model->removeRows(0, model->rowCount());
|
||||
g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting");
|
||||
connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#ifndef NO_FILTER
|
||||
>>>>>>> font
|
||||
QJsonObject sendData;
|
||||
sendData["cmd"] = "97";
|
||||
QJsonArray chan_list;
|
||||
@ -743,15 +724,12 @@ void CChannelList::on_pushButton_refresh_clicked()
|
||||
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
||||
req.setUrl(sUrl);
|
||||
g_NetMgr->PostJson(req,sendData);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#else
|
||||
initReadConfig();
|
||||
#endif
|
||||
#ifdef QT_DEBUG
|
||||
initReadConfig();
|
||||
#endif
|
||||
>>>>>>> font
|
||||
}
|
||||
|
||||
void CChannelList::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
@ -779,13 +757,9 @@ void CChannelList::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
initReadConfig();
|
||||
=======
|
||||
#ifndef NO_FILTER
|
||||
initReadConfig();
|
||||
#endif
|
||||
>>>>>>> font
|
||||
}
|
||||
}
|
||||
disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
||||
|
||||
@ -850,14 +850,7 @@ void CChannelSetting::on_pushButton_CustomFilter_clicked()
|
||||
|
||||
CustomFilter *pCustomFilter = new CustomFilter();
|
||||
pCustomFilter->channel_ID = channelSetting.channelId;
|
||||
<<<<<<< HEAD
|
||||
if(ui->channelTypeCombox->currentText()=="径向振动位移" && ui->comboBox_sensorType->currentText() =="低频位移")
|
||||
pCustomFilter->vibrate_channel = 1;
|
||||
else
|
||||
pCustomFilter->vibrate_channel = 0;
|
||||
=======
|
||||
pCustomFilter->vibrate_channel = 1;
|
||||
>>>>>>> font
|
||||
pCustomFilter->setWindowModality(Qt::ApplicationModal);
|
||||
pCustomFilter->show();
|
||||
pCustomFilter->getfilterInfo();
|
||||
|
||||
@ -418,6 +418,7 @@ QJsonArray CConfiguration::GetItem(QStandardItem *item,int MinimumNumber)
|
||||
QJsonArray ret;
|
||||
ret.append(jsonObjLogic);
|
||||
m_deleteInputArray.append(jsonObjLogic2);
|
||||
qDebug() << "m_array" << ret << endl;
|
||||
return ret;
|
||||
|
||||
|
||||
@ -501,6 +502,9 @@ void CConfiguration::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
|
||||
void CConfiguration::on_pushButton_save_clicked()
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
PushData();
|
||||
#endif
|
||||
connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
||||
g_NetMgr->DetectNet();
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel> //数据模型类
|
||||
#include <QTreeView>
|
||||
#include "global.h"
|
||||
#include "sqlitedb.h"
|
||||
#include "ftpclient.h"
|
||||
@ -79,6 +80,7 @@ private:
|
||||
QVector<QJsonObject> m_vecWorkConditionObj;
|
||||
QVector<QJsonObject> m_vecWorkConditionObj2;
|
||||
|
||||
|
||||
void LoadConfiguration();
|
||||
QJsonObject SelectChannel(int channelNo);
|
||||
void ViewRelay(int ChannelNoInBoard);
|
||||
|
||||
@ -92,11 +92,7 @@ void CustomFilter::on_pushButton_Submit_clicked()
|
||||
type = false;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(ui->spinBox_start->text().toInt() >= ui->spinBox_stop->text().toInt()){
|
||||
=======
|
||||
if(ui->doubleSpinBox_start->text().toDouble() >= ui->doubleSpinBox_stop->text().toDouble()){
|
||||
>>>>>>> font
|
||||
QMessageBox::warning(this, QStringLiteral("提示"), QStringLiteral("频率下限设置错误!"));
|
||||
return;
|
||||
}
|
||||
@ -104,18 +100,11 @@ void CustomFilter::on_pushButton_Submit_clicked()
|
||||
sendData2["cmd"] = "95";
|
||||
sendData2["chan_id"] = channel_ID;
|
||||
sendData2["open"] = type;
|
||||
<<<<<<< HEAD
|
||||
sendData2["start"] = ui->spinBox_start->text().toInt();
|
||||
sendData2["stop"] = ui->spinBox_stop->text().toInt();
|
||||
req.setUrl(sUrl);
|
||||
g_NetMgr->PostJson(req,sendData2);
|
||||
=======
|
||||
sendData2["start"] = ui->doubleSpinBox_start->text().toDouble();
|
||||
sendData2["stop"] = ui->doubleSpinBox_stop->text().toDouble();
|
||||
req.setUrl(sUrl);
|
||||
g_NetMgr->PostJson(req,sendData2);
|
||||
this->close();
|
||||
>>>>>>> font
|
||||
}
|
||||
|
||||
void CustomFilter::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
@ -134,23 +123,15 @@ void CustomFilter::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
if(arrays_value.toString() == "94"){
|
||||
|
||||
int Statusfilter = objec.take("status").toInt();
|
||||
<<<<<<< HEAD
|
||||
ui->spinBox_start->setValue(objec.take("start").toInt());
|
||||
ui->spinBox_stop->setValue(objec.take("stop").toInt());
|
||||
=======
|
||||
ui->doubleSpinBox_start->setValue(objec.take("start").toDouble());
|
||||
ui->doubleSpinBox_stop->setValue(objec.take("stop").toDouble());
|
||||
>>>>>>> font
|
||||
|
||||
if(Statusfilter){
|
||||
ui->comboBox_open->setCurrentText("是");
|
||||
}else if(!Statusfilter){
|
||||
ui->comboBox_open->setCurrentText("否");
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
ui->doubleSpinBox_start->setEnabled(false);
|
||||
ui->doubleSpinBox_stop->setEnabled(false);
|
||||
>>>>>>> font
|
||||
}
|
||||
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("获取成功!"));
|
||||
}else if(arrays_value.toString() == "98"){
|
||||
@ -167,23 +148,15 @@ void CustomFilter::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("获取成功!"));
|
||||
}else if(arrays_value.toString() == "112"){
|
||||
int Statusfilter = objec.take("status").toInt();
|
||||
<<<<<<< HEAD
|
||||
ui->spinBox_start->setValue(objec.take("start").toInt());
|
||||
ui->spinBox_stop->setValue(objec.take("stop").toInt());
|
||||
=======
|
||||
ui->doubleSpinBox_start->setValue(objec.take("start").toDouble());
|
||||
ui->doubleSpinBox_stop->setValue(objec.take("stop").toDouble());
|
||||
>>>>>>> font
|
||||
|
||||
if(Statusfilter){
|
||||
ui->comboBox_open->setCurrentText("是");
|
||||
}else if(!Statusfilter){
|
||||
ui->comboBox_open->setCurrentText("否");
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
ui->doubleSpinBox_start->setEnabled(false);
|
||||
ui->doubleSpinBox_stop->setEnabled(false);
|
||||
>>>>>>> font
|
||||
}
|
||||
int num = objec["num"].toInt();
|
||||
int j = 0;
|
||||
@ -202,13 +175,8 @@ void CustomFilter::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||
}
|
||||
if(!vibrate_channel){
|
||||
ui->comboBox_open->setEnabled(false);
|
||||
<<<<<<< HEAD
|
||||
ui->spinBox_start->setEnabled(false);
|
||||
ui->spinBox_stop->setEnabled(false);
|
||||
=======
|
||||
ui->doubleSpinBox_start->setEnabled(false);
|
||||
ui->doubleSpinBox_stop->setEnabled(false);
|
||||
>>>>>>> font
|
||||
}
|
||||
|
||||
}
|
||||
@ -226,11 +194,6 @@ void CustomFilter::getfilterInfo()
|
||||
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
void CustomFilter::comboBox_open_currentTextChanged(const QString &)
|
||||
{
|
||||
qDebug() << "" << endl;
|
||||
=======
|
||||
void CustomFilter::comboBox_open_currentTextChanged(const QString &str)
|
||||
{
|
||||
if(str == "否"){
|
||||
@ -240,5 +203,4 @@ void CustomFilter::comboBox_open_currentTextChanged(const QString &str)
|
||||
ui->doubleSpinBox_start->setEnabled(true);
|
||||
ui->doubleSpinBox_stop->setEnabled(true);
|
||||
}
|
||||
>>>>>>> font
|
||||
}
|
||||
|
||||
@ -28,11 +28,7 @@ private slots:
|
||||
|
||||
void on_pushButton_Submit_clicked();
|
||||
void slotNetMgr(QString sAddr,const QVariant& msg);
|
||||
<<<<<<< HEAD
|
||||
void comboBox_open_currentTextChanged(const QString &);
|
||||
=======
|
||||
void comboBox_open_currentTextChanged(const QString &str);
|
||||
>>>>>>> font
|
||||
private:
|
||||
Ui::CustomFilter *ui;
|
||||
TableHeaderView *myHeader;
|
||||
|
||||
@ -94,21 +94,9 @@ color: rgb(27, 30, 35);</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<<<<<<< HEAD
|
||||
<widget class="QSpinBox" name="spinBox_start">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
=======
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_start">
|
||||
<property name="maximum">
|
||||
<double>999999.989999999990687</double>
|
||||
>>>>>>> font
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -144,20 +132,6 @@ color: rgb(27, 30, 35);</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<<<<<<< HEAD
|
||||
<widget class="QSpinBox" name="spinBox_stop">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>200</number>
|
||||
=======
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_stop">
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
@ -167,7 +141,6 @@ color: rgb(27, 30, 35);</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.989999999990687</double>
|
||||
>>>>>>> font
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -214,15 +187,11 @@ color: rgb(27, 30, 35);</string>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<<<<<<< HEAD
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
=======
|
||||
<widget class="QTableView" name="tableView">
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
>>>>>>> font
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@ -139,7 +139,7 @@ void CDIO_Board::Init()
|
||||
void CDIO_Board::on_pushButton_Close_clicked()
|
||||
{
|
||||
QMessageBox:: StandardButton iResult = QMessageBox::question(this, QStringLiteral("提示"),
|
||||
QStringLiteral("确认后将关闭选择的开出通道!"),
|
||||
QStringLiteral("确认后继电器闭合!"),
|
||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
|
||||
switch (iResult) {
|
||||
case QMessageBox::Yes:
|
||||
@ -254,7 +254,7 @@ void CDIO_Board::on_pushButton_Open_clicked()
|
||||
// }
|
||||
// }
|
||||
QMessageBox:: StandardButton iResult = QMessageBox::question(this, QStringLiteral("提示"),
|
||||
QStringLiteral("确认后将打开选择的开出通道!"),
|
||||
QStringLiteral("确认后继电器断开!"),
|
||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
|
||||
switch (iResult) {
|
||||
case QMessageBox::Yes:
|
||||
|
||||
@ -118,14 +118,15 @@ void CHistoryAlarm::on_pushButton_search_clicked()
|
||||
|
||||
QString strTableName = "t_AlarmStatusInfo",strSql;
|
||||
if(ui->comboBox_channel->currentText() == "请选择通道..."){
|
||||
strSql = QString(" timestamp > %1 and timestamp < %2 order by timestamp ").arg(timestampStart).arg(timestampEnd);
|
||||
strSql = QString(" timestamp > %1 and timestamp < %2 order by timestamp desc").arg(timestampStart).arg(timestampEnd);
|
||||
}
|
||||
else{
|
||||
strSql = QString(" channelId = '%1' and timestamp > %2 and timestamp < %3 order by timestamp desc").arg(m_strChannelID).arg(timestampStart).arg(timestampEnd);
|
||||
}
|
||||
QVector<TriggerAlarmStatusInfo_t>().swap(m_vecTriggerAlarmStatusInfo);
|
||||
m_vecTriggerAlarmStatusInfo = g_SqliteDB->GetTriggerAlarmStatusInfo(strTableName,strSql);
|
||||
|
||||
|
||||
QString strSize = QString(" 事件个数 : %1").arg(m_vecTriggerAlarmStatusInfo.size());
|
||||
customLogMessageHandler(QtInfoMsg,strSize);
|
||||
if(m_vecTriggerAlarmStatusInfo.size() > 0){
|
||||
for (int i = 0; i < m_vecTriggerAlarmStatusInfo.size(); i++) {
|
||||
QVariantList strRowItem ;
|
||||
|
||||
@ -252,6 +252,19 @@ void CImportConfig::on_pushButton_confirm_clicked()
|
||||
// g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
||||
// g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json");
|
||||
g_FtpClient->uploadFile(str,name,"UnitBoardsInfo.json");
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
QString fileNameChannel = QCoreApplication::applicationDirPath() + "\\config\\ChannelSettings.json";
|
||||
#endif
|
||||
#ifdef Q_OS_LINUX
|
||||
QString fileNameChannel = QCoreApplication::applicationDirPath() + "/config/ChannelSettings.json";
|
||||
#endif
|
||||
QString strChannelSettings = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("ChannelSettings.json");
|
||||
// g_FtpClient->SetServerInfo(str);
|
||||
// g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
||||
// g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json");
|
||||
g_FtpClient->uploadFile(strChannelSettings,fileNameChannel,"UnitBoardsInfo.json");
|
||||
|
||||
qApp->exit(0);
|
||||
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ MqttClient::MqttClient(QObject *parent) : QObject(parent)
|
||||
void MqttClient::onMQTT_Connected()
|
||||
{
|
||||
qDebug()<< "doConnected" <<endl;
|
||||
emit DoConnect_sig();
|
||||
}
|
||||
|
||||
void MqttClient::onMQTT_disconnected()
|
||||
@ -48,37 +49,44 @@ void MqttClient::onMQTT_Connected()
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void MqttClient::onMQTT_error(QMQTT::ClientError err)
|
||||
{
|
||||
//todo: should emit on server suback
|
||||
|
||||
QString errInfo;
|
||||
QString errInfo;
|
||||
QTimer *timer;
|
||||
|
||||
switch(err) {
|
||||
// 0 The connection was refused by the peer (or timed out).
|
||||
case QAbstractSocket::ConnectionRefusedError:
|
||||
errInfo = tr("Connection Refused");
|
||||
break;
|
||||
// 1 The remote host closed the connection. Note that the client socket (i.e., this socket) will be closed after the remote close notification has been sent.
|
||||
case QAbstractSocket::RemoteHostClosedError:
|
||||
errInfo = tr("Remote Host Closed");
|
||||
break;
|
||||
// 2 The host address was not found.
|
||||
case QAbstractSocket::HostNotFoundError:
|
||||
errInfo = tr("Host Not Found Error");
|
||||
break;
|
||||
// 3 The socket operation failed because the application lacked the required privileges.
|
||||
case QAbstractSocket::SocketAccessError:
|
||||
errInfo = tr("Socket Access Error");
|
||||
break;
|
||||
// 4 The local system ran out of resources (e.g., too many sockets).
|
||||
case QAbstractSocket::SocketResourceError:
|
||||
errInfo = tr("Socket Resource Error");
|
||||
break;
|
||||
// 5 The socket operation timed out.
|
||||
case QAbstractSocket::SocketTimeoutError:
|
||||
errInfo = tr("Socket Timeout Error");
|
||||
break;
|
||||
default:
|
||||
errInfo = tr("Socket Error");
|
||||
break;
|
||||
}
|
||||
|
||||
qDebug()<< errInfo <<endl;;
|
||||
qDebug()<< errInfo <<endl;
|
||||
|
||||
}
|
||||
|
||||
@ -112,7 +120,7 @@ void MqttClient::onMQTT_Connected()
|
||||
|
||||
void MqttClient::onMQTT_unsubscribed(const QString &topic)
|
||||
{
|
||||
|
||||
m_client->unsubscribe(topic);
|
||||
}
|
||||
|
||||
void MqttClient::onMQTT_unsubacked(quint16 msgid)
|
||||
@ -134,13 +142,11 @@ void MqttClient::subscribed(QString strTopic)
|
||||
void MqttClient::ConnectMQTT(QString strIP)
|
||||
{
|
||||
m_client = new QMQTT::Client(QHostAddress(strIP),1883);
|
||||
|
||||
//m_client->setHost(QHostAddress("192.168.1.156"));
|
||||
//m_client->setPort(51613);
|
||||
m_client->setUsername("chaos");
|
||||
m_client->setPassword("HSD272*#xkd");
|
||||
m_client->connectToHost();
|
||||
|
||||
m_client->setAutoReconnect(true);
|
||||
m_client->setAutoReconnectInterval(60);
|
||||
connect(m_client, SIGNAL(connected()), this, SLOT(onMQTT_Connected()));
|
||||
//todo: should emit on server suback
|
||||
//connect(_client, SIGNAL(connacked(quint8)), this, SLOT(onMQTT_Connacked(quint8)));
|
||||
|
||||
@ -28,6 +28,7 @@ public slots:
|
||||
void onMQTT_disconnected();
|
||||
signals:
|
||||
void Recevive_sig(QString,QByteArray);
|
||||
void DoConnect_sig();
|
||||
};
|
||||
|
||||
#endif // MQTTCLIENT_H
|
||||
|
||||
@ -20,10 +20,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
g_FtpClient = new FtpClient();
|
||||
|
||||
//读取ini
|
||||
<<<<<<< HEAD
|
||||
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat);
|
||||
g_strVersion = "SJ90C V1.1";
|
||||
=======
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat);
|
||||
@ -34,9 +30,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
||||
|
||||
g_strVersion = "SJ90C V1.1_" + buildDate.toString("yyyyMMdd");
|
||||
g_strVersion = "SJ90C V1.1.0_" + buildDate.toString("yyyyMMdd");
|
||||
customLogMessageHandler(QtDebugMsg,g_strVersion + " " + buildTime.toString());
|
||||
>>>>>>> font
|
||||
g_strProject = settingsread.value("main/Project").toString();
|
||||
g_strFre = settingsread.value("main/Fre").toString();
|
||||
|
||||
@ -91,13 +86,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
mqttclient = new MqttClient(this);
|
||||
mqttclient->ConnectMQTT(IP);
|
||||
|
||||
|
||||
id1 = startTimer(5000); //参数1 间隔 单位 毫秒
|
||||
//定时器第二种方式
|
||||
QTimer * timer = new QTimer(this);
|
||||
//启动定时器
|
||||
timer->start(500);
|
||||
|
||||
connect(mqttclient, SIGNAL(DoConnect_sig()), this, SLOT(mqttDoConnect_slot()));
|
||||
connect(mqttclient, SIGNAL(Recevive_sig(QString,QByteArray)), this, SLOT(mqttReceive_slot(QString,QByteArray)));
|
||||
LoadTrigerConfig();
|
||||
|
||||
}
|
||||
@ -106,19 +96,15 @@ void MainWindow::LoadTrigerConfig()
|
||||
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
|
||||
}
|
||||
|
||||
void MainWindow::mqttDoConnect_slot(){
|
||||
|
||||
m_strTriggerEnevtTopic = QString("up/%1/trigger").arg(MAC);//订阅
|
||||
m_triggerAlarmSatusTopic = QString("up/%1/triggerAlarmStatus").arg(MAC);
|
||||
//m_strTriggerEnevtTopic = QString("up/%1/characteristic").arg(MAC);//订阅
|
||||
mqttclient->subscribed(m_strTriggerEnevtTopic);
|
||||
mqttclient->subscribed(m_triggerAlarmSatusTopic);
|
||||
|
||||
|
||||
void MainWindow::timerEvent(QTimerEvent *ev)
|
||||
{
|
||||
if(ev->timerId() == id1)
|
||||
{
|
||||
m_strTriggerEnevtTopic = QString("up/%1/trigger").arg(MAC);//订阅
|
||||
m_triggerAlarmSatusTopic = QString("up/%1/triggerAlarmStatus").arg(MAC);
|
||||
//m_strTriggerEnevtTopic = QString("up/%1/characteristic").arg(MAC);//订阅
|
||||
mqttclient->subscribed(m_strTriggerEnevtTopic);
|
||||
mqttclient->subscribed(m_triggerAlarmSatusTopic);
|
||||
connect(mqttclient, SIGNAL(Recevive_sig(QString,QByteArray)), this, SLOT(mqttReceive_slot(QString,QByteArray)));
|
||||
killTimer(id1);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -178,8 +164,6 @@ void MainWindow::initWindow()
|
||||
//设置顶部导航按钮
|
||||
QList<QAbstractButton *> tbtns = ui->widgetTop->findChildren<QAbstractButton *>();
|
||||
foreach (QAbstractButton *btn, tbtns) {
|
||||
//btn->setIconSize(icoSize);
|
||||
//btn->setMinimumWidth(icoWidth);
|
||||
btn->setCheckable(true);
|
||||
connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick()));
|
||||
}
|
||||
@ -286,9 +270,6 @@ void MainWindow::leftConfigClick()
|
||||
ui->tabWidget_main->setCurrentWidget(pWaveDisPlay);
|
||||
|
||||
}else if(name == "开入开出"){
|
||||
// Form *dlg = new Form();
|
||||
// dlg->setWindowModality(Qt::ApplicationModal);
|
||||
// dlg->show();
|
||||
if(pDIOBoard == NULL)
|
||||
pDIOBoard = new CDIO_Board(this);
|
||||
ui->tabWidget_main->addTab(pDIOBoard,"");
|
||||
@ -587,6 +568,12 @@ void MainWindow::leftConfigClick4()
|
||||
QProcess process(this);
|
||||
process.startDetached(".\\Calibration\\NARI3500Calibration.exe");
|
||||
}else if(name == "其他配置"){
|
||||
|
||||
if(pDIOBoard){
|
||||
delete pDIOBoard;
|
||||
pDIOBoard = NULL;
|
||||
}
|
||||
|
||||
if(pOtherConfig == NULL)
|
||||
pOtherConfig = new COtherConfig (this);
|
||||
ui->tabWidget_sysConfig->addTab(pOtherConfig,"");
|
||||
@ -684,6 +671,7 @@ void MainWindow::slotRPM(QString& str)
|
||||
|
||||
void MainWindow::mqttReceive_slot(QString strTopic,QByteArray payload)
|
||||
{
|
||||
qDebug() << payload << strTopic << endl;
|
||||
if(strTopic == m_strTriggerEnevtTopic){
|
||||
QString strReceive = QString(payload);
|
||||
qDebug() << strReceive.size() << endl;
|
||||
|
||||
@ -61,6 +61,7 @@ private slots:
|
||||
void slotWCStatus(QString&);
|
||||
void slotRPM(QString&);
|
||||
void mqttReceive_slot(QString,QByteArray);
|
||||
void mqttDoConnect_slot();
|
||||
|
||||
void on_pushButton_detail_clicked();
|
||||
void slotNetMgr(QString sAddr,const QVariant& msg);
|
||||
@ -92,9 +93,6 @@ private:
|
||||
COtherConfig *pOtherConfig;
|
||||
MqttClient *mqttclient;
|
||||
QString m_strTriggerEnevtTopic,m_triggerAlarmSatusTopic;
|
||||
|
||||
virtual void timerEvent(QTimerEvent *);
|
||||
int id1; //定时器1的唯一标示
|
||||
void LoadTrigerConfig();
|
||||
};
|
||||
|
||||
|
||||
11
sqlitedb.cpp
11
sqlitedb.cpp
@ -81,17 +81,6 @@ int SqliteDB::initTable()
|
||||
iRet = ExeSqlData(strSql);
|
||||
if(iRet == 0){
|
||||
strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer DEFAULT 1";
|
||||
<<<<<<< HEAD
|
||||
ExeSqlData(strSql);
|
||||
}
|
||||
|
||||
strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
|
||||
.arg("sqlite_master").arg("t_ChannelSetting").arg("filterStatus");
|
||||
iRet = ExeSqlData(strSql);
|
||||
if(iRet == 0){
|
||||
strSql = "ALTER TABLE t_ChannelSetting ADD COLUMN 'filterStatus' integer";
|
||||
=======
|
||||
>>>>>>> font
|
||||
ExeSqlData(strSql);
|
||||
}
|
||||
//#ifndef NO_FILTER
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user