|
|
|
@ -7,6 +7,8 @@
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *ReadOnlyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
@ -62,6 +64,10 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
crc32_table_init();
|
|
|
|
|
|
|
|
|
|
// 隐藏不用的页面
|
|
|
|
|
//ui->tabWidget->setTabEnabled(ui->tabWidget->indexOf(ui->frequencyTab), false);
|
|
|
|
|
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->frequencyTab));
|
|
|
|
|
|
|
|
|
|
/* 配置校准页面表格 */
|
|
|
|
|
ui->adjustTable->horizontalHeader()->setVisible(true);
|
|
|
|
|
ui->adjustTable->horizontalHeader()->resizeSection(0,20);
|
|
|
|
@ -129,16 +135,24 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
/* 打开配置文件, 恢复关闭前的状态. */
|
|
|
|
|
QString file = QCoreApplication::applicationDirPath()+"/CableTool.ini";
|
|
|
|
|
settings = new QSettings(file, QSettings::IniFormat, this);
|
|
|
|
|
#if 0
|
|
|
|
|
for(int i = 0; i < ui->comboPort->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (!QString::compare(ui->comboPort->itemText(i), settings->value("usartBoxName", "COM1").toString(), Qt::CaseSensitive))
|
|
|
|
|
if (QString::compare(ui->comboPort->itemText(i), settings->value("usartBoxName", "COM1").toString(), Qt::CaseSensitive) == 0)
|
|
|
|
|
{
|
|
|
|
|
ui->comboPort->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
ui->comboBaud->setCurrentIndex(settings->value("baudBoxIndex", 6).toInt());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ui->comboBaud->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (QString::compare(ui->comboBaud->itemText(i), settings->value("baudBoxIndex", "115200").toString(), Qt::CaseSensitive) == 0)
|
|
|
|
|
{
|
|
|
|
|
ui->comboBaud->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ui->comboBaud->setCurrentIndex(11);
|
|
|
|
|
QString pcom = settings->value("usartBoxName").toString();
|
|
|
|
|
qDebug() << "com:" << pcom << endl;
|
|
|
|
|
filePath = settings->value("updateFile", "").toString();
|
|
|
|
|
adjFilePath = settings->value("adjFile", "").toString();
|
|
|
|
|
waveFilePath = settings->value("waveFile", "").toString();
|
|
|
|
@ -148,6 +162,29 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
ui->fileTypeBox->setCurrentIndex(settings->value("updateFileType", 0).toInt());
|
|
|
|
|
ui->freChBox->setCurrentIndex(settings->value("freChIndex", 0).toInt());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//创建辅助线程,
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
|
|
|
|
|
|
//创建任务类,不能指定父指针为this,否则还是会在当前线程
|
|
|
|
|
worker=new Worker;
|
|
|
|
|
//移动到线程
|
|
|
|
|
worker->moveToThread(m_thread);
|
|
|
|
|
|
|
|
|
|
//绑定worker发射的信号,来更新ui界面的label
|
|
|
|
|
connect(worker,&Worker::changeString,this,&Widget::on_displayMessage);
|
|
|
|
|
|
|
|
|
|
//绑定自定义的triggerWork信号,来触发worker的工作函数,工作函数就会在子线程中执行
|
|
|
|
|
connect(this,&Widget::triggerWork,worker,&Worker::doWork);
|
|
|
|
|
|
|
|
|
|
//手动启动线程
|
|
|
|
|
m_thread->start();
|
|
|
|
|
|
|
|
|
|
qDebug()<<"主函数所在线程:"<<QThread::currentThreadId();
|
|
|
|
|
|
|
|
|
|
emit triggerWork();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget::~Widget()
|
|
|
|
@ -220,9 +257,23 @@ void Widget::serialDisconnect()
|
|
|
|
|
buttonEnable(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::on_displayMessage(QString text)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), text);
|
|
|
|
|
if (QString::compare(UART_COMMUNICATION_ERROR, text, Qt::CaseSensitive) == 0)
|
|
|
|
|
{
|
|
|
|
|
serialDisconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::initSerial()
|
|
|
|
|
int Widget::openSerial()
|
|
|
|
|
{
|
|
|
|
|
if (serialPort)
|
|
|
|
|
{
|
|
|
|
|
delete serialPort;
|
|
|
|
|
serialPort = nullptr;
|
|
|
|
|
}
|
|
|
|
|
serialPort = new QSerialPort;
|
|
|
|
|
serialPort->setPortName(ui->comboPort->currentText());
|
|
|
|
|
serialPort->setBaudRate(ui->comboBaud->currentText().toInt());
|
|
|
|
@ -239,8 +290,6 @@ int Widget::initSerial()
|
|
|
|
|
{ // open failed
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), serialPort->errorString());
|
|
|
|
|
}
|
|
|
|
|
//serialPort->setBaudRate(ui->comboBaud->currentText().toInt());
|
|
|
|
|
qDebug() << "baudrate:" << serialPort->baudRate();
|
|
|
|
|
|
|
|
|
|
//newTask = new QThread;
|
|
|
|
|
//usartProtocol = new Protocol;
|
|
|
|
@ -259,9 +308,10 @@ int Widget::deinitSerial()
|
|
|
|
|
if (serialPort->isOpen())
|
|
|
|
|
{
|
|
|
|
|
//disconnect(&serialPort, &QSerialPort::readyRead, this, &Widget::readData);
|
|
|
|
|
serialPort->waitForReadyRead(500); // Wait 0.5 second to read all the data.
|
|
|
|
|
serialPort->waitForReadyRead(100); // Wait 0.5 second to read all the data.
|
|
|
|
|
serialPort->close();
|
|
|
|
|
delete serialPort;
|
|
|
|
|
serialPort = nullptr;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -277,33 +327,39 @@ int Widget::readData()
|
|
|
|
|
char *buf = qarry.data();
|
|
|
|
|
int len = qarry.size();
|
|
|
|
|
|
|
|
|
|
qDebug() << __FUNCTION__ << "LEN=" << len << endl;
|
|
|
|
|
//qDebug() << __FUNCTION__ << "LEN=" << len << "rxbufLen:" << rxbufLen << endl;
|
|
|
|
|
//HexPrint(__FUNCTION__, buf, len);
|
|
|
|
|
|
|
|
|
|
if (len < 0 || len > USART_BUF_SIZE)
|
|
|
|
|
if (len < 0 || static_cast<unsigned int>(len) > USART_BUF_SIZE)
|
|
|
|
|
{
|
|
|
|
|
rxbufLen = 0;
|
|
|
|
|
qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n";
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len + rxbufLen > USART_BUF_SIZE)
|
|
|
|
|
{
|
|
|
|
|
rxbufLen = 0;
|
|
|
|
|
qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n";
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy(rxbuf + rxbufLen, buf, len);
|
|
|
|
|
memcpy(rxbuf + rxbufLen, buf, static_cast<unsigned int>(len));
|
|
|
|
|
rxbufLen += len;
|
|
|
|
|
|
|
|
|
|
if (rxbufLen < sizeof(proto_head_t))
|
|
|
|
|
if (static_cast<unsigned int>(rxbufLen) < sizeof(proto_head_t))
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n";
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(rxbuf);
|
|
|
|
|
//qDebug() << "header->len:" << header->len << endl;
|
|
|
|
|
//qDebug() << "header->len:" << header->len << " " << "rxbufLen:" << rxbufLen << endl;
|
|
|
|
|
if (rxbufLen != header->len + 4)
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n";
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* CRC32 校验. */
|
|
|
|
|
if (crc32(rxbuf, header->len) != (*reinterpret_cast<uint32_t*>(rxbuf + header->len)))
|
|
|
|
@ -312,12 +368,13 @@ int Widget::readData()
|
|
|
|
|
rxbufLen = 0;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
rxbufLen = 0;
|
|
|
|
|
|
|
|
|
|
//printHexArray(__FUNCTION__, buf, len);
|
|
|
|
|
//HexPrint(__FUNCTION__, rxbuf, (header->len + 4));
|
|
|
|
|
|
|
|
|
|
paraseProtocols(rxbuf);
|
|
|
|
|
rxbufLen = 0;
|
|
|
|
|
|
|
|
|
|
//qDebug() << "end rxbufLen = " << rxbufLen << endl;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
qarry.clear();
|
|
|
|
@ -489,6 +546,7 @@ void Widget::uiDevInfoRefresh()
|
|
|
|
|
|
|
|
|
|
void Widget::uiDevConfigRefresh()
|
|
|
|
|
{
|
|
|
|
|
qDebug() << __FUNCTION__ << "flag:" << clientDevConfig.flag << endl;
|
|
|
|
|
if (IS_MONITOR_BIT_SET(clientDevConfig.flag, DEV_FLAG_CLI))
|
|
|
|
|
{
|
|
|
|
|
ui->debugModeBox->setCurrentIndex(0);
|
|
|
|
@ -525,7 +583,7 @@ void Widget::uiDevConfigRefresh()
|
|
|
|
|
ui->normalSleepBox->setCurrentIndex(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui->APNEdit->setText(QString(reinterpret_cast<char*>(clientDevConfig.APN_long)));
|
|
|
|
|
//ui->APNEdit->setText(QString(reinterpret_cast<char*>(clientDevConfig.APN_long)));
|
|
|
|
|
|
|
|
|
|
ui->colIntervalEdit->setText(QString::number(clientDevConfig.collectInterval));
|
|
|
|
|
ui->waveIntervalEdit->setText(QString::number(clientDevConfig.waveInterval));
|
|
|
|
@ -745,6 +803,7 @@ void Widget::protoContact(char *data)
|
|
|
|
|
memcpy(&clientDevInfo, pbody, sizeof(devInfo));
|
|
|
|
|
uiDevInfoRefresh();
|
|
|
|
|
buttonEnable(true);
|
|
|
|
|
worker->timeCounterReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::protoConfig(char *data)
|
|
|
|
@ -931,16 +990,44 @@ int Widget::protoManualAdjust(char *data)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Widget::protoAdjustInfo(char *data)
|
|
|
|
|
int Widget::protoAdjustInfoGet(char *data)
|
|
|
|
|
{
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
memcpy(&clientAdjInfo, data + sizeof(proto_head_t), sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
|
|
/* 更新界面. */
|
|
|
|
|
protoManualAdjust(data);
|
|
|
|
|
uiAdjustInfoRefresh();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Widget::protoAutoAdjust(char *data)
|
|
|
|
|
{
|
|
|
|
|
int32_t rv = *reinterpret_cast<int32_t*>(data + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
|
|
/* 跳转状态. */
|
|
|
|
|
//if (work)
|
|
|
|
|
{
|
|
|
|
|
//work->stateSet(CM_usart::WS_ADJ_INFO_GET);
|
|
|
|
|
//work->mutexUnlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustInfoGet();
|
|
|
|
|
buttonEnable(true);
|
|
|
|
|
|
|
|
|
|
/* 判断返回值. */
|
|
|
|
|
if (0 == rv)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "校准完成.", QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "WARNING", "校准失败!", QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoLog(char * data)
|
|
|
|
|
{
|
|
|
|
|
mul_head_t *header = reinterpret_cast<mul_head_t*>(data + sizeof(proto_head_t));
|
|
|
|
@ -1097,8 +1184,8 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
|
{
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(data);
|
|
|
|
|
|
|
|
|
|
//qDebug() << "cmd_type:" << header->cmd_type << "cmd:" << header->cmd << endl;
|
|
|
|
|
//qDebug() << "len:" << header->len << endl;
|
|
|
|
|
qDebug() << "cmd_type:" << header->cmd_type << "cmd:" << header->cmd << endl;
|
|
|
|
|
qDebug() << "len:" << header->len << endl;
|
|
|
|
|
if (DEBUG_CT_REPLY == header->cmd_type)
|
|
|
|
|
{
|
|
|
|
|
/* 共有命令处理. */
|
|
|
|
@ -1146,14 +1233,14 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
|
protoWaveDataUploadReply(data);
|
|
|
|
|
break;
|
|
|
|
|
case DEBUG_PRV_ADJ_INFO:
|
|
|
|
|
protoAdjustInfo(data);
|
|
|
|
|
protoAdjustInfoGet(data);
|
|
|
|
|
break;
|
|
|
|
|
case DEBUG_PRV_ADJ_INFO_SET:
|
|
|
|
|
/* 更新界面. */
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "操作完成.", QMessageBox::Ok);
|
|
|
|
|
break;
|
|
|
|
|
case DEBUG_PRV_ADJ_AUTO:
|
|
|
|
|
//_debug_pkt_adj_auto();
|
|
|
|
|
protoAutoAdjust(data);
|
|
|
|
|
break;
|
|
|
|
|
case DEBUG_PRV_DEV_STATE:
|
|
|
|
|
protoState(data);
|
|
|
|
@ -1183,6 +1270,7 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Widget::snedMsgDeviceInfoGet()
|
|
|
|
@ -1192,7 +1280,7 @@ int Widget::snedMsgDeviceInfoGet()
|
|
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t *>(buf);
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t), 0xFFFFFFFF, DEBUG_CT_REQUEST, DEBUG_C_CONTACT);
|
|
|
|
|
header->dev_type_m = 1;
|
|
|
|
|
header->dev_type_m = 2;
|
|
|
|
|
header->dev_type_s = 255;
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
@ -1200,7 +1288,7 @@ int Widget::snedMsgDeviceInfoGet()
|
|
|
|
|
*crc = crc32(buf, header->len);
|
|
|
|
|
|
|
|
|
|
//printHexArray(__FUNCTION__, buf, header->len + 4);
|
|
|
|
|
//HexPrint(__FUNCTION__, buf, header->len + 4);
|
|
|
|
|
HexPrint(__FUNCTION__, buf, header->len + 4);
|
|
|
|
|
writeData(buf, header->len + 4);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -1502,7 +1590,7 @@ int Widget::sendMsgDeviceAdjustInfoGet()
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Widget::sendMsgDeviceAdjustMode(int cmd)
|
|
|
|
|
int Widget::sendMsgDeviceAdjustMode(uint8_t cmd, adjSet *param)
|
|
|
|
|
{
|
|
|
|
|
char buf[2048] = {0};
|
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
@ -1512,7 +1600,7 @@ int Widget::sendMsgDeviceAdjustMode(int cmd)
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t) + sizeof(adjSet), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, cmd);
|
|
|
|
|
|
|
|
|
|
memcpy(pdata, &clientAdjSet, sizeof(adjSet));
|
|
|
|
|
memcpy(pdata, param, sizeof(adjSet));
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
|
crc = reinterpret_cast<uint32_t*>(buf + header->len);
|
|
|
|
@ -1613,18 +1701,31 @@ int Widget::sendMsgHistoryDataGet()
|
|
|
|
|
|
|
|
|
|
void Widget::on_btnConn_clicked()
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "1###isConnected =" << isConnected << endl;
|
|
|
|
|
if (!isConnected)
|
|
|
|
|
{
|
|
|
|
|
initSerial();
|
|
|
|
|
/* 保存串口配置. */
|
|
|
|
|
if (QString::compare(settings->value("usartBoxName").toString(), ui->comboPort->currentText(), Qt::CaseSensitive) != 0)
|
|
|
|
|
{
|
|
|
|
|
settings->setValue("usartBoxName", ui->comboPort->currentText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (QString::compare(settings->value("baudBoxIndex").toString(), ui->comboBaud->currentText(), Qt::CaseSensitive) != 0)
|
|
|
|
|
{
|
|
|
|
|
settings->setValue("baudBoxIndex", ui->comboBaud->currentText());
|
|
|
|
|
}
|
|
|
|
|
openSerial();
|
|
|
|
|
/* 变更按钮文字. */
|
|
|
|
|
ui->btnConn->setText("断开");
|
|
|
|
|
snedMsgDeviceInfoGet();
|
|
|
|
|
isConnected = 1;
|
|
|
|
|
worker->timeCounterStart();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
serialDisconnect();
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "2###isConnected =" << isConnected << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::on_btnReset_clicked()
|
|
|
|
@ -1824,7 +1925,7 @@ void Widget::on_configSetButton_clicked()
|
|
|
|
|
clientDevConfig.energyMode = static_cast<uint8_t>(ui->energyModeBox->currentIndex());
|
|
|
|
|
clientDevConfig.normalSleep = static_cast<uint8_t>(ui->normalSleepBox->currentIndex());
|
|
|
|
|
memset(clientDevConfig.APN, 0, DEV_APN_LEN);
|
|
|
|
|
stringToChar(ui->APNEdit->text(), reinterpret_cast<char*>(clientDevConfig.APN_long), DEV_APN_LEN_LONG);
|
|
|
|
|
//stringToChar(ui->APNEdit->text(), reinterpret_cast<char*>(clientDevConfig.APN_long), DEV_APN_LEN_LONG);
|
|
|
|
|
|
|
|
|
|
clientDevConfig.collectInterval = ui->colIntervalEdit->text().toUShort();
|
|
|
|
|
clientDevConfig.waveInterval = ui->waveIntervalEdit->text().toUShort();
|
|
|
|
@ -2131,7 +2232,7 @@ void Widget::on_manualAdjButton_clicked()
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
buttonEnable(false);
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_MANUAL);
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_MANUAL, &adj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2324,7 +2425,7 @@ void Widget::on_adjButton_clicked()
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
buttonEnable(false);
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO);
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO, &adj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::on_tabWidget_tabBarClicked(int index)
|
|
|
|
@ -2335,3 +2436,32 @@ void Widget::on_tabWidget_tabBarClicked(int index)
|
|
|
|
|
uiAdjustInfoRefresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Widget::closeEvent(QCloseEvent* ev)
|
|
|
|
|
{
|
|
|
|
|
//关闭事件中 停掉子线程
|
|
|
|
|
worker->Stop();//终止工作函数
|
|
|
|
|
m_thread->exit();//线程退出事件循环
|
|
|
|
|
m_thread->wait();//等待线程退出
|
|
|
|
|
qDebug()<<"线程退出了";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Worker::doWork()
|
|
|
|
|
{
|
|
|
|
|
//打印下线程id,看和主线程的线程id是否一样
|
|
|
|
|
qDebug()<<"工作函数所在线程:"<<QThread::currentThreadId();
|
|
|
|
|
while(!stop)
|
|
|
|
|
{
|
|
|
|
|
qint64 timestamp = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
|
if (timestamp > m_timestamp + 1000)
|
|
|
|
|
{
|
|
|
|
|
if (m_timeCounterStat)
|
|
|
|
|
{
|
|
|
|
|
m_timeCounterStat = CNT_RST;
|
|
|
|
|
emit changeString(tr(UART_COMMUNICATION_ERROR));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QThread::msleep(20);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|