增加变体数据文件
This commit is contained in:
+30
-8
@@ -1,4 +1,4 @@
|
||||
#include "Parse.h"
|
||||
#include "Parse.h"
|
||||
|
||||
Parse::Parse(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -920,28 +920,28 @@ void Parse::run()
|
||||
|
||||
union
|
||||
{
|
||||
char ch1;
|
||||
char ch2;
|
||||
uint8_t c[2];
|
||||
|
||||
int t;
|
||||
} test;
|
||||
|
||||
test.t = 0;
|
||||
|
||||
data = raw.mid(247);
|
||||
test.ch1 = data[0];
|
||||
test.ch2 = data[1];
|
||||
test.c[0] = data[0];
|
||||
test.c[1] = data[1];
|
||||
|
||||
var.l_var_current = test.t * 0.1;
|
||||
|
||||
test.t = 0;
|
||||
test.ch1 = data[2];
|
||||
test.ch2 = data[3];
|
||||
test.c[0] = data[2];
|
||||
test.c[1] = data[3];
|
||||
|
||||
var.r_var_current = test.t * 0.1;
|
||||
|
||||
var.l_var_dir = data[4];
|
||||
var.r_var_dir = data[5];
|
||||
|
||||
qDebug() << "variant: " << data;
|
||||
|
||||
saveActuatorDataToFile(group);
|
||||
emit actuator_info_brake(group);
|
||||
@@ -1878,6 +1878,28 @@ void Parse::parseData(const int id, const QByteArray data)
|
||||
*/
|
||||
}
|
||||
|
||||
void Parse::saveVariantToFile(const Variant &var)
|
||||
{
|
||||
QFile file(ins_file_name);
|
||||
if(file.open(QIODevice::Append) )
|
||||
{
|
||||
//qDebug() << u8"保存ins数据";
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec("UTF-8");
|
||||
|
||||
stream << QDateTime::currentDateTime().toString("yyyyMMddHHmmss").toUtf8() << ",";
|
||||
stream << var.l_var_current << ",";
|
||||
stream << var.r_var_current << ",";
|
||||
stream << (var.l_var_dir ? "反转" : "正转") << ",";
|
||||
stream << (var.r_var_dir ? "反转" : "正转") << "\n";
|
||||
|
||||
stream.flush();
|
||||
|
||||
file.flush();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void Parse::saveInsDataToFile(const _ins &ins)
|
||||
{
|
||||
QFile file(ins_file_name);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "QFile"
|
||||
#include "QDateTime"
|
||||
#include "QDataStream"
|
||||
#include <QMetaType>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -20,6 +21,9 @@ typedef struct
|
||||
quint8 r_var_dir; //右变体方向
|
||||
} Variant;
|
||||
|
||||
Q_DECLARE_METATYPE(Variant);
|
||||
|
||||
|
||||
class Parse : public QObject, public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -505,6 +509,7 @@ public:
|
||||
QString sspc_file_name;
|
||||
QString vel_file_name;
|
||||
QString pos_file_name;
|
||||
QString variant_file_name;
|
||||
|
||||
explicit Parse(QObject *parent = nullptr);
|
||||
~Parse();
|
||||
@@ -548,6 +553,11 @@ signals:
|
||||
void variantInfo(Variant const &info);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief 将变体的信息保存到文件中
|
||||
* @param var
|
||||
*/
|
||||
void saveVariantToFile(Variant const &var);
|
||||
/**
|
||||
* @brief 把ins解析的数据保存到文件
|
||||
* @param ins 保存ins数据的结构体
|
||||
|
||||
+22
-1
@@ -1,4 +1,4 @@
|
||||
#include "ToolsUI.h"
|
||||
#include "ToolsUI.h"
|
||||
#include "ui_ToolsUI.h"
|
||||
#include <QTextStream>
|
||||
|
||||
@@ -221,6 +221,7 @@ void ToolsUI::recieveDataSlot(const int &id, const QByteArray &data)
|
||||
parse->sspc_file_name = sspc_file_name;
|
||||
parse->vel_file_name = vel_file_name;
|
||||
parse->pos_file_name = pos_file_name;
|
||||
parse->variant_file_name = variant_file_name;
|
||||
|
||||
connect(this,&ToolsUI::parseData,
|
||||
parse,&Parse::parseData);
|
||||
@@ -944,6 +945,26 @@ void ToolsUI::createRecordDataFiles()
|
||||
file.flush(); //将数据刷新到文件中
|
||||
file.close(); //关闭文件
|
||||
}
|
||||
|
||||
variant_file_name = QString("./log/other/variant_%1.csv").arg(QDateTime::currentDateTime().toString("yyyyMMddHHmmss") );
|
||||
file.setFileName(variant_file_name);
|
||||
if(file.open(QIODevice::WriteOnly | QIODevice::Text) )
|
||||
{
|
||||
// QByteArray data;
|
||||
|
||||
QTextStream stream(&file);
|
||||
|
||||
stream.setCodec("utf-8");
|
||||
stream << tr("time,");
|
||||
stream << tr("l_var_current,");
|
||||
stream << tr("r_var_current,");
|
||||
stream << tr("l_var_dir,");
|
||||
stream << tr("r_var_dir\n");
|
||||
|
||||
// stream << data;
|
||||
file.flush(); //将数据刷新到文件中
|
||||
file.close(); //关闭文件
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -146,6 +146,8 @@ private:
|
||||
QString sspc_file_name;
|
||||
QString vel_file_name;
|
||||
QString pos_file_name;
|
||||
QString variant_file_name;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -171,6 +171,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
qRegisterMetaType<uint8_t>("uint8_t");
|
||||
|
||||
qRegisterMetaType<MavLinkNode::_vehicle>("MavLinkNode::_vehicle");
|
||||
qRegisterMetaType<Variant>("Variant");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user