2020-11-21 18:19:28 +08:00
|
|
|
#include "GlobalSetting.h"
|
|
|
|
|
#include "ui_GlobalSetting.h"
|
|
|
|
|
|
|
|
|
|
GlobalSetting::GlobalSetting(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
ui(new Ui::GlobalSetting)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
ui->comboBox_ID->addItem(tr("250"),250);
|
|
|
|
|
ui->comboBox_ID->addItem(tr("251"),251);
|
|
|
|
|
ui->comboBox_ID->addItem(tr("252"),252);
|
|
|
|
|
ui->comboBox_ID->addItem(tr("253"),253);
|
|
|
|
|
ui->comboBox_ID->addItem(tr("254"),254);
|
|
|
|
|
ui->comboBox_ID->addItem(tr("255"),255);
|
|
|
|
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
QVariant id;
|
|
|
|
|
|
|
|
|
|
cfg->get_GCS_ID(&id);
|
|
|
|
|
|
|
|
|
|
qDebug() << id;
|
|
|
|
|
|
|
|
|
|
ui->comboBox_ID->setCurrentIndex(ui->comboBox_ID->findData(id.toInt()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit setGCSID(id.toInt());//设置全局ID
|
|
|
|
|
|
|
|
|
|
|
2020-12-08 22:21:52 +08:00
|
|
|
on_pushButton_getServoOffset_clicked();
|
|
|
|
|
|
|
|
|
|
|
2020-12-11 17:47:29 +08:00
|
|
|
QVariant frq;
|
|
|
|
|
QVariant state;
|
|
|
|
|
cfg->getHeartBeat(&state,&frq);
|
|
|
|
|
|
2020-12-10 18:47:49 +08:00
|
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("1.0Hz"),1.0);
|
|
|
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("2.0Hz"),2.0);
|
|
|
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("5.0Hz"),5.0);
|
|
|
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("10Hz"),10);
|
2020-12-11 17:47:29 +08:00
|
|
|
ui->comboBox_HeartBeat_Frq->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(frq));
|
2020-12-10 18:47:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->comboBox_HeartBeat_State->addItem(tr("发送心跳包"),true);
|
|
|
|
|
ui->comboBox_HeartBeat_State->addItem(tr("关闭心跳包"),false);
|
2020-12-11 17:47:29 +08:00
|
|
|
ui->comboBox_HeartBeat_State->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(state));
|
2020-12-10 18:47:49 +08:00
|
|
|
|
|
|
|
|
on_pushButton_getHeartBeat_clicked();
|
|
|
|
|
|
|
|
|
|
|
2020-11-21 18:19:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GlobalSetting::~GlobalSetting()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::on_pushButton_setGCSID_clicked()
|
|
|
|
|
{
|
|
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
|
|
id = ui->comboBox_ID->currentData(Qt::DisplayRole).toInt();
|
|
|
|
|
|
|
|
|
|
qDebug() << id;
|
|
|
|
|
|
|
|
|
|
emit setGCSID(id);
|
|
|
|
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
cfg->set_GCS_ID(id);
|
|
|
|
|
|
|
|
|
|
cfg->deleteLater();
|
|
|
|
|
delete cfg;
|
2020-12-08 22:21:52 +08:00
|
|
|
|
|
|
|
|
emit showMessage(tr("设置本机ID成功,ID:%1").arg(QString::number(id)));
|
|
|
|
|
|
2020-11-21 18:19:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::getGCSID(void)
|
|
|
|
|
{
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
QVariant id;
|
|
|
|
|
cfg->get_GCS_ID(&id);
|
|
|
|
|
emit setGCSID(id.toInt());//设置全局ID
|
2020-12-08 22:21:52 +08:00
|
|
|
|
|
|
|
|
delete cfg;
|
|
|
|
|
|
|
|
|
|
emit showMessage(tr("设置本机ID成功,ID:%1").arg(QString::number(id.toInt())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::getServo(void)
|
|
|
|
|
{
|
|
|
|
|
on_pushButton_getServoOffset_clicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::on_pushButton_getServoOffset_clicked()
|
|
|
|
|
{
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
QVariant la;
|
|
|
|
|
QVariant ra;
|
|
|
|
|
QVariant le;
|
|
|
|
|
QVariant re;
|
|
|
|
|
QVariant ru;
|
|
|
|
|
|
|
|
|
|
cfg->getServoOffset(&la,&ra,&le,&re,&ru);
|
|
|
|
|
|
|
|
|
|
ui->doubleSpinBox_la->setValue(la.toDouble());
|
|
|
|
|
ui->doubleSpinBox_ra->setValue(ra.toDouble());
|
|
|
|
|
ui->doubleSpinBox_le->setValue(le.toDouble());
|
|
|
|
|
ui->doubleSpinBox_re->setValue(re.toDouble());
|
|
|
|
|
ui->doubleSpinBox_ru->setValue(ru.toDouble());
|
|
|
|
|
|
|
|
|
|
emit setServo(la,ra,le,re,ru);
|
|
|
|
|
|
|
|
|
|
delete cfg;
|
|
|
|
|
|
|
|
|
|
emit showMessage(tr("舵面偏差读取成功"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::on_pushButton_setServoOffset_clicked()
|
|
|
|
|
{
|
|
|
|
|
QVariant la;
|
|
|
|
|
QVariant ra;
|
|
|
|
|
QVariant le;
|
|
|
|
|
QVariant re;
|
|
|
|
|
QVariant ru;
|
|
|
|
|
|
|
|
|
|
la = ui->doubleSpinBox_la->value();
|
|
|
|
|
ra = ui->doubleSpinBox_ra->value();
|
|
|
|
|
le = ui->doubleSpinBox_le->value();
|
|
|
|
|
re = ui->doubleSpinBox_re->value();
|
|
|
|
|
ru = ui->doubleSpinBox_ru->value();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit setServo(la,ra,le,re,ru);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
cfg->setServoOffset(la,ra,le,re,ru);
|
|
|
|
|
|
|
|
|
|
cfg->deleteLater();
|
|
|
|
|
delete cfg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit showMessage(tr("舵面偏差设置成功"));
|
|
|
|
|
|
2020-11-21 18:19:28 +08:00
|
|
|
}
|
2020-12-10 18:47:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::getHeartBeat(void)
|
|
|
|
|
{
|
|
|
|
|
on_pushButton_getHeartBeat_clicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::on_pushButton_getHeartBeat_clicked()
|
|
|
|
|
{
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
QVariant state;
|
|
|
|
|
QVariant frq;
|
|
|
|
|
|
|
|
|
|
cfg->getHeartBeat(&state,&frq);
|
|
|
|
|
|
|
|
|
|
ui->comboBox_HeartBeat_Frq->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(frq));
|
|
|
|
|
ui->comboBox_HeartBeat_State->setCurrentIndex(ui->comboBox_HeartBeat_State->findData(state));
|
|
|
|
|
|
|
|
|
|
delete cfg;
|
|
|
|
|
|
|
|
|
|
emit setHeartBeat(state,frq);
|
|
|
|
|
|
|
|
|
|
emit showMessage(tr("心跳读取成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GlobalSetting::on_pushButton_setHeartBeat_clicked()
|
|
|
|
|
{
|
|
|
|
|
QVariant state;
|
|
|
|
|
QVariant frq;
|
|
|
|
|
|
|
|
|
|
state = ui->comboBox_HeartBeat_State->currentData();
|
|
|
|
|
frq = ui->comboBox_HeartBeat_Frq->currentData();
|
|
|
|
|
|
|
|
|
|
emit setHeartBeat(state,frq);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
cfg->setHeartBeat(state,frq);
|
|
|
|
|
|
|
|
|
|
cfg->deleteLater();
|
|
|
|
|
delete cfg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit showMessage(tr("心跳设置成功"));
|
|
|
|
|
}
|