You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

575 lines
18 KiB
C++

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// SendControlCommand.cpp : ʵÏÖÎļþ
//
#include "stdafx.h"
#include "CH91PayloadSoftware.h"
#include "SendControlCommand.h"
#include "afxdialogex.h"
#include "Global.h"
#include "GlobalMember.h"
#include "GlobalMessage.h"
// CSendControlCommand ¶Ô»°¿ò
//struct struCHECK
//{
// struCHECK()
// {
// C0 = C1 = 0;
// };
//
// BYTE C0;
// BYTE C1;
//};
// const UINT16 Crc_Table[256] = // X16+X12+X5+1 1021Óàʽ±í CCITT
// {
// 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
// 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
// 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
// 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
// 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
// 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
// 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
// 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
// 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
// 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
// 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
// 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
// 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
// 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
// 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
// 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
// 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
// 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
// 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
// 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
// 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
// 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
// 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
// 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
// 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
// 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
// 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
// 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
// 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
// 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
// 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
// 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
// };
//const UINT8 Crc_Table[512]=
//{
// 0x0,0x0,0x89,0x11,0x12,0x23,0x9b,0x32,0x24,0x46,0xad,0x57,0x36,0x65,0xbf,0x74,
// 0x48,0x8c,0xc1,0x9d,0x5a,0xaf,0xd3,0xbe,0x6c,0xca,0xe5,0xdb,0x7e,0xe9,0xf7,0xf8,
// 0x81,0x10,0x8,0x1,0x93,0x33,0x1a,0x22,0xa5,0x56,0x2c,0x47,0xb7,0x75,0x3e,0x64,
// 0xc9,0x9c,0x40,0x8d,0xdb,0xbf,0x52,0xae,0xed,0xda,0x64,0xcb,0xff,0xf9,0x76,0xe8,
// 0x2,0x21,0x8b,0x30,0x10,0x2,0x99,0x13,0x26,0x67,0xaf,0x76,0x34,0x44,0xbd,0x55,
// 0x4a,0xad,0xc3,0xbc,0x58,0x8e,0xd1,0x9f,0x6e,0xeb,0xe7,0xfa,0x7c,0xc8,0xf5,0xd9,
// 0x83,0x31,0xa,0x20,0x91,0x12,0x18,0x3,0xa7,0x77,0x2e,0x66,0xb5,0x54,0x3c,0x45,
// 0xcb,0xbd,0x42,0xac,0xd9,0x9e,0x50,0x8f,0xef,0xfb,0x66,0xea,0xfd,0xd8,0x74,0xc9,
// 0x4,0x42,0x8d,0x53,0x16,0x61,0x9f,0x70,0x20,0x4,0xa9,0x15,0x32,0x27,0xbb,0x36,
// 0x4c,0xce,0xc5,0xdf,0x5e,0xed,0xd7,0xfc,0x68,0x88,0xe1,0x99,0x7a,0xab,0xf3,0xba,
// 0x85,0x52,0xc,0x43,0x97,0x71,0x1e,0x60,0xa1,0x14,0x28,0x5,0xb3,0x37,0x3a,0x26,
// 0xcd,0xde,0x44,0xcf,0xdf,0xfd,0x56,0xec,0xe9,0x98,0x60,0x89,0xfb,0xbb,0x72,0xaa,
// 0x6,0x63,0x8f,0x72,0x14,0x40,0x9d,0x51,0x22,0x25,0xab,0x34,0x30,0x6,0xb9,0x17,
// 0x4e,0xef,0xc7,0xfe,0x5c,0xcc,0xd5,0xdd,0x6a,0xa9,0xe3,0xb8,0x78,0x8a,0xf1,0x9b,
// 0x87,0x73,0xe,0x62,0x95,0x50,0x1c,0x41,0xa3,0x35,0x2a,0x24,0xb1,0x16,0x38,0x7,
// 0xcf,0xff,0x46,0xee,0xdd,0xdc,0x54,0xcd,0xeb,0xb9,0x62,0xa8,0xf9,0x9a,0x70,0x8b,
// 0x8,0x84,0x81,0x95,0x1a,0xa7,0x93,0xb6,0x2c,0xc2,0xa5,0xd3,0x3e,0xe1,0xb7,0xf0,
// 0x40,0x8,0xc9,0x19,0x52,0x2b,0xdb,0x3a,0x64,0x4e,0xed,0x5f,0x76,0x6d,0xff,0x7c,
// 0x89,0x94,0x0,0x85,0x9b,0xb7,0x12,0xa6,0xad,0xd2,0x24,0xc3,0xbf,0xf1,0x36,0xe0,
// 0xc1,0x18,0x48,0x9,0xd3,0x3b,0x5a,0x2a,0xe5,0x5e,0x6c,0x4f,0xf7,0x7d,0x7e,0x6c,
// 0xa,0xa5,0x83,0xb4,0x18,0x86,0x91,0x97,0x2e,0xe3,0xa7,0xf2,0x3c,0xc0,0xb5,0xd1,
// 0x42,0x29,0xcb,0x38,0x50,0xa,0xd9,0x1b,0x66,0x6f,0xef,0x7e,0x74,0x4c,0xfd,0x5d,
// 0x8b,0xb5,0x2,0xa4,0x99,0x96,0x10,0x87,0xaf,0xf3,0x26,0xe2,0xbd,0xd0,0x34,0xc1,
// 0xc3,0x39,0x4a,0x28,0xd1,0x1a,0x58,0xb,0xe7,0x7f,0x6e,0x6e,0xf5,0x5c,0x7c,0x4d,
// 0xc,0xc6,0x85,0xd7,0x1e,0xe5,0x97,0xf4,0x28,0x80,0xa1,0x91,0x3a,0xa3,0xb3,0xb2,
// 0x44,0x4a,0xcd,0x5b,0x56,0x69,0xdf,0x78,0x60,0xc,0xe9,0x1d,0x72,0x2f,0xfb,0x3e,
// 0x8d,0xd6,0x4,0xc7,0x9f,0xf5,0x16,0xe4,0xa9,0x90,0x20,0x81,0xbb,0xb3,0x32,0xa2,
// 0xc5,0x5a,0x4c,0x4b,0xd7,0x79,0x5e,0x68,0xe1,0x1c,0x68,0xd,0xf3,0x3f,0x7a,0x2e,
// 0xe,0xe7,0x87,0xf6,0x1c,0xc4,0x95,0xd5,0x2a,0xa1,0xa3,0xb0,0x38,0x82,0xb1,0x93,
// 0x46,0x6b,0xcf,0x7a,0x54,0x48,0xdd,0x59,0x62,0x2d,0xeb,0x3c,0x70,0xe,0xf9,0x1f,
// 0x8f,0xf7,0x6,0xe6,0x9d,0xd4,0x14,0xc5,0xab,0xb1,0x22,0xa0,0xb9,0x92,0x30,0x83,
// 0xc7,0x7b,0x4e,0x6a,0xd5,0x58,0x5c,0x49,0xe3,0x3d,0x6a,0x2c,0xf1,0x1e,0x78,0xf
//};
//struCHECK MakeCheckCRC(UINT8 *ptr,UINT8 len)
//{
// UINT8 temp,i;
// UINT16 crc = 0;
//
// for(i = 0; i < len; i++)
// {
// temp = (UINT8) (crc / 256); // ÒÔ8λ¶þ½øÖÆÊýÔÝ´æCRC µÄ¸ß8 λ
// crc <<= 8; // ×óÒÆ 8 λ
// crc ^= Crc_Table[temp ^ *ptr]; // ¸ß×ֽں͵±Ç°Êý¾ÝXOR ÔÙ²é±í
// ptr++;
// }
// struCHECK ck;
// ck.C1 = (crc>>8);
// ck.C0 = (crc&0xff);
// return ck;
//}
IMPLEMENT_DYNAMIC(CSendControlCommand, CDialogEx)
CSendControlCommand::CSendControlCommand(CWnd* pParent /*=NULL*/)
: CDialogEx(CSendControlCommand::IDD, pParent)
{
// ¸÷±äÁ¿³õʼ»¯
memset(g_payloadCtrlInstruction, 0, 32); // ³õʼ»¯Îª0
g_bCreatUDP = false;
m_wndManual_Search = nullptr;
// ÊÖ¶¯ËÑË÷Ö¸ÁîÅÌ°´Å¥³õʼÒƶ¯ËÙ¶È
m_Speed = 0;
m_Speed_UpDown = 0;
m_Speed_LeftRight = 0;
}
CSendControlCommand::~CSendControlCommand()
{
}
void CSendControlCommand::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CSendControlCommand, CDialogEx)
ON_WM_TIMER()
ON_MESSAGE(WM_SHOW_MANUAL_SEARCH, CSendControlCommand::ManualSpeed)
ON_WM_DESTROY()
END_MESSAGE_MAP()
// CSendControlCommand ÏûÏ¢´¦Àí³ÌÐò
// ÊÖ¶¯ËÑË÷Ö¸ÁîÅÌ
void CALLBACK GetDistRatioAndAngleProc(double distRatio, double angle)
{
if (distRatio >= 0 && distRatio <= 1 && abs(angle) <= 180)
{
if (distRatio > 0.5)
{
distRatio = 0.5;
}
g_MS_Ratio = distRatio;
g_MS_Angle = angle;
::SendMessage(g_SendControlCommandDlgHwnd, WM_SHOW_MANUAL_SEARCH , WPARAM(0), LPARAM(0));
}
}
//ÊÖ¶¯ËÑË÷Ö¸ÁîÅÌ
LRESULT CSendControlCommand::ManualSpeed(WPARAM wParam, LPARAM lParam)
{
// ¶¨ÒåЭÒéÐòºÅ
g_payloadCtrlProtocol = 1001;
if (g_MS_Ratio < 1e-6)
{
g_payloadCtrlProtocol = 0;
}
// ËٶȱäÁ¿´«µÝ
m_Speed = static_cast<int>(2 * 512 * g_MS_Ratio);
m_Speed_LeftRight = static_cast<int>(m_Speed * sin(g_MS_Angle / 180 * CV_PI));
m_Speed_UpDown = static_cast<int>(m_Speed * cos(g_MS_Angle / 180 * CV_PI));
// ¸üÐÂÖ¸ÁîÅÌͼÏñ
ShowManualSearchImg(g_MS_Angle, g_MS_Ratio);
return 0;
}
BOOL CSendControlCommand::OnInitDialog()
{
CDialogEx::OnInitDialog();
// ¸ü¸ÄÖ¸Áî·¢ËÍ֡Ƶ
SetTimer(1,40, nullptr);
g_SendControlCommandDlgHwnd = GetSafeHwnd();
// ¿ØÖÆIPºÍ¶Ë¿Ú°ó¶¨
CString fileSysName = GetSoftwareCurrentDirectory()+ "\\ini\\" + "config.ini";
char LocalIp1[20];
unsigned int LocalPort1 = 0; //±¾µØ¶Ë¿Ú
char RemoteIp1[20];
unsigned int RemotePort1 = 0; //¶Ô·½¶Ë¿Ú
GetPrivateProfileString("UDPInfo_SEND2PAYLOAD", "UDPRemoteIP ", "0", RemoteIp1, 20, fileSysName);
GetPrivateProfileString("UDPInfo_SEND2PAYLOAD", "UDPLocalIP", "0", LocalIp1, 20, fileSysName);
RemotePort1 = GetPrivateProfileInt("UDPInfo_SEND2PAYLOAD", "UDPRemotePort", 0, fileSysName);
LocalPort1 = GetPrivateProfileInt("UDPInfo_SEND2PAYLOAD", "UDPLocalPort", 0, fileSysName);
assert(LocalPort1 != 0 && RemotePort1 != 0);
g_UdpSend2Payload.SetParams(LocalIp1, LocalPort1, RemoteIp1, RemotePort1);
g_bCreatUDP = g_UdpSend2Payload.StartListening();
if( g_bCreatUDP == false)
{
::MessageBoxA(NULL, g_str_WarningPayloadControl, g_str_WarningTitle, MB_OK);
}
//ÊÖ¶¯ËÑË÷¿ØÖÆÃæ°å
if (m_wndManual_Search == nullptr)
{
m_wndManual_Search = new CExportSimpleImgShow();
}
if (g_SendControlCommandDlgHwnd != nullptr && m_wndManual_Search != NULL)
{
m_wndManual_Search->CreateWnd(g_SendControlCommandDlgHwnd);
CRect rect_Manual_Search;
GetDlgItem(IDC_STATIC_MANUAL_SEARCH)->GetWindowRect(&rect_Manual_Search);
ScreenToClient(&rect_Manual_Search);
m_wndManual_Search->MoveWnd(rect_Manual_Search);
m_wndManual_Search->ShowWnd(SW_SHOW);
m_wndManual_Search->SetCallBackFun(GetDistRatioAndAngleProc);
// ÏÔʾͼÏñ
m_ManualSearchImg = imread("back_ManualSearch_English.jpg");
ShowManualSearchImg(0, 0);
}
return TRUE; // return TRUE unless you set the focus to a control
// Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE
}
void CSendControlCommand::OnTimer(UINT_PTR nIDEvent)
{
// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
for( size_t i = 0; i < 32; i++)
{
g_payloadCtrlInstruction[i] = 0x00;
}
g_payloadCtrlInstruction[0] = 0xEB; // Ö¡Í·
g_payloadCtrlInstruction[1] = 0x90;
g_payloadCtrlInstruction[2] = 0x02; // Ä¿µÄµØÖ· Ô´µØÖ·
g_payloadCtrlInstruction[3] = 0x01; // ·É»úIDÔÝʱÖÃΪ¶¨Öµ0
static int cnt = 0;
if (cnt > 255)
{
cnt = 0;
}
g_payloadCtrlInstruction[4] = BYTE(cnt); // Ö¡¼ÆÊý
cnt++;
// Êý¾Ý×¢ÈëÖ¸ÁîÖ¡
g_payloadCtrlInstruction[12] = 0x1F;
// Ö´ÐÐÊó±ê¹öÂÖ¿ØÖÆÊÓ³¡´óСָÁî
// Ñ­»·Èý´Î
static int zoomCnt = 0;
if (g_CtrlFocusThroughMouseWheel == TRUE)
{
if (zoomCnt < 3 )
{
zoomCnt++;
}
else
{
zoomCnt = 0;
g_bCtrlFromSoftware = FALSE;
}
}
else
{
zoomCnt = 0;
}
switch(g_payloadCtrlProtocol)
{
case 1: // ËÙ¶ÈÅäÖÃ
g_payloadCtrlInstruction[29] = 0x00;
g_payloadCtrlInstruction[25] = 0x00;
g_payloadCtrlInstruction[26] = 0x00;
g_payloadCtrlInstruction[27] = 0x00;
g_payloadCtrlInstruction[28] = 0x00;
g_sCtrlInstruction = "ËÙ¶ÈÅäÖÃ";
break;
case 2: // Ëø¶¨Ä£Ê½
g_payloadCtrlInstruction[29] = 0x15;
g_sCtrlInstruction = "Ëø¶¨Ä£Ê½";
break;
case 3: // ɨÃèģʽ
g_payloadCtrlInstruction[29] = 0x17;
g_sCtrlInstruction = "ɨÃèģʽ";
break;
case 4: // Êý×ÖÒýµ¼Ä£Ê½
g_payloadCtrlInstruction[29] = 0x19;
g_payloadCtrlInstruction[25] = INT16(g_Guide_Pitch * 36000 / 360) & 0xFF;
g_payloadCtrlInstruction[26] = (INT16(g_Guide_Pitch * 36000 / 360) >> 8) & 0xFF;
g_payloadCtrlInstruction[27] = INT16(g_Guide_Azimuth * 36000 / 360) & 0xFF;
g_payloadCtrlInstruction[28] = (INT16(g_Guide_Azimuth * 36000 / 360) >> 8) & 0xFF;
g_sCtrlInstruction = "Êý×ÖÒýµ¼";
break;
case 5: // ƽ̨¸´Î»
g_payloadCtrlInstruction[29] = 0x1B;
g_sCtrlInstruction = "ƽ̨¸´Î»";
break;
case 6: // ²¹Æ¯·½Î»-
g_payloadCtrlInstruction[29] = 0x1D;
g_sCtrlInstruction = "²¹Æ¯·½Î»-";
break;
case 7: // ²¹Æ¯·½Î»+
g_payloadCtrlInstruction[29] = 0x1F;
g_sCtrlInstruction = "²¹Æ¯·½Î»+";
break;
case 8: // ²¹Æ¯¸©Ñö-
g_payloadCtrlInstruction[29] = 0x21;
g_sCtrlInstruction = "²¹Æ¯¸©Ñö-";
break;
case 9: // ²¹Æ¯¸©Ñö+
g_payloadCtrlInstruction[29] = 0x23;
g_sCtrlInstruction = g_sCtrlInstruction = "²¹Æ¯¸©Ñö+";
break;
case 10: // ÊÖ¶¯Ä£Ê½
g_payloadCtrlInstruction[29] = 0x25;
g_sCtrlInstruction = "ÊÖ¶¯Ä£Ê½";
break;
case 11: // Ä¿±ê¸ú×Ù
g_payloadCtrlInstruction[29] = 0x27;
g_payloadCtrlInstruction[25] = INT16(g_TrackOffset.y) & 0xFF;
g_payloadCtrlInstruction[26] = (INT16(g_TrackOffset.y) >> 8) & 0xFF;
g_payloadCtrlInstruction[27] = INT16(g_TrackOffset.x / 2) & 0xFF;
g_payloadCtrlInstruction[28] = (INT16(g_TrackOffset.x / 2) >> 8) & 0xFF;
g_sCtrlInstruction = "Ä¿±ê¸ú×Ù";
break;
case 12: // ºìÍâ°×ÈÈ
g_payloadCtrlInstruction[29] = 0x81;
g_sCtrlInstruction = "ºìÍâ°×ÈÈ";
break;
case 13: // ºìÍâºÚÈÈ
g_payloadCtrlInstruction[29] = 0x82;
g_sCtrlInstruction = "ºìÍâºÚÈÈ";
break;
case 14: // EOÊÓ³¡Ð¡
g_payloadCtrlInstruction[29] = 0x85;
if (g_CtrlFocusThroughMouseWheel == true && zoomCnt == 3)
{
g_CtrlFocusThroughMouseWheel = false;
g_payloadCtrlProtocol = 0;
}
g_sCtrlInstruction = "EOÊÓ³¡Ð¡";
break;
case 15: // EOÊÓ³¡´ó
g_payloadCtrlInstruction[29] = 0x86;
if (g_CtrlFocusThroughMouseWheel == true && zoomCnt == 3)
{
g_CtrlFocusThroughMouseWheel = false;
g_payloadCtrlProtocol = 0;
}
g_sCtrlInstruction = "EOÊÓ³¡´ó";
break;
case 16: // IRÊÓ³¡Ð¡
g_payloadCtrlInstruction[29] = 0x87;
if (g_CtrlFocusThroughMouseWheel == true && zoomCnt == 3)
{
g_CtrlFocusThroughMouseWheel = false;
g_payloadCtrlProtocol = 0;
}
g_sCtrlInstruction = "IRÊÓ³¡Ð¡";
break;
case 17: // IRÊÓ³¡´ó
g_payloadCtrlInstruction[29] = 0x89;
if (g_CtrlFocusThroughMouseWheel == true && zoomCnt == 3)
{
g_CtrlFocusThroughMouseWheel = false;
g_payloadCtrlProtocol = 0;
}
g_sCtrlInstruction = "IRÊÓ³¡´ó";
break;
case 18: // OSD on/off
g_payloadCtrlInstruction[29] = 0xA1;
g_sCtrlInstruction = "OSD ON/OFF";
break;
case 19: // ͼÏñÇл»
g_payloadCtrlInstruction[29] = 0xA3;
g_sCtrlInstruction = "ͼÏñÇл»";
break;
case 20: // »­Öл­¿ª
g_payloadCtrlInstruction[29] = 0xB5;
g_sCtrlInstruction = "»­Öл­¿ª";
break;
case 21: // »­Öл­¹Ø
g_payloadCtrlInstruction[29] = 0xB6;
g_sCtrlInstruction = "»­Öл­¹Ø";
break;
case 22: // ͼÏñÎȶ¨¹Ø
g_payloadCtrlInstruction[29] = 0xB7;
g_sCtrlInstruction = "ͼÏñÎȶ¨¹Ø";
break;
case 23: // ͼÏñÎȶ¨¿ª
g_payloadCtrlInstruction[29] = 0xB8;
g_sCtrlInstruction = "ͼÏñÎȶ¨¿ª";
break;
case 24: // ¿É¼û¹â͸Îí1
g_payloadCtrlInstruction[29] = 0xBB;
g_sCtrlInstruction = "¿É¼û¹â͸Îí1";
break;
case 25: // ¿É¼û¹â͸Îí2
g_payloadCtrlInstruction[29] = 0xBC;
g_sCtrlInstruction = "¿É¼û¹â͸Îí2";
break;
case 26: // ¿É¼û¹â͸Îí3
g_payloadCtrlInstruction[29] = 0xBD;
g_sCtrlInstruction = "¿É¼û¹â͸Îí3";
break;
case 27: // ¿É¼û¹â͸Îí¹Ø
g_payloadCtrlInstruction[29] = 0xBE;
g_sCtrlInstruction = "¿É¼û¹â͸Îí¹Ø";
break;
case 28: // ¿ªÊ¼Á¬ÐøÕÕÏà
g_payloadCtrlInstruction[29] = 0xC1;
g_sCtrlInstruction = "Á¬ÐøÕÕÏà";
break;
case 29: // Í£Ö¹ÕÕÏà
g_payloadCtrlInstruction[29] = 0xC3;
g_sCtrlInstruction = "Í£Ö¹ÕÕÏà";
break;
case 30: // ÅÄÒ»ÕÅÕÕ
g_payloadCtrlInstruction[29] = 0xC6;
g_sCtrlInstruction = "ÅÄÒ»ÕÅÕÕ";
break;
case 31: // ¼¤¹â²â¾à¿ª
g_payloadCtrlInstruction[29] = 0x91;
g_sCtrlInstruction = "¼¤¹â²â¾à¿ª";
break;
case 32: // ¼¤¹â²â¾à¹Ø
g_payloadCtrlInstruction[29] = 0x92;
g_sCtrlInstruction = "¼¤¹â²â¾à¹Ø";
break;
case 33: // ¼¤¹âµçÔ´¿ª
g_payloadCtrlInstruction[29] = 0x93;
g_sCtrlInstruction = "¼¤¹âµçÔ´¿ª";
break;
case 34: // ¼¤¹âµçÔ´¹Ø
g_payloadCtrlInstruction[29] = 0x94;
g_sCtrlInstruction = "¼¤¹âµçÔ´¹Ø";
break;
// ÐèÒª¶ÔÕÕЭÒé½øÐÐÐÞ¸Ä
case 1001: // µ±Êó±êÍ϶¯ÔغÉÐýתʱ£¬g_payloadCtrlProtocol ¶¨ÒåΪ1001; ¼ûº¯Êý£ºManualSpeed
// ÊÖ¶¯
if ((g_CH96TransFJData.ZH_Pitch>0)&&(m_Speed_UpDown>0))
{
g_payloadCtrlInstruction[25] = 0;
g_payloadCtrlInstruction[26] = 0;
g_payloadCtrlInstruction[27] = INT16(m_Speed_LeftRight) & 0xFF;
g_payloadCtrlInstruction[28] = (INT16(m_Speed_LeftRight) >> 8) & 0xFF;
g_bCtrlFromSoftware = TRUE;
}
else
{
g_payloadCtrlInstruction[25] = INT16(m_Speed_UpDown) & 0xFF;
g_payloadCtrlInstruction[26] = (INT16(m_Speed_UpDown) >> 8) & 0xFF;
g_payloadCtrlInstruction[27] = INT16(m_Speed_LeftRight) & 0xFF;
g_payloadCtrlInstruction[28] = (INT16(m_Speed_LeftRight) >> 8) & 0xFF;
}
g_bCtrlFromSoftware = TRUE;
break;
default:
break;
}
// »ñÈ¡CRCУÑéλ ¼ÆËãg_payloadCtrlInstruction[30-31]
// ÅäºÏCH96ЭÒé½øÐиü¸Ä
BYTE _PayloadCtrlInstruction[28];
memcpy(&_PayloadCtrlInstruction, g_payloadCtrlInstruction + 2, 28);
struCHECK tempstruCheck = MakeCheckCRC(_PayloadCtrlInstruction, 28);
g_payloadCtrlInstruction[30] = tempstruCheck.C0;
g_payloadCtrlInstruction[31] = tempstruCheck.C1;
// UDP ·¢Íù·É¿ØÈí¼þ
if (g_bCreatUDP == true)
{
g_UdpSend2Payload.WriteBuffer(g_payloadCtrlInstruction, 32);
}
// ·¢ËÍÏûÏ¢, ÈÃÖ÷´°¿ÚÏÔʾ·¢ËÍÖ¸Áî
//::PostMessageA(g_mainDlgHwnd, WM_SHOW_CTRL_INSTRUCTIONS, 0, 0);
// ÊÖ¶¯¼°Ä¿±ê¸ú×ÙÑ­»·Ö¸Áî
static int Cnt = 0; // ¼ÆÊýÓÃ
if (g_payloadCtrlProtocol == 10 || g_payloadCtrlProtocol == 11)
{
if (Cnt < 4)
{
Cnt++;
}
else
{
Cnt = 0;
g_payloadCtrlProtocol = 0;
}
}
else
{
Cnt = 0;
}
// ¸ü¸ÄÊÖ¶¯ËÑË÷Ö¸ÁîÅÌ°´Å¥ÑÕÉ«£¬Ö»ÓиıäÓÐЧָÁîʱ²Åµ÷ÓÃÏÔʾ
if (g_payloadCtrlProtocol >=1 && g_payloadCtrlProtocol <= 34)
{
ShowManualSearchImg(0, 0);
}
CDialogEx::OnTimer(nIDEvent);
}
void CSendControlCommand::ShowManualSearchImg( double Angle, double Ratio)
{
// ÊäÈëÅжÏ
if (abs(Angle) > 180 || Ratio < 0 || Ratio > 1)
{
return;
}
// ÏÞÖÆ»æÖư뾶
double R = m_ManualSearchImg.cols / 2 * Ratio; // ±ÈÀý°ë¾¶
if (R > 110)
{
R = 110;
}
cv::Point drawPt(0,0);
Angle = Angle / 180 * CV_PI;
drawPt.x = static_cast<int>(R * sin(Angle) + m_ManualSearchImg.cols / 2 + 0.5);
drawPt.y = static_cast<int>(-R * cos(Angle) + m_ManualSearchImg.rows / 2 + 0.5);
cv::Mat local;
m_ManualSearchImg.copyTo(local);
if (g_sCtrlInstruction == "ÊÖ¶¯Ä£Ê½")
{
cv::circle(local, drawPt, 20, cv::Scalar(52, 116, 64), -1);
}
else
{
cv::Point drawPt(0,0);
drawPt.x = static_cast<int>(m_ManualSearchImg.cols / 2 + 0.5);
drawPt.y = static_cast<int>(m_ManualSearchImg.rows / 2 + 0.5);
cv::circle(local, drawPt, 20, cv::Scalar(31, 31, 197), -1);
}
if (m_wndManual_Search != nullptr)
{
BITMAPINFO info;
info.bmiHeader.biBitCount = 24;
info.bmiHeader.biHeight = local.rows;
info.bmiHeader.biWidth = local.cols;
m_wndManual_Search->ShowImage(&info, local.data);
}
}
void CSendControlCommand::OnDestroy()
{
CDialogEx::OnDestroy();
// TODO: ÔÚ´Ë´¦Ìí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂë
KillTimer(1);
}