1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

更新说明文件 和QQt Network example

This commit is contained in:
tianduanrui 2018-01-27 22:14:00 +08:00
parent e16f666402
commit abc6f91df0
14 changed files with 802 additions and 8 deletions

View File

@ -24,6 +24,14 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。
[详细介绍](content.md)
========================================================================
# 使用案例
[看入门用例截图](screenshot.md)
========================================================================
# 使用方法
@ -33,11 +41,6 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。
[走,去看看入门用法](usage.md)
========================================================================
# 使用案例
[看入门用例截图](screenshot.md)
========================================================================

View File

@ -0,0 +1,219 @@
#include "cedianudpmessage.h"
#include <qqtcore.h>
CedianUdpMessage::CedianUdpMessage(QObject *parent) : QQtMessage(parent)
{
qreal mVAA = 0;
qreal mVAB = 0;
qreal mVAC = 0;
qreal mVPA = 0;
qreal mVPB = 0;
qreal mVPC = 0;
qreal mIAA = 0;
qreal mIAB = 0;
qreal mIAC = 0;
qreal mIPA = 0;
qreal mIPB = 0;
qreal mIPC = 0;
qreal mFA = 0;
qreal mFB = 0;
qreal mFC = 0;
QString mDateTime =0;
mqbaVAA.clear();
mqbaVAB.clear();
}
/*把测点发来的数据解出来*/
void CedianUdpMessage::parser(const QByteArray & data)
{
QByteArray l = data;
quint8 DataLen = 0, temp = 0, Month = 0, Day = 0, Hour = 0, Minute = 0, Second =0;
quint16 Year = 0;
//跳过包头 0-5
for (int i=0; i<6 ;i++)
{
l >> temp;
DataLen++;
}
//跳过空格 6
l >> temp;
DataLen++;
//日 7-8
l >> temp;
mqbaDateTime << temp;
Day = 10 * (temp - 0x30);
l >> temp;
mqbaDateTime << temp;
Day = Day + (temp - 0x30);
DataLen = DataLen + 2;
//月 9-10
l >> temp;
mqbaDateTime << temp;
Month = 10 * (temp - 0x30);
l >> temp;
mqbaDateTime << temp;
Month = Month + (temp - 0x30);
DataLen = DataLen + 2;
//年 11-12
l >> temp;
mqbaDateTime << temp;
Year = 10 * (temp - 0x30) + 2000;
l >> temp;
mqbaDateTime << temp;
Year = Year + (temp - 0x30);
DataLen = DataLen + 2;
//跳过空格 13
l >> temp;
DataLen++;
//时 14-15
l >> temp;
mqbaDateTime << temp;
Hour = 10 * (temp - 0x30);
l >> temp;
mqbaDateTime << temp;
Hour = Hour + (temp - 0x30);
DataLen = DataLen + 2;
//分 16-17
l >> temp;
mqbaDateTime << temp;
Minute = 10 * (temp - 0x30);
l >> temp;
mqbaDateTime << temp;
Minute = Minute + (temp - 0x30);
DataLen = DataLen + 2;
//秒 18-19
l >> temp;
mqbaDateTime << temp;
Second = 10 * (temp - 0x30);
l >> temp;
mqbaDateTime << temp;
Second = Second + (temp - 0x30);
DataLen = DataLen + 2;
//拼接并赋值给成员变量 年月日时分秒
mDateTime = QString("%1-%2-%3 %4:%5:%6").arg(Year).arg(Month).arg(Day).arg(Hour).arg(Minute).arg(Second);
//跳过空格 20
l >> temp;
DataLen++;
//秒内标号 21-22
l >> temp;
mqbaBuffer << temp;
mBuffer = 10 * (temp - 0x30);
l >> temp;
mqbaBuffer << temp;
mBuffer = mBuffer + (temp - 0x30);
DataLen = DataLen + 2;
//跳过空格 23
l >> temp;
DataLen++;
//频率mFA 24-30
l >> temp;
mqbaFA << temp;
mFA = (temp - 0x30) * 100000;
l >> temp;
mqbaFA << temp;
mFA = mFA + (temp - 0x30) * 10000;
l >> temp; //小数点
mqbaFA << temp;
l >> temp;
mqbaFA << temp;
mFA = mFA + (temp - 0x30) * 1000;
l >> temp;
mqbaFA << temp;
mFA = mFA + (temp - 0x30) * 100;
l >> temp;
mqbaFA << temp;
mFA = mFA + (temp - 0x30) * 10;
l >> temp;
mqbaFA << temp;
mFA = mFA + (temp - 0x30);
mFA = mFA / 10000;
DataLen = DataLen + 7;
//跳过空格 31
l >> temp;
DataLen++;
//频率弃用 32-38
for (int i=0; i<7 ;i++)
{
l >> temp;
DataLen++;
}
//跳过空格 39
l >> temp;
DataLen++;
//电压幅值mVAA 40-45
l >> temp;
mqbaVAA << temp;
mVAA = (temp - 0x30) * 10000;
l >> temp;
mqbaVAA << temp;
mVAA = mVAA + (temp - 0x30) * 1000;
l >> temp;
mqbaVAA << temp;
mVAA = mVAA + (temp - 0x30) * 100;
l >> temp; //小数点
mqbaVAA << temp;
l >> temp;
mqbaVAA << temp;
mVAA = mVAA + (temp - 0x30) * 10;
l >> temp;
mqbaVAA << temp;
mVAA = mVAA + (temp - 0x30);
mVAA = mVAA / 100;
DataLen = DataLen + 6;
//跳过空格 46
l >> temp;
DataLen++;
//电压相位mVPA 47-51
l >> temp;
mqbaVPA << temp;
mVPA = (temp - 0x30) * 1000;
l >> temp; //小数点
mqbaVPA << temp;
l >> temp;
mqbaVPA << temp;
mVPA = mVPA + (temp - 0x30) * 100;
l >> temp;
mqbaVPA << temp;
mVPA = mVPA + (temp - 0x30) * 10;
l >> temp;
mqbaVPA << temp;
mVPA = mVPA + (temp - 0x30);
mVPA = mVPA / 1000;
mVPA = mVPA * 57.296;
DataLen = DataLen + 5;
//跳过包尾 52-54
for (int i=0; i<3 ;i++)
{
l >> temp;
DataLen++;
}
}
//监测点数据只有接收没有发送所以不需要实现packer函数
void CedianUdpMessage::packer(QByteArray & l) const
{
}
QDebug operator<<(QDebug dbg, const CedianUdpMessage &c)
{
// dbg.nospace() << "{" << hex << c.head() << "|" <<
// hex << c.size() << "=" << dec << c.size() << "|" <<
// hex << c.cmd() << "|" <<
// hex << c.uid() << "|" <<
// c.data().data() << "@" << dec << c.data().size() << "|" <<
// hex << c.sum() << "|" <<
// hex << c.tail() << "}";
dbg.nospace() << "{" << hex << "}";
return dbg.space();
}

