1 Star 0 Fork 4

leaveing/packet_analyzer

forked from black0592/packet_analyzer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mainobject.cpp 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
#include "mainobject.h"
#include <QTimer>
#include <QSettings>
extern QString etherPortName;
mainObject::mainObject()
{
QSettings settings("HKEY_CURRENT_USER\\Software\\sanwei",QSettings::NativeFormat);
etherPortName = settings.value("port").toString();
settings.deleteLater();
udp = new myUDP;
udp->start();
connect(udp, SIGNAL(startOrStop(bool)), this, SLOT(startSMV(bool)));
smv = new smvProcess;
smv->run_mode = smvProcess::TIME;
smv->start();
connect(smv, SIGNAL(samplesIsReady()), this, SLOT(zeroSmpcntIsComing()));
QTimer *taskTimer = new QTimer;
taskTimer->start(200);
connect(taskTimer, SIGNAL(timeout()), this, SLOT(sendResult()));
resultIsReady = false;
}
void mainObject::startSMV(bool flag)
{
qDebug()<<"to start?"<<flag;
if(flag)
{
if(!smv->isOpen()) smv->start();
smv->setReopen(smvProcess::TIME);
if(!smv->isOpen())
{
udp->sendResult("ERROR",5);
}
}
else
{
smv->run_mode = smvProcess::NOOP;
smv->setClose();
}
}
void mainObject::zeroSmpcntIsComing()
{
resultIsReady = true;
}
void mainObject::sendResult()
{
if(resultIsReady)
{
smv->test_result.flag = 'a';
smv->test_result.de_name[0] = 's';
smv->test_result.de_name[1] = 'a';
smv->test_result.de_name[2] = 'n';
smv->test_result.de_name[3] = 'w';
smv->test_result.de_name[4] = 'e';
smv->test_result.de_name[5] = 'i';
smv->test_result.error_1 = (double)smv->test_result.error_1 / smv->test_result.total * 10000;
smv->test_result.error_2 = (double)smv->test_result.error_2 / smv->test_result.total * 10000;
smv->test_result.error_4 = (double)smv->test_result.error_4 / smv->test_result.total * 10000;
smv->test_result.error_6 = (double)smv->test_result.error_6 / smv->test_result.total * 10000;
char *ch = (char*)&(smv->test_result);
udp->sendResult(ch, sizeof(smv->test_result));
resultIsReady = false;
qDebug()<<"send done!";
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/leaveing/packet_analyzer.git
git@gitee.com:leaveing/packet_analyzer.git
leaveing
packet_analyzer
packet_analyzer
master

搜索帮助