diff --git a/MavLinkNode/Terminal.cpp b/MavLinkNode/Terminal.cpp index 9381b3d..59b8b7b 100644 --- a/MavLinkNode/Terminal.cpp +++ b/MavLinkNode/Terminal.cpp @@ -4,7 +4,7 @@ terminal::terminal(QObject *parent) : ThreadTemplet(parent) { - setRunFrq(10);//默认50Hz频率运行 + setRunFrq(1);//默认10Hz频率运行 status.m_Mode = Nop_Mode; } diff --git a/MavLinkNode/ThreadTemplet.cpp b/MavLinkNode/ThreadTemplet.cpp index b675f6a..fd837ff 100644 --- a/MavLinkNode/ThreadTemplet.cpp +++ b/MavLinkNode/ThreadTemplet.cpp @@ -82,8 +82,11 @@ void ThreadTemplet::pause() sleep_time = -1; } + void ThreadTemplet::process()//线程函数 { + + /* while (true) { diff --git a/MavLinkNode/ThreadTemplet.h b/MavLinkNode/ThreadTemplet.h index 636122d..96de81e 100644 --- a/MavLinkNode/ThreadTemplet.h +++ b/MavLinkNode/ThreadTemplet.h @@ -66,11 +66,13 @@ public slots: void Send(mavlink_message_t msg); + private slots: //线程私有接口 virtual void process(); //缓存私有接口 + virtual void wakeup(); virtual void pause(); //解析 diff --git a/MavLinkNode/commandprocess.cpp b/MavLinkNode/commandprocess.cpp index 916f7d8..5d32906 100644 --- a/MavLinkNode/commandprocess.cpp +++ b/MavLinkNode/commandprocess.cpp @@ -31,8 +31,8 @@ void commandprocess::process()//线程函数 { default: case Nop_Mode : QThread::msleep(1000.0/frq());break; - case RecieveMode : ReadStateMachine();QApplication::processEvents();break; - case TransmitMode : WriteStateMachine();QApplication::processEvents();break; + case RecieveMode : ReadStateMachine();break;//QApplication::processEvents();break; + case TransmitMode : WriteStateMachine();break;//QApplication::processEvents();break; } if(isInterruptionRequested())//退出 diff --git a/MavLinkNode/mavlinknode.cpp b/MavLinkNode/mavlinknode.cpp index 5d0ddcd..e4afe11 100644 --- a/MavLinkNode/mavlinknode.cpp +++ b/MavLinkNode/mavlinknode.cpp @@ -514,7 +514,7 @@ void MavLinkNode::process()//线程函数 else { //QThread::msleep(1000/running_frq); - QThread::yieldCurrentThread(); + QThread::yieldCurrentThread();//打开这个CPU占用50% } if(isInterruptionRequested())//退出 diff --git a/MavLinkNode/missionprocess.cpp b/MavLinkNode/missionprocess.cpp index 30680f0..bee44e3 100644 --- a/MavLinkNode/missionprocess.cpp +++ b/MavLinkNode/missionprocess.cpp @@ -27,10 +27,10 @@ void MissionProcess::process()//线程函数 { default: case Nop_Mode : QThread::msleep(1000/frq());break; - case RecieveMode : ReadStateMachine();QApplication::processEvents();break; + case RecieveMode : ReadStateMachine();break;//QApplication::processEvents();break; case TransmitMode : { - QApplication::processEvents(); + //QApplication::processEvents(); if(mission_status.transmit.type == 0)//航线传输 { WriteStateMachine(); diff --git a/MavLinkNode/parameterprocess.cpp b/MavLinkNode/parameterprocess.cpp index b8a82b1..ec759b3 100644 --- a/MavLinkNode/parameterprocess.cpp +++ b/MavLinkNode/parameterprocess.cpp @@ -2,7 +2,7 @@ ParameterProcess::ParameterProcess(QObject *parent) : ThreadTemplet(parent) { - setRunFrq(20); + setRunFrq(10); status.m_Mode = Nop_Mode; status.recieve.type = _readtype::All; @@ -24,8 +24,8 @@ void ParameterProcess::process()//线程函数 { default: case Nop_Mode : QThread::msleep(1000/frq());break; - case RecieveMode : ReadStateMachine();QApplication::processEvents();break; - case TransmitMode : WriteStateMachine();QApplication::processEvents();break; + case RecieveMode : ReadStateMachine();break;//QApplication::processEvents();break; + case TransmitMode : WriteStateMachine();break;//QApplication::processEvents();break; } if(isInterruptionRequested())//退出 diff --git a/MavLinkNode/replay.cpp b/MavLinkNode/replay.cpp index b0aa359..eac49b9 100644 --- a/MavLinkNode/replay.cpp +++ b/MavLinkNode/replay.cpp @@ -123,6 +123,7 @@ void Replay::process()//线程函数 } else { + //QThread::yieldCurrentThread();//放弃运行 QThread::msleep(1000);//如果没有播放,那么每秒钟检测一下是否要播放 } diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index 2924543..3234e90 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -804,7 +804,7 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event) WayPointItem *OPMapWidget::WPCreate() { //获取当前组下面的seq最大值 - int seq = getWaypointSize(currentGroup); + int seq = getWaypointSize(currentGroup) + 1; WayPointItem *item = new WayPointItem(this->CurrentPosition(), 0,seq,currentGroup, map); @@ -818,7 +818,7 @@ WayPointItem *OPMapWidget::WPCreate() WayPointItem *OPMapWidget::magicWPCreate() { //获取当前组下面的seq最大值 - int seq = getWaypointSize(currentGroup); + int seq = getWaypointSize(currentGroup) + 1; WayPointItem *item = new WayPointItem(seq,currentGroup,map, true); @@ -839,7 +839,7 @@ void OPMapWidget::WPCreate(WayPointItem *item) WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int const & altitude) { //获取当前组下面的seq最大值 - int seq = getWaypointSize(currentGroup); + int seq = getWaypointSize(currentGroup) + 1; WayPointItem *item = new WayPointItem(coord, altitude,seq,currentGroup, map); @@ -854,7 +854,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int const & altitude, QString const & description) { //获取当前组下面的seq最大值 - int seq = getWaypointSize(currentGroup); + int seq = getWaypointSize(currentGroup) + 1; WayPointItem *item = new WayPointItem(coord, altitude,seq,currentGroup, description, map); @@ -869,7 +869,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co WayPointItem *OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, const QString &description) { //获取当前组下面的seq最大值 - int seq = getWaypointSize(currentGroup); + int seq = getWaypointSize(currentGroup) + 1; WayPointItem *item = new WayPointItem(relativeCoord,seq,currentGroup, description, map); @@ -1174,10 +1174,13 @@ void OPMapWidget::WPSetVisibleAll(bool value) { foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); - if (w) { - if (w->Number() != -1) { - w->setVisible(value); + + if(w->MissionType() == currentGroup) + { + if (w->Number() != -1) { + w->setVisible(value); + } } } } @@ -2022,10 +2025,14 @@ void OPMapWidget::WPUpload(void) foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) { - list.append(w); - w->emitWPProperty(); + //上传当前选中的航线 + if(w->MissionType() == currentGroup) + { + list.append(w); + w->emitWPProperty(); - //w->setVisible(false); + //w->setVisible(false); + } } } @@ -2212,7 +2219,6 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par { qDebug() << "receivers Point"; - // << QThread::currentThreadId(); //emit showMessage(tr("recieve way point %1").arg(seq + 1)); @@ -2225,35 +2231,40 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) { - if(w->Number() == (seq+1)) + if(w->MissionType() == mission_type)//如果组别一样,那么就赋值 { - isExist = true; + if(w->Number() == (seq+1)) + { + qDebug() << "waypoint exist:" << w->Number() << seq+1; - internals::PointLatLng LatLng; + isExist = true; - LatLng.SetLat(x * 10e-8); - LatLng.SetLng(y * 10e-8); + internals::PointLatLng LatLng; + + LatLng.SetLat(x * 10e-8); + LatLng.SetLng(y * 10e-8); - w->SetLat(LatLng.Lat()); - LatLng.SetLng(LatLng.Lng()); - w->SetNumber(seq+1); + w->SetLat(LatLng.Lat()); + LatLng.SetLng(LatLng.Lng()); + w->SetNumber(seq+1); - emit setWPProperty(param1,param2,param3,param4, - x,y,z, - seq+1, - group, - command, - target_system, - target_component, - frame, - current, - autocontinue, - mission_type); + emit setWPProperty(param1,param2,param3,param4, + x,y,z, + seq+1, + group, + command, + target_system, + target_component, + frame, + current, + autocontinue, + mission_type); - w->emitWPProperty(); + w->emitWPProperty(); + } } } } @@ -2261,15 +2272,24 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par if(!isExist) { + + internals::PointLatLng LatLng; LatLng.SetLat(x * 10e-8); LatLng.SetLng(y * 10e-8); + //设置好当前的航线 + currentGroup = mission_type; + + + //生成的时候默认设定不对,导致下载时切换过去 WayPointItem *Item = WPCreate(LatLng,z); Item->SetNumber(seq+1); + qDebug() << "waypoint not exist:" << Item->Number() << seq+1 <emitWPProperty(); + + + //===========连线 +/* + WayPointItem *w_last = WPFind(mission_type,Item->Number() - 1); + if(w_last) + { + WPLineCreate(w_last,Item,Qt::green,false,2); + } + + + WayPointItem *w_next = WPFind(group,Item->Number() + 1); + if(w_next) + { + WPLineCreate(item,w_next,Qt::green,false,2); + } + */ + } qDebug() << "Exist" << isExist; diff --git a/opmap/mapwidget/waypointitem.cpp b/opmap/mapwidget/waypointitem.cpp index f2d1536..332cf9f 100644 --- a/opmap/mapwidget/waypointitem.cpp +++ b/opmap/mapwidget/waypointitem.cpp @@ -734,7 +734,7 @@ void WayPointItem::setWPProperty(float param1,float param2,float param3,float pa qDebug() << this->Number(); - emit WPFollowPrevious(isFollowPrevious,this); + //emit WPFollowPrevious(isFollowPrevious,this); ElevationTrig();