View File

@ -0,0 +1,157 @@
#ifndef CEDIANUDPMESSAGE_H
#define CEDIANUDPMESSAGE_H
#include <qqtmessage.h>
#include <qqtcore.h>
#include <QDebug>
class CedianUdpMessage : public QQtMessage
{
Q_OBJECT
public:
explicit CedianUdpMessage(QObject *parent = nullptr);
virtual ~CedianUdpMessage() {}
/*用函数把成员变量公开出来*/
//qint8 getSite(void) { return mSite; }
/*用函数设置成员变量*/
//void setSite(qint8 mSite) { this->mSite = mSite; }
/*比较简便的处理成员变量的方式。读写都用这个函数。*/
//获取mVAA
qreal& getVAA() { return mVAA; }
const qreal& getVAA() const { return mVAA; }
//获取mVAB
qreal& getVAB() { return mVAB; }
const qreal& getVAB() const { return mVAB; }
//获取mVAC
qreal& getVAC() { return mVAC; }
const qreal& getVAC() const { return mVAC; }
//获取mVPA
qreal& getVPA() { return mVPA; }
const qreal& getVPA() const { return mVPA; }
//获取mVPB
qreal& getVPB() { return mVPB; }
const qreal& getVPB() const { return mVPB; }
//获取mVPC
qreal& getVPC() { return mVPC; }
const qreal& getVPC() const { return mVPC; }
//获取mIAA
qreal& getIAA() { return mIAA; }
const qreal& getIAA() const { return mIAA; }
//获取mIAB
qreal& getIAB() { return mIAB; }
const qreal& getIAB() const { return mIAB; }
//获取mIAC
qreal& getIAC() { return mIAC; }
const qreal& getIAC() const { return mIAC; }
//获取mIPA
qreal& getIPA() { return mIPA; }
const qreal& getIPA() const { return mIPA; }
//获取mIPB
qreal& getIPB() { return mIPB; }
const qreal& getIPB() const { return mIPB; }
//获取mIPC
qreal& getIPC() { return mIPC; }
const qreal& getIPC() const { return mIPC; }
//获取mFA
qreal& getFA() { return mFA; }
const qreal& getFA() const { return mFA; }
//获取mFB
qreal& getFB() { return mFB; }
const qreal& getFB() const { return mFB; }
//获取mFC
qreal& getFC() { return mFC; }
const qreal& getFC() const { return mFC; }
//获取mDateTime
QString& getDateTime() { return mDateTime; }
const QString& getDateTime() const { return mDateTime; }
//获取mBuffer
quint8& getBuffer() { return mBuffer; }
const quint8& getBuffer() const { return mBuffer; }
QByteArray& getQbaVAA() { return mqbaVAA; }
const QByteArray& getQbaVAA() const { return mqbaVAA; }
QByteArray& getQbaVAB() { return mqbaVAB; }
const QByteArray& getQbaVAB() const { return mqbaVAB; }
QByteArray& getQbaVAC() { return mqbaVAC; }
const QByteArray& getQbaVAC() const { return mqbaVAC; }
QByteArray& getQbaVPA() { return mqbaVPA; }
const QByteArray& getQbaVPA() const { return mqbaVPA; }
QByteArray& getQbaVPB() { return mqbaVPB; }
const QByteArray& getQbaVPB() const { return mqbaVPB; }
QByteArray& getQbaVPC() { return mqbaVPC; }
const QByteArray& getQbaVPC() const { return mqbaVPC; }
QByteArray& getQbaIAA() { return mqbaIAA; }
const QByteArray& getQbaIAA() const { return mqbaIAA; }
QByteArray& getQbaIAB() { return mqbaIAB; }
const QByteArray& getQbaIAB() const { return mqbaIAB; }
QByteArray& getQbaIAC() { return mqbaIAC; }
const QByteArray& getQbaIAC() const { return mqbaIAC; }
QByteArray& getQbaIPA() { return mqbaIPA; }
const QByteArray& getQbaIPA() const { return mqbaIPA; }
QByteArray& getQbaIPB() { return mqbaIPB; }
const QByteArray& getQbaIPB() const { return mqbaIPB; }
QByteArray& getQbaIPC() { return mqbaIPC; }
const QByteArray& getQbaIPC() const { return mqbaIPC; }
QByteArray& getQbaFA() { return mqbaFA; }
const QByteArray& getQbaFA() const { return mqbaFA; }
QByteArray& getQbaFB() { return mqbaFB; }
const QByteArray& getQbaFB() const { return mqbaFB; }
QByteArray& getQbaFC() { return mqbaFC; }
const QByteArray& getQbaFC() const { return mqbaFC; }
QByteArray& getQbaDateTime() { return mqbaDateTime; }
const QByteArray& getQbaDateTime() const { return mqbaDateTime; }
QByteArray& getQbaBuffer() { return mqbaBuffer; }
const QByteArray& getQbaBuffer() const { return mqbaBuffer; }
signals:
public slots:
// QQtMessage interface
public:
virtual void parser(const QByteArray &) override;
virtual void packer(QByteArray &) const override;
private:
QByteArray mqbaVAA;
QByteArray mqbaVAB;
QByteArray mqbaVAC;
QByteArray mqbaVPA;
QByteArray mqbaVPB;
QByteArray mqbaVPC;
QByteArray mqbaIAA;
QByteArray mqbaIAB;
QByteArray mqbaIAC;
QByteArray mqbaIPA;
QByteArray mqbaIPB;
QByteArray mqbaIPC;
QByteArray mqbaFA;
QByteArray mqbaFB;
QByteArray mqbaFC;
QByteArray mqbaDateTime;
QByteArray mqbaBuffer;
qreal mVAA;
qreal mVAB;
qreal mVAC;
qreal mVPA;
qreal mVPB;
qreal mVPC;
qreal mIAA;
qreal mIAB;
qreal mIAC;
qreal mIPA;
qreal mIPB;
qreal mIPC;
qreal mFA;
qreal mFB;
qreal mFC;
QString mDateTime;
quint8 mBuffer;
};
QDebug operator<<(QDebug dbg, const CedianUdpMessage &c);
#endif // CEDIANUDPMESSAGE_H

