修正航线有多条连线的bug

This commit is contained in:
2020-06-06 16:08:11 +08:00
parent ca0f9363fd
commit 5740ba1ed4
9 changed files with 253 additions and 230 deletions
+17
View File
@@ -141,6 +141,21 @@ void Inputter::on_pushButton_0_clicked()
on_NumberClicked(ui->pushButton_0->text()); on_NumberClicked(ui->pushButton_0->text());
} }
void Inputter::on_pushButton_minus_clicked()
{
if(curentStr.at(0) == '-')
{
curentStr = curentStr.mid(1);
}
else
{
curentStr.insert(0,'-');
}
ui->lineEdit->setText(curentStr);
}
void Inputter::on_pushButton_del_clicked() void Inputter::on_pushButton_del_clicked()
{ {
curentStr = curentStr.mid(0,curentStr.size() - 1); curentStr = curentStr.mid(0,curentStr.size() - 1);
@@ -208,3 +223,5 @@ void Inputter::on_pushButton_nan_clicked()
curentStr = "nan"; curentStr = "nan";
ui->lineEdit->setText(curentStr); ui->lineEdit->setText(curentStr);
} }
+2
View File
@@ -66,6 +66,8 @@ private slots:
void on_pushButton_nan_clicked(); void on_pushButton_nan_clicked();
void on_pushButton_minus_clicked();
private: private:
Ui::Inputter *ui; Ui::Inputter *ui;
+194 -175
View File
@@ -77,101 +77,6 @@
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_1">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_3">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_8">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_6">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_0">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QPushButton" name="pushButton_point"> <widget class="QPushButton" name="pushButton_point">
<property name="minimumSize"> <property name="minimumSize">
@@ -191,44 +96,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_4">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_del">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>del</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="pushButton_5"> <widget class="QPushButton" name="pushButton_5">
<property name="minimumSize"> <property name="minimumSize">
@@ -267,8 +134,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="1">
<widget class="QPushButton" name="pushButton_9"> <widget class="QPushButton" name="pushButton_8">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>80</width>
@@ -282,7 +149,83 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>9</string> <string>8</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_6">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="0" column="3" rowspan="2">
<widget class="QPushButton" name="pushButton_minus">
<property name="minimumSize">
<size>
<width>80</width>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>6666</height>
</size>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_1">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_3">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>3</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -305,45 +248,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="3" column="2">
<widget class="QPushButton" name="pushButton_ok">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>ok</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_cancel">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>cancel</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButton_nan"> <widget class="QPushButton" name="pushButton_nan">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@@ -362,6 +267,120 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_0">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_9">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_4">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_cancel">
<property name="minimumSize">
<size>
<width>160</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>666</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>cancel</string>
</property>
</widget>
</item>
<item row="2" column="3" rowspan="2">
<widget class="QPushButton" name="pushButton_del">
<property name="minimumSize">
<size>
<width>80</width>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>6666</height>
</size>
</property>
<property name="text">
<string>del</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<widget class="QPushButton" name="pushButton_ok">
<property name="minimumSize">
<size>
<width>160</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>6666</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>ok</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@@ -343,8 +343,13 @@ void ParameterInspector::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item,
if(item->parent())//不是根节点才可以把数据写入框内 if(item->parent())//不是根节点才可以把数据写入框内
{ {
ui->SearchlineEdit->setText(item->data(0,Qt::DisplayRole).toString()); ui->SearchlineEdit->setText(item->data(0,Qt::DisplayRole).toString());
parentItem = item->parent()->data(0,Qt::DisplayRole).toString();
ui->ValuelineEdit->setText(QString::number(item->data(1,Qt::DisplayRole).toFloat())); ui->ValuelineEdit->setText(QString::number(item->data(1,Qt::DisplayRole).toFloat()));
parentItem = item->parent()->data(0,Qt::DisplayRole).toString();
currentSelectType = item->data(2,Qt::DisplayRole).toUInt();
} }
} }
@@ -361,38 +366,9 @@ void ParameterInspector::on_WriteButton_clicked()
char *id = ui->SearchlineEdit->text().toLatin1().data(); char *id = ui->SearchlineEdit->text().toLatin1().data();
ui->treeWidget->takeTopLevelItem(0);
/*
foreach (QTreeWidgetItem* Item, uasTopLevelItems.values()) {
if(Item->data(0,Qt::DisplayRole) == parentItem)
{
QList<QTreeWidgetItem *> Itemlist = Item->takeChildren();
foreach (QTreeWidgetItem* item, Itemlist)
{
//if(Item->data(0,Qt::DisplayRole).toString() == ui->SearchlineEdit->text())
{
qDebug() << item->data(0,Qt::DisplayRole)
<< item->data(1,Qt::DisplayRole)
<< item->data(2,Qt::DisplayRole);
}
}
}
}
*/
//qDebug() << id << ui->SearchlineEdit->text().toLatin1();
uint8_t type = 9;
float value = ui->ValuelineEdit->text().toFloat(); float value = ui->ValuelineEdit->text().toFloat();
emit WriteCmd(sysid,1,id,currentSelectType,value);
//emit WriteCmd(sysid,1,id,type,value);
//读取是哪设备,是哪个参数,然后发送出去 //读取是哪设备,是哪个参数,然后发送出去
} }
@@ -158,7 +158,7 @@ private:
QString parentItem; QString parentItem;
uint8_t currentSelectType;
//char * S //char * S
+1 -1
View File
@@ -233,7 +233,7 @@ void commandprocess::WriteStateMachine(void)
{ {
timeout_count ++; timeout_count ++;
step = 0;//返回上一个步骤 step = 0;//返回上一个步骤
if(timeout_count > 5)//如果指令发5次还没发出去,那么结束发送 if(timeout_count > 0)//如果指令发1次还没发出去,那么结束发送
{ {
qDebug() << "command set value time out fail"; qDebug() << "command set value time out fail";
step = 0; step = 0;
+2 -1
View File
@@ -30,9 +30,10 @@ MavLinkNode::MavLinkNode(QObject *parent) : QObject(parent)
connect(Parameter,SIGNAL(SendMessageTo(quint8,quint8*,quint16)), connect(Parameter,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
this,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection); this,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);
/*
connect(this,SIGNAL(setCurrentID(int,int)), connect(this,SIGNAL(setCurrentID(int,int)),
Parameter,SLOT(setID(int,int)),Qt::DirectConnection); Parameter,SLOT(setID(int,int)),Qt::DirectConnection);
*/
Commander = new commandprocess(); Commander = new commandprocess();
+4 -7
View File
@@ -71,13 +71,6 @@ void ParameterProcess::stop()
void ParameterProcess::process()//线程函数 void ParameterProcess::process()//线程函数
{ {
uint8_t count = 0; uint8_t count = 0;
connect(paramInspect,SIGNAL(ReadCmd(uint8_t,uint8_t,uint8_t)),
this,SLOT(ReadCmd(uint8_t,uint8_t,uint8_t)));
connect(paramInspect,SIGNAL(WriteCmd(uint8_t,uint8_t,uint32_t)),
this,SLOT(WriteCmd(uint8_t,uint8_t,uint32_t)));
while (running_flag) while (running_flag)
{ {
count ++; count ++;
@@ -146,6 +139,9 @@ void ParameterProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,const char *i
qDebug() << "sysid" << sysid << endl qDebug() << "sysid" << sysid << endl
<< "compid" << compid << endl << "compid" << compid << endl
<< "param_id" << param_set.param_id << endl
<< "param_type" << param_set.param_type << endl
<< "param_value" << param_set.param_value << endl
<< "Mode" << status.m_Mode << endl << "Mode" << status.m_Mode << endl
<< "type" << status.recieve.type << endl << "type" << status.recieve.type << endl
<< "start..."; << "start...";
@@ -320,6 +316,7 @@ void ParameterProcess::WriteStateMachine(void)
//收到Value //收到Value
if(status.transmit.isWaitingforValue == false) if(status.transmit.isWaitingforValue == false)
{ {
qDebug() << "parameter set value ok";
step = 0; step = 0;
status.m_Mode = Nop_Mode; status.m_Mode = Nop_Mode;
status.transmit.isWaitingforValue = false; status.transmit.isWaitingforValue = false;
+25 -14
View File
@@ -206,10 +206,6 @@ void OPMapWidget::setUAVHeading(int sysid,int compid,float Heading)
} }
WayPointLine *OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed, int width) WayPointLine *OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed, int width)
{ {
if (!from | !to) { if (!from | !to) {
@@ -231,12 +227,18 @@ WayPointLine *OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to, QColor
void OPMapWidget::WPLineDelete(WayPointItem *from, WayPointItem *to) void OPMapWidget::WPLineDelete(WayPointItem *from, WayPointItem *to)
{ {
WayPointLine *line = WPLineFind(from,to); do
if(line)
{ {
delete line; WayPointLine *line = WPLineFind(from,to);
} if(line)
{
delete line;
}
else
{
break;
}
}while(1);
} }
WayPointLine *OPMapWidget::WPLineFind(WayPointItem *from, WayPointItem *to) WayPointLine *OPMapWidget::WPLineFind(WayPointItem *from, WayPointItem *to)
@@ -477,19 +479,20 @@ void OPMapWidget::WPInsert(const int &position)
//删除连线 //删除连线
if((item_old1)&&(item_old2)) if((item_old1)&&(item_old2))
{ {
WPLineDelete(item_old1,item_old2); WPLineDelete(item_old1,item_old2);
WPLineDelete(item_old1,item_old2); //WPLineDelete(item_old1,item_old2);
WPLineDelete(item_old1,item_old2); //WPLineDelete(item_old1,item_old2);
} }
//删除连线 //删除连线
if((item_old1)&&(item_old0)) if((item_old1)&&(item_old0))
{ {
WPLineDelete(item_old0,item_old1); WPLineDelete(item_old0,item_old1);
WPLineDelete(item_old0,item_old1); //WPLineDelete(item_old0,item_old1);
WPLineDelete(item_old0,item_old1); //WPLineDelete(item_old0,item_old1);
internals::PointLatLng latlng1 = item_old0->Coord(); internals::PointLatLng latlng1 = item_old0->Coord();
internals::PointLatLng latlng2 = item_old1->Coord(); internals::PointLatLng latlng2 = item_old1->Coord();
@@ -505,6 +508,7 @@ void OPMapWidget::WPInsert(const int &position)
} }
} }
if(item_old1)//如果指定的点存在,那么就可以在这之前插入一个点 if(item_old1)//如果指定的点存在,那么就可以在这之前插入一个点
{ {
WayPointItem *item = new WayPointItem(latlng, item_old1->Altitude(), map); WayPointItem *item = new WayPointItem(latlng, item_old1->Altitude(), map);
@@ -535,6 +539,7 @@ void OPMapWidget::WPInsert(const int &position)
WayPointItem *w_next = WPFind(item->Number() + 1); WayPointItem *w_next = WPFind(item->Number() + 1);
if(w_next) if(w_next)
{ {
@@ -547,6 +552,7 @@ void OPMapWidget::WPInsert(const int &position)
} }
} }
/*
WayPointItem *w_last = WPFind(item->Number() - 1); WayPointItem *w_last = WPFind(item->Number() - 1);
if(w_last) if(w_last)
{ {
@@ -559,6 +565,8 @@ void OPMapWidget::WPInsert(const int &position)
} }
} }
*/
} }
@@ -567,6 +575,9 @@ void OPMapWidget::WPInsert(const int &position)
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i); WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) { if (w) {
qDebug() << "all number" << w->Number() << w->snumber; qDebug() << "all number" << w->Number() << w->snumber;
WPFollowPrevious(w->FollowPrevious(),w);
} }
} }
} }
@@ -1275,7 +1286,7 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
} }
else else
{ {
WPLineCreate(WPFind(Item->Number() - 1),Item,Qt::green,false,2); //WPLineCreate(WPFind(Item->Number() - 1),Item,Qt::green,false,2);
} }
emit setWPProperty(param1,param2,param3,param4, emit setWPProperty(param1,param2,param3,param4,