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.
226 lines
5.6 KiB
C++
226 lines
5.6 KiB
C++
#include "StdAfx.h"
|
|
#include "JoyKeybordControl.h"
|
|
|
|
|
|
CJoyKeybordControl::CJoyKeybordControl(void)
|
|
{
|
|
}
|
|
|
|
|
|
CJoyKeybordControl::~CJoyKeybordControl(void)
|
|
{
|
|
}
|
|
// 串口收来自视频键盘的数
|
|
void GetSerialPortData(char *buffer,const DWORD size)
|
|
{
|
|
memcpy(g_payloadCtrlInstructionFromVK, buffer, size);
|
|
// 如果控制指令来自视频键盘
|
|
if (g_bCtrlFromSoftware == FALSE)
|
|
{
|
|
if (0x12 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 2;
|
|
g_sCtrlInstruction = g_str_VerticalView;
|
|
}
|
|
else if (0x13 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 3;
|
|
g_sCtrlInstruction = g_str_AutoScan;
|
|
}
|
|
else if (0x11 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 1;
|
|
g_sCtrlInstruction = g_str_ManualSlew;
|
|
}
|
|
else if (0x1C == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 10;
|
|
g_sCtrlInstruction = g_str_TurretStow;
|
|
}
|
|
else if (0x1D == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 11;
|
|
g_sCtrlInstruction = g_str_TurretFWD;
|
|
}
|
|
else if (0x23 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 14;
|
|
g_sCtrlInstruction = g_str_CorrelationTracking;
|
|
}
|
|
else if (0x24 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 15;
|
|
g_sCtrlInstruction = g_str_CentroidBlackTracking;
|
|
}
|
|
else if (0x25 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 16;
|
|
g_sCtrlInstruction = g_str_CentroidWhiteTracking;
|
|
}
|
|
else if (0x40 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 25;
|
|
g_sCtrlInstruction = g_str_LRFPowerON;
|
|
}
|
|
else if (0x41 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 26;
|
|
g_sCtrlInstruction = g_str_LRFPowerOFF;
|
|
}
|
|
else if (0x42 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 27;
|
|
g_sCtrlInstruction = g_str_LRFArmed;
|
|
}
|
|
else if (0x43 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 28;
|
|
g_sCtrlInstruction = g_str_LRFSafe;
|
|
}
|
|
else if (0xA2 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol =29;
|
|
g_sCtrlInstruction = g_str_LDArmed;
|
|
}
|
|
else if (0x45 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 30;
|
|
g_sCtrlInstruction = g_str_LDSafe;
|
|
}
|
|
else if (0x46 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 31;
|
|
g_sCtrlInstruction = g_str_LaserNo1;
|
|
}
|
|
else if (0x47 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 32;
|
|
g_sCtrlInstruction = g_str_LaserNo2;
|
|
}
|
|
else if (0x48 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 33;
|
|
g_sCtrlInstruction = g_str_LaserNo3;
|
|
}
|
|
else if (0x49 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 34;
|
|
g_sCtrlInstruction = g_str_LaserNo4;
|
|
}
|
|
else if (0x4A == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 35;
|
|
g_sCtrlInstruction = g_str_LaserNo5;
|
|
}
|
|
else if (0x4B == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 36;
|
|
g_sCtrlInstruction = g_str_LaserNo6;
|
|
}
|
|
else if (0x4C == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 37;
|
|
g_sCtrlInstruction = g_str_LaserNo7;
|
|
}
|
|
else if (0x4D == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 38;
|
|
g_sCtrlInstruction = g_str_LaserNo8;
|
|
}
|
|
else if (0x4E == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 39;
|
|
g_sCtrlInstruction = g_str_LaserNo9;
|
|
}
|
|
else if (0x4F == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 40;
|
|
g_sCtrlInstruction = g_str_LaserNo10;
|
|
}
|
|
else if (0x54 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 42;
|
|
g_sCtrlInstruction = g_str_ICRON;
|
|
}
|
|
else if (0x55 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 43;
|
|
g_sCtrlInstruction = g_str_ICROFF;
|
|
}
|
|
else if (0x56 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 44;
|
|
g_sCtrlInstruction = g_str_DefogON;
|
|
}
|
|
else if (0x58 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 45;
|
|
g_sCtrlInstruction = g_str_DefogOFF;
|
|
}
|
|
else if (0x52 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 48;
|
|
g_sCtrlInstruction = g_str_EOZoomOut;
|
|
}
|
|
else if (0x53 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 49;
|
|
g_sCtrlInstruction = g_str_EOZoomOut;
|
|
}
|
|
else if (0x83 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 62;
|
|
g_sCtrlInstruction = g_str_IRFocusPlus;
|
|
}
|
|
else if (0x84 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 63;
|
|
g_sCtrlInstruction = g_str_IRFocusMinus;
|
|
}
|
|
else if (0x85 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 65;
|
|
g_sCtrlInstruction = g_str_IRZoomOut;
|
|
}
|
|
else if (0x86 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 66;
|
|
g_sCtrlInstruction = g_str_IRZoomIn;
|
|
}
|
|
else if (0x87 == g_payloadCtrlInstructionFromVK[2])
|
|
{
|
|
g_payloadCtrlProtocol = 67;
|
|
g_sCtrlInstruction = g_str_BHWH;
|
|
}
|
|
else
|
|
{
|
|
g_payloadCtrlProtocol = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
void CJoyKeybordControl::OnInitJoyKeybord()
|
|
{
|
|
// 设置视频键盘串口初始化
|
|
CString fileSysName = GetSoftwareCurrentDirectory()+ "\\ini\\" + "config.ini";
|
|
char char_COMName[20];
|
|
GetPrivateProfileString("CONTROL_FROM_COM", "COMName", "0", char_COMName, 20, fileSysName);
|
|
if (!m_Serial.Initialize(char_COMName, 38400))
|
|
{
|
|
::MessageBoxA(NULL, g_str_WarningSerialReceive, g_str_WarningTitle, MB_OK);
|
|
}
|
|
else
|
|
{
|
|
m_Serial.SetComReadCallback(GetSerialPortData);
|
|
}
|
|
|
|
}
|
|
|
|
void CJoyKeybordControl::OnDestoryJoyKeybord()
|
|
{
|
|
// 卸载串口
|
|
if (TRUE == m_Serial.IsInitialized())
|
|
{
|
|
m_Serial.DeInit();
|
|
}
|
|
} |