航迹最大1000个点,数据保存1分钟存一次
This commit is contained in:
@@ -99,6 +99,14 @@ MavLinkNode::~MavLinkNode()
|
||||
mavLogFile = NULL;
|
||||
}
|
||||
|
||||
if(logTimer)
|
||||
{
|
||||
logTimer->stop();
|
||||
delete logTimer;
|
||||
logTimer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
//停止回放
|
||||
if(replay)
|
||||
{
|
||||
@@ -199,12 +207,31 @@ void MavLinkNode::start()
|
||||
{
|
||||
mavLogFile->close();
|
||||
delete mavLogFile;
|
||||
mavLogFile = nullptr;
|
||||
}
|
||||
|
||||
QDateTime current = QDateTime::currentDateTime();
|
||||
mavLogFile = new QFile(QString("./Tlog/%1.tlog").arg(current.toString("yyyyMMddHHmmss")));
|
||||
mavlogFileName = QString("./Tlog/%1.tlog").arg(current.toString("yyyyMMddHHmmss"));
|
||||
mavLogFile = new QFile(mavlogFileName);
|
||||
mavLogFile->open(QIODevice::WriteOnly);
|
||||
|
||||
if(logTimer)
|
||||
{
|
||||
logTimer->stop();
|
||||
delete logTimer;
|
||||
logTimer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
logTimer = new QTimer();
|
||||
logTimer->setInterval(60 * 1000);//1min
|
||||
|
||||
connect(logTimer,&QTimer::timeout,
|
||||
this,&MavLinkNode::LogTimerOut,Qt::DirectConnection);
|
||||
|
||||
logTimer->start();
|
||||
|
||||
|
||||
//初始化buff
|
||||
initbuff();
|
||||
|
||||
@@ -253,6 +280,14 @@ void MavLinkNode::stop()
|
||||
mavLogFile = NULL;
|
||||
}
|
||||
|
||||
if(logTimer)
|
||||
{
|
||||
logTimer->stop();
|
||||
delete logTimer;
|
||||
logTimer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
running_flag = false;
|
||||
qDebug() << "thread stop" << running_flag;
|
||||
}
|
||||
@@ -335,6 +370,23 @@ void MavLinkNode::TimerOut(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MavLinkNode::LogTimerOut(void)
|
||||
{
|
||||
if(mavLogFile)
|
||||
{
|
||||
//qDebug() << "flush file" << mavLogFile->bytesToWrite();
|
||||
|
||||
//mavLogFile->bytesToWrite();
|
||||
|
||||
//if(!mavLogFile->flush())
|
||||
{
|
||||
mavLogFile->close();
|
||||
mavLogFile->open(QIODevice::Append);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MavLinkNode::initbuff(void)
|
||||
{
|
||||
@@ -470,8 +522,12 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
|
||||
if (mavLogFile)
|
||||
{
|
||||
mavLogFile->write((const char *)buff, len+sizeof(quint64));
|
||||
|
||||
}
|
||||
|
||||
//mavLogFile->size()
|
||||
|
||||
|
||||
count++;
|
||||
if(msg.sysid < 250) //过滤地面站发过来的数据
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user