View File

@ -0,0 +1,63 @@
#include "cedianudpprotocol.h"
CedianUdpProtocol::CedianUdpProtocol(QObject *parent) : QQtUdpProtocol(parent)
{
}
bool CedianUdpProtocol::dispatcher(const QNetworkDatagram & dg)
{
mDG = dg;
mAddress = dg.senderAddress();
mPort = dg.senderPort();
mLocalPort = dg.destinationPort();
QByteArray data = dg.data();
mMsg.parser(data);
emit msgIncoming();
}
/*依赖已经初始化好的端口*/
CedianUdpProtocol *cedianUdpServer(QObject *parent)
{
static CedianUdpServer* s0[9] = {NULL};
static CedianUdpProtocol* p0 = NULL;
if(!s0[0] && !p0)
{
p0 = new CedianUdpProtocol(parent);
for(int i =0; i < 9; i++)
{
int port = cedianUdpPort(i+1);
pline() << i+1 << port;
s0[i] = new CedianUdpServer(parent);
/*通讯端口:绑定本地端口*/
s0[i]->bind(port);
/*通讯端口:给测点协议*/
s0[i]->installProtocol(p0);
}
}
return p0;
}
/*
* Port列表设置函数mainwindow调用
* port列表传进去
*
* 9
* 1-9
*/
qint32 cedianUdpPort(int siteID, qint32* portList)
{
if(siteID < 1 || siteID > 9)
return 0;
static qint32 sPort[9] = {0};
if(portList)
{
for (int i =0; i < 9; i++)
{
sPort[i] = portList[i];
}
}
return sPort[siteID-1];
}

