📄 camera.cpp
字号:
return 1;
}
bool CCamera::SetPreset(int nNum)
{
switch( pCameraList[m_iCurrentCamera].iType ){
case JIMU:
JIMU_SetPreset(nNum);
break;
case MPEG:
MPEG_SetPreset(nNum);
break;
default:
return 0;
}
return 1;
}
bool CCamera::GotoPreset(int nNum)
{
switch( pCameraList[m_iCurrentCamera].iType ){
case JIMU:
JIMU_GotoPreset(nNum);
break;
case MPEG:
MPEG_GotoPreset(nNum);
break;
default:
return 0;
}
return 1;
}
int CCamera::GetNextChimneyID(int nCameraID)
{
int iReturnValue = pCameraList[nCameraID].piCmnID[m_iCurrentChimney + 1];
if(iReturnValue == -1){
m_iCurrentChimney = 0;
}
else{
m_iCurrentChimney = (m_iCurrentChimney + 1) % (MAXCHIMNEY - 1);
}
return iReturnValue;
}
int CCamera::GetCurrentChimneyID(int nCameraID)
{
int iReturnValue = pCameraList[nCameraID].piCmnID[m_iCurrentChimney];
return iReturnValue;
}
int CCamera::GetNextCameraID()
{
m_iCurrentChimney = 0;
m_iCurrentCamera = (m_iCurrentCamera + 1) % 16;
while(pCameraList[m_iCurrentCamera].iType == INVALID){
m_iCurrentCamera = (m_iCurrentCamera + 1) % 16;
}
return m_iCurrentCamera;
}
bool CCamera::GetChimneyQueue(int nCamID, char* lpszCmnQueue)
{
HKEY hKey;
char lpstrValue[300], lpstrTemp[30], lpszMessage[100];
DWORD cbData = 300, dwType;
unsigned long dwRtValue;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\ChimneyID", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
cbData = 200;
sprintf(lpstrTemp, "ChimneyID_Table%d", nCamID);
dwRtValue = RegQueryValueEx(hKey, lpstrTemp, NULL, &dwType, (LPBYTE)lpstrValue, &cbData);
if (dwRtValue != ERROR_SUCCESS){
// FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwRtValue, 0, lpszMessage, 100, NULL);
sprintf(lpszMessage, "找不到指定文件, 请与供应商联系");
MessageBox(NULL, lpszMessage, "error", MB_OK | MB_ICONERROR);
return 0;
}
else
strcpy(lpszCmnQueue, lpstrValue);
return 1;
}
bool CCamera::GetIPAdress(int nCamID, char* lpszIPAdress)
{
HKEY hKey;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
char lpstrValue[100], lpstrTemp[30], lpszMessage[100];
DWORD cbData = 100, dwType;
unsigned long dwRtValue;
cbData = 100;
sprintf(lpstrTemp, "IPAdress%d", nCamID);
dwRtValue = RegQueryValueEx(hKey, lpstrTemp, NULL, &dwType, (LPBYTE)lpstrValue, &cbData);
if (dwRtValue != ERROR_SUCCESS){
// FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwRtValue, 0, lpszMessage, 100, NULL);
sprintf(lpszMessage, "找不到指定文件, 请与供应商联系");
MessageBox(NULL, lpszMessage, "error", MB_OK | MB_ICONERROR);
return 0;
}
else
strcpy(lpszIPAdress, lpstrValue);
return 1;
}
bool CCamera::SetChimneyQueue(int nCamID, char* lpszCmnQueue)
{
int i, j, k;
char lpstrValue[300];
HKEY hKey;
char lpszKey[30];
char lpstrTemp[10];
i = 0;
j = 0;
k = 0;
strcpy(lpstrValue, lpszCmnQueue);
while((lpstrValue[i] != '\0') && (k <= MAXCHIMNEY - 1)){
while((lpstrValue[i] != ',')&&(lpstrValue[i] != '\0')){
lpstrTemp[j] = lpstrValue[i];
i++;
j++;
}
lpstrTemp[j] = '\0';
j = 0;
pCameraList[nCamID].piCmnID[k] = atoi(lpstrTemp);
// skip ','
if(lpstrValue[i] != '\0')
i ++;
k ++;
}
if(k < MAXCHIMNEY){
while(k <= MAXCHIMNEY - 1){
pCameraList[nCamID].piCmnID[k] = -1;
k ++;
}
}
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\Cameras", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
return 0;
}
sprintf(lpszKey, "CmnQ%d", nCamID);
RegSetValueEx(hKey, lpszKey, NULL, REG_SZ, (BYTE*)lpszCmnQueue, strlen(lpszCmnQueue));
RegCloseKey(hKey);
return 1;
}
CCamera::~CCamera()
{
//CloseComm();
}
bool CCamera::MPEG_PanLeft()
{
sprintf(lpszCommand, "La%d", GetPanSpeed());
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopPanLeft()
{
sprintf(lpszCommand, "Lz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_PanRight()
{
sprintf(lpszCommand, "Ra%d", GetPanSpeed());
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopPanRight()
{
sprintf(lpszCommand, "Rz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_TiltUp()
{
sprintf(lpszCommand, "Ua%d", GetPanSpeed());
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopTiltUp()
{
sprintf(lpszCommand, "Uz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_TiltDown()
{
sprintf(lpszCommand, "Da%d", GetPanSpeed());
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopTiltDown()
{
sprintf(lpszCommand, "Dz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_ZoomTelephoto()
{
sprintf(lpszCommand, "Ta");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopZoomTelephoto()
{
sprintf(lpszCommand, "Tz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_ZoomWide()
{
sprintf(lpszCommand, "Wa");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopZoomWide()
{
sprintf(lpszCommand, "Wz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_FocusNear()
{
sprintf(lpszCommand, "Na");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopFocusNear()
{
sprintf(lpszCommand, "Nz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_FocusFar()
{
sprintf(lpszCommand, "Fa");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopFocusFar()
{
sprintf(lpszCommand, "Fz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_IrisOpen()
{
sprintf(lpszCommand, "Oa");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopIrisOpen()
{
sprintf(lpszCommand, "Oz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_IrisClose()
{
sprintf(lpszCommand, "Ca");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_StopIrisClose()
{
sprintf(lpszCommand, "Cz");
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_SetPreset(int nNum)
{
sprintf(lpszCommand, "Pa%d", nNum);
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::MPEG_GotoPreset(int nNum)
{
sprintf(lpszCommand, "Pz%d", nNum);
mySocket.TransmitCommand(lpszCommand, strlen(lpszCommand));
return 1;
}
bool CCamera::JIMU_PanLeft()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x4;
szCommandLine[4] = pnSpeedTable[dwPanSpeed];
szCommandLine[5] = 0x0;
szCommandLine[6] = CheckSum();
nStrLen = 7;
}
//int nStrLen = strlen((char*)szCommandLine);
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x4;
szCommandLine[4] = 0x20;//pnSpeedTable[nSpeed];
szCommandLine[5] = 0x0;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x2b;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_StopPanLeft()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0x0;
szCommandLine[5] = 0x0;
szCommandLine[6] = 0x1;
nStrLen = 7;
}
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0;//pnSpeedTable[nSpeed];
szCommandLine[5] = 0x0;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x0f;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_PanRight()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x2;
szCommandLine[4] = pnSpeedTable[dwPanSpeed];
szCommandLine[5] = 0x0;
szCommandLine[6] = CheckSum();
nStrLen = 7;
}
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x2;
szCommandLine[4] = 0x20;//pnSpeedTable[iSpd];
szCommandLine[5] = 0x0;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x2d;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_StopPanRight()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0x0;
szCommandLine[5] = 0x0;
szCommandLine[6] = 0x1;
nStrLen = 7;
}
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0;//pnSpeedTable[iSpd];
szCommandLine[5] = 0x0;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x0f;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_TiltUp()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x8;
szCommandLine[4] = 0x0;
szCommandLine[5] = pnSpeedTable[dwTiltSpeed];
szCommandLine[6] = CheckSum();
nStrLen = 7;
}
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x10;
szCommandLine[4] = 0;//pnSpeedTable[iSpd];
szCommandLine[5] = 0x20;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x3f;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_StopTiltUp()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0x0;
szCommandLine[5] = 0x0;
szCommandLine[6] = 0x1;
nStrLen = 7;
}
else{
szCommandLine[0] = 0xa0;
szCommandLine[1] = 0x0;
szCommandLine[2] = 0x0;
szCommandLine[3] = 0x0;
szCommandLine[4] = 0;//pnSpeedTable[iSpd];
szCommandLine[5] = 0x0;
szCommandLine[6] = 0xaf;
szCommandLine[7] = 0x0f;
nStrLen = 8;
}
if(pCameraList[m_iCurrentCamera].iAVPort == 1){// Channel 1
if(M7_WriteAuxCom(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
else{
if(M7_WriteAuxCom2(m_hM7, nStrLen, szCommandLine)){
MessageBox(NULL, "WriteComm error", "error", MB_OK | MB_ICONERROR);
return 0;
}
}
return 1;
}
bool CCamera::JIMU_TiltDown()
{
int nStrLen;
if(pCameraList[m_iCurrentCamera].iProtocol == PELCO_D){
szCommandLine[0] = 0xff;
szCommandLine[1] = 0x1;
szCommandLine[2] = 0x0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -