提交 e3e3e125 作者: zhangyl

添加发卡系统-0.0.1

上级 692e1171
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++ \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/i686-w64-mingw32 \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/backward \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include-fixed \
C:/Qt/Qt5.13.2/Tools/mingw730_32/i686-w64-mingw32/include
QMAKE_CXX.LIBDIRS = \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0 \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib/gcc \
C:/Qt/Qt5.13.2/Tools/mingw730_32/i686-w64-mingw32/lib \
C:/Qt/Qt5.13.2/Tools/mingw730_32/lib
QT += core gui serialport network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
#自定Pro结构文件
MOC_DIR = temp/moc
RCC_DIR = temp/rcc
UI_DIR = temp/ui
OBJECTS_DIR = temp/obj
#这样只有exe文件在bin文件夹
DESTDIR = bin
#为了使日志在 Release 模式下也可输出文件名和代码行数
DEFINES += QT_MESSAGELOGCONTEXT
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
bridge.cpp \
main.cpp \
mainwindow.cpp
HEADERS += \
bridge.h \
mainwindow.h \
vehinfo.h
FORMS += \
mainwindow.ui
include(readEPC/readEPC.pri)
include(TCPSocketHelper/TCPSocketHelper.pri)
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
/*******************************************************************************
* 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();
SocketState getSocketStatus(){
return m_TCPSocket->state();
}
signals:
void ResponseData(MessageTypes,short,QByteArray);
void ResponseInfoData(MessageTypes,short,QByteArray);
void TCPSocketIsConnected();
void TCPSocketIsDisconnected();
void TCPSocketUnstable();
public slots:
///站点注册
void Register();
///绑定
void Binding(QString epc,QString carPlnum);
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 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 = "127.0.0.1";
quint16 m_ServerPort = 40008;
int m_LossCount = 0;
bool m_heartbeatFlag = true;
bool m_CloseFlag = false;
QByteArray m_ArrBuff;
};
#endif // TCPSOCKETHELPER_H
#include "bridge.h"
#include <QDebug>
Bridge::Bridge(QObject *parent) : QObject(parent)
{
m_TCPSocketHelper = new TCPSocketHelper();
m_TCPSocketHelper_thread = new QThread;
//m_TCPSocketHelper->moveToThread(m_TCPSocketHelper_thread);
connect(this,&Bridge::SendToTCPSocketHelperConnect,m_TCPSocketHelper,&TCPSocketHelper::openTCPSocket);
connect(this,&Bridge::SendToTCPSocketHelperRegister,m_TCPSocketHelper,&TCPSocketHelper::Register);
connect(this,&Bridge::SendToTCPSocketHelperBinding,m_TCPSocketHelper,&TCPSocketHelper::Binding);
m_ReadEPCControl = new ReadEPCControl();
m_ReadEPCControl_thread = new QThread;
m_ReadEPCControl->moveToThread(m_ReadEPCControl_thread);
m_ReadEPCControl_thread->start();
ReadEPCControl_Func();
}
void Bridge::ReadEPCControl_Func()
{
connect(this,&Bridge::SendToReadEPCControl_Start_Read,m_ReadEPCControl,&ReadEPCControl::setComm);
connect(m_ReadEPCControl,&ReadEPCControl::SendToBridge,this,[=](QByteArray data){
QString str;
str = data.toHex();
qDebug()<< str;
if(str.size() == 16){
str = str.mid(8,4);
qDebug()<< str;
bool ok;
int hexnum = str.toInt(&ok,16); // 表示以16进制方式读取字符串
emit SendToWindow(hexnum);
}
});
}
#ifndef BRIDGE_H
#define BRIDGE_H
#include <QObject>
#include <QWidget>
#include <QThread>
#include "readEPC/readepccontrol.h" //EPC读取数据助手
#include "TCPSocketHelper/tcpsockethelper.h" //TCP助手
class Bridge : public QObject
{
Q_OBJECT
public:
explicit Bridge(QObject *parent = nullptr);
ReadEPCControl *m_ReadEPCControl;
TCPSocketHelper *m_TCPSocketHelper;
signals:
void SendToTCPSocketHelperConnect(); //连接服务器
void SendToTCPSocketHelperRegister(); //站点注册
void SendToTCPSocketHelperBinding(QString epc,QString carPlnum); //绑定
void SendToReadEPCControl_Start_Read(QString ComName,long baudRate);
void SendToWindow(int data);
public slots:
private:
void ReadEPCControl_Func();
private:
QThread *m_ReadEPCControl_thread;
QThread *m_TCPSocketHelper_thread;
};
#endif // BRIDGE_H
/****************************************************************************
** Meta object code from reading C++ file 'mainwindow.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 "../mainwindow.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mainwindow.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_MainWindow_t {
QByteArrayData data[1];
char stringdata0[11];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
{
QT_MOC_LITERAL(0, 0, 10) // "MainWindow"
},
"MainWindow"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_MainWindow[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
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);
}
QT_INIT_METAOBJECT const QMetaObject MainWindow::staticMetaObject = { {
&QMainWindow::staticMetaObject,
qt_meta_stringdata_MainWindow.data,
qt_meta_data_MainWindow,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *MainWindow::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *MainWindow::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0))
return static_cast<void*>(this);
return QMainWindow::qt_metacast(_clname);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSerialPortInfo>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_Bridge = new Bridge();
connect(ui->pbn_sure,&QPushButton::clicked,this,[=](){
if(ui->lineEdit_EPC->text().isEmpty()){
qDebug()<<"请检查识别卡";
return ;
}
if(ui->lineEdit_carPlnum->text().isEmpty()){
qDebug()<<"请检查输入的车牌信息";
return ;
}
emit m_Bridge->SendToTCPSocketHelperBinding(ui->lineEdit_EPC->text(),ui->lineEdit_carPlnum->text());
});
connect(ui->actionRegister,&QAction::triggered,this,[=](){
//点击注册
emit m_Bridge->SendToTCPSocketHelperConnect();
emit m_Bridge->SendToTCPSocketHelperRegister();
});
ReadWindow_init();
Updata_ui();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::ReadWindow_init()
{
setWindowTitle("车辆ID绑定");
ui->lineEdit_EPC->setFixedHeight(this->height()/4);
ui->lineEdit_carPlnum->setFixedHeight(this->height()/4);
ui->lineEdit_carPlnum->setPlaceholderText("请输入要绑定的车牌号");
ui->lineEdit_EPC->setPlaceholderText("请将车辆识别卡放入识别区");
ui->lineEdit_EPC->setReadOnly(true);
emit m_Bridge->SendToReadEPCControl_Start_Read("COM2",57600);
}
void MainWindow::Updata_ui()
{
connect(m_Bridge,&Bridge::SendToWindow,this,[=](int data){
ui->lineEdit_EPC->setText(QString::number(data));
});
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "bridge.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
Bridge *m_Bridge;
private:
void ReadWindow_init();
void Updata_ui();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true">font: 14pt &quot;Microsoft YaHei UI&quot;;</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>EPC:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_EPC">
<property name="styleSheet">
<string notr="true">font: 20pt &quot;Microsoft YaHei UI&quot;;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>车牌号:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_carPlnum">
<property name="styleSheet">
<string notr="true">font: 20pt &quot;Microsoft YaHei UI&quot;;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pbn_sure">
<property name="text">
<string>绑定</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>设置</string>
</property>
<addaction name="actionRegister"/>
</widget>
<addaction name="menu"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionRegister">
<property name="text">
<string>Register</string>
</property>
<property name="toolTip">
<string>站点注册</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
temp/obj/bridge.o
temp/obj/main.o
temp/obj/mainwindow.o
temp/obj/readepccontrol.o
temp/obj/CJsonObject.o
temp/obj/cJSON.o
temp/obj/tcpsockethelper.o
temp/obj/moc_bridge.o
temp/obj/moc_mainwindow.o
temp/obj/moc_readepccontrol.o
temp/obj/moc_tcpsockethelper.o
temp/obj/bridge.o
temp/obj/main.o
temp/obj/mainwindow.o
temp/obj/readepccontrol.o
temp/obj/CJsonObject.o
temp/obj/cJSON.o
temp/obj/tcpsockethelper.o
temp/obj/moc_bridge.o
temp/obj/moc_mainwindow.o
temp/obj/moc_readepccontrol.o
temp/obj/moc_tcpsockethelper.o
HEADERS += \
$$PWD/readepccontrol.h
SOURCES += \
$$PWD/readepccontrol.cpp
#include "readepccontrol.h"
#include <QDebug>
ReadEPCControl::ReadEPCControl(QObject *parent) : QObject(parent)
{
}
void ReadEPCControl::setComm(QString ComName, long baudRate)
{
SerialPort = new QSerialPort(this);
// 设置串口号
SerialPort->setPortName(ComName);
// 打开串口
if(SerialPort->open(QIODevice::ReadOnly))
{
// 设置波特率
SerialPort->setBaudRate(baudRate);
SerialPort->setDataBits(QSerialPort::Data8);
SerialPort->setParity(QSerialPort::NoParity);
// 设置流控制
SerialPort->setFlowControl(QSerialPort::NoFlowControl);
SerialPort->setStopBits(QSerialPort::OneStop);
//qDebug()<<"打开RFID";
}else {
qDebug()<<"打开RFID失败";
return;
}
connect(SerialPort,&QSerialPort::readyRead,this,[=](){
QByteArray data = SerialPort->readAll();
//QString str(SerialPort.readAll());
//qDebug()<<"接收到的初始EPC:"<<data;
emit SendToBridge(data);
});
}
#ifndef READEPCCONTROL_H
#define READEPCCONTROL_H
#include <QObject>
#include <QWidget>
#include <QSerialPort>
class ReadEPCControl : public QObject
{
Q_OBJECT
public:
explicit ReadEPCControl(QObject *parent = nullptr);
signals:
void SendToBridge(QByteArray data);
public slots:
void setComm(QString ComName,long baudRate);
private:
QString m_RepeatScan = nullptr;
QSerialPort *SerialPort;
};
#endif // READEPCCONTROL_H
/****************************************************************************
** Meta object code from reading C++ file 'bridge.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 "../../bridge.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'bridge.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_Bridge_t {
QByteArrayData data[12];
char stringdata0[176];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_Bridge_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_Bridge_t qt_meta_stringdata_Bridge = {
{
QT_MOC_LITERAL(0, 0, 6), // "Bridge"
QT_MOC_LITERAL(1, 7, 28), // "SendToTCPSocketHelperConnect"
QT_MOC_LITERAL(2, 36, 0), // ""
QT_MOC_LITERAL(3, 37, 29), // "SendToTCPSocketHelperRegister"
QT_MOC_LITERAL(4, 67, 28), // "SendToTCPSocketHelperBinding"
QT_MOC_LITERAL(5, 96, 3), // "epc"
QT_MOC_LITERAL(6, 100, 8), // "carPlnum"
QT_MOC_LITERAL(7, 109, 31), // "SendToReadEPCControl_Start_Read"
QT_MOC_LITERAL(8, 141, 7), // "ComName"
QT_MOC_LITERAL(9, 149, 8), // "baudRate"
QT_MOC_LITERAL(10, 158, 12), // "SendToWindow"
QT_MOC_LITERAL(11, 171, 4) // "data"
},
"Bridge\0SendToTCPSocketHelperConnect\0"
"\0SendToTCPSocketHelperRegister\0"
"SendToTCPSocketHelperBinding\0epc\0"
"carPlnum\0SendToReadEPCControl_Start_Read\0"
"ComName\0baudRate\0SendToWindow\0data"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_Bridge[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
5, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
5, // signalCount
// signals: name, argc, parameters, tag, flags
1, 0, 39, 2, 0x06 /* Public */,
3, 0, 40, 2, 0x06 /* Public */,
4, 2, 41, 2, 0x06 /* Public */,
7, 2, 46, 2, 0x06 /* Public */,
10, 1, 51, 2, 0x06 /* Public */,
// signals: parameters
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::QString, QMetaType::QString, 5, 6,
QMetaType::Void, QMetaType::QString, QMetaType::Long, 8, 9,
QMetaType::Void, QMetaType::Int, 11,
0 // eod
};
void Bridge::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<Bridge *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SendToTCPSocketHelperConnect(); break;
case 1: _t->SendToTCPSocketHelperRegister(); break;
case 2: _t->SendToTCPSocketHelperBinding((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
case 3: _t->SendToReadEPCControl_Start_Read((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< long(*)>(_a[2]))); break;
case 4: _t->SendToWindow((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (Bridge::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToTCPSocketHelperConnect)) {
*result = 0;
return;
}
}
{
using _t = void (Bridge::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToTCPSocketHelperRegister)) {
*result = 1;
return;
}
}
{
using _t = void (Bridge::*)(QString , QString );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToTCPSocketHelperBinding)) {
*result = 2;
return;
}
}
{
using _t = void (Bridge::*)(QString , long );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToReadEPCControl_Start_Read)) {
*result = 3;
return;
}
}
{
using _t = void (Bridge::*)(int );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Bridge::SendToWindow)) {
*result = 4;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject Bridge::staticMetaObject = { {
&QObject::staticMetaObject,
qt_meta_stringdata_Bridge.data,
qt_meta_data_Bridge,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *Bridge::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *Bridge::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_Bridge.stringdata0))
return static_cast<void*>(this);
return QObject::qt_metacast(_clname);
}
int Bridge::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 < 5)
qt_static_metacall(this, _c, _id, _a);
_id -= 5;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 5)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 5;
}
return _id;
}
// SIGNAL 0
void Bridge::SendToTCPSocketHelperConnect()
{
QMetaObject::activate(this, &staticMetaObject, 0, nullptr);
}
// SIGNAL 1
void Bridge::SendToTCPSocketHelperRegister()
{
QMetaObject::activate(this, &staticMetaObject, 1, nullptr);
}
// SIGNAL 2
void Bridge::SendToTCPSocketHelperBinding(QString _t1, QString _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, 2, _a);
}
// SIGNAL 3
void Bridge::SendToReadEPCControl_Start_Read(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, 3, _a);
}
// SIGNAL 4
void Bridge::SendToWindow(int _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))) };
QMetaObject::activate(this, &staticMetaObject, 4, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
/****************************************************************************
** Meta object code from reading C++ file 'mainwindow.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 "../../mainwindow.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mainwindow.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_MainWindow_t {
QByteArrayData data[1];
char stringdata0[11];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
{
QT_MOC_LITERAL(0, 0, 10) // "MainWindow"
},
"MainWindow"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_MainWindow[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
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);
}
QT_INIT_METAOBJECT const QMetaObject MainWindow::staticMetaObject = { {
&QMainWindow::staticMetaObject,
qt_meta_stringdata_MainWindow.data,
qt_meta_data_MainWindow,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *MainWindow::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *MainWindow::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0))
return static_cast<void*>(this);
return QMainWindow::qt_metacast(_clname);
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
/****************************************************************************
** Meta object code from reading C++ file 'readepccontrol.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 "../../readEPC/readepccontrol.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'readepccontrol.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_ReadEPCControl_t {
QByteArrayData data[7];
char stringdata0[59];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_ReadEPCControl_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_ReadEPCControl_t qt_meta_stringdata_ReadEPCControl = {
{
QT_MOC_LITERAL(0, 0, 14), // "ReadEPCControl"
QT_MOC_LITERAL(1, 15, 12), // "SendToBridge"
QT_MOC_LITERAL(2, 28, 0), // ""
QT_MOC_LITERAL(3, 29, 4), // "data"
QT_MOC_LITERAL(4, 34, 7), // "setComm"
QT_MOC_LITERAL(5, 42, 7), // "ComName"
QT_MOC_LITERAL(6, 50, 8) // "baudRate"
},
"ReadEPCControl\0SendToBridge\0\0data\0"
"setComm\0ComName\0baudRate"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_ReadEPCControl[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 24, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
4, 2, 27, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::QByteArray, 3,
// slots: parameters
QMetaType::Void, QMetaType::QString, QMetaType::Long, 5, 6,
0 // eod
};
void ReadEPCControl::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<ReadEPCControl *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->SendToBridge((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
case 1: _t->setComm((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< long(*)>(_a[2]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (ReadEPCControl::*)(QByteArray );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&ReadEPCControl::SendToBridge)) {
*result = 0;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject ReadEPCControl::staticMetaObject = { {
&QObject::staticMetaObject,
qt_meta_stringdata_ReadEPCControl.data,
qt_meta_data_ReadEPCControl,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *ReadEPCControl::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *ReadEPCControl::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_ReadEPCControl.stringdata0))
return static_cast<void*>(this);
return QObject::qt_metacast(_clname);
}
int ReadEPCControl::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 < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
}
return _id;
}
// SIGNAL 0
void ReadEPCControl::SendToBridge(QByteArray _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[17];
char stringdata0[219];
};
#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, 8), // "Register"
QT_MOC_LITERAL(9, 132, 7), // "Binding"
QT_MOC_LITERAL(10, 140, 3), // "epc"
QT_MOC_LITERAL(11, 144, 8), // "carPlnum"
QT_MOC_LITERAL(12, 153, 11), // "onConnected"
QT_MOC_LITERAL(13, 165, 11), // "onReadyRead"
QT_MOC_LITERAL(14, 177, 14), // "onDisconnected"
QT_MOC_LITERAL(15, 192, 14), // "checkHeartBeat"
QT_MOC_LITERAL(16, 207, 11) // "LatencyTest"
},
"TCPSocketHelper\0ResponseData\0\0"
"MessageTypes\0ResponseInfoData\0"
"TCPSocketIsConnected\0TCPSocketIsDisconnected\0"
"TCPSocketUnstable\0Register\0Binding\0"
"epc\0carPlnum\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
11, 14, // methods
0, 0, // properties
1, 96, // enums/sets
0, 0, // constructors
0, // flags
5, // signalCount
// signals: name, argc, parameters, tag, flags
1, 3, 69, 2, 0x06 /* Public */,
4, 3, 76, 2, 0x06 /* Public */,
5, 0, 83, 2, 0x06 /* Public */,
6, 0, 84, 2, 0x06 /* Public */,
7, 0, 85, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
8, 0, 86, 2, 0x0a /* Public */,
9, 2, 87, 2, 0x0a /* Public */,
12, 0, 92, 2, 0x08 /* Private */,
13, 0, 93, 2, 0x08 /* Private */,
14, 0, 94, 2, 0x08 /* Private */,
15, 0, 95, 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,
// slots: parameters
QMetaType::Void,
QMetaType::Void, QMetaType::QString, QMetaType::QString, 10, 11,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
// enums: name, alias, flags, count, data
3, 3, 0x0, 1, 101,
// enum data: key, value
16, 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->Register(); break;
case 6: _t->Binding((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
case 7: _t->onConnected(); break;
case 8: _t->onReadyRead(); break;
case 9: _t->onDisconnected(); break;
case 10: _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;
}
}
}
}
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 < 11)
qt_static_metacall(this, _c, _id, _a);
_id -= 11;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 11)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 11;
}
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);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created by: Qt User Interface Compiler version 5.13.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QAction *actionRegister;
QWidget *centralwidget;
QGridLayout *gridLayout;
QVBoxLayout *verticalLayout;
QHBoxLayout *horizontalLayout;
QLabel *label;
QLineEdit *lineEdit_EPC;
QHBoxLayout *horizontalLayout_2;
QLabel *label_2;
QLineEdit *lineEdit_carPlnum;
QPushButton *pbn_sure;
QMenuBar *menubar;
QMenu *menu;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(400, 300);
MainWindow->setMinimumSize(QSize(400, 300));
MainWindow->setMaximumSize(QSize(400, 300));
actionRegister = new QAction(MainWindow);
actionRegister->setObjectName(QString::fromUtf8("actionRegister"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
centralwidget->setStyleSheet(QString::fromUtf8("font: 14pt \"Microsoft YaHei UI\";"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
verticalLayout = new QVBoxLayout();
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
label = new QLabel(centralwidget);
label->setObjectName(QString::fromUtf8("label"));
horizontalLayout->addWidget(label);
lineEdit_EPC = new QLineEdit(centralwidget);
lineEdit_EPC->setObjectName(QString::fromUtf8("lineEdit_EPC"));
lineEdit_EPC->setStyleSheet(QString::fromUtf8("font: 20pt \"Microsoft YaHei UI\";"));
horizontalLayout->addWidget(lineEdit_EPC);
verticalLayout->addLayout(horizontalLayout);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
label_2 = new QLabel(centralwidget);
label_2->setObjectName(QString::fromUtf8("label_2"));
horizontalLayout_2->addWidget(label_2);
lineEdit_carPlnum = new QLineEdit(centralwidget);
lineEdit_carPlnum->setObjectName(QString::fromUtf8("lineEdit_carPlnum"));
lineEdit_carPlnum->setStyleSheet(QString::fromUtf8("font: 20pt \"Microsoft YaHei UI\";"));
horizontalLayout_2->addWidget(lineEdit_carPlnum);
verticalLayout->addLayout(horizontalLayout_2);
pbn_sure = new QPushButton(centralwidget);
pbn_sure->setObjectName(QString::fromUtf8("pbn_sure"));
verticalLayout->addWidget(pbn_sure);
gridLayout->addLayout(verticalLayout, 0, 0, 1, 1);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 400, 23));
menu = new QMenu(menubar);
menu->setObjectName(QString::fromUtf8("menu"));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
menubar->addAction(menu->menuAction());
menu->addAction(actionRegister);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
actionRegister->setText(QCoreApplication::translate("MainWindow", "Register", nullptr));
#if QT_CONFIG(tooltip)
actionRegister->setToolTip(QCoreApplication::translate("MainWindow", "\347\253\231\347\202\271\346\263\250\345\206\214", nullptr));
#endif // QT_CONFIG(tooltip)
label->setText(QCoreApplication::translate("MainWindow", "EPC:", nullptr));
label_2->setText(QCoreApplication::translate("MainWindow", "\350\275\246\347\211\214\345\217\267:", nullptr));
pbn_sure->setText(QCoreApplication::translate("MainWindow", "\347\273\221\345\256\232", nullptr));
menu->setTitle(QCoreApplication::translate("MainWindow", "\350\256\276\347\275\256", nullptr));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
#ifndef VEHINFO_H
#define VEHINFO_H
#include <iostream>
#include <vector>
#include <QQueue>
using namespace std;
/*
*上行指令 0x00 : 注册
Json字段 数据类型 描述
stationCode String 站点编号
上行指令 0x01 :车辆驶入,是否放行进入厂区
*Json字段 数据类型 描述
stationCode String 站点编号
plateNum string 车牌号
上行指令0x02: 前道闸是否开启
Json字段 数据类型 描述
plateNum string 车牌号
上行指令 0x03:上传称重数据
Json字段 数据类型 描述
plateNum string 车牌号
vehicleType int 车型
axleCnt Int 轴数
axleType Int 轴型
sumWeight int 车货总重,放大一百倍
axleWeight1 Int 1轴重,放大一百倍
axleWeight2 Int 2轴重,放大一百倍
axleWeight3 Int 3轴重,放大一百倍
axleWeight4 Int 4轴重,放大一百倍
axleWeight5 Int 5轴重,放大一百倍
axleWeight6 Int 6轴重,放大一百倍
axleWeight7 Int 7轴重,放大一百倍
axleWeight8 Int 8轴重,放大一百倍
limitWeight Int 限重,放大一百倍
overWeight Int 超重,放大一百倍
weightTime String 称重时间,格式yyyy-MM-dd HH:mm:ss
platePic String 车牌特写图,base64编码
platePicPostfix String 图片后缀,默认jpg
frontPic String 前抓拍,base64编码
frontPicPostfix String 图片后缀,默认jpg
backPic String 后抓拍,base64编码
backPicPostfix String 图片后缀,默认jpg
lSidePic String 左侧侧抓拍,base64编码
lsidePicPostfix String 图片后缀,默认jpg
rSidePic String 右侧侧测抓拍,base64编码
rsidePicPostfix String 图片后缀,默认jpg
upPic String 顶抓拍,base64编码
upPicPostfix String 图片后缀,默认jpg
movie String 过车小视频,base64编码
moviePostfix String 短视频后缀,默认mp4
上行指令0x03:过磅异常
Json字段 数据类型 描述
stationCode String 站点编号
plateNum string 车牌号
exceptionCode int 异常代码
weightTime String 格式yyyy-MM-dd HH:mm:ss
上行指令 0x04: 车辆驶出,是否放行
Json字段 数据类型 描述
stationCode String 站点编号
plateNum string 车牌号
*
*/
#pragma pack(1)
//
struct VehInfor
{
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 overPer;
string goodsName;
string goodsType;
string driver;
string sendCompany;
string recvCompany;
string trafficCompany;
string remark;
int go;
int lane;
int speed;
int length;
int width;
int height;
string picPath;
string dateTime;
string createTime;
string interTime;//入口时间,格式yyyy-MM-dd HH:mm:ss
string platePic; //车牌特写图,base64编码
string platePicPostfix;//图片后缀,默认jpg
string frontPic;//前抓拍,base64编码
string frontPicPostfix;//图片后缀,默认jpg
string key = "123456";
};
struct SelectInfor
{
string startTime;
string stopTime;
string plateNum;
int overPer;
float startWeight;
float stopWeight;
string remark;
};
struct SelectInfor1
{
string startTime;
string stopTime;
string plateNum;
float startWeight;
float stopWeight;
string remark;
};
typedef struct TSversion
{
char szVersion[64];
char szDateTime[64];
char szDescription[128];
}TSVERSION;
struct Vehicle{
int lane;
long flowNo;
char dateTime[50];
unsigned char runState;
unsigned char deviceState;
double speed;
double acceleration;
int reverse;//0 正向,1 逆向
int axleCnt;
int axleGrpCnt;
string axleWeight;
string axleGrpWeight;
string axleDis;
string axleCrpType;
long sumWeight;
int length;
char timeFlowNo[64];
};
struct VehicleCam
{
string plateNum;
string picPath;
string deviceId;
void* picContent;
long picLen;
};
struct CameraInfor
{
string ip;
int port;
string user;
string pwd;
int lane;
int direction;
string deviceId;
};
struct screenArea
{
int areaId;
int x;
int y;
int w;
int h;
int fontSize;
};
struct User
{
string userName;
string pwd;
string sex;
string mobile;
string remark;
bool isRemeber;
};
struct SendWeightForm
{
string key = "123456";
string poundNo; //磅号
string checkNo;
string stationCode; //站点编号
string plateNum; //车牌号
int tareWeight;
int grossWeight;
int suttleWeight;
string dateTime;
//新增字段
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轴重,放大一百倍
int axleWeight4; //4轴重,放大一百倍
int axleWeight5; //5轴重,放大一百倍
int axleWeight6; //6轴重,放大一百倍
int axleWeight7; //7轴重,放大一百倍
int axleWeight8; //8轴重,放大一百倍
int limitWeight; //限重,放大一百倍
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
{/*心跳包
上行指令 0x05: 心跳包
Json字段 数据类型 描述
ping String 值为1*/
string key = "123456";
string ping;
string pang = "1";
};
#pragma pack ()
#endif // VEHINFO_H
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论