From e0d707fe344801994590f0ac1407cd525fca8209 Mon Sep 17 00:00:00 2001
From: luoliangyi <87842688@qq.com>
Date: Tue, 24 May 2022 10:01:36 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=97=A0=E9=9C=80=E5=AF=BC=E5=87=BA?=
=?UTF-8?q?=E7=9A=84=E5=A4=B4=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80=E6=94=B9?=
=?UTF-8?q?=E4=B8=BAhpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
build/linux/HGBase/HGBase.cbp | 2 +-
build/windows/HGBase/HGBase.vcxproj | 2 +-
modules/base/HGMsgPump.cpp | 4 +--
modules/base/HGMsgPump.h | 8 ++---
modules/base/HGMsgPumpImpl.cpp | 2 +-
.../{HGMsgPumpImpl.h => HGMsgPumpImpl.hpp} | 2 +-
sdk/webservice/ManagerV1.cpp | 12 +++----
sdk/webservice/ManagerV2.cpp | 2 +-
sdk/webservice/ManagerV2.h | 34 +++++++++---------
sdk/webservice/Msg.h | 2 +-
sdk/webservice/SockIoServer.cpp | 2 +-
sdk/webservice/SockIoServer.h | 2 +-
sdk/webservice/SockIoUser.cpp | 4 +--
sdk/webservice/WSServer.cpp | 2 +-
sdk/webservice/WSServer.h | 2 +-
sdk/webservice/WSUser.cpp | 36 +++++++++----------
sdk/webservice/WSUser.h | 2 +-
sdk/webservice/WebServer.cpp | 4 +--
sdk/webservice/WebServer.h | 2 +-
19 files changed, 63 insertions(+), 63 deletions(-)
rename modules/base/{HGMsgPumpImpl.h => HGMsgPumpImpl.hpp} (87%)
diff --git a/build/linux/HGBase/HGBase.cbp b/build/linux/HGBase/HGBase.cbp
index f42c3683..96a4bb5f 100644
--- a/build/linux/HGBase/HGBase.cbp
+++ b/build/linux/HGBase/HGBase.cbp
@@ -237,7 +237,7 @@
-
+
diff --git a/build/windows/HGBase/HGBase.vcxproj b/build/windows/HGBase/HGBase.vcxproj
index 3dbee6ff..6e2863dc 100644
--- a/build/windows/HGBase/HGBase.vcxproj
+++ b/build/windows/HGBase/HGBase.vcxproj
@@ -58,7 +58,7 @@
-
+
diff --git a/modules/base/HGMsgPump.cpp b/modules/base/HGMsgPump.cpp
index 89fa4771..b3ba81e5 100644
--- a/modules/base/HGMsgPump.cpp
+++ b/modules/base/HGMsgPump.cpp
@@ -1,5 +1,5 @@
-#include "HGMsgPump.h"
-#include "HGMsgPumpImpl.h"
+#include "HGMsgPump.h"
+#include "HGMsgPumpImpl.hpp"
HGResult HGAPI HGBase_CreateMsgPump(HGMsgPump* msgPump)
{
diff --git a/modules/base/HGMsgPump.h b/modules/base/HGMsgPump.h
index a62f3ab9..add33c0f 100644
--- a/modules/base/HGMsgPump.h
+++ b/modules/base/HGMsgPump.h
@@ -1,4 +1,4 @@
-#ifndef __HGMSGPUMP_H__
+#ifndef __HGMSGPUMP_H__
#define __HGMSGPUMP_H__
#include "HGDef.h"
@@ -6,11 +6,11 @@
HG_DECLARE_HANDLE(HGMsgPump);
-/* Ϣṹ, Զ */
+/* 消息结构体, 可以自定义 */
typedef struct
{
- HGUInt id; /* ϢID, Ϊ0 */
- HGPointer data; /* Я */
+ HGUInt id; /* 消息ID, 不能为0 */
+ HGPointer data; /* 携带的数据 */
}HGMsg;
typedef void (*HGMsgPumpFunc)(HGMsgPump msgPump, const HGMsg* msg, HGPointer param);
diff --git a/modules/base/HGMsgPumpImpl.cpp b/modules/base/HGMsgPumpImpl.cpp
index 876e0903..6764955a 100644
--- a/modules/base/HGMsgPumpImpl.cpp
+++ b/modules/base/HGMsgPumpImpl.cpp
@@ -1,4 +1,4 @@
-#include "HGMsgPumpImpl.h"
+#include "HGMsgPumpImpl.hpp"
HGMsgPumpImpl::HGMsgPumpImpl()
{
diff --git a/modules/base/HGMsgPumpImpl.h b/modules/base/HGMsgPumpImpl.hpp
similarity index 87%
rename from modules/base/HGMsgPumpImpl.h
rename to modules/base/HGMsgPumpImpl.hpp
index 52628ab9..1cfb138b 100644
--- a/modules/base/HGMsgPumpImpl.h
+++ b/modules/base/HGMsgPumpImpl.hpp
@@ -1,4 +1,4 @@
-#ifndef __HGMSGPUMPIMPL_H__
+#ifndef __HGMSGPUMPIMPL_H__
#define __HGMSGPUMPIMPL_H__
#include "HGDef.h"
diff --git a/sdk/webservice/ManagerV1.cpp b/sdk/webservice/ManagerV1.cpp
index df992241..65d0fffb 100644
--- a/sdk/webservice/ManagerV1.cpp
+++ b/sdk/webservice/ManagerV1.cpp
@@ -1,4 +1,4 @@
-#include "ManagerV1.h"
+#include "ManagerV1.h"
#include "base/HGBuffer.h"
#include "base/HGBase64.h"
#include "base/HGUtility.h"
@@ -77,7 +77,7 @@ namespace ver_1
paperType = strValue;
HGBase_GetProfileInt(cfgPath.c_str(), "devParam", "splitImage", 0, &intValue);
splitImage = intValue;
- HGBase_GetProfileInt(cfgPath.c_str(), "devParam", "noiseDetachEnable", 1, &intValue);
+ HGBase_GetProfileInt(cfgPath.c_str(), "devParam", "noiseDetachEnable”", 1, &intValue);
noiseDetachEnable = (bool)intValue;
HGBase_GetProfileInt(cfgPath.c_str(), "devParam", "noiseDetach", 15, &intValue);
noiseDetach = intValue;
@@ -364,7 +364,7 @@ namespace ver_1
{
m_devParam.device = m_devName;
- // 豸ȡm_devParam
+ // 从设备获取到m_devParam
SANE_Int num_dev_options = 0;
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
@@ -486,7 +486,7 @@ namespace ver_1
bool ret = false;
if (NULL != m_devHandle)
{
- // m_devParam豸
+ // 设置m_devParam到设备
SANE_Int num_dev_options = 0;
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
@@ -1671,7 +1671,7 @@ namespace ver_1
#endif
#if defined(HG_CMP_MSC)
- u_long ul = 1; // Ϊ
+ u_long ul = 1; // 设为非阻塞
ioctlsocket(sockClient, FIONBIO, &ul);
#else
ioctl(sockClient, FIONBIO, 1);
@@ -1722,7 +1722,7 @@ namespace ver_1
}
#if defined(HG_CMP_MSC)
- ul = 0; // Ϊ
+ ul = 0; // 设为阻塞
ioctlsocket(sockClient, FIONBIO, &ul);
#else
ioctl(sockClient, FIONBIO, 0);
diff --git a/sdk/webservice/ManagerV2.cpp b/sdk/webservice/ManagerV2.cpp
index 4cdab754..89782758 100644
--- a/sdk/webservice/ManagerV2.cpp
+++ b/sdk/webservice/ManagerV2.cpp
@@ -1,4 +1,4 @@
-#include "ManagerV2.h"
+#include "ManagerV2.h"
#include "base/HGBuffer.h"
#include "base/HGBase64.h"
#include "base/HGUtility.h"
diff --git a/sdk/webservice/ManagerV2.h b/sdk/webservice/ManagerV2.h
index 780fcf04..61c196bd 100644
--- a/sdk/webservice/ManagerV2.h
+++ b/sdk/webservice/ManagerV2.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "base/HGDef.h"
#include "base/HGInc.h"
@@ -16,16 +16,16 @@ namespace ver_2
{
struct GlobalConfig
{
- // ļ
+ // 文件保存
std::string fileSavePath;
std::string fileNamePrefix;
std::string fileNameMode;
- // ͼ
+ // 图像保存
std::string imageFormat;
int imageJpegQuality;
std::string imageTiffCompression;
int imageTiffJpegQuality;
- // ϴ
+ // 上传
std::string uploadHttpHost;
unsigned short uploadHttpPort;
std::string uploadHttpPath;
@@ -41,35 +41,35 @@ namespace ver_2
ManagerV2(HGMsgPump msgPump);
virtual ~ManagerV2();
- // ɨ
+ // 扫描完成
void ScanFinish(const ScanFinishParam* param);
- // ȫ
+ // 设置全局配置
int SetGlobalConfig(const GlobalConfig& cfg);
- // ȡȫ
+ // 获取全局配置
int GetGlobalConfig(GlobalConfig& cfg);
- // رͼ
+ // 加载本地图像
int LoadLocalImage(const std::string& imagePath, std::string& imgBase64);
- // 汾ͼ
+ // 保存本地图像
int SaveLocalImage(const std::string& imgBase64, std::string& imagePath);
- // ɾļ
+ // 删除本地文件
int DeleteLocalFile(const std::string& filePath);
- // ȫļĿ¼
+ // 清理全局文件保存目录
int ClearGlobalFileSavePath();
- // ϳɱͼ
+ // 合成本地图像
int MergeLocalImage(const std::vector& imagePathList, const std::string& mode,
const std::string& align, int interval, std::string& outImagePath);
- // غϳɶͼ
+ // 本地合成多张图像
int LocalMakeMultiImage(const std::vector& imagePathList, const std::string& format,
const std::string& tiffCompression, int tiffJpegQuality, std::string& outImagePath);
- // ֱͼ
+ // 拆分本地图像
int SplitLocalImage(const std::string& imagePath, const std::string& mode, int location,
std::vector& outImagePathList);
- // ѹļ
+ // 本地生成压缩文件
int LocalMakeZipFile(const std::vector& filePathList, std::string& outZipPath);
- // ͼƫ
+ // 本地图像纠偏
int LocalImageDeskew(const std::string& imagePath, std::string& outImagePath);
- // ϴļ
+ // 上传文件
int UploadLocalFile(const std::string& filePath, const std::string& mode, const std::string& remoteFilePath);
private:
diff --git a/sdk/webservice/Msg.h b/sdk/webservice/Msg.h
index 7c360c2b..b3c202a5 100644
--- a/sdk/webservice/Msg.h
+++ b/sdk/webservice/Msg.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "base/HGDef.h"
#include "base/HGInc.h"
diff --git a/sdk/webservice/SockIoServer.cpp b/sdk/webservice/SockIoServer.cpp
index 2024325d..88b1b9c9 100644
--- a/sdk/webservice/SockIoServer.cpp
+++ b/sdk/webservice/SockIoServer.cpp
@@ -1,4 +1,4 @@
-#include "SockIoServer.h"
+#include "SockIoServer.h"
#include "SockIoUser.h"
#include "base/HGInfo.h"
diff --git a/sdk/webservice/SockIoServer.h b/sdk/webservice/SockIoServer.h
index 6696bfce..02056dee 100644
--- a/sdk/webservice/SockIoServer.h
+++ b/sdk/webservice/SockIoServer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "WebServer.h"
#include "Msg.h"
diff --git a/sdk/webservice/SockIoUser.cpp b/sdk/webservice/SockIoUser.cpp
index 6a00c7e1..d5a01f54 100644
--- a/sdk/webservice/SockIoUser.cpp
+++ b/sdk/webservice/SockIoUser.cpp
@@ -404,7 +404,7 @@ namespace ver_1
}
else
{
- PostCmdMsg(&vAllData[0], vAllData.size());
+ PostCmdMsg(&vAllData[0], (HGUInt)vAllData.size());
}
bHandle = false;
@@ -464,7 +464,7 @@ namespace ver_1
if (NULL != resp)
{
- p->PostEventMsg((const HGByte*)resp, strlen(resp));
+ p->PostEventMsg((const HGByte*)resp, (HGUInt)strlen(resp));
delete[] resp;
}
}
diff --git a/sdk/webservice/WSServer.cpp b/sdk/webservice/WSServer.cpp
index 66220b80..d067e9d7 100644
--- a/sdk/webservice/WSServer.cpp
+++ b/sdk/webservice/WSServer.cpp
@@ -1,4 +1,4 @@
-#include "WSServer.h"
+#include "WSServer.h"
#include "WSUser.h"
#include "base/HGInfo.h"
diff --git a/sdk/webservice/WSServer.h b/sdk/webservice/WSServer.h
index 488ed594..1e079167 100644
--- a/sdk/webservice/WSServer.h
+++ b/sdk/webservice/WSServer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "WebServer.h"
#include "Msg.h"
diff --git a/sdk/webservice/WSUser.cpp b/sdk/webservice/WSUser.cpp
index 59445ad6..59a501a0 100644
--- a/sdk/webservice/WSUser.cpp
+++ b/sdk/webservice/WSUser.cpp
@@ -1,4 +1,4 @@
-#include "WSUser.h"
+#include "WSUser.h"
#include "WSServer.h"
#include "ManagerV2.h"
#include "base/HGInfo.h"
@@ -192,7 +192,7 @@ namespace ver_2
int len = recv(m_sockConn, chBuffer, 2048, 0);
if (len <= 0)
{
- // ǷرsocketConn߿ͻ˹رsocketϿ
+ // 这里跳出,可能是服务器关闭了socketConn,或者客户端关闭了socket,或者网络断开
PostDisConnectMsg();
break;
}
@@ -254,34 +254,34 @@ namespace ver_2
if (1 == nHeadDataLen)
{
- if ((0x80 | 0x08) == headData[0]) // Ͽ
+ if ((0x80 | 0x08) == headData[0]) // 断开连接
{
PostDisConnectMsg();
break;
}
- else if ((0x80 | 0x09) == headData[0]) // PING֡
+ else if ((0x80 | 0x09) == headData[0]) // PING帧
{
//
}
- else if ((0x80 | 0x0A) == headData[0]) // PONG֡
+ else if ((0x80 | 0x0A) == headData[0]) // PONG帧
{
//
}
else if ((0x00 | 0x01) == headData[0] || (0x00 | 0x02) == headData[0] || (0x00 | 0x00) == headData[0] || (0x80 | 0x00) == headData[0]
- || (0x80 | 0x01) == headData[0] || (0x80 | 0x02) == headData[0]) // ֡
+ || (0x80 | 0x01) == headData[0] || (0x80 | 0x02) == headData[0]) // 数据帧
{
if ((0x80 | 0x00) == headData[0] || (0x80 | 0x01) == headData[0] || (0x80 | 0x02) == headData[0])
{
- // Ƭ
+ // 分片结束
bHandle = true;
}
else
{
- // Ƭ֡
+ // 分片帧
bHandle = false;
}
}
- else // ֡Ͽ
+ else // 帧错误,断开连接
{
PostDisConnectMsg();
break;
@@ -289,13 +289,13 @@ namespace ver_2
}
else if (2 == nHeadDataLen)
{
- if (0 == (headData[1] & 0x80)) // 뾭봦
+ if (0 == (headData[1] & 0x80)) // 必须经过掩码处理
{
PostDisConnectMsg();
break;
}
- if ((0x80 | 0x09) == headData[0]) // PING֡
+ if ((0x80 | 0x09) == headData[0]) // PING帧
{
if (0x80 != headData[1])
{
@@ -303,7 +303,7 @@ namespace ver_2
break;
}
}
- else if ((0x80 | 0x0A) == headData[0]) // PONG֡
+ else if ((0x80 | 0x0A) == headData[0]) // PONG帧
{
if (0x80 != headData[1])
{
@@ -333,11 +333,11 @@ namespace ver_2
}
else if (4 == nHeadDataLen)
{
- if ((0x80 | 0x09) == headData[0]) // PING֡
+ if ((0x80 | 0x09) == headData[0]) // PING帧
{
//
}
- else if ((0x80 | 0x0A) == headData[0]) // PONG֡
+ else if ((0x80 | 0x0A) == headData[0]) // PONG帧
{
//
}
@@ -363,20 +363,20 @@ namespace ver_2
}
else if (6 == nHeadDataLen)
{
- if ((0x80 | 0x09) == headData[0]) // PING֡
+ if ((0x80 | 0x09) == headData[0]) // PING帧
{
nHeadDataLen = 0;
Pong();
}
- else if ((0x80 | 0x0A) == headData[0]) // PONG֡
+ else if ((0x80 | 0x0A) == headData[0]) // PONG帧
{
nHeadDataLen = 0;
}
}
else if (10 == nHeadDataLen)
{
- if ((headData[1] & 0x7F) == 127) // һ127
+ if ((headData[1] & 0x7F) == 127) // 这里一定会等于127
{
uint32_t nCmdSizeHigh = ntohl(*(uint32_t*)&headData[2]);
uint32_t nCmdSize = ntohl(*(uint32_t*)&headData[6]);
@@ -432,7 +432,7 @@ namespace ver_2
if (bHandle)
{
- PostCmdMsg(&vAllData[0], vAllData.size());
+ PostCmdMsg(&vAllData[0], (HGUInt)vAllData.size());
bHandle = false;
vAllData.clear();
diff --git a/sdk/webservice/WSUser.h b/sdk/webservice/WSUser.h
index 875d944e..8bd78de6 100644
--- a/sdk/webservice/WSUser.h
+++ b/sdk/webservice/WSUser.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "WebUser.h"
#include "Msg.h"
diff --git a/sdk/webservice/WebServer.cpp b/sdk/webservice/WebServer.cpp
index 8386ec85..71f8b9b2 100644
--- a/sdk/webservice/WebServer.cpp
+++ b/sdk/webservice/WebServer.cpp
@@ -1,4 +1,4 @@
-#include "WebServer.h"
+#include "WebServer.h"
#include "WebUser.h"
#include "base/HGInfo.h"
@@ -195,7 +195,7 @@ void WebServer::ThreadFunc(HGThread thread, HGPointer param)
if (-1 == socketConn)
#endif
{
- // Ƿرm_sockServer
+ // 这里跳出,可能是服务器关闭了m_sockServer
break;
}
diff --git a/sdk/webservice/WebServer.h b/sdk/webservice/WebServer.h
index 702c041f..96d87cca 100644
--- a/sdk/webservice/WebServer.h
+++ b/sdk/webservice/WebServer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "base/HGDef.h"
#include "base/HGInc.h"