修正可能存在的闪退因素

This commit is contained in:
hm
2021-08-03 13:43:17 +08:00
parent 5c2c10c9f4
commit 84e2ed855c
6 changed files with 40 additions and 26 deletions
+6
View File
@@ -75,8 +75,11 @@ void HealthUI::setColor(uint32_t pos,state sta)
if(LabelMap.keys().contains(pos))
{
QLabel *label = LabelMap.value(pos);
if(label)
{
setState(label,sta);
}
}
else
{
//找不到就不设置
@@ -89,8 +92,11 @@ void HealthUI::setValue(uint32_t pos,QVariant sta)
if(LabelMap.contains(pos))
{
QLabel *label = LabelMap.value(pos);
if(label)
{
setString(label,sta.toString());
}
}
else
{
//找不到就不设置
+1 -1
View File
@@ -40,7 +40,7 @@ StatusUI::StatusUI(QWidget *parent) :
install(base,0,"真空速[m/s]",0,QMap<QVariant, StateWidget::state>{{100,StateWidget::state::red},{700,StateWidget::state::green}});
install(base,0,"地速[m/s]",0,QMap<QVariant, StateWidget::state>{{100,StateWidget::state::red},{700,StateWidget::state::green}});
install(base,0,"马赫数[Ma]",0,QMap<QVariant, StateWidget::state>{{0.3,StateWidget::state::red},{0.8,StateWidget::state::green},{2,StateWidget::state::orange}});
install(base,0,"爬升率[m/s]",0,QMap<QVariant, StateWidget::state>{{-50,StateWidget::state::red},{100,StateWidget::state::green},{500,StateWidget::state::orange}});
install(base,0,"爬升率[m/s]",0,QMap<QVariant, StateWidget::state>{{-80,StateWidget::state::red},{100,StateWidget::state::green},{500,StateWidget::state::orange}});
install(actuator,0,"左翼尖[°]",0);
install(actuator,0,"右翼尖[°]",0);
+23 -18
View File
@@ -120,17 +120,7 @@ MainWindow::MainWindow(QWidget *parent)
setFocusPolicy(Qt::StrongFocus);
setAttribute(Qt::WA_AcceptTouchEvents);
/*
//设置优先生成,然后对全局进行设置
setting = new Setting(this);
setting->hide();
*/
setAttribute(Qt::WA_TransparentForMouseEvents,true);
tts = new QTextToSpeech(this);
@@ -924,6 +914,7 @@ void MainWindow::beep(int sysid)
{
if(map->getUAVCurrent() == sysid)
{
QApplication::beep();
}
}
@@ -945,11 +936,14 @@ void MainWindow::setCommunicationLostState(bool flag)
if(isEnableTTS)
{
if(tts)
{
if(tts->state() == QTextToSpeech::Ready)
{
tts->say(tr("Communication Lost"));
}
}
}
}
healthui->setFailure();
//statusui->setFailure();
@@ -963,12 +957,15 @@ void MainWindow::setCommunicationLostState(bool flag)
if(isEnableTTS)
{
if(tts)
{
if(tts->state() == QTextToSpeech::Ready)
{
tts->say(tr("Communication Regain"));
}
}
}
}
}
last = flag;
}
@@ -1104,11 +1101,22 @@ void MainWindow::update_servo_output_raw(mavlink_servo_output_raw_t servo)
}
// 16~20Hz左右 运行频率可能太高
// 16~20Hz左右 运行频率可能太高30fps
void MainWindow::updateUI()//事件驱动式更新数据
{
int currentUAV = map->getUAVCurrent();
if(currentUAV < 1)//滤掉错值
{
return;
}
if(!dlink->mavlinknode->vehicleList.keys().contains(currentUAV))//滤掉不存在的无人机
{
return;
}
//设置舵机显示
update_servo_output_raw(dlink->mavlinknode->vehicleList.value(currentUAV).servo_output_raw);
@@ -1118,7 +1126,7 @@ void MainWindow::updateUI()//事件驱动式更新数据
bool isStateChanged = false;
static qint64 frq_time = QDateTime::currentMSecsSinceEpoch();//10hz
if((QDateTime::currentMSecsSinceEpoch() - frq_time) <= 100)
if(((quint64)(QDateTime::currentMSecsSinceEpoch() - frq_time)) <= 100)
{
return;
}
@@ -1351,7 +1359,7 @@ void MainWindow::updateUI()//事件驱动式更新数据
{
if(tts)
{
if(tts->state() == QTextToSpeech::Ready)
tts->say(arm_str);
}
}
@@ -1364,6 +1372,7 @@ void MainWindow::updateUI()//事件驱动式更新数据
{
if(tts)
{
if(tts->state() == QTextToSpeech::Ready)
tts->say(mode_str);
}
}
@@ -1454,11 +1463,7 @@ void MainWindow::updateUI()//事件驱动式更新数据
healthui->setColor(20,getBit(health,27)?(HealthUI::state::success):(HealthUI::state::failure));//侧滑角
//===================status ui =============================================
//========================0
statusui->setValue(0,0,mode_str);
//========================1
+1 -1
View File
@@ -3,7 +3,7 @@ TEMPLATE = subdirs
CONFIG += ordered
#SUBDIRS += VehicleManage
SUBDIRS += VehicleManage
SUBDIRS += Skin
SUBDIRS += opmap
SUBDIRS += Cockpit
+3 -2
View File
@@ -774,6 +774,8 @@ void MavLinkNode::MAVLinkRcv_Handler(mavlink_message_t msg)
void MavLinkNode::StatusParse(mavlink_message_t msg)
{
_vehicle vehicle = vehicleList.value(msg.sysid);
switch (msg.msgid) {
@@ -1122,9 +1124,8 @@ void MavLinkNode::StatusParse(mavlink_message_t msg)
}
vehicleList.insert(msg.sysid,vehicle);//直接覆盖
//emit showMessage(tr("update ui info %1").arg(vehicle.sysid));
vehicleList.insert(msg.sysid,vehicle);//直接覆盖
emit state_updated();
}
+2
View File
@@ -47,6 +47,8 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
QCoreApplication::installTranslator(translator);
*/
setAttribute(Qt::WA_TransparentForMouseEvents,true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
core = new internals::Core;