View File

@ -0,0 +1,44 @@
#ifndef CEDIANUDPPROTOCOL_H
#define CEDIANUDPPROTOCOL_H
#include <qqtudpprotocol.h>
#include <cedianudpmessage.h>
#include <qqtcore.h>
#include <cedianudpserver.h>
class CedianUdpProtocol : public QQtUdpProtocol
{
Q_OBJECT
public:
explicit CedianUdpProtocol(QObject *parent = nullptr);
virtual ~CedianUdpProtocol() {}
QNetworkDatagram& dataGram() { return mDG; }
QHostAddress& address() { return mAddress; }
qint32& port() { return mPort; }
qint32& localPort() { return mLocalPort; }
CedianUdpMessage& msg() { return mMsg; }
signals:
void msgIncoming();
public slots:
// QQtUdpProtocol interface
protected:
virtual bool dispatcher(const QNetworkDatagram &) override;
private:
/*发送者IP 端口 这个IP比较重要但是在程序中没有用*/
QHostAddress mAddress;
qint32 mPort;
/*这个端口是重点*/
qint32 mLocalPort;
CedianUdpMessage mMsg;
QNetworkDatagram mDG;
};
/*建议空调用一次赋值parent进行初始化*/
CedianUdpProtocol* cedianUdpServer(QObject* parent = 0);
qint32 cedianUdpPort(int siteID, qint32* portList = 0);
#endif // CEDIANUDPPROTOCOL_H

View File

@ -0,0 +1,6 @@
#include "cedianudpserver.h"
#include <QNetworkDatagram>
CedianUdpServer::CedianUdpServer ( QObject* parent ) : QQtSocketUdpClient ( parent )
{
}

View File

@ -0,0 +1,19 @@
#ifndef CEDIANUDPSERVER_H
#define CEDIANUDPSERVER_H
#include <qqtsocketudpclient.h>
#include <qqtcore.h>
class CedianUdpServer : public QQtSocketUdpClient
{
Q_OBJECT
public:
explicit CedianUdpServer ( QObject* parent = nullptr );
virtual ~CedianUdpServer() {}
signals:
public slots:
};
#endif // CEDIANUDPSERVER_H

View File

@ -0,0 +1,37 @@
#include "kongzhiqiudpmessage.h"
KongzhiqiUdpMessage::KongzhiqiUdpMessage(QObject *parent) : QQtMessage(parent)
{
quint8 mDesType = 1;
quint8 mCommand = 0;
}
//控制器数据没有数据接收只有控制命令发送所以不需要实现parser函数
void KongzhiqiUdpMessage::parser(const QByteArray &)
{
}
//控制命令组包packer函数
void KongzhiqiUdpMessage::packer(QByteArray & command) const
{
//写入包头 0-5
command << 0x31;
command << 0x20;
command << 0x30;
command << 0x30;
command << 0x33;
command << 0x30;
//写入空格 6
command << 0x20;
//写入目标控制器类型 7-8
command << 0x30;
command << (mDesType + 0x30);
//写入控制命令 9-10
command << 0x30;
command << (mCommand + 0x30);
//写入包尾 11-13
command << 0x31;
command << 0x31;
command << 0x31;
}

View File

@ -0,0 +1,33 @@
#ifndef KONGZHIQIUDPMESSAGE_H
#define KONGZHIQIUDPMESSAGE_H
#include <qqtmessage.h>
#include <qqtcore.h>
class KongzhiqiUdpMessage : public QQtMessage
{
Q_OBJECT
public:
explicit KongzhiqiUdpMessage(QObject *parent = nullptr);
virtual ~KongzhiqiUdpMessage() {}
/*比较简便的处理成员变量的方式。读写都用这个函数。*/
//获取mDesType的引用
quint8& getDesType() { return mDesType; }
const quint8& getDesType() const { return mDesType; }
//获取mCommand的引用
quint8& getCommand() { return mCommand; }
const quint8& getCommand() const { return mCommand; }
signals:
public slots:
// QQtMessage interface
public:
virtual void parser(const QByteArray &) override;
virtual void packer(QByteArray &command) const override;
private:
quint8 mDesType;
quint8 mCommand;
};
#endif // KONGZHIQIUDPMESSAGE_H

View File

@ -0,0 +1,140 @@
#include "kongzhiqiudpprotocol.h"
KongzhiqiUdpProtocol::KongzhiqiUdpProtocol(QObject *parent) : QQtUdpProtocol(parent)
{
}
//起动命令
void KongzhiqiUdpProtocol::sendStartMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 1;
st.packer(msg);
sendStartMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendStartMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendStartMessage(dg);
}
void KongzhiqiUdpProtocol::sendStartMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
//停机命令
void KongzhiqiUdpProtocol::sendStopMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 2;
st.packer(msg);
sendStopMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendStopMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendStopMessage(dg);
}
void KongzhiqiUdpProtocol::sendStopMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
//自动频率调节命令
void KongzhiqiUdpProtocol::sendFreMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 3;
st.packer(msg);
sendFreMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendFreMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendFreMessage(dg);
}
void KongzhiqiUdpProtocol::sendFreMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
//自动励磁调节命令
void KongzhiqiUdpProtocol::sendVolMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 4;
st.packer(msg);
sendVolMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendVolMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendVolMessage(dg);
}
void KongzhiqiUdpProtocol::sendVolMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
//并网命令
void KongzhiqiUdpProtocol::sendSynMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 5;
st.packer(msg);
sendSynMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendSynMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendSynMessage(dg);
}
void KongzhiqiUdpProtocol::sendSynMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
//解列命令
void KongzhiqiUdpProtocol::sendStepoutMessage(const QHostAddress &address, quint16 port, const KongzhiqiUdpMessage &st)
{
QByteArray msg;
st.getCommand() << 6;
st.packer(msg);
sendStepoutMessage(address, port, msg);
}
void KongzhiqiUdpProtocol::sendStepoutMessage(const QHostAddress &address, quint16 port, const QByteArray msg)
{
QNetworkDatagram dg;
dg.setDestination(address, port);
dg.setData(msg);
sendStepoutMessage(dg);
}
void KongzhiqiUdpProtocol::sendStepoutMessage(const QNetworkDatagram &dg)
{
writeDatagram(dg);
}
KongzhiqiUdpProtocol *kongzhiqiUdpServer(QObject *parent){
static CedianUdpServer* s0 = NULL;
static KongzhiqiUdpProtocol* p0 = NULL;
if(!s0 && !p0){
p0 = new KongzhiqiUdpProtocol(parent);
s0 = new CedianUdpServer(p0);
/*通讯端口:绑定本地端口*/
s0->bind(7200);
/*通讯端口:给控制器协议*/
s0->installProtocol(p0);
}
return p0;
}

