提交 5910561c 作者: zhangyl

添加发送服务,目前版本1.0.0

上级 058a2825
......@@ -234,6 +234,7 @@ Makefile: XinHu_VehicleID.pro C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/win32-g++
sqliteassistant/sqliteassistant.pri \
readEPC/readEPC.pri \
comChange/comChange.pri \
TCPSocketHelper/TCPSocketHelper.pri \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/resolve_config.prf \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/exclusive_builds_post.prf \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/default_post.prf \
......@@ -257,6 +258,7 @@ Makefile: XinHu_VehicleID.pro C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/win32-g++
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Gui.prl \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Sql.prl \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5SerialPort.prl \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Network.prl \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Core.prl \
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/qtmain.prl
$(QMAKE) -o Makefile XinHu_VehicleID.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
......@@ -431,6 +433,7 @@ modeller_applog/applogmodel.pri:
sqliteassistant/sqliteassistant.pri:
readEPC/readEPC.pri:
comChange/comChange.pri:
TCPSocketHelper/TCPSocketHelper.pri:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/resolve_config.prf:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/exclusive_builds_post.prf:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/mkspecs/features/default_post.prf:
......@@ -454,6 +457,7 @@ C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Widgets.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Gui.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Sql.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5SerialPort.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Network.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/Qt5Core.prl:
C:/Qt/Qt5.13.2/5.13.2/mingw73_32/lib/qtmain.prl:
qmake: FORCE
......
/*******************************************************************************
* Project: neb
* @file CJsonObject.hpp
* @brief Json
* @author bwarliao
* @date: 2014-7-16
* @note
* Modify history:
******************************************************************************/
#ifndef CJSONOBJECT_H_
#define CJSONOBJECT_H_
#include <stdio.h>
#include <stddef.h>
#include <malloc.h>
#include <errno.h>
//#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <string>
#include <map>
#include <list>
#ifdef __cplusplus
extern "C" {
#endif
#include "cJSON.h"
#ifdef __cplusplus
}
#endif
namespace neb
{
class CJsonObject
{
public: // method of ordinary json object or json array
CJsonObject();
CJsonObject(const std::string& strJson);
CJsonObject(const CJsonObject* pJsonObject);
CJsonObject(const CJsonObject& oJsonObject);
virtual ~CJsonObject();
CJsonObject& operator=(const CJsonObject& oJsonObject);
bool operator==(const CJsonObject& oJsonObject) const;
bool Parse(const std::string& strJson);
void Clear();
bool IsEmpty() const;
bool IsArray() const;
std::string ToString() const;
std::string ToFormattedString() const;
const std::string& GetErrMsg() const
{
return(m_strErrMsg);
}
public: // method of ordinary json object
bool AddEmptySubObject(const std::string& strKey);
bool AddEmptySubArray(const std::string& strKey);
bool GetKey(std::string& strKey);
CJsonObject& operator[](const std::string& strKey);
std::string operator()(const std::string& strKey) const;
bool Get(const std::string& strKey, CJsonObject& oJsonObject) const;
bool Get(const std::string& strKey, std::string& strValue) const;
bool Get(const std::string& strKey, int32& iValue) const;
bool Get(const std::string& strKey, uint32& uiValue) const;
bool Get(const std::string& strKey, int64& llValue) const;
bool Get(const std::string& strKey, uint64& ullValue) const;
bool Get(const std::string& strKey, bool& bValue) const;
bool Get(const std::string& strKey, float& fValue) const;
bool Get(const std::string& strKey, double& dValue) const;
bool Add(const std::string& strKey, const CJsonObject& oJsonObject);
bool Add(const std::string& strKey, const std::string& strValue);
bool Add(const std::string& strKey, int32 iValue);
bool Add(const std::string& strKey, uint32 uiValue);
bool Add(const std::string& strKey, int64 llValue);
bool Add(const std::string& strKey, uint64 ullValue);
bool Add(const std::string& strKey, bool bValue, bool bValueAgain);
bool Add(const std::string& strKey, float fValue);
bool Add(const std::string& strKey, double dValue);
bool Delete(const std::string& strKey);
bool Replace(const std::string& strKey, const CJsonObject& oJsonObject);
bool Replace(const std::string& strKey, const std::string& strValue);
bool Replace(const std::string& strKey, int32 iValue);
bool Replace(const std::string& strKey, uint32 uiValue);
bool Replace(const std::string& strKey, int64 llValue);
bool Replace(const std::string& strKey, uint64 ullValue);
bool Replace(const std::string& strKey, bool bValue, bool bValueAgain);
bool Replace(const std::string& strKey, float fValue);
bool Replace(const std::string& strKey, double dValue);
public: // method of json array
int GetArraySize();
CJsonObject& operator[](unsigned int uiWhich);
std::string operator()(unsigned int uiWhich) const;
bool Get(int iWhich, CJsonObject& oJsonObject) const;
bool Get(int iWhich, std::string& strValue) const;
bool Get(int iWhich, int32& iValue) const;
bool Get(int iWhich, uint32& uiValue) const;
bool Get(int iWhich, int64& llValue) const;
bool Get(int iWhich, uint64& ullValue) const;
bool Get(int iWhich, bool& bValue) const;
bool Get(int iWhich, float& fValue) const;
bool Get(int iWhich, double& dValue) const;
bool Add(const CJsonObject& oJsonObject);
bool Add(const std::string& strValue);
bool Add(int32 iValue);
bool Add(uint32 uiValue);
bool Add(int64 llValue);
bool Add(uint64 ullValue);
bool Add(int iAnywhere, bool bValue);
bool Add(float fValue);
bool Add(double dValue);
bool AddAsFirst(const CJsonObject& oJsonObject);
bool AddAsFirst(const std::string& strValue);
bool AddAsFirst(int32 iValue);
bool AddAsFirst(uint32 uiValue);
bool AddAsFirst(int64 llValue);
bool AddAsFirst(uint64 ullValue);
bool AddAsFirst(int iAnywhere, bool bValue);
bool AddAsFirst(float fValue);
bool AddAsFirst(double dValue);
bool Delete(int iWhich);
bool Replace(int iWhich, const CJsonObject& oJsonObject);
bool Replace(int iWhich, const std::string& strValue);
bool Replace(int iWhich, int32 iValue);
bool Replace(int iWhich, uint32 uiValue);
bool Replace(int iWhich, int64 llValue);
bool Replace(int iWhich, uint64 ullValue);
bool Replace(int iWhich, bool bValue, bool bValueAgain);
bool Replace(int iWhich, float fValue);
bool Replace(int iWhich, double dValue);
private:
CJsonObject(cJSON* pJsonData);
private:
cJSON* m_pJsonData;
cJSON* m_pExternJsonDataRef;
std::string m_strErrMsg;
std::map<unsigned int, CJsonObject*> m_mapJsonArrayRef;
std::map<std::string, CJsonObject*> m_mapJsonObjectRef;
std::list<std::string> m_listKeys;
std::list<std::string>::const_iterator m_itKey;
};
}
#endif /* CJSONHELPER_HPP_ */
HEADERS += \
$$PWD/CJsonObject.h \
$$PWD/cJSON.h \
$$PWD/tcpsockethelper.h
SOURCES += \
$$PWD/CJsonObject.cpp \
$$PWD/cJSON.c \
$$PWD/tcpsockethelper.cpp
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Int 3
#define cJSON_Double 4
#define cJSON_String 5
#define cJSON_Array 6
#define cJSON_Object 7
#define cJSON_IsReference 256
/* The cJSON structure: */
typedef struct cJSON
{
struct cJSON *next, *prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
uint64 valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
int sign; /* sign of valueint, 1(unsigned), -1(signed) */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks
{
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array, int item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern const char *cJSON_GetErrorPtr();
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull();
extern cJSON *cJSON_CreateTrue();
extern cJSON *cJSON_CreateFalse();
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateDouble(double num, int sign);
extern cJSON *cJSON_CreateInt(uint64 num, int sign);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray();
extern cJSON *cJSON_CreateObject();
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(int *numbers, int sign, int count);
extern cJSON *cJSON_CreateFloatArray(float *numbers, int count);
extern cJSON *cJSON_CreateDoubleArray(double *numbers, int count);
extern cJSON *cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToArrayHead(cJSON *array, cJSON *item); /* add by Bwar on 2015-01-28 */
extern void cJSON_AddItemToObject(cJSON *object, const char *string,
cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object, const char *string,
cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array, int which);
extern void cJSON_DeleteItemFromArray(cJSON *array, int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object, const char *string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object, const char *string,
cJSON *newitem);
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
#ifdef __cplusplus
}
#endif
#endif
#ifndef TCPSOCKETHELPER_H
#define TCPSOCKETHELPER_H
#include <QObject>
#include <QTcpSocket>
#include <QTimer>
#include <windows.h>
#include "TCPSocketHelper/CJsonObject.h"
#include "TCPSocketHelper/cJSON.h"
#include "vehinfo.h"
using namespace std;
using namespace neb;
class TCPSocketHelper : public QObject
{
Q_OBJECT
public:
explicit TCPSocketHelper(QObject *parent = nullptr);
~TCPSocketHelper();
using SocketState = QAbstractSocket::SocketState;
enum MessageTypes {
LatencyTest, //服务器测速
};
Q_ENUM(MessageTypes)
void setHostAndePort(const QString &m_ServerHost,const int &m_ServerPort);
void closeTCPSocker();//TCPSocket 默认启动,用此函数可以停止 TCP 连接,它会直接关掉 Socket ,并置 isClose 为真,以关闭心跳检查,防止自动重连机制恢复连接.
void openTCPSocket(QString Host,long Port);
SocketState getSocketStatus(){
return m_TCPSocket->state();
}
signals:
void ResponseData(MessageTypes,short,QByteArray);
void ResponseInfoData(MessageTypes,short,QByteArray);
void TCPSocketIsConnected();
void TCPSocketIsDisconnected();
void TCPSocketUnstable();
///返回发送状态
void ReturnBindingStatus(bool status);
public slots:
///站点注册
void Register();
///绑定
void Binding(PacketBinding from);
private slots:
void onConnected();
void onReadyRead(); //负责接收数据,并缓存以及验证这些数据.
void onDisconnected();
void checkHeartBeat(); //心跳检查
private:
///获取 opcode ,(有待优化) <--- opcode
char getOpCode(const QByteArray& Arr);
bool writeData(const QByteArray& payloadData);
///设置套接字关闭标志
void setCloseFlag(bool _isClose){
m_CloseFlag = _isClose;
}
///判断返回状态
bool JudgmentState(QByteArray returnData); //returnData服务器返回数据
///获取套接字关闭标志
bool getCloseFlag(){
return m_CloseFlag;
}
///心跳标记
void setHeartBeatFlag(bool _Flag){m_heartbeatFlag = _Flag;}
///获取心跳标记
bool getHeartBeatFlag(){return m_heartbeatFlag;}
///发送一个ping
void sendPing();
///按照 OPCode 分类
void classifyByOPCode(const QByteArray& Arrtmp);
//心跳测试
QByteArray Send_HeartBeat_rv(PacketHeartBeat &heartBeat);
//注册
QByteArray Send_Register(PacketRegister &m_register);
QByteArray Send_Binding(PacketBinding &form);
string MD5(CJsonObject cj,string key);
private:
QTcpSocket *m_TCPSocket = nullptr;
bool m_tcpServerStatus = true;
QTimer *m_tcpServerTimer; //定时重连服务器
QTimer *m_HeartBeatTimer; //心跳定时
QString m_ServerHost;
quint16 m_ServerPort;
int m_LossCount = 0;
bool m_heartbeatFlag = true;
bool m_CloseFlag = false;
QByteArray m_ArrBuff;
};
#endif // TCPSOCKETHELPER_H
QT += core gui sql serialport
QT += core gui sql serialport network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
......@@ -38,7 +38,8 @@ HEADERS += \
iconhelper.h \
logindlg.h \
mainwindow.h \
myhelper.h
myhelper.h \
vehinfo.h
FORMS += \
frmmessagebox.ui \
......@@ -52,6 +53,8 @@ include(sqliteassistant/sqliteassistant.pri)
include(readEPC/readEPC.pri)
#添加串口热插拔检测
include(comChange/comChange.pri)
#添加网络助手
include(TCPSocketHelper/TCPSocketHelper.pri)
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.1, 2022-02-11T13:59:50. -->
<!-- Written by QtCreator 4.10.1, 2022-02-14T11:24:39. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
File:(sqliteassistant\sqliteassistant.cpp) Line:(30) Function:long int SqliteAssistant::connectSql() Succeed to connect database. (2022-02-11 08:55:13 周五)
File:(main.cpp) Line:(22) Function:int qMain(int, char**) connectSql ok (2022-02-11 08:55:13 周五)
File:(mainwindow.cpp) Line:(51) Function:void MainWindow::SoftStart() 软件启动时间: "2022-02-11 08:55:13" (2022-02-11 08:55:13 周五)
File:(sqliteassistant\sqliteassistant.cpp) Line:(30) Function:long int SqliteAssistant::connectSql() Succeed to connect database. (2022-02-11 08:59:37 周五)
File:(main.cpp) Line:(22) Function:int qMain(int, char**) connectSql ok (2022-02-11 08:59:37 周五)
File:(mainwindow.cpp) Line:(51) Function:void MainWindow::SoftStart() 软件启动时间: "2022-02-11 08:59:37" (2022-02-11 08:59:37 周五)
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,6 +7,7 @@ extern QString DataBase_ComBund;
Bridge::Bridge(QObject *parent) : QObject(parent)
{
m_ReadEPCControl = new ReadEPCControl();
m_TCPSocketHelper = new TCPSocketHelper();
m_ReadEPCControl_thread = new QThread;
m_ReadEPCControl->moveToThread(m_ReadEPCControl_thread);
m_ReadEPCControl_thread->start();
......@@ -14,6 +15,10 @@ Bridge::Bridge(QObject *parent) : QObject(parent)
qDebug()<<"串口启动";
m_ReadEPCControl->setComm(DataBase_ComName,DataBase_ComBund.toLong());
});
connect(m_ReadEPCControl,&ReadEPCControl::SendRFIDStatus,this,[=](bool sta){
//qDebug()<<"bridge"<<sta;
emit SendReadEPCControlStyatusToWindow(sta);
});
connect(m_ReadEPCControl,&ReadEPCControl::SendToBridge,this,[=](QByteArray data){
QString str;
str = data.toHex();
......@@ -26,4 +31,13 @@ Bridge::Bridge(QObject *parent) : QObject(parent)
emit SendToWindow(QString::number(hexnum));
}
});
connect(this,&Bridge::SendToTCPSocketHelper_Connect,m_TCPSocketHelper,&TCPSocketHelper::openTCPSocket);
connect(m_TCPSocketHelper,&TCPSocketHelper::ReturnBindingStatus,this,[=](bool sta){
emit SendBindingStatusToWindow(sta);
});
}
void Bridge::SendToTCPSocketHelper(PacketBinding form)
{
m_TCPSocketHelper->Binding(form);
}
......@@ -10,21 +10,28 @@
#include <QObject>
#include <QThread>
#include "vehinfo.h"
#include "readEPC/readepccontrol.h"
#include "TCPSocketHelper/tcpsockethelper.h"
class Bridge : public QObject
{
Q_OBJECT
public:
explicit Bridge(QObject *parent = nullptr);
ReadEPCControl *m_ReadEPCControl; //定义EPC对象
TCPSocketHelper *m_TCPSocketHelper; //定义网络助手对象
signals:
void SendToReadEPCControl_Connect();
void SendToWindow(QString data);
void SendReadEPCControlStyatusToWindow(bool sattus);
void SendBindingStatusToWindow(bool sattus); //发送绑定结果
void SendToTCPSocketHelper_Connect(QString Host,long Prot);
public slots:
void SendToTCPSocketHelper(PacketBinding form); //发送绑定信息
private:
QThread *m_ReadEPCControl_thread; //定义子线程
//QThread *m_TCPSocketHelper_thread; //定义网络子线程
};
#endif // BRIDGE_H
......@@ -92,7 +92,8 @@ LoginDlg::~LoginDlg()
void LoginDlg::InitGui()
{
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
//setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
ui->lab_title->setText("用户登陆");
ui->lab_name->setText("车辆ID管理系统");
......
......@@ -2,12 +2,13 @@
#include "ui_mainwindow.h"
#include <QDateTime>
#include <QDebug>
#include <QProcess>
#include <QSerialPort>
#include <QSerialPortInfo>
#include "sqliteassistant/sqliteassistant.h"
#include "myhelper.h"
#include <QRegExp>
#include "vehinfo.h"
extern QString DataBase_ServerIP;
extern QString DataBase_ServerProt;
extern QString DataBase_ComName;
......@@ -26,7 +27,8 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
m_Bridge = new Bridge();
SoftStart();
EPCUpDate();
//dataUpDate();
m_SoftBreath = new QTimer(this);
m_systemTime = new QLabel();
......@@ -58,8 +60,9 @@ MainWindow::MainWindow(QWidget *parent)
QString::number(m_SoftBreath_s)+"秒"+"--");
});
PubClicked();
SoftStart();
Windowsinit();
EPCUpDate();
}
MainWindow::~MainWindow()
......@@ -126,19 +129,26 @@ void MainWindow::Windowsinit()
ui->lineEdit_CarPlnum->setValidator(new QRegExpValidator(iptext));
ui->lineEdit_serverIP->setValidator(new QRegExpValidator(iptext2));
ui->lineEdit_serverPort->setValidator(new QRegExpValidator(iptext3));
ui->comboBox_comName->addItems(getAvailablePort());
//ui->comboBox_comName->addItems(getAvailablePort());
///显示首页
ui->stackedWidget->setCurrentWidget(ui->page);
QStringList baudList;
QStringList baudList; //波特率
QStringList nameList; //串口名
// 波特率 //波特率默认选择下拉第三项:9600
baudList<<"1200"<<"2400"<<"4800"<<"9600"
<<"14400"<<"19200"<<"38400"<<"56000"
<<"57600"<<"115200";
nameList<<"COM1"<<"COM2"<<"COM3"<<"COM4"<<"COM5"<<"COM6"
<<"COM7"<<"COM8"<<"COM9"<<"COM10"<<"COM11"<<"COM12"
<<"COM13"<<"COM14"<<"COM15"<<"COM16"<<"COM17"<<"COM18";
ui->comboBox_baudRate->addItems(baudList);
ui->comboBox_comName->addItems(nameList);
ui->lineEdit_serverIP->setText(DataBase_ServerIP);
ui->lineEdit_serverPort->setText(DataBase_ServerProt);
ui->lineEdit_serverPort->setText(DataBase_ComName);
ui->lineEdit_serverPort->setText(DataBase_ComBund);
ui->comboBox_comName->setCurrentIndex(m_SqliteAssistant->Select_SystemConfigInfo(DataBase_ComName).toInt());
ui->comboBox_baudRate->setCurrentIndex(m_SqliteAssistant->Select_SystemConfigInfo(DataBase_ComBund).toInt());
///快捷输入
//1-10京津沪渝,桂蒙宁新藏,港澳,粤湘鄂冀豫,黑吉辽晋陕,青鲁苏皖浙,闽赣琼甘贵川,
//ABCDEFGHJKLMNPQRSTUVWXYZ
......@@ -230,6 +240,14 @@ void MainWindow::SoftStart()
QString str=time.toString("yyyy-MM-dd hh:mm:ss");
qDebug()<<"软件启动时间:"<<str;
emit m_Bridge->SendToReadEPCControl_Connect();
QString serIp = m_SqliteAssistant->Select_SystemConfigInfo(ServerIP);
QString serprot = m_SqliteAssistant->Select_SystemConfigInfo(ServerProt);
qDebug()<<"QtPing(serIp):"<<QtPing(serIp);
if(!QtPing(serIp)){
myHelper::ShowMessageBoxError(QString("服务器IP:%1异常,请检查服务器连接").arg(serIp));
return;
}
emit m_Bridge->SendToTCPSocketHelper_Connect(serIp,serprot.toLong());
}
void MainWindow::SoftClose()
......@@ -248,9 +266,22 @@ void MainWindow::EPCUpDate()
}
ui->lineEdit_EPC->setText(data);
});
connect(m_Bridge->m_ReadEPCControl,&ReadEPCControl::SendRFIDStatus,this,[=](bool sta){
connect(m_Bridge,&Bridge::SendReadEPCControlStyatusToWindow,this,[=](bool sta){
qDebug()<<"win"<<sta;
if(sta){
m_EPCstatus->setStyleSheet("background-color: rgb(0, 255, 0);");
return;
}
if(!sta){
m_EPCstatus->setStyleSheet("background-color: rgb(255, 0, 0);");
myHelper::ShowMessageBoxError("射频读卡器异常,请检查读卡器连接后重启软件");
return;
}
});
connect(this,&MainWindow::SendToBridge,m_Bridge,&Bridge::SendToTCPSocketHelper);
connect(m_Bridge,&Bridge::SendBindingStatusToWindow,this,[=](bool status){
if(!status){
myHelper::ShowMessageBoxInfo("数据发送失败,请重新发送");
}
});
}
......@@ -269,9 +300,13 @@ void MainWindow::PubClicked()
}
//发送数据
QString str_EPC = ui->lineEdit_EPC->text();
QString str_CarPlnum= ui->lineEdit_CarPlnum->text();
QString str_CarPlnum = ui->lineEdit_CarPlnum->text();
if(!m_SqliteAssistant->Insert_CarIDConfigInfo(str_CarPlnum,str_EPC)){
myHelper::ShowMessageBoxInfo(QString("绑定成功车牌号为:%1").arg(str_CarPlnum));
PacketBinding from;
from.plateNum = str_CarPlnum.toStdString();
from.vehicleId = str_EPC.toStdString();
emit SendToBridge(from);
//myHelper::ShowMessageBoxInfo(QString("绑定成功车牌号为:%1").arg(str_CarPlnum));
ui->lineEdit_EPC->clear();
ui->lineEdit_CarPlnum->clear();
ui->lineEdit_CarPlnum->setFocus();
......@@ -312,6 +347,32 @@ void MainWindow::PubClicked()
});
}
bool MainWindow::QtPing(const QString ip)
{
// #Linux指令 "ping -s 1 -c 1 IP"
//QString cmdstr = QString("ping -s 1 -c 1 %1")
// .arg(ip);
// #Windows指令 "ping IP -n 1 -w 超时(ms)"
QString cmdstr = QString("ping %1 -n 1 -w %2")
.arg(ip).arg(1000);
QProcess cmd;
cmd.start(cmdstr);
cmd.waitForReadyRead(1000);
cmd.waitForFinished(1000);
QString response = cmd.readAll();
if (response.indexOf("TTL") == -1)
{
return false;
}
else
{
return true;
}
}
QStringList MainWindow::getAvailablePort()
{
QStringList strName;
......
......@@ -16,13 +16,15 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
signals:
void SendToBridge(PacketBinding from); //发送绑定信息
private:
void Windowsinit(); //界面设置
void SoftStart();
void SoftClose();
void EPCUpDate();
void PubClicked(); //快捷按键
bool QtPing(const QString ip); //网络检查
QStringList getAvailablePort();
protected:
bool eventFilter(QObject *watched, QEvent *event);
......
......@@ -9,6 +9,9 @@ temp/obj/sqliteassistant.o
temp/obj/readepccontrol.o
temp/obj/comchange.o
temp/obj/porttest.o
temp/obj/CJsonObject.o
temp/obj/cJSON.o
temp/obj/tcpsockethelper.o
temp/obj/qrc_image.o
temp/obj/moc_bridge.o
temp/obj/moc_frmmessagebox.o
......@@ -18,3 +21,4 @@ temp/obj/moc_sqliteassistant.o
temp/obj/moc_readepccontrol.o
temp/obj/moc_comchange.o
temp/obj/moc_porttest.o
temp/obj/moc_tcpsockethelper.o
......@@ -9,6 +9,9 @@ temp/obj/sqliteassistant.o
temp/obj/readepccontrol.o
temp/obj/comchange.o
temp/obj/porttest.o
temp/obj/CJsonObject.o
temp/obj/cJSON.o
temp/obj/tcpsockethelper.o
temp/obj/qrc_image.o
temp/obj/moc_bridge.o
temp/obj/moc_frmmessagebox.o
......@@ -18,3 +21,4 @@ temp/obj/moc_sqliteassistant.o
temp/obj/moc_readepccontrol.o
temp/obj/moc_comchange.o
temp/obj/moc_porttest.o
temp/obj/moc_tcpsockethelper.o
......@@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_Bridge_t {
QByteArrayData data[5];
char stringdata0[55];
QByteArrayData data[14];
char stringdata0[203];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -36,11 +36,24 @@ QT_MOC_LITERAL(0, 0, 6), // "Bridge"
QT_MOC_LITERAL(1, 7, 28), // "SendToReadEPCControl_Connect"
QT_MOC_LITERAL(2, 36, 0), // ""
QT_MOC_LITERAL(3, 37, 12), // "SendToWindow"
QT_MOC_LITERAL(4, 50, 4) // "data"
QT_MOC_LITERAL(4, 50, 4), // "data"
QT_MOC_LITERAL(5, 55, 33), // "SendReadEPCControlStyatusToWi..."
QT_MOC_LITERAL(6, 89, 6), // "sattus"
QT_MOC_LITERAL(7, 96, 25), // "SendBindingStatusToWindow"
QT_MOC_LITERAL(8, 122, 29), // "SendToTCPSocketHelper_Connect"
QT_MOC_LITERAL(9, 152, 4), // "Host"
QT_MOC_LITERAL(10, 157, 4), // "Prot"
QT_MOC_LITERAL(11, 162, 21), // "SendToTCPSocketHelper"
QT_MOC_LITERAL(12, 184, 13), // "PacketBinding"
QT_MOC_LITERAL(13, 198, 4) // "form"
},
"Bridge\0SendToReadEPCControl_Connect\0"
"\0SendToWindow\0data"
"\0SendToWindow\0data\0SendReadEPCControlStyatusToWindow\0"
"sattus\0SendBindingStatusToWindow\0"
"SendToTCPSocketHelper_Connect\0Host\0"
"Prot\0SendToTCPSocketHelper\0PacketBinding\0"
"form"
};
#undef QT_MOC_LITERAL
......@@ -50,20 +63,32 @@ static const uint qt_meta_data_Bridge[] = {
8, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
6, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
5, // signalCount
// signals: name, argc, parameters, tag, flags
1, 0, 24, 2, 0x06 /* Public */,
3, 1, 25, 2, 0x06 /* Public */,
1, 0, 44, 2, 0x06 /* Public */,
3, 1, 45, 2, 0x06 /* Public */,
5, 1, 48, 2, 0x06 /* Public */,
7, 1, 51, 2, 0x06 /* Public */,
8, 2, 54, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
11, 1, 59, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 4,
QMetaType::Void, QMetaType::Bool, 6,
QMetaType::Void, QMetaType::Bool, 6,
QMetaType::Void, QMetaType::QString, QMetaType::Long, 9, 10,
// slots: parameters
QMetaType::Void, 0x80000000 | 12, 13,
0 // eod
};
......@@ -76,6 +101,10 @@ void Bridge::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void
switch (_id) {
case 0: _t->SendToReadEPCControl_Connect(); break;
case 1: _t->SendToWindow((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 2: _t->SendReadEPCControlStyatusToWindow((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 3: _t->SendBindingStatusToWindow((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 4: _t->SendToTCPSocketHelper_Connect((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< long(*)>(_a[2]))); break;
case 5: _t->SendToTCPSocketHelper((*reinterpret_cast< PacketBinding(*)>(_a[1]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
......@@ -94,6 +123,27 @@ void Bridge::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void
return;
}
}
{
using _t = void (Bridge::*)(bool );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendReadEPCControlStyatusToWindow)) {
*result = 2;
return;
}
}
{
using _t = void (Bridge::*)(bool );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendBindingStatusToWindow)) {
*result = 3;
return;
}
}
{
using _t = void (Bridge::*)(QString , long );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToTCPSocketHelper_Connect)) {
*result = 4;
return;
}
}
}
}
......@@ -126,13 +176,13 @@ int Bridge::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
if (_id < 6)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
_id -= 6;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
if (_id < 6)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
_id -= 6;
}
return _id;
}
......@@ -149,5 +199,26 @@ void Bridge::SendToWindow(QString _t1)
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
// SIGNAL 2
void Bridge::SendReadEPCControlStyatusToWindow(bool _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 2, _a);
}
// SIGNAL 3
void Bridge::SendBindingStatusToWindow(bool _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 3, _a);
}
// SIGNAL 4
void Bridge::SendToTCPSocketHelper_Connect(QString _t1, long _t2)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))) };
QMetaObject::activate(this, &staticMetaObject, 4, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
......@@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_MainWindow_t {
QByteArrayData data[1];
char stringdata0[11];
QByteArrayData data[5];
char stringdata0[44];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -32,10 +32,15 @@ struct qt_meta_stringdata_MainWindow_t {
)
static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
{
QT_MOC_LITERAL(0, 0, 10) // "MainWindow"
QT_MOC_LITERAL(0, 0, 10), // "MainWindow"
QT_MOC_LITERAL(1, 11, 12), // "SendToBridge"
QT_MOC_LITERAL(2, 24, 0), // ""
QT_MOC_LITERAL(3, 25, 13), // "PacketBinding"
QT_MOC_LITERAL(4, 39, 4) // "from"
},
"MainWindow"
"MainWindow\0SendToBridge\0\0PacketBinding\0"
"from"
};
#undef QT_MOC_LITERAL
......@@ -45,22 +50,41 @@ static const uint qt_meta_data_MainWindow[] = {
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
1, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 19, 2, 0x06 /* Public */,
// signals: parameters
QMetaType::Void, 0x80000000 | 3, 4,
0 // eod
};
void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<MainWindow *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SendToBridge((*reinterpret_cast< PacketBinding(*)>(_a[1]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (MainWindow::*)(PacketBinding );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MainWindow::SendToBridge)) {
*result = 0;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject MainWindow::staticMetaObject = { {
......@@ -89,7 +113,25 @@ void *MainWindow::qt_metacast(const char *_clname)
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 1)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 1;
}
return _id;
}
// SIGNAL 0
void MainWindow::SendToBridge(PacketBinding _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
/****************************************************************************
** Meta object code from reading C++ file 'tcpsockethelper.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.13.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include <memory>
#include "../../TCPSocketHelper/tcpsockethelper.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'tcpsockethelper.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.13.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_TCPSocketHelper_t {
QByteArrayData data[19];
char stringdata0[252];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_TCPSocketHelper_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_TCPSocketHelper_t qt_meta_stringdata_TCPSocketHelper = {
{
QT_MOC_LITERAL(0, 0, 15), // "TCPSocketHelper"
QT_MOC_LITERAL(1, 16, 12), // "ResponseData"
QT_MOC_LITERAL(2, 29, 0), // ""
QT_MOC_LITERAL(3, 30, 12), // "MessageTypes"
QT_MOC_LITERAL(4, 43, 16), // "ResponseInfoData"
QT_MOC_LITERAL(5, 60, 20), // "TCPSocketIsConnected"
QT_MOC_LITERAL(6, 81, 23), // "TCPSocketIsDisconnected"
QT_MOC_LITERAL(7, 105, 17), // "TCPSocketUnstable"
QT_MOC_LITERAL(8, 123, 19), // "ReturnBindingStatus"
QT_MOC_LITERAL(9, 143, 6), // "status"
QT_MOC_LITERAL(10, 150, 8), // "Register"
QT_MOC_LITERAL(11, 159, 7), // "Binding"
QT_MOC_LITERAL(12, 167, 13), // "PacketBinding"
QT_MOC_LITERAL(13, 181, 4), // "from"
QT_MOC_LITERAL(14, 186, 11), // "onConnected"
QT_MOC_LITERAL(15, 198, 11), // "onReadyRead"
QT_MOC_LITERAL(16, 210, 14), // "onDisconnected"
QT_MOC_LITERAL(17, 225, 14), // "checkHeartBeat"
QT_MOC_LITERAL(18, 240, 11) // "LatencyTest"
},
"TCPSocketHelper\0ResponseData\0\0"
"MessageTypes\0ResponseInfoData\0"
"TCPSocketIsConnected\0TCPSocketIsDisconnected\0"
"TCPSocketUnstable\0ReturnBindingStatus\0"
"status\0Register\0Binding\0PacketBinding\0"
"from\0onConnected\0onReadyRead\0"
"onDisconnected\0checkHeartBeat\0LatencyTest"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_TCPSocketHelper[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
12, 14, // methods
0, 0, // properties
1, 102, // enums/sets
0, 0, // constructors
0, // flags
6, // signalCount
// signals: name, argc, parameters, tag, flags
1, 3, 74, 2, 0x06 /* Public */,
4, 3, 81, 2, 0x06 /* Public */,
5, 0, 88, 2, 0x06 /* Public */,
6, 0, 89, 2, 0x06 /* Public */,
7, 0, 90, 2, 0x06 /* Public */,
8, 1, 91, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
10, 0, 94, 2, 0x0a /* Public */,
11, 1, 95, 2, 0x0a /* Public */,
14, 0, 98, 2, 0x08 /* Private */,
15, 0, 99, 2, 0x08 /* Private */,
16, 0, 100, 2, 0x08 /* Private */,
17, 0, 101, 2, 0x08 /* Private */,
// signals: parameters
QMetaType::Void, 0x80000000 | 3, QMetaType::Short, QMetaType::QByteArray, 2, 2, 2,
QMetaType::Void, 0x80000000 | 3, QMetaType::Short, QMetaType::QByteArray, 2, 2, 2,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::Bool, 9,
// slots: parameters
QMetaType::Void,
QMetaType::Void, 0x80000000 | 12, 13,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
// enums: name, alias, flags, count, data
3, 3, 0x0, 1, 107,
// enum data: key, value
18, uint(TCPSocketHelper::LatencyTest),
0 // eod
};
void TCPSocketHelper::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<TCPSocketHelper *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->ResponseData((*reinterpret_cast< MessageTypes(*)>(_a[1])),(*reinterpret_cast< short(*)>(_a[2])),(*reinterpret_cast< QByteArray(*)>(_a[3]))); break;
case 1: _t->ResponseInfoData((*reinterpret_cast< MessageTypes(*)>(_a[1])),(*reinterpret_cast< short(*)>(_a[2])),(*reinterpret_cast< QByteArray(*)>(_a[3]))); break;
case 2: _t->TCPSocketIsConnected(); break;
case 3: _t->TCPSocketIsDisconnected(); break;
case 4: _t->TCPSocketUnstable(); break;
case 5: _t->ReturnBindingStatus((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 6: _t->Register(); break;
case 7: _t->Binding((*reinterpret_cast< PacketBinding(*)>(_a[1]))); break;
case 8: _t->onConnected(); break;
case 9: _t->onReadyRead(); break;
case 10: _t->onDisconnected(); break;
case 11: _t->checkHeartBeat(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (TCPSocketHelper::*)(MessageTypes , short , QByteArray );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::ResponseData)) {
*result = 0;
return;
}
}
{
using _t = void (TCPSocketHelper::*)(MessageTypes , short , QByteArray );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::ResponseInfoData)) {
*result = 1;
return;
}
}
{
using _t = void (TCPSocketHelper::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::TCPSocketIsConnected)) {
*result = 2;
return;
}
}
{
using _t = void (TCPSocketHelper::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::TCPSocketIsDisconnected)) {
*result = 3;
return;
}
}
{
using _t = void (TCPSocketHelper::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::TCPSocketUnstable)) {
*result = 4;
return;
}
}
{
using _t = void (TCPSocketHelper::*)(bool );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPSocketHelper::ReturnBindingStatus)) {
*result = 5;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject TCPSocketHelper::staticMetaObject = { {
&QObject::staticMetaObject,
qt_meta_stringdata_TCPSocketHelper.data,
qt_meta_data_TCPSocketHelper,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *TCPSocketHelper::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *TCPSocketHelper::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_TCPSocketHelper.stringdata0))
return static_cast<void*>(this);
return QObject::qt_metacast(_clname);
}
int TCPSocketHelper::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 12)
qt_static_metacall(this, _c, _id, _a);
_id -= 12;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 12)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 12;
}
return _id;
}
// SIGNAL 0
void TCPSocketHelper::ResponseData(MessageTypes _t1, short _t2, QByteArray _t3)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t3))) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void TCPSocketHelper::ResponseInfoData(MessageTypes _t1, short _t2, QByteArray _t3)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t3))) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
// SIGNAL 2
void TCPSocketHelper::TCPSocketIsConnected()
{
QMetaObject::activate(this, &staticMetaObject, 2, nullptr);
}
// SIGNAL 3
void TCPSocketHelper::TCPSocketIsDisconnected()
{
QMetaObject::activate(this, &staticMetaObject, 3, nullptr);
}
// SIGNAL 4
void TCPSocketHelper::TCPSocketUnstable()
{
QMetaObject::activate(this, &staticMetaObject, 4, nullptr);
}
// SIGNAL 5
void TCPSocketHelper::ReturnBindingStatus(bool _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 5, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
/*
* 封装发送类
*/
#ifndef VEHINFO_H
#ifndef VEHINFO_H
#define VEHINFO_H
#include <iostream>
#include <vector>
#include <QQueue>
using namespace std;
#pragma pack(1)
//
struct VehInfor
{
string weightNum;
string plateNum;
int axleCnt;
float sumWeight;
float tareWeight;
string stationCode; //站点编号
string weightNum; //磅号
string plateNum; //车牌号
int axleCnt; //轴数
float sumWeight; //车货总重,放大一百倍
float tareWeight; //轴数
float grossWeight;
float suttleWeight;
int reduceWeightPer;
float realWeight;
float limitWeight;
float overWeight;
float limitWeight; //限重,放大一百倍
float overWeight; //超重,放大一百倍
float overPer;
string goodsName;
string goodsType;
......@@ -29,6 +28,7 @@ struct VehInfor
string recvCompany;
string trafficCompany;
string remark;
int go;
int lane;
int speed;
int length;
......@@ -37,31 +37,23 @@ struct VehInfor
string picPath;
string dateTime;
string createTime;
string weightTime;
string printerTime;
string interTime;//入口时间,格式yyyy-MM-dd HH:mm:ss
string outTime;//入口时间,格式yyyy-MM-dd HH:mm:ss
string platePic; //车牌特写图,base64编码
string platePicPostfix = "jpg";//图片后缀,默认jpg
string platePicPostfix;//图片后缀,默认jpg
string frontPic;//前抓拍,base64编码
string frontPicPostfix = "jpg";//图片后缀,默认jpg
string frontPicPostfix;//图片后缀,默认jpg
string key = "123456";
};
struct SelectInfor
{
int ECode;
string Operator;
string startTime;
string Pound;
string stopTime;
string Weight;
string Type;
string Time;
string RealCache;
string GoodsType;
string Customer;
string Notes;
string plateNum;
int overPer;
float startWeight;
float stopWeight;
string remark;
string Operator;
};
struct SelectInfor1
{
......@@ -135,27 +127,25 @@ struct User
};
struct SendWeightForm
{
string userName = "admin"; //过磅员
string poundNo = "001"; //磅号
string key = "123456";
string poundNo; //磅号
string checkNo;
string stationCode; //站点编号
string plateNum; //车牌号
string checkNo;
string stationId;
int patternType = 2; //业务模式: 1-标准流程一 2-标准流程二
int modeDisplayType = 2; //业务详情显示: 1-标准流程一显示出入口信息 2-标准流程二不显示出入口信息
int tareWeight;
int grossWeight;
int suttleWeight;
string dateTime;
//新增字段
int weighterNum;
int success; //注册成功
int exceptionCode; //异常代码
int vehicleType; //车型
int axleCnt; //轴数
int axleType; //轴型
float sumWeight; //车货总重,放大一百倍
int go;
int result; //上传称重回复
int success; //注册成功
int exceptionCode; //异常代码
int vehicleType; //车型
int axleCnt; //轴数
int axleType; //轴型
int sumWeight; //车货总重,放大一百倍
int axleWeight1; //1轴重,放大一百倍
int axleWeight2; //2轴重,放大一百倍
int axleWeight3; //3轴重,放大一百倍
......@@ -165,27 +155,40 @@ struct SendWeightForm
int axleWeight7; //7轴重,放大一百倍
int axleWeight8; //8轴重,放大一百倍
int limitWeight; //限重,放大一百倍
int overWeight; //超重,放大一百倍
string weightTime; //称重时间,格式yyyy-MM-dd HH:mm:ss
string interTime; //入口时间,格式yyyy-MM-dd HH:mm:ss
string outTime; //入口时间,格式yyyy-MM-dd HH:mm:ss
string platePic; //车牌特写图,base64编码
string platePicPostfix = "jpg"; //图片后缀,默认jpg
string frontPic; //前抓拍,base64编码
string frontPicPostfix = "jpg"; //图片后缀,默认jpg
string backPic; //后抓拍,base64编码
string backPicPostfix = "jpg"; //图片后缀,默认jpg
string lSidePic; //左侧侧抓拍,base64编码
string lsidePicPostfix = "jpg"; //图片后缀,默认jpg
string rSidePic; //右侧侧抓拍,base64编码
string rsidePicPostfix = "jpg"; //图片后缀,默认jpg
string upPic; //顶抓拍,base64编码
string upPicPostfix = "jpg"; //图片后缀,默认jpg
string movie; //过车小视频,base64编码
string moviePostfix = "mp4"; //短视频后缀,默认mp4
string busNum; //订单业务流水号
string icNum; //订单业务流水号
int overWeight; //超重,放大一百倍
string weightTime; //称重时间,格式yyyy-MM-dd HH:mm:ss
string platePic; //车牌特写图,base64编码
string platePicPostfix; //图片后缀,默认jpg
string frontPic; //前抓拍,base64编码
string frontPicPostfix; //图片后缀,默认jpg
string backPic; //后抓拍,base64编码
string backPicPostfix; //图片后缀,默认jpg
string lSidePic; //左侧侧抓拍,base64编码
string lsidePicPostfix; //图片后缀,默认jpg
string rSidePic; //右侧侧抓拍,base64编码
string rsidePicPostfix; //图片后缀,默认jpg
string upPic; //顶抓拍,base64编码
string upPicPostfix; //图片后缀,默认jpg
string movie; //过车小视频,base64编码
string moviePostfix; //短视频后缀,默认mp4
};
struct PacketRegister
{/*注册包
上行指令 0x05: 心跳包
Json字段 数据类型 描述
ping String 值为1*/
string key = "123456";
string stationCode; //站点编号
};
struct PacketBinding
{/*绑定
上行指令 0x05: 心跳包
Json字段 数据类型 描述
ping String 值为1*/
string key = "123456";
string plateNum; //车牌号
string vehicleId; //车辆ID
};
struct PacketHeartBeat
{/*心跳包
......@@ -194,6 +197,9 @@ struct PacketHeartBeat
ping String 值为1*/
string key = "123456";
string ping;
string pang = "1";
};
#pragma pack ()
#endif // VEHINFO_H
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论