diff --git a/App/ToolsUI/ServoSystem/ServoSystem.cpp b/App/ToolsUI/ServoSystem/ServoSystem.cpp index 0966181..c9d1113 100644 --- a/App/ToolsUI/ServoSystem/ServoSystem.cpp +++ b/App/ToolsUI/ServoSystem/ServoSystem.cpp @@ -172,10 +172,47 @@ ServoSystem::ServoSystem(QWidget *parent) : }); + HILStateFile = new QFile(QString("./log/Other/HILState%1.csv").arg(QDateTime::currentDateTime().toString("yyyyMMddHHmmss"))); + HILStateFile->open(QIODevice::WriteOnly); + + if(HILStateFile) + { + QString data; + + data.clear(); + data.append("year,mon,day,hour,min,sec,ms,"); + data.append("parse"); data.append(","); + data.append("comm"); data.append(","); + data.append("parse"); data.append(","); + data.append("comm"); data.append("\n"); + + + + + QTextStream stream(HILStateFile); + stream << data; + HILStateFile->flush(); + } + + /* + ui->comboBox_HoverDir->addItem("左盘旋",-1); + ui->comboBox_HoverDir->addItem("右盘旋",1); + ui->comboBox_HoverDir->setCurrentIndex(1); +*/ + + } ServoSystem::~ServoSystem() { + if (HILStateFile) + { + HILStateFile->close(); + delete HILStateFile; + HILStateFile = NULL; + } + + delete ui; } @@ -397,8 +434,64 @@ void ServoSystem::setHILMode(QString mode) emit showMessage((mode.toInt()>0)?("进入HIL仿真"):("退出HIL仿真")); } +void ServoSystem::setSimulatorState(bool paser,bool comm) +{ + QString state; + + state = (comm)?("通讯正常"):("通讯丢失"); + + + if(comm == true) + { + //通讯正常 + if(paser == true) + { + state = "通讯正常,解析正确"; + } + else + { + state = "通讯正常,解析错误"; + } + } + else + { + state = "通讯丢失"; + } + + + ui->label_simulator->setText(state); + + + if(HILStateFile) + { + QString data; + + data.clear(); + QDateTime time = QDateTime::currentDateTime(); + + data.append(QString::number(time.date().year())); data.append(","); + data.append(QString::number(time.date().month())); data.append(","); + data.append(QString::number(time.date().day())); data.append(","); + data.append(QString::number(time.time().hour())); data.append(","); + data.append(QString::number(time.time().minute())); data.append(","); + data.append(QString::number(time.time().second())); data.append(","); + data.append(QString::number(time.time().msec())); data.append(","); + + data.append(paser?("1"):("0")); data.append(","); + data.append(comm?("1"):("0")); data.append(","); + data.append((paser)?("parse ok"):("parse error")); data.append(","); + data.append((comm)?("connet"):("lost")); data.append("\n"); + + QTextStream stream(HILStateFile); + stream << data; + HILStateFile->flush(); + } + + +} + float ServoSystem::param_getvalue(QVariant param,uint8_t type) { float value; diff --git a/App/ToolsUI/ServoSystem/ServoSystem.h b/App/ToolsUI/ServoSystem/ServoSystem.h index 996551a..786e5e2 100644 --- a/App/ToolsUI/ServoSystem/ServoSystem.h +++ b/App/ToolsUI/ServoSystem/ServoSystem.h @@ -165,6 +165,7 @@ public slots: void setAPversion(QString ver); void setHILMode(QString mode); + void setSimulatorState(bool paser, bool comm); void setServoOffset(QVariant dirla, QVariant dirra, QVariant dirle, QVariant dirre, QVariant dirru, QVariant maxla, QVariant maxra, QVariant maxle, QVariant maxre, QVariant maxru, @@ -237,6 +238,8 @@ private: bool isWaitPitotClose = true; bool isWaitTracerAck = false; + QFile *HILStateFile; + }; #endif // SERVOSYSTEM_H diff --git a/App/ToolsUI/ServoSystem/ServoSystem.ui b/App/ToolsUI/ServoSystem/ServoSystem.ui index db118f0..9657a4c 100644 --- a/App/ToolsUI/ServoSystem/ServoSystem.ui +++ b/App/ToolsUI/ServoSystem/ServoSystem.ui @@ -1172,27 +1172,8 @@ 版本信息 - - - - - 0 - 30 - - - - - 120 - 16777215 - - - - 飞控固件版本号: - - - - - + + 0 @@ -1207,7 +1188,7 @@ - + @@ -1226,7 +1207,14 @@ - + + + + 仿真机状态: + + + + @@ -1242,6 +1230,41 @@ + + + + + 0 + 30 + + + + background-color: rgb(205, 205, 205); + + + 0 + + + + + + + + 0 + 30 + + + + + 120 + 16777215 + + + + 飞控固件版本号: + + + diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index c7f91ca..70d3a43 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -1688,6 +1688,10 @@ void MainWindow::updateUI()//事件驱动式更新数据 healthui->setState(25,getBit(enable,7)?(HealthUI::state::success):(HealthUI::state::failure));//安控区 healthui->setValueState(25,getBit(enable,7)?(tr("安控区内")):(tr("安控区外")));//安控区 + if(toolsui->servosystem) + { + toolsui->servosystem->setSimulatorState(getBit(enable,11),getBit(enable,12)); + } if(((vehicle.turbinstate.SysState & 0x000F) == 0x04) || ((vehicle.turbinstate.SysState & 0x000F) == 0x00)) diff --git a/MavLinkNode/mavlinknode.cpp b/MavLinkNode/mavlinknode.cpp index 6cdd22e..3aff732 100644 --- a/MavLinkNode/mavlinknode.cpp +++ b/MavLinkNode/mavlinknode.cpp @@ -863,10 +863,6 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram) for (QByteArray::const_iterator i = datagram.cbegin(); i != datagram.cend(); ++i) { - - //QApplication::processEvents(); - - if(MAVLINK_FRAMING_OK == mavlink_parse_char(src,*i,&msg,&status)) { parserSuccess += 1; diff --git a/MavLinkNode/statusprocess.cpp b/MavLinkNode/statusprocess.cpp index b347794..e07d0b0 100644 --- a/MavLinkNode/statusprocess.cpp +++ b/MavLinkNode/statusprocess.cpp @@ -22,6 +22,7 @@ statusprocess::statusprocess(QObject *parent) : ThreadTemplet(parent) data.clear(); data.append("date"); data.append(","); + data.append("year,mon,day,hour,min,sec,ms,");data.append(","); data.append("elapse"); data.append(","); data.append("custom_mode "); data.append(","); data.append("type "); data.append(","); @@ -108,6 +109,18 @@ void statusprocess::process()//线程函数 QString data; data.clear(); + + QDateTime time = QDateTime::currentDateTime(); + + data.append(QString::number(time.date().year())); data.append(","); + data.append(QString::number(time.date().month())); data.append(","); + data.append(QString::number(time.date().day())); data.append(","); + data.append(QString::number(time.time().hour())); data.append(","); + data.append(QString::number(time.time().minute())); data.append(","); + data.append(QString::number(time.time().second())); data.append(","); + data.append(QString::number(time.time().msec())); data.append(","); + + data.append(QDateTime::currentDateTimeUtc().toString("yyyy.MM.dd HH:mm:ss:zzz")); data.append(","); data.append(QString::number(QTime::currentTime().msecsSinceStartOfDay() - timeCount)); data.append(","); data.append(QString::number(m_heartbeat.custom_mode)); data.append(",");