View File

@ -0,0 +1,46 @@
#ifndef KONGZHIQIUDPPROTOCOL_H
#define KONGZHIQIUDPPROTOCOL_H
#include <qqtudpprotocol.h>
#include <qqtcore.h>
#include <kongzhiqiudpmessage.h>
#include <cedianudpserver.h>
class KongzhiqiUdpProtocol : public QQtUdpProtocol
{
Q_OBJECT
public:
explicit KongzhiqiUdpProtocol(QObject *parent = nullptr);
virtual ~KongzhiqiUdpProtocol() {}
//起动命令
void sendStartMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendStartMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendStartMessage(const QNetworkDatagram &dg);
//停机命令
void sendStopMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendStopMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendStopMessage(const QNetworkDatagram &dg);
//频率调节命令
void sendFreMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendFreMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendFreMessage(const QNetworkDatagram &dg);
//励磁调节命令
void sendVolMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendVolMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendVolMessage(const QNetworkDatagram &dg);
//并网命令
void sendSynMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendSynMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendSynMessage(const QNetworkDatagram &dg);
//解列命令
void sendStepoutMessage(const QHostAddress& address, quint16 port, const KongzhiqiUdpMessage &st);
void sendStepoutMessage(const QHostAddress& address, quint16 port, const QByteArray msg);
void sendStepoutMessage(const QNetworkDatagram &dg);
signals:
public slots:
};
KongzhiqiUdpProtocol* kongzhiqiUdpServer(QObject* parent = 0);
#endif // KONGZHIQIUDPPROTOCOL_H

View File

@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "cedianudpprotocol.h"
MainWindow::MainWindow ( QWidget* parent ) :
@ -7,6 +8,21 @@ MainWindow::MainWindow ( QWidget* parent ) :
ui ( new Ui::MainWindow )
{
ui->setupUi ( this );
/*初始化端口*/
qint32 nPort[9] = {0};
for ( int i = 0 ; i < 9; i++ )
{
//int port = ui->widget_12->getLocalPort ( i + 1 );
/*正式版*/
//nPort[i] = port;
/*有规律版*/
nPort[i] = 7000 + i * 10;
//pline() << nPort[i];
}
cedianUdpPort ( 5, nPort );
// serialport example
// tcpsocket example
// websocket?

View File

@ -29,7 +29,12 @@ SOURCES += \
qqtnetworkmessage.cpp \
qqtserialmessage.cpp \
qqtuserserialprotocol.cpp \
qqtsubprotocoltest.cpp
qqtsubprotocoltest.cpp \
cedianudpmessage.cpp \
cedianudpprotocol.cpp \
cedianudpserver.cpp \
kongzhiqiudpmessage.cpp \
kongzhiqiudpprotocol.cpp
HEADERS += \
mainwindow.h \
@ -38,7 +43,12 @@ HEADERS += \
qqtnetworkmessage.h \
qqtserialmessage.h \
qqtuserserialprotocol.h \
qqtsubprotocoltest.h
qqtsubprotocoltest.h \
cedianudpmessage.h \
cedianudpprotocol.h \
cedianudpserver.h \
kongzhiqiudpmessage.h \
kongzhiqiudpprotocol.h
FORMS += \
mainwindow.ui

View File

@ -17,6 +17,7 @@ APP_DEPLOY_ROOT = /Users/abel/Develop/d1-product
如果设置成功qmake应当显示如上例程的样子
#V2.1.6更新链接QQt的方法
![链接QQt](screenshot/7.png "这是链接QQt的方法pri都在LibQQt目录里")
![QQt内部pri的设置](screenshot/8.png "这是LibQQt需要设置的几个路径这是新的版本pri位置有改动")