b
This commit is contained in:
@@ -1025,7 +1025,7 @@ void propertyui::setallPoint(QMap<int,int> list)
|
||||
void propertyui::setSeqNav(QVariant value)
|
||||
{
|
||||
//读取这个值得航点
|
||||
emit WPotherPoint(value.toInt());
|
||||
emit WPotherPoint(value.toInt()+1);
|
||||
}
|
||||
|
||||
void propertyui::on_pushButton_Seq_clicked()
|
||||
@@ -1535,6 +1535,7 @@ void propertyui::on_pushButton_Param7_clicked()
|
||||
//模仿qgc
|
||||
void propertyui::setLoad(QVariant value)
|
||||
{
|
||||
qDebug() << "Loadvalue" << value;
|
||||
if(value.toBool() == true)
|
||||
{
|
||||
QFileDialog *dlg = new QFileDialog(this);
|
||||
|
||||
+4
-1
@@ -143,7 +143,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
w.setWindowTitle(QString("GCS New Frame by Qt%1").arg(QT_VERSION_STR));//with version
|
||||
// 主要是控制HDMI输出,如果是LCD显示,此行无关紧要
|
||||
w.resize(GetDesktopSize());
|
||||
//w.resize(GetDesktopSize());
|
||||
//w.move(0,0);
|
||||
|
||||
w.setWindowState(Qt::WindowMaximized);
|
||||
|
||||
w.show();
|
||||
|
||||
|
||||
+5
-6
@@ -9,6 +9,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
|
||||
//setGeometry();
|
||||
|
||||
//检测qml文件夹,如果不存在,那么就新建一个,这里存着所有的qml文件
|
||||
QDir *qmlDir = new QDir;
|
||||
if(!qmlDir->exists("./qml"))
|
||||
@@ -36,10 +38,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
checkUI = new CheckUI(this);
|
||||
checkUI->hide();
|
||||
|
||||
//---
|
||||
//inspectui = new InspectUI(this);
|
||||
//inspectui->hide();
|
||||
|
||||
//信息
|
||||
toolsui = new ToolsUI(this);
|
||||
toolsui->hide();
|
||||
@@ -227,7 +225,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
qDebug() << "main window start";
|
||||
|
||||
|
||||
//监测ssl,用于网络连接
|
||||
qDebug()<<"QSslSocket="<<QSslSocket::sslLibraryBuildVersionString();
|
||||
qDebug() << "OpenSSL支持情况:" << QSslSocket::supportsSsl();
|
||||
@@ -302,7 +299,6 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
void MainWindow::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -366,6 +362,9 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
break;
|
||||
case Qt::Key_Space :
|
||||
{
|
||||
//map->setcu
|
||||
map->SetCurrentPosition();
|
||||
//根据选中的飞机设置当前位置
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -240,7 +240,7 @@ void commandprocess::WriteStateMachine(void)
|
||||
}
|
||||
else if(step == 1)//等待返回
|
||||
{
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 5000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > sendTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
step = 0;//返回上一个步骤
|
||||
|
||||
@@ -141,6 +141,11 @@ private:
|
||||
int Current_sysID = 0xF1;
|
||||
int Current_CompID = 0xF1;
|
||||
|
||||
//超时时间(ms)
|
||||
int readTimeout = 5000;
|
||||
int sendTimeout = 5000;
|
||||
|
||||
|
||||
mavlink_command_int_t cmd_int;
|
||||
mavlink_command_long_t cmd_long;
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
|
||||
{
|
||||
if(MAVLINK_FRAMING_OK == mavlink_parse_char(src,*i,&msg,&status))
|
||||
{
|
||||
if(msg.compid != Current_CompID)//过滤地面站发过来的数据
|
||||
if(msg.compid != Current_CompID) //过滤地面站发过来的数据
|
||||
{
|
||||
emit recievemsg(msg); //将信息广播出去
|
||||
MAVLinkRcv_Handler(msg); //接收完一帧数据并处理
|
||||
@@ -377,8 +377,6 @@ void MavLinkNode::MAVLinkRcv_Handler(mavlink_message_t msg)
|
||||
case MAVLINK_MSG_ID_EngineState:
|
||||
case MAVLINK_MSG_ID_VFR_HUD:
|
||||
StatusParse(msg);
|
||||
//qDebug() << msg.compid << msg.sysid;
|
||||
|
||||
break;
|
||||
|
||||
//航线部分
|
||||
@@ -395,7 +393,6 @@ void MavLinkNode::MAVLinkRcv_Handler(mavlink_message_t msg)
|
||||
case MAVLINK_MSG_ID_MISSION_ITEM_REACHED:
|
||||
case MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST:
|
||||
case MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST:
|
||||
|
||||
Mission->Parse(msg);
|
||||
break;
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ void MissionProcess::ReadStateMachine(void)
|
||||
else if(step == 1)//等待收到Count
|
||||
{
|
||||
//如果超时,那么重新发一次指令
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > readTimeout)
|
||||
{
|
||||
step = 0;//如果超时没有收到就返回上一个步骤
|
||||
timeout_count ++;
|
||||
@@ -372,7 +372,7 @@ void MissionProcess::ReadStateMachine(void)
|
||||
else if(step ==2)//请求航点第0个航点
|
||||
{
|
||||
//超过时间
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > readTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
qDebug() << "mission request 0 time out " << timeout_count << "times, retry again";
|
||||
@@ -399,7 +399,7 @@ void MissionProcess::ReadStateMachine(void)
|
||||
else if(step ==3)//请求航点
|
||||
{
|
||||
//超过时间
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > readTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
qDebug() << "mission request " << (mission_item_int.seq+1) << " time out " << timeout_count << "times, retry again";
|
||||
@@ -470,7 +470,7 @@ void MissionProcess::WriteStateMachine(void)
|
||||
else if(step == 1)//等待收到Request
|
||||
{
|
||||
//如果超时,那么重新发一次指令
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > sendTimeout)
|
||||
{
|
||||
step = 0;//返回上一个阶段
|
||||
timeout_count ++;
|
||||
@@ -501,7 +501,7 @@ void MissionProcess::WriteStateMachine(void)
|
||||
}
|
||||
else if(step == 2)
|
||||
{
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > sendTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
if(timeout_count > 5)//如果指令发5次还没发出去,那么结束读取,并报错
|
||||
@@ -567,7 +567,7 @@ void MissionProcess::WriteStateMachine(void)
|
||||
}
|
||||
else if(step == 3)//航线传输结束,等待ack,如果没接收到就算了,超时也结束
|
||||
{
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > sendTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
if(timeout_count > 5)//如果指令发5次还没发出去,那么结束读取
|
||||
|
||||
@@ -187,6 +187,11 @@ private:
|
||||
int Current_sysID = 0xF1;
|
||||
int Current_CompID = 0xF1;
|
||||
|
||||
|
||||
//超时时间(ms)
|
||||
int readTimeout = 3000;
|
||||
int sendTimeout = 3000;
|
||||
|
||||
QList<mapcontrol::WayPointItem *> wplist;
|
||||
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ void ParameterProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,const char *i
|
||||
//这个函数类似中断,专门处理接收到的状态
|
||||
void ParameterProcess::Parse(mavlink_message_t msg)
|
||||
{
|
||||
|
||||
//qDebug() << "Parameter" << msg.msgid;
|
||||
|
||||
switch (msg.msgid) {
|
||||
case MAVLINK_MSG_ID_PARAM_SET:{
|
||||
@@ -176,7 +176,7 @@ void ParameterProcess::Parse(mavlink_message_t msg)
|
||||
|
||||
status.recieve.isWaitingforValue = false;
|
||||
status.transmit.isWaitingforValue = false;
|
||||
//qDebug() << "param_value.param_index" << param_value.param_index;
|
||||
qDebug() << "param_value.param_index" << param_value.param_index;
|
||||
}break;
|
||||
case MAVLINK_MSG_ID_PARAM_EXT_ACK:{
|
||||
mavlink_msg_param_ext_ack_decode(&msg,¶m_ext_ack);
|
||||
@@ -225,7 +225,7 @@ void ParameterProcess::ReadStateMachine(void)//一整列
|
||||
else if(step == 1)//等待收到Item
|
||||
{
|
||||
//如果超时,那么结束
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > readTimeout)
|
||||
{
|
||||
|
||||
//做一个列表,记录谁丢了,后面单独请求
|
||||
@@ -310,7 +310,7 @@ void ParameterProcess::WriteStateMachine(void)
|
||||
}
|
||||
else if(step == 1)//等待返回
|
||||
{
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > 2000)
|
||||
if((QTime::currentTime().msecsSinceStartOfDay() - time) > sendTimeout)
|
||||
{
|
||||
timeout_count ++;
|
||||
step = 0;//返回上一个步骤
|
||||
|
||||
@@ -135,6 +135,11 @@ private:
|
||||
int Current_sysID = 0xF1;
|
||||
int Current_CompID = 0xF1;
|
||||
|
||||
|
||||
//超时时间(ms)
|
||||
int readTimeout = 3000;
|
||||
int sendTimeout = 3000;
|
||||
|
||||
mavlink_param_set_t param_set;//
|
||||
mavlink_param_union_t param_union;
|
||||
mavlink_param_value_t param_value;//
|
||||
|
||||
+4
-3
@@ -242,13 +242,14 @@ bool DLink::setupClient(const QHostAddress &local_addr,int local_port,const QHos
|
||||
Clientsock = new QUdpSocket(this);
|
||||
if (Clientsock->bind(QHostAddress::AnyIPv4, local_port, QUdpSocket::ShareAddress))
|
||||
{
|
||||
Clientsock->joinMulticastGroup(remote_addr);
|
||||
//Clientsock->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,1024*1024*8);
|
||||
//Clientsock->setSocketOption(QAbstractSocket::MulticastTtlOption, 3);
|
||||
|
||||
if(Clientsock->open(QIODevice::ReadWrite))
|
||||
//if(Clientsock->joinMulticastGroup(remote_addr))
|
||||
{
|
||||
|
||||
Clientsock->joinMulticastGroup(remote_addr);
|
||||
Clientsock->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,1024*1024*8);
|
||||
Clientsock->setSocketOption(QAbstractSocket::MulticastTtlOption, 3);
|
||||
|
||||
connect(Clientsock, SIGNAL(readyRead()),
|
||||
this, SLOT(readPendingDatagramsClient()));
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
#include "dlink.h"
|
||||
#include <string.h>
|
||||
//#include "windows.h"
|
||||
#include "QDateTime"
|
||||
|
||||
|
||||
DLink::DLink(QObject *parent) : QObject(parent)
|
||||
{
|
||||
qDebug() << "Dlink " << QThread::currentThreadId();
|
||||
|
||||
//采用插件导入的方式(plugin)
|
||||
|
||||
//mavlink协议节点
|
||||
mavlinknode = new MavLinkNode();//不允许带参数,因为这是单独的线程
|
||||
connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
||||
this,SLOT(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);//采用直连的方式,因为是多线程
|
||||
|
||||
connect(mavlinknode,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
|
||||
|
||||
mavlinknode->start();
|
||||
|
||||
|
||||
connect(this,&DLink::REVMessageTo1,
|
||||
this,&DLink::SendMessageTo1);
|
||||
|
||||
//其他协议节点。。。
|
||||
|
||||
}
|
||||
DLink::~DLink()
|
||||
{
|
||||
mavlinknode->stop();
|
||||
delete mavlinknode;
|
||||
}
|
||||
|
||||
|
||||
int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
|
||||
{
|
||||
//让这个函数在其他线程运行
|
||||
|
||||
//Q_UNUSED(ch);
|
||||
|
||||
//更加ch选择
|
||||
if (DLink::Clientsock)
|
||||
{
|
||||
foreach(Node node,clientSockets)
|
||||
{
|
||||
DLink::Clientsock->writeDatagram((const char *)msg, len,
|
||||
node.addr, node.port);
|
||||
qDebug() << "Client Send Msg";
|
||||
}
|
||||
}
|
||||
|
||||
//这个地方有问题,会导致数据中断
|
||||
emit REVMessageTo1(ch,msg,len);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DLink::SendMessageTo1(quint8 ch, quint8 *msg, quint16 len)
|
||||
{
|
||||
|
||||
if (DLink::serialPort)
|
||||
{
|
||||
|
||||
/*
|
||||
QString num;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
num.append(QString::number(msg[i],16).toUpper());
|
||||
num.append(" ");
|
||||
}
|
||||
qDebug() << num;
|
||||
*/
|
||||
|
||||
//qDebug() << QThread::currentThread();
|
||||
|
||||
qint64 flag = DLink::serialPort->write((const char *)msg,len);
|
||||
|
||||
/*
|
||||
if(flag != -1)
|
||||
{
|
||||
qDebug() << "serial send Success,Send " << flag << "bytes";
|
||||
}
|
||||
|
||||
qDebug() << QThread::currentThread();
|
||||
|
||||
*/
|
||||
qDebug() << "serialPort Send Msg";
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DLink::setupPort(const QString port, qint32 baudrate, QSerialPort::Parity parity)
|
||||
{
|
||||
|
||||
qDebug() << port
|
||||
<< baudrate
|
||||
<< parity;
|
||||
|
||||
bool isSuccess = false;
|
||||
|
||||
if (serialPort)//多串口接入
|
||||
{
|
||||
serialPort->close();
|
||||
delete serialPort;
|
||||
}
|
||||
serialPort = new QSerialPort(this);
|
||||
|
||||
serialPort->setPortName(port);
|
||||
|
||||
if (serialPort->open(QIODevice::ReadWrite))
|
||||
{
|
||||
serialPort->setBaudRate(baudrate);
|
||||
serialPort->setParity(parity);
|
||||
serialPort->setDataBits(QSerialPort::Data8);
|
||||
serialPort->setStopBits(QSerialPort::OneStop);
|
||||
|
||||
DLink::serialPort->write("serial connet ok",16);
|
||||
|
||||
qDebug() << QThread::currentThread();
|
||||
|
||||
//mavlinknode->start();//启动之后串口就找不到了
|
||||
|
||||
connect(serialPort, SIGNAL(readyRead()), this, SLOT(readPendingDatagramsSerialPort()));
|
||||
|
||||
|
||||
isSuccess = true;
|
||||
|
||||
emit showMessage(tr("Serial Port Open Success"));
|
||||
qDebug() << "Serial Port Open Success";
|
||||
}
|
||||
else
|
||||
{
|
||||
isSuccess = false;
|
||||
emit showMessage(tr("Serial Port Open Fail"));
|
||||
qDebug() << "Serial Port Open Fail";
|
||||
delete serialPort;
|
||||
serialPort = nullptr;
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
bool DLink::statesPort()
|
||||
{
|
||||
return (serialPort != nullptr)?(true):(false);
|
||||
}
|
||||
|
||||
void DLink::stopPort()
|
||||
{
|
||||
emit showMessage(tr("Serial Port close"));
|
||||
serialPort->close();
|
||||
delete serialPort;
|
||||
serialPort = nullptr;
|
||||
}
|
||||
|
||||
void DLink::connectSignal(QVariant m_state,
|
||||
QVariant m_usrName,QVariant m_Type,
|
||||
QVariant m_Param1,QVariant m_Param2,
|
||||
QVariant m_Param3,QVariant m_Param4,
|
||||
QVariant m_Param5)
|
||||
{
|
||||
if(m_state.toBool() == true)
|
||||
{
|
||||
|
||||
|
||||
if(m_Type.toString() == "SerialPort")
|
||||
{
|
||||
QSerialPort::Parity parity;
|
||||
if(m_Param4.toString() == "NONE")
|
||||
{
|
||||
parity = QSerialPort::Parity::NoParity;
|
||||
}
|
||||
if(m_Param4.toString() == "ODD")
|
||||
{
|
||||
parity = QSerialPort::Parity::OddParity;
|
||||
}
|
||||
if(m_Param4.toString() == "EVEN")
|
||||
{
|
||||
parity = QSerialPort::Parity::EvenParity;
|
||||
}
|
||||
|
||||
|
||||
qDebug() << m_Type << m_Param1 << m_Param2.toString().toInt() << parity;
|
||||
|
||||
if(setupPort(m_Param1.toString(),m_Param2.toString().toInt(),parity))
|
||||
{
|
||||
emit PortConnected(true,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit PortConnected(false,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
}
|
||||
else if(m_Type.toString() == "UDP")
|
||||
{
|
||||
//qDebug() << m_Type << m_Param1 << m_Param2 << m_Param4;
|
||||
if(setupClient(QHostAddress(m_Param1.toString()),m_Param2.toString().toInt(),QHostAddress(m_Param3.toString()),m_Param4.toString().toInt()))
|
||||
{
|
||||
emit PortConnected(true,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit PortConnected(false,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "disconnect";
|
||||
if(m_Type.toString() == "SerialPort")
|
||||
{
|
||||
stopPort();
|
||||
emit PortConnected(false,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
else if(m_Type.toString() == "UDP")
|
||||
{
|
||||
emit PortConnected(false,m_usrName,m_Type,m_Param1,m_Param2,m_Param3,m_Param4,m_Param5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool DLink::setupClient(const QHostAddress &local_addr,int local_port,const QHostAddress &remote_addr,int remote_port)
|
||||
{
|
||||
if(Clientsock)
|
||||
{
|
||||
delete Clientsock;
|
||||
Clientsock = nullptr;
|
||||
}
|
||||
|
||||
bool isSuccess = false;
|
||||
Clientsock = new QUdpSocket(this);
|
||||
if (Clientsock->bind(QHostAddress::AnyIPv4, local_port, QUdpSocket::ShareAddress))
|
||||
{
|
||||
if(Clientsock->open(QIODevice::ReadWrite))
|
||||
//if(Clientsock->joinMulticastGroup(remote_addr))
|
||||
{
|
||||
Clientsock->joinMulticastGroup(remote_addr);
|
||||
Clientsock->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,1024*1024*8);
|
||||
Clientsock->setSocketOption(QAbstractSocket::MulticastTtlOption, 3);
|
||||
|
||||
connect(Clientsock, SIGNAL(readyRead()),
|
||||
this, SLOT(readPendingDatagramsClient()));
|
||||
|
||||
Node node;
|
||||
node.sock = Clientsock;
|
||||
node.addr = remote_addr;
|
||||
node.port = remote_port;
|
||||
|
||||
clientSockets.append(node);
|
||||
qDebug() << "UdpSocket open:"
|
||||
<< remote_addr
|
||||
<< local_port
|
||||
<< remote_port;
|
||||
|
||||
isSuccess = true;
|
||||
emit showMessage(tr("UdpSocket open"));
|
||||
}
|
||||
else
|
||||
{
|
||||
isSuccess = false;
|
||||
qDebug() << "sock not open";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isSuccess = false;
|
||||
qWarning("sock is not binded.");
|
||||
delete Clientsock;
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
|
||||
}
|
||||
|
||||
void DLink::readPendingDatagramsSerialPort(void)
|
||||
{
|
||||
QByteArray datagram = serialPort->readAll();
|
||||
mavlinknode->setbuff(SourceType::s_port,datagram);
|
||||
|
||||
/*
|
||||
QString num;
|
||||
for (int i = 0; i < datagram.size(); ++i) {
|
||||
num.append(QString::number((uint8_t)datagram.at(i) & 0xFF,16).toUpper());
|
||||
num.append(" ");
|
||||
}
|
||||
qDebug() << num;
|
||||
*/
|
||||
|
||||
//qDebug() << "reci";
|
||||
|
||||
}
|
||||
|
||||
void DLink::readPendingDatagramsClient(void)
|
||||
{
|
||||
//轮番查询
|
||||
while (Clientsock->hasPendingDatagrams()) {
|
||||
QByteArray datagram;
|
||||
datagram.resize(Clientsock->pendingDatagramSize());
|
||||
Clientsock->readDatagram(datagram.data(), datagram.size());
|
||||
mavlinknode->setbuff(SourceType::c_sock,datagram);
|
||||
}
|
||||
|
||||
//qDebug() << "client recieve";
|
||||
|
||||
}
|
||||
|
||||
|
||||
//在这里做一个检查缓冲区有没有数,有数据就往上发的一个函数
|
||||
//dlink底下的所有协议都可以往这个缓存发数据
|
||||
|
||||
|
||||
@@ -183,13 +183,34 @@ void OPMapWidget::addUAV(int sysid,int compid)
|
||||
|
||||
void OPMapWidget::NOPTimeout()
|
||||
{
|
||||
qDebug() << "NOPTimeout";
|
||||
//qDebug() << "NOPTimeout";
|
||||
if(isWPCreate == false)
|
||||
{
|
||||
isLNOP = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OPMapWidget::SetCurrentPosition()
|
||||
{
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
|
||||
if(u->Select())//当前选中,那么检查如果超出了屏幕范围,就将位置拉回中点
|
||||
{
|
||||
map->core->SetCurrentPosition(u->UAVPos());//缓慢拉回来
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::SetCurrentPosition(internals::PointLatLng const & value)
|
||||
{
|
||||
map->core->SetCurrentPosition(value);
|
||||
}
|
||||
|
||||
|
||||
void OPMapWidget::setUAVPos(int sysid,int compid,double x,double y,double z)
|
||||
{
|
||||
//qDebug() << sysid << compid;
|
||||
@@ -1356,6 +1377,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
|
||||
|
||||
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq,
|
||||
@@ -1369,6 +1391,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
mission_type);
|
||||
|
||||
|
||||
Item->emitWPProperty();
|
||||
|
||||
}
|
||||
|
||||
@@ -1611,6 +1634,9 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
//Item->setParent(map);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq+1,
|
||||
@@ -1623,6 +1649,9 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
autocontinue,
|
||||
mission_type);
|
||||
|
||||
|
||||
Item->emitWPProperty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -279,10 +279,11 @@ public:
|
||||
{
|
||||
return map->core->CurrentPosition();
|
||||
}
|
||||
void SetCurrentPosition(internals::PointLatLng const & value)
|
||||
{
|
||||
map->core->SetCurrentPosition(value);
|
||||
}
|
||||
|
||||
void SetCurrentPosition();
|
||||
void SetCurrentPosition(internals::PointLatLng const & value);
|
||||
|
||||
|
||||
|
||||
double ZoomReal()
|
||||
{
|
||||
|
||||
@@ -99,10 +99,16 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||
//qDebug() << "selected" << sysid << compid;
|
||||
painter->setPen(QColor(255*(1-sysid/255.0f),255*(1-sysid/255.0f),255*(1-sysid/255.0f)));
|
||||
painter->drawRect(QRectF(boundingRect()));
|
||||
|
||||
//qreal width = pic.width(); //获得以前图片的宽和高
|
||||
//qreal height = pic.height();
|
||||
|
||||
//pic.scaled(width*2,height*2,Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
// Draw plane
|
||||
//pic.toImage().setColor(2,Qt::yellow);
|
||||
painter->drawPixmap(-pic.width() / 2, -pic.height() / 2, pic);
|
||||
|
||||
// Return if UAV Info context menu is turned off
|
||||
|
||||
Reference in New Issue
Block a user