154 lines
4.3 KiB
C++
154 lines
4.3 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include "uhd_device.h"
|
|
#include <QMessageBox>
|
|
#include <QFile>
|
|
#include <QFileDialog>
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
this->setWindowTitle(tr("gnss sim V1.0"));
|
|
psettings = new QSettings("settings.ini", QSettings::IniFormat);
|
|
loadSetting();
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
saveSetting();
|
|
psettings->sync();
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::on_pushButton_start_clicked()
|
|
{
|
|
if(ui->lineEdit_gpsfile->text().length() == 0)
|
|
{
|
|
QMessageBox::warning(NULL,tr("星历文件错误"),tr("请设置星历文件"),QMessageBox::Ok,QMessageBox::Ok);
|
|
return;
|
|
}
|
|
if(!QFile(ui->lineEdit_gpsfile->text()).exists())
|
|
{
|
|
QMessageBox::warning(NULL, tr("星历文件路径错误"), tr("没有这个文件,请确认路径是否正确。"), QMessageBox::Ok, QMessageBox::Ok);
|
|
return;
|
|
}
|
|
if(ui->lineEdit_motionfile->text().length() == 0)
|
|
{
|
|
QMessageBox::warning(NULL, tr("轨迹文件错误"), tr("请设置轨迹文件。"), QMessageBox::Ok, QMessageBox::Ok);
|
|
return;
|
|
}
|
|
if(!QFile(ui->lineEdit_motionfile->text()).exists())
|
|
{
|
|
QMessageBox::warning(NULL, tr("轨迹文件路径错误"), tr("没有这个文件,请确认路径是否正确。"), QMessageBox::Ok, QMessageBox::Ok);
|
|
return;
|
|
}
|
|
if(ui->lineEdit_gain->text().length() == 0)
|
|
{
|
|
QMessageBox::warning(NULL, tr("增益错误"), tr("请设置增益。"), QMessageBox::Ok, QMessageBox::Ok);
|
|
return;
|
|
}
|
|
float radio_gain = ui->lineEdit_gain->text().toFloat();
|
|
workThread.setGain(radio_gain);
|
|
workThread.setNavFilePath(ui->lineEdit_gpsfile->text());
|
|
workThread.setUmfile(ui->lineEdit_motionfile->text());
|
|
if(ui->lineEdit_motionfile->text().endsWith(".csv")){
|
|
workThread.useNmeaGGA(0);
|
|
}else{
|
|
workThread.useNmeaGGA(1);
|
|
}
|
|
if(ui->checkBox_currentTime->isChecked()){
|
|
workThread.useCurrentTime(true);
|
|
}else{
|
|
workThread.useCurrentTime(false);
|
|
}
|
|
|
|
workThread.start();
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_stop_clicked()
|
|
{
|
|
workThread.stop();
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_browsegps_clicked()
|
|
{
|
|
QString path = ui->lineEdit_gpsfile->text();
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this,
|
|
"",
|
|
path,
|
|
"(brdc*)");
|
|
if (!fileName.isEmpty()) {
|
|
ui->lineEdit_gpsfile->setText(fileName);
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_browsemotion_clicked()
|
|
{
|
|
QString path = ui->lineEdit_motionfile->text();
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this,
|
|
"",
|
|
path,
|
|
"*.csv *.txt");
|
|
if (!fileName.isEmpty()) {
|
|
ui->lineEdit_motionfile->setText(fileName);
|
|
}
|
|
}
|
|
|
|
void MainWindow::loadSetting()
|
|
{
|
|
QDir dir = QDir::current();
|
|
QStringList files;
|
|
|
|
if(psettings->contains("/setting/gps_file"))
|
|
{
|
|
QVariant gpsfile = psettings->value("/setting/gps_file");
|
|
ui->lineEdit_gpsfile->setText(gpsfile.toString());
|
|
}
|
|
|
|
if(psettings->contains("/setting/motion_file"))
|
|
{
|
|
QVariant motionfile = psettings->value("/setting/motion_file");
|
|
ui->lineEdit_motionfile->setText(motionfile.toString());
|
|
}
|
|
|
|
if(psettings->contains("/setting/radio_gain"))
|
|
{
|
|
QVariant radio_gain = psettings->value("/setting/radio_gain");
|
|
ui->lineEdit_gain->setText(radio_gain.toString());
|
|
}
|
|
|
|
if(psettings->contains("/setting/use_timenow"))
|
|
{
|
|
bool ok;
|
|
QVariant external_clock = psettings->value("/setting/use_timenow");
|
|
int val = external_clock.toInt(&ok);
|
|
if(ok && val == 1){
|
|
ui->checkBox_currentTime->setCheckState(Qt::Checked);
|
|
}else{
|
|
ui->checkBox_currentTime->setCheckState(Qt::Unchecked);
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::saveSetting()
|
|
{
|
|
int val;
|
|
psettings->setValue("/setting/gps_file", ui->lineEdit_gpsfile->text());
|
|
psettings->setValue("/setting/motion_file", ui->lineEdit_motionfile->text());
|
|
psettings->setValue("/setting/radio_gain", ui->lineEdit_gain->text());
|
|
if(ui->checkBox_currentTime->isChecked()){
|
|
val = 1;
|
|
}else{
|
|
val = 0;
|
|
}
|
|
psettings->setValue("/setting/use_timenow", val);
|
|
}
|
|
|