commit for pull
This commit is contained in:
parent
62924be8d7
commit
b0b79c4f80
6
3rdparty/dahua/inc/dhnetsdk.h
vendored
6
3rdparty/dahua/inc/dhnetsdk.h
vendored
@ -21285,12 +21285,12 @@ typedef struct tagIMAGE_INFO
|
||||
int nHeight; // 图片高度
|
||||
char szFilePath[260]; // 文件路径
|
||||
BYTE byReserved[512]; // 预留字节
|
||||
}IMAGE_INFO;
|
||||
}DH_IMAGE_INFO;
|
||||
|
||||
// 目标人脸信息
|
||||
typedef struct tagFACE_INFO_OBJECT
|
||||
{
|
||||
IMAGE_INFO stuImageInfo; // 物体截图信息
|
||||
DH_IMAGE_INFO stuImageInfo; // 物体截图信息
|
||||
EM_DEV_EVENT_FACEDETECT_SEX_TYPE emSex; // 性别类型
|
||||
unsigned int nAge; // 年龄
|
||||
EM_FACEDETECT_GLASSES_TYPE emGlasses; // 是否戴眼镜
|
||||
@ -22226,7 +22226,7 @@ typedef struct tagMEDIAFILE_DOORCONTROL_RECORD_INFO
|
||||
// 门打开事件信息
|
||||
EM_OPEN_DOOR_METHOD emOpenDoorMethod; // 开门方式
|
||||
EM_OPEN_DOOR_STATE emOpenDoorState; // 开门结果
|
||||
IMAGE_INFO stuSceneImageInfo; // 全景大图信息
|
||||
DH_IMAGE_INFO stuSceneImageInfo; // 全景大图信息
|
||||
NET_TIME stuSnapTime; // 抓拍时间
|
||||
NET_DOORCONTROL_FACE_OBJECT stuFaceObject; // 目标人脸信息
|
||||
UINT nCandidatesNum; // 候选人数量
|
||||
|
@ -348,6 +348,7 @@ void CDriverMainDlg::ProcessPipeMsg(int lMsgId, char* pData, int lLen)
|
||||
float targetAngle = 0.0f; // 目标角度(度)
|
||||
//计算纠正角度
|
||||
theApp.m_fAngleForFast = CorrectAngle(currentAngle, targetAngle);
|
||||
LogOutToFile("currentAngled : = %f, CorrectAng = %f", currentAngled, theApp.m_fAngleForFast);
|
||||
}
|
||||
|
||||
//获取设备配置信息返回
|
||||
@ -394,9 +395,10 @@ float CDriverMainDlg::CorrectAngle(float currentAngle, float targetAngle) {
|
||||
// 这些参数 是要根据实际情况进行调整的
|
||||
//pid 对象在第一次调用 CorrectAngle 函数时创建,并且在程序的整个运行期间不会被销毁。即使函数执行结束,pid 对象仍然存在,其内部状态(如积分项 integral、上一次误差 prevError 等)会被持久化保存
|
||||
static PIDController pid(
|
||||
0.5f, //比例系数
|
||||
0.2f, //积分系数
|
||||
0.1f, //微分系数
|
||||
0.6f, //比例系数 P
|
||||
0.0f, //积分系数 I
|
||||
0.0f, //微分系数 D
|
||||
|
||||
-10.0f, //积分限幅
|
||||
10.0f, //积分上限
|
||||
-45.0f, //输出下限
|
||||
@ -404,7 +406,6 @@ float CDriverMainDlg::CorrectAngle(float currentAngle, float targetAngle) {
|
||||
0.023f //时间步长(秒)
|
||||
);
|
||||
|
||||
|
||||
// 规范化角度,确保角度在-180°到180°之间
|
||||
currentAngle = NormalizeAngle(currentAngle);
|
||||
targetAngle = NormalizeAngle(targetAngle);
|
||||
@ -530,7 +531,7 @@ BOOL CDriverMainDlg::OpenCanDevice()
|
||||
return FALSE;
|
||||
}
|
||||
VCI_INIT_CONFIG InitInfo[1];
|
||||
InitInfo->Timing0 = 0x01; //250K
|
||||
InitInfo->Timing0 = 0x03; //250K
|
||||
InitInfo->Timing1 = 0x1C;
|
||||
InitInfo->Filter = 0;
|
||||
InitInfo->AccCode = 0x80000000;
|
||||
@ -1031,7 +1032,7 @@ void CDriverMainDlg::SendCanAGVMoveData(float Vel) {
|
||||
mvDirection = 3; //后退
|
||||
Vel = -Vel;
|
||||
}
|
||||
reSpeed = Vel * 60 / C * 20.2; //RPM
|
||||
reSpeed = Vel * 60 / C * 20.2; //RPM,20.2是减速比。
|
||||
int16_t bytePair = static_cast<int16_t>(reSpeed);
|
||||
uint8_t reSpeedHByte = (bytePair >> 8) & 0xFF; // 高字节
|
||||
uint8_t reSpeedLByte = bytePair & 0xFF; // 低字节
|
||||
|
@ -133,6 +133,7 @@ CString CFastApp::SendMsg2Platform(CString strReceiver, int nMsgType, Json::Valu
|
||||
string strJson = writer.write(root);
|
||||
|
||||
g_pstPipeClient->SendeMsg(WCS_2_WMS_DATA, (char*)strJson.c_str(), strJson.length());
|
||||
|
||||
LogOutToFile("FAST::SendMsg2Platform End");
|
||||
|
||||
return "";
|
||||
|
@ -23,18 +23,18 @@
|
||||
<ProjectGuid>{EDB92B51-C3C2-44DA-B21D-6BB824264D08}</ProjectGuid>
|
||||
<RootNamespace>GrabImage_Display</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
|
@ -121,135 +121,7 @@ void CFastMainDialog::ProcessPipeMsg(int lMsgId, char* pData, int lLen)
|
||||
LogOutToFile("HttpServiceListener::OnRecvRequest End");
|
||||
}
|
||||
|
||||
// TCP服务端线程
|
||||
/*UINT CFastMainDialog::TCPListenerThread(LPVOID pParam) {
|
||||
CFastMainDialog* pThis = (CFastMainDialog*)pParam;
|
||||
SOCKET hServer = pThis->m_hServerSocket;
|
||||
|
||||
while (true) {
|
||||
SOCKET hClient = accept(hServer, NULL, NULL);
|
||||
if (hClient == INVALID_SOCKET) continue;
|
||||
|
||||
char buffer[4096];
|
||||
int bytesRecv = recv(hClient, buffer, sizeof(buffer), 0);
|
||||
if (bytesRecv > 0) {
|
||||
CString strMsg(buffer, bytesRecv);
|
||||
pThis->ProcessTCPMessage(strMsg);
|
||||
}
|
||||
closesocket(hClient);
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
UINT CFastMainDialog::TCPListenerThread(LPVOID pParam) {
|
||||
CFastMainDialog* pThis = (CFastMainDialog*)pParam;
|
||||
SOCKET hServer = pThis->m_hServerSocket;
|
||||
|
||||
while (true) {
|
||||
SOCKET hClient = accept(hServer, NULL, NULL);
|
||||
if (hClient == INVALID_SOCKET) continue;
|
||||
|
||||
// 禁用Nagle算法(可选)
|
||||
int optval = 1;
|
||||
setsockopt(hClient, IPPROTO_TCP, TCP_NODELAY, (char*)&optval, sizeof(optval));
|
||||
|
||||
// 持续接收数据直到连接关闭
|
||||
char buffer[4096];
|
||||
while (true) {
|
||||
int bytesRecv = recv(hClient, buffer, sizeof(buffer), 0);
|
||||
if (bytesRecv <= 0) { // 连接断开或错误
|
||||
LogOutToFile("[TCP] Client disconnected or error: %d", WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
CString strMsg(buffer, bytesRecv);
|
||||
pThis->ProcessTCPMessage(strMsg);
|
||||
}
|
||||
closesocket(hClient); // 最终关闭连接
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 处理收到的TCP消息
|
||||
void CFastMainDialog::ProcessTCPMessage(const CString& strJson) {
|
||||
LogOutToFile("FAST::ProcessTCPMessage Received: %s", strJson);
|
||||
|
||||
Json::Reader reader;
|
||||
Json::Value root;
|
||||
if (!reader.parse((LPCTSTR)strJson, root)) {
|
||||
LogOutToFile("JSON parse error!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证必要字段
|
||||
if (!root.isMember("receiver") || !root.isMember("type")) {
|
||||
LogOutToFile("Invalid message format");
|
||||
return;
|
||||
}
|
||||
|
||||
// 通过现有平台接口转发
|
||||
CString strReceiver = root["receiver"].asString().c_str();
|
||||
int nMsgType = root["type"].asInt();
|
||||
Json::Value params = root.get("params", Json::nullValue);
|
||||
|
||||
theApp.SendMsg2Platform(strReceiver, nMsgType, params);
|
||||
}
|
||||
|
||||
// 启动TCP服务
|
||||
void CFastMainDialog::StartTCPServer()
|
||||
{
|
||||
// 1. 初始化Winsock
|
||||
WSADATA wsaData;
|
||||
int wsResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (wsResult != 0) {
|
||||
LogOutToFile("[TCP] WSAStartup failed: %d", wsResult);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 创建Socket
|
||||
m_hServerSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (m_hServerSocket == INVALID_SOCKET) {
|
||||
LogOutToFile("[TCP] Socket creation failed: %d", WSAGetLastError());
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 设置端口复用(可选)
|
||||
int optval = 1;
|
||||
setsockopt(m_hServerSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval));
|
||||
|
||||
// 4. 绑定端口
|
||||
sockaddr_in service;
|
||||
service.sin_family = AF_INET;
|
||||
service.sin_addr.s_addr = INADDR_ANY;
|
||||
service.sin_port = htons(6000);
|
||||
|
||||
if (::bind(m_hServerSocket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR)
|
||||
{
|
||||
LogOutToFile("[TCP] Bind failed on port 6000: %d", WSAGetLastError());
|
||||
closesocket(m_hServerSocket);
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. 开始监听
|
||||
if (listen(m_hServerSocket, SOMAXCONN) == SOCKET_ERROR)
|
||||
{
|
||||
LogOutToFile("[TCP] Listen failed: %d", WSAGetLastError());
|
||||
closesocket(m_hServerSocket);
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// 6. 启动线程
|
||||
m_pListenerThread = AfxBeginThread(TCPListenerThread, this);
|
||||
if (m_pListenerThread == NULL) {
|
||||
LogOutToFile("[TCP] Thread creation failed!");
|
||||
closesocket(m_hServerSocket);
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
LogOutToFile("[TCP] Server successfully started on port 6000");
|
||||
}
|
||||
BOOL CFastMainDialog::OnInitDialog()
|
||||
{
|
||||
CDialogEx::OnInitDialog();
|
||||
@ -283,7 +155,7 @@ BOOL CFastMainDialog::OnInitDialog()
|
||||
|
||||
//初始化本地相机
|
||||
InitLocalCamera();
|
||||
StartTCPServer(); // 新增TCP服务启动
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
@ -13,9 +13,6 @@ public:
|
||||
CFastMainDialog(CWnd* pParent = NULL); // 标准构造函数
|
||||
virtual ~CFastMainDialog();
|
||||
|
||||
void StartTCPServer();
|
||||
void StopTCPServer();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_MAIN_DIALOG };
|
||||
@ -38,10 +35,4 @@ public:
|
||||
|
||||
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||||
void ProcessPipeMsg(int lMsgId, char* pData, int lLen);
|
||||
|
||||
private:
|
||||
static UINT __cdecl TCPListenerThread(LPVOID pParam);
|
||||
void ProcessTCPMessage(const CString& strJson);
|
||||
CWinThread* m_pListenerThread;
|
||||
SOCKET m_hServerSocket;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{77089A10-F10B-4E0E-B045-86271BFD1A07}</ProjectGuid>
|
||||
<RootNamespace>VcsClient</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
@ -21,7 +21,7 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{CD291D2B-F677-46FC-BC5F-0C4A18CBBC11}</ProjectGuid>
|
||||
<RootNamespace>VcsClient</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
@ -23,7 +23,7 @@
|
||||
<ProjectGuid>{A98ADD5C-021A-494A-9E04-61E7F3220104}</ProjectGuid>
|
||||
<RootNamespace>GrabImage_Display</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
Loading…
Reference in New Issue
Block a user