// PageControlPtz.cpp: implementation of the CPageControlPtz class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "mgrnve.h" #include "ConnectionManager.h" #include "PageControlPtz.h" #include "proc_cyber2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // Define for Pelco-D // Byte 1 ; Sync Byte #define SYNC_BYTE1 0xFF // Byte 2 ; Address // Byte 3 ; Command1 #define DB3_CMD_SENSE 0x80 // On/Off #define DB3_CMD_RESERVED1 0x40 #define DB3_CMD_RESERVED2 0x20 #define DB3_CMD_AUTOSCAN 0x10 // Auto/Manual Scan #define DB3_CMD_CAMERAON 0x08 // Camera On/Off #define DB3_CMD_IRISCLOSE 0x04 #define DB3_CMD_IRISOPEN 0x02 #define DB3_CMD_FOCUSNEAR 0x01 #define DB4_CMD_FOCUSFAR 0x80 #define DB4_CMD_ZOOMOUT 0x40 //wide #define DB4_CMD_ZOOMIN 0x20 //tele #define DB4_CMD_TILTDOWN 0x10 #define DB4_CMD_TILTUP 0x08 #define DB4_CMD_PANLEFT 0x04 #define DB4_CMD_PANRIGHT 0x02 #define DB5_PANSPEED 0x00 // 0 : stop #define DB6_TILTSPEED 0x00 // 0 : stop // End of define for Pelco-D ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Define for Pelco-P // Byte 1 ; Sync Byte #define PELCO_P_DB1_STX 0xA0 // Byte 2 ; Address // Byte 3 ; Command1 #define PELCO_P_DB3_CMD_RESERVED1 0x80 #define PELCO_P_DB3_CMD_CAMERAON 0x40 #define PELCO_P_DB3_CMD_AUTOSCAN 0x20 // Auto/Manual Scan #define PELCO_P_DB3_CMD_CAMERAONOFF 0x10 #define PELCO_P_DB3_CMD_IRISCLOSE 0x08 #define PELCO_P_DB3_CMD_IRISOPEN 0x04 #define PELCO_P_DB3_CMD_FOCUSNEAR 0x02 #define PELCO_P_DB3_CMD_FOCUSFAR 0x01 #define PELCO_P_DB4_CMD_RESERVED1 0x80 #define PELCO_P_DB4_CMD_ZOOMOUT 0x40 //wide #define PELCO_P_DB4_CMD_ZOOMIN 0x20 //tele #define PELCO_P_DB4_CMD_TILTDOWN 0x10 #define PELCO_P_DB4_CMD_TILTUP 0x08 #define PELCO_P_DB4_CMD_PANLEFT 0x04 #define PELCO_P_DB4_CMD_PANRIGHT 0x02 #define PELCO_P_DB4_CMD_RESERVED2 0x01 #define PELCO_P_DB5_PANSPEED 0x00 // 0 : stop #define PELCO_P_DB6_TILTSPEED 0x00 // 0 : stop #define PELCO_P_DB7_ETX 0xAF // End of define for Pelco-P ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Define for Mark Mercer 232MX-B9_1 #define MM_STX 0x5B // '[' #define MM_ETX 0x5D // ']' // End of define for Mark Mercer 232MX-B9_1 ///////////////////////////////////////////////////////////////////////////// #define PTZ_ADDR 1 #define PT_MAX_SPEED 0x3F #define PT_MID_SPEED 0x1F #define PTZ_STEP_DELAY 150 #define CHAR_DELAY FALSE enum PTZ_COMMAND { PTZ_UP = 1, PTZ_DOWN = 2, PTZ_LEFT = 3, PTZ_RIGHT = 4, PTZ_STOP = 5, PTZ_ZOOMIN = 6, PTZ_ZOOMOUT = 7, PTZ_FOCUS_NEAR = 8, PTZ_FOCUS_FAR = 9, PTZ_PAN_STOP = 20, PTZ_TILT_STOP = 21, PTZ_ZOOM_STOP = 22, PTZ_FOCUS_STOP = 23, PTZ_INIT = 99, PTZ_DELAY = 100, }; enum PTZ_PROTOCOL { PTZ_Pelco_P = 0, PTZ_Pelco_D = 1, PTZ_Custom01 = 2, PTZ_232MX_B9 = 3, PTZ_CYBER_SCAN2 = 4,// - cjy, 07_0417 17:19 PTZ_Custom03 = 5, }; #define UM_CTRL_PTZ_BTN_DOWN WM_USER+0x0211 #define UM_CTRL_PTZ_BTN_UP WM_USER+0x0212 #define RS232_PORT_NUM 0 #define RS485_PORT_NUM 1 #define CYBER2_TIMER 1 ///////////////////////////////////////////////////////////////////////////// // CCtrlPtzButton class CCtrlPtzButton::CCtrlPtzButton(CPageControlPtz* pParent, UINT uID) : CWnd() { //{{AFX_DATA_INIT(CCtrlPtzButton) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_pPage = pParent; m_uId = uID; } BEGIN_MESSAGE_MAP(CCtrlPtzButton, CWnd) //{{AFX_MSG_MAP(CCtrlPtzButton) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() //}}AFX_MSG_MAP END_MESSAGE_MAP() #if 0 void CCtrlPtzButton::SetContainer(CPageControlPtz* pPage, UINT uiBtnId) { m_pPage = pPage; m_uId = uiBtnId; } #endif void CCtrlPtzButton::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_pPage->OnCtrlPtzBtnDown(m_uId); CWnd::OnLButtonDown(nFlags, point); } void CCtrlPtzButton::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_pPage->OnCtrlPtzBtnUp(m_uId); CWnd::OnLButtonUp(nFlags, point); } BOOL CCtrlPtzButton::DestroyWindow() { // TODO: Add your specialized code here and/or call the base class m_pPage = NULL; return CWnd::DestroyWindow(); } ////////////////////////////////////////////////////////////////////// // CPageControlPtz dialog CPageControlPtz::CPageControlPtz(CWnd* pParent, CMgrNVE* pMgrCM, CConnectionManager *pConnMgr) : CParamDlg(CPageControlPtz::IDD, pParent, pMgrCM, pConnMgr) { m_iLastCmd = 0; m_nCameraID = 1; ZeroMemory(m_pTextCmd, sizeof(m_pTextCmd)); //{{AFX_DATA_INIT(CPageControlPtz) //}}AFX_DATA_INIT } void CPageControlPtz::DoDataExchange(CDataExchange* pDX) { m_btnUp = new CCtrlPtzButton(this, IDC_BUTTON_UP); m_btnDown = new CCtrlPtzButton(this, IDC_BUTTON_DOWN); m_btnLeft = new CCtrlPtzButton(this, IDC_BUTTON_LEFT); m_btnRight = new CCtrlPtzButton(this, IDC_BUTTON_RIGHT); m_btnZoomIn = new CCtrlPtzButton(this, IDC_BUTTON_ZOOMIN); m_btnZoomOut = new CCtrlPtzButton(this, IDC_BUTTON_ZOOMOUT); m_btnUpSlow = new CCtrlPtzButton(this, IDC_BUTTON_UP_SLOW); m_btnDownSlow = new CCtrlPtzButton(this, IDC_BUTTON_DOWN_SLOW); m_btnLeftSlow = new CCtrlPtzButton(this, IDC_BUTTON_LEFT_SLOW); m_btnRightSlow = new CCtrlPtzButton(this, IDC_BUTTON_RIGHT_SLOW); m_btnFocusNear = new CCtrlPtzButton(this, IDC_BUTTON_FOCUS_NEAR); m_btnFocusFar = new CCtrlPtzButton(this, IDC_BUTTON_FOCUS_FAR); m_btnInit = new CCtrlPtzButton(this, IDC_BUTTON_INIT); CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPageControlPtz) DDX_Control(pDX, IDC_CHECK_COM_OPEN, m_btnComOpen); DDX_Control(pDX, IDC_COMBO_COM_PORT, m_cbComPort); DDX_Control(pDX, IDC_CHECK_TEXT, m_chkText); DDX_Control(pDX, IDC_CB_CAM_TYPE, m_cbCamType); //}}AFX_DATA_MAP DDX_Control(pDX, IDC_BUTTON_UP, *m_btnUp); DDX_Control(pDX, IDC_BUTTON_DOWN, *m_btnDown); DDX_Control(pDX, IDC_BUTTON_LEFT, *m_btnLeft); DDX_Control(pDX, IDC_BUTTON_RIGHT, *m_btnRight); DDX_Control(pDX, IDC_BUTTON_ZOOMIN, *m_btnZoomIn); DDX_Control(pDX, IDC_BUTTON_ZOOMOUT, *m_btnZoomOut); DDX_Control(pDX, IDC_BUTTON_UP_SLOW, *m_btnUpSlow); DDX_Control(pDX, IDC_BUTTON_DOWN_SLOW, *m_btnDownSlow); DDX_Control(pDX, IDC_BUTTON_LEFT_SLOW, *m_btnLeftSlow); DDX_Control(pDX, IDC_BUTTON_RIGHT_SLOW, *m_btnRightSlow); DDX_Control(pDX, IDC_BUTTON_FOCUS_NEAR, *m_btnFocusNear); DDX_Control(pDX, IDC_BUTTON_FOCUS_FAR, *m_btnFocusFar); DDX_Control(pDX, IDC_BUTTON_INIT, *m_btnInit); DDX_Control(pDX, IDC_COMBO_CAMERA_ID, m_ctrlCameraID); } BEGIN_MESSAGE_MAP(CPageControlPtz, CDialog) //{{AFX_MSG_MAP(CPageControlPtz) ON_BN_CLICKED(IDC_CHECK_COM_OPEN, OnCheckCOMOpen) ON_CBN_SELCHANGE(IDC_CB_CAM_TYPE, OnSelchangeCbCamType) ON_CBN_KILLFOCUS(IDC_COMBO_CAMERA_ID, OnKillfocusComboCameraId) ON_CBN_SELENDOK(IDC_COMBO_CAMERA_ID, OnSelendokComboCameraId) ON_WM_TIMER() //}}AFX_MSG_MAP ON_WM_SERIAL(OnSerialMsg) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPageControlPtz message handlers ULONG g_Baudrate[MAX_BAUDRATE_COUNT] = { 1200, 2400, 4800, 9600, 19200, 38400, 115200 }; BOOL CPageControlPtz::OnInitDialog() { CDialog::OnInitDialog(); m_pNet5Api = m_pConnection->GetNet5Api(); m_pMsgMgr = m_pMgrNVE->GetMsgManager(); m_pStorage = m_pMgrNVE->GetStorage(); #if 0 CString str; if(m_iPtzProtocol == PTZ_Pelco_P) { str.FormatV("%s","PTZ: Pelco_P 9600"); } else if(m_iPtzProtocol == PTZ_Pelco_D) { str.FormatV("%s","PTZ: Pelco_D 9600"); } else if(m_iPtzProtocol == PTZ_Custom01) { str.FormatV("%s","PTZ: Custom01 4800"); } CStatic *pE = (CStatic*)GetDlgItem(IDC_STATIC_PROTOCOL); if(pE) { pE->SetWindowText(str); } #endif m_cbCamType.AddString("Pelco_P 9600"); m_cbCamType.AddString("Pelco_D 9600"); m_cbCamType.AddString("Custom01 4800"); m_cbCamType.AddString("232MX_B9_1"); //m_cbCamType.AddString("CyberScan2"); // - cjy, 07_0417 17:19 m_cbCamType.AddString("Custom02 9600"); // - cjy, 07_0426 17:00 m_cbCamType.AddString("Custom03 38400"); ULONG uLen; SSVType type; ULONG uValue; if (SUCCEEDED(m_pStorage->Read("CamType", &type, &uLen, &uValue))) { m_cbCamType.SetCurSel(uValue); }else{ m_cbCamType.SetCurSel(0); } m_iPtzProtocol = m_cbCamType.GetCurSel(); GetDlgItem(IDC_COMBO_COM_PORT)->SendMessage(CB_SETCURSEL, 0, NULL); ////////Camera ID char strCamera[4]; for(ULONG i = 0; i < 999; i++) { _itoa(i+1, strCamera, 10); m_ctrlCameraID.AddString(strCamera); } m_nCameraID = GetPrivateProfileInt("CAMERA_ID", "CameraID" , 1, "Custom01CameraID.ini"); m_ctrlCameraID.SetCurSel(m_nCameraID - 1); ////////Camera ID end OnSelchangeCbCamType(); return TRUE; } BOOL CPageControlPtz::DestroyWindow() { // TODO: Add your specialized code here and/or call the base class delete m_btnUp; delete m_btnDown; delete m_btnLeft; delete m_btnRight; delete m_btnZoomIn; delete m_btnZoomOut; delete m_btnUpSlow; delete m_btnDownSlow; delete m_btnLeftSlow; delete m_btnRightSlow; delete m_btnFocusNear; delete m_btnFocusFar; delete m_btnInit; return CParamDlg::DestroyWindow(); } void CPageControlPtz::OnCtrlPtzBtnDown(UINT uId) { // id¸¦ ¼öµ¿ÀÔ·ÂÀ¸·Î ¹Ù²Ù°í ptz¹öÆ°À» ´©¸£´Â°æ¿ì focus lost¸Þ½ÃÁöº¸´Ù btn downÀÌ // ¸ÕÀú ¹ß»ýÇÕ´Ï´Ù. ±×·¡¼­ °­Á¦·Î ¸ÕÀú id°¡ ¹Ù²¼´ÂÁö üũÇØÁÖ°Ô ÇÕ´Ï´Ù. OnSelendokComboCameraId(); ActButtonPtz(uId); if(m_iPtzProtocol == PTZ_CYBER_SCAN2) { m_LastuID = uId; SetTimer(CYBER2_TIMER, 300, NULL); } } void CPageControlPtz::ActButtonPtz(UINT uId) { if(uId == IDC_BUTTON_UP) { MakeNSendCmd(PTZ_UP, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_DOWN) { MakeNSendCmd(PTZ_DOWN, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_LEFT) { MakeNSendCmd(PTZ_LEFT, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_RIGHT) { MakeNSendCmd(PTZ_RIGHT, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_ZOOMIN) { MakeNSendCmd(PTZ_ZOOMIN, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_ZOOMOUT) { MakeNSendCmd(PTZ_ZOOMOUT, PT_MAX_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_UP_SLOW) { MakeNSendCmd(PTZ_UP, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_DOWN_SLOW) { MakeNSendCmd(PTZ_DOWN, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_LEFT_SLOW) { MakeNSendCmd(PTZ_LEFT, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_RIGHT_SLOW) { MakeNSendCmd(PTZ_RIGHT, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_FOCUS_NEAR) { MakeNSendCmd(PTZ_FOCUS_NEAR, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_FOCUS_FAR) { MakeNSendCmd(PTZ_FOCUS_FAR, PT_MID_SPEED, m_iPtzProtocol); } else if(uId == IDC_BUTTON_INIT) { MakeNSendCmd(PTZ_INIT, PT_MID_SPEED, m_iPtzProtocol); } } void CPageControlPtz::OnCtrlPtzBtnUp(UINT uId) { // for cyber scan2 KillTimer(CYBER2_TIMER); if (m_chkText.GetCheck()) { return; } if(m_iPtzProtocol == PTZ_Custom01) { int nextStop = 0; if(m_iLastCmd == PTZ_DOWN || m_iLastCmd == PTZ_UP) { nextStop = PTZ_TILT_STOP; } else if(m_iLastCmd == PTZ_LEFT || m_iLastCmd == PTZ_RIGHT) { nextStop = PTZ_PAN_STOP; } else if(m_iLastCmd == PTZ_ZOOMIN || m_iLastCmd == PTZ_ZOOMOUT) { nextStop = PTZ_ZOOM_STOP; } else if(m_iLastCmd == PTZ_FOCUS_NEAR || m_iLastCmd == PTZ_FOCUS_FAR) { nextStop = PTZ_FOCUS_STOP; } else { return; } MakeNSendCmd(nextStop, 0, m_iPtzProtocol); } else if(m_iPtzProtocol == PTZ_CYBER_SCAN2) { int nextStop = 0; // if(m_iLastCmd == PTZ_DOWN || m_iLastCmd == PTZ_UP) { // nextStop = PTZ_TILT_STOP; // } else if(m_iLastCmd == PTZ_LEFT || m_iLastCmd == PTZ_RIGHT) { // nextStop = PTZ_PAN_STOP; if(m_iLastCmd == PTZ_ZOOMIN || m_iLastCmd == PTZ_ZOOMOUT) { nextStop = PTZ_ZOOM_STOP; } else if(m_iLastCmd == PTZ_FOCUS_NEAR || m_iLastCmd == PTZ_FOCUS_FAR) { nextStop = PTZ_FOCUS_STOP; } else { MakeNSendCmd(PTZ_STOP, 0, m_iPtzProtocol); return; } MakeNSendCmd(nextStop, 0, m_iPtzProtocol); } else if(m_iPtzProtocol == PTZ_Custom03) { // do nothing }else { MakeNSendCmd(PTZ_STOP, 0, m_iPtzProtocol); } } BOOL CPageControlPtz::MakeNSendCmd(int iCmd, BYTE bytSpeed, int iProtocal) { PBYTE pCmd; ULONG uSize; if(iProtocal == PTZ_Pelco_P){ pCmd = m_pPelcoPCmd; uSize = sizeof(m_pPelcoPCmd); MakePtzCmd(iCmd, iProtocal, pCmd, bytSpeed); } else if(iProtocal == PTZ_Pelco_D) { pCmd = m_pPelcoDCmd; uSize = sizeof(m_pPelcoDCmd); MakePtzCmd(iCmd, iProtocal, pCmd, bytSpeed); } else if(iProtocal == PTZ_Custom01) { int rsBytes = 0; pCmd = m_pCustom01Cmd; //uSize = sizeof(m_pCustom01Cmd); MakeEblexPtzCmd(iCmd, pCmd, bytSpeed, &rsBytes); uSize = rsBytes; } else if(iProtocal == PTZ_232MX_B9) { int rsBytes = 0; pCmd = m_p232MXB9Cmd; //uSize = sizeof(m_p232MXB9Cmd); Make232MXB9PtzCmd(iCmd, pCmd, bytSpeed, &rsBytes); uSize = rsBytes; } else if(iProtocal == PTZ_CYBER_SCAN2) { // - cjy, 07_0417 17:48 int rsBytes = 0; pCmd = m_pCyberScan2Cmd; //uSize = sizeof(m_p232MXB9Cmd); MakeCyberScan2PtzCmd(iCmd, pCmd, bytSpeed, &rsBytes); uSize = rsBytes; } else if(iProtocal == PTZ_Custom03) { int rsBytes = 0; pCmd = m_pCustom03Cmd; MakeCustom03PtzCmd(iCmd, pCmd, bytSpeed, &rsBytes); uSize = rsBytes; } else { TRACE("Set PTZ protocol error\n"); return FALSE; } if (m_chkText.GetCheck()) { pCmd = (PBYTE)m_pTextCmd; uSize = strlen(m_pTextCmd); MakeTextCmd(iCmd, (char*)pCmd); } ULONG uPortNum = RS485_PORT_NUM; if (!m_pNet5Api->Net5Command(NET5_NC_SEND_SERIAL_DATA, &uPortNum, (ULONG*)pCmd, &uSize, NULL)) { m_pMgrNVE->GetMsgManager()->PushErrorCodeF("Net5Command[%d] failed\n", NET5_NC_SEND_SERIAL_DATA); m_pMgrNVE->GetMsgManager()->Show(TRUE); } #if 0 for(int i=0; i 32)? 32:dwRead; TRACE("===Transfer Serial Data[%d] : ", TransSize); for(i = 0 ; i < TransSize ; i++){ TRACE("%X ", pTransData[i]); } TRACE("\n"); ULONG uPortNum = 1; if (!m_pNet5Api->Net5Command(NET5_NC_SEND_SERIAL_DATA, &uPortNum, (ULONG*)pTransData, &TransSize, NULL)) { m_pMgrNVE->GetMsgManager()->PushErrorCodeF("Net5Command[%d] failed\n", NET5_NC_SEND_SERIAL_DATA); m_pMgrNVE->GetMsgManager()->Show(TRUE); } dwRead -= TransSize; pTransData += TransSize; }while(dwRead != 0); } void CPageControlPtz::OnCheckCOMOpen() { // TODO: Add your control notification handler code here if(!IsDlgButtonChecked(IDC_CHECK_COM_OPEN)){ if(m_serial.IsOpen()){ m_serial.Close(); } GetDlgItem(IDC_CHECK_COM_OPEN)->SetWindowText("Open"); return; } char strTemp[100]; int port = GetDlgItem(IDC_COMBO_COM_PORT)->SendMessage(CB_GETCURSEL, NULL, NULL); sprintf(strTemp, "COM%d", port+1); if (m_serial.Open(strTemp,this) != ERROR_SUCCESS) { AfxMessageBox(_T("Unable to open COM-port"),MB_ICONSTOP|MB_OK); } m_serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1); GetDlgItem(IDC_CHECK_COM_OPEN)->SetWindowText("Close"); } LRESULT CPageControlPtz::OnSerialMsg (WPARAM wParam, LPARAM /*lParam*/) { CSerial::EEvent eEvent = CSerial::EEvent(LOWORD(wParam)); CSerial::EError eError = CSerial::EError(HIWORD(wParam)); if (eError) TRACE(_T("An internal error occurred.")); if (eEvent & CSerial::EEventBreak) TRACE(_T("Break detected on input.")); if (eEvent & CSerial::EEventError) TRACE(_T("A line-status error occurred.")); if (eEvent & CSerial::EEventRcvEv) TRACE(_T("Event character has been received.")); if (eEvent & CSerial::EEventRing) TRACE(_T("Ring detected")); if (eEvent & CSerial::EEventSend) TRACE(_T("All data is send")); if (eEvent & CSerial::EEventCTS) TRACE(_T("CTS signal change %s %d"), _T("CTS"), m_serial.GetCTS()); if (eEvent & CSerial::EEventDSR) TRACE(_T("DSR signal change %s %d"), _T("DSR"), m_serial.GetDSR()); if (eEvent & CSerial::EEventRLSD) TRACE(_T("RLSD signal change %s %d"), _T("RLSD"), m_serial.GetRLSD()); if (eEvent & CSerial::EEventRecv) { // Create a clean buffer DWORD dwRead, dwTotal; char szData[255]; //{{{ // [MOD] // read one byte at once const int nBuflen = 1; //const int nBuflen = sizeof(szData)-1; //}}} dwTotal =0; do { m_serial.Read(&szData[dwTotal],nBuflen,&dwRead); dwTotal+= dwRead; } while (dwRead == nBuflen); ProcessSerialData((BYTE*)szData, dwTotal); //TRACE(szData); } return 0; } void CPageControlPtz::OnSelchangeCbCamType() { // TODO: Add your control notification handler code here m_iPtzProtocol = m_cbCamType.GetCurSel(); m_ctrlCameraID.EnableWindow(TRUE); m_btnUpSlow->EnableWindow(TRUE); m_btnDownSlow->EnableWindow(TRUE); m_btnLeftSlow->EnableWindow(TRUE); m_btnRightSlow->EnableWindow(TRUE); m_chkText.EnableWindow(TRUE); m_btnFocusNear->EnableWindow(TRUE); m_btnFocusFar->EnableWindow(TRUE); m_btnZoomIn->EnableWindow(TRUE); m_btnZoomOut->EnableWindow(TRUE); m_btnInit->EnableWindow(TRUE); m_btnFocusNear->SetWindowText("Near"); m_btnFocusFar->SetWindowText("Far"); m_btnZoomIn->SetWindowText("+"); m_btnZoomOut->SetWindowText("-"); m_btnInit->SetWindowText("Init"); if (m_cbCamType.GetCurSel() == 3 || m_cbCamType.GetCurSel() == 4) { // - cjy, 07_0417 18:11 m_btnInit->EnableWindow(FALSE); } else if (m_cbCamType.GetCurSel() == 5) { m_ctrlCameraID.EnableWindow(FALSE); m_btnUpSlow->EnableWindow(FALSE); m_btnDownSlow->EnableWindow(FALSE); m_btnLeftSlow->EnableWindow(FALSE); m_btnRightSlow->EnableWindow(FALSE); m_chkText.EnableWindow(FALSE); m_btnFocusNear->SetWindowText("M-In"); m_btnFocusFar->SetWindowText("M-Out"); m_btnZoomIn->SetWindowText("In"); m_btnZoomOut->SetWindowText("Out"); m_btnInit->SetWindowText("Abort"); } else { m_btnInit->EnableWindow(FALSE); m_btnFocusNear->EnableWindow(FALSE); m_btnFocusFar->EnableWindow(FALSE); m_ctrlCameraID.EnableWindow(FALSE); } m_pStorage->Write("CamType", SSVT_DWORD, sizeof(m_iPtzProtocol), &m_iPtzProtocol); } BOOL CPageControlPtz::MakeTextCmd(UINT iCmd, char* pCmd) { if(iCmd == PTZ_UP) { strcpy(pCmd, "PTZ_UP\r\n"); } else if(iCmd == PTZ_DOWN) { strcpy(pCmd, "PTZ_DOWN\r\n"); } else if(iCmd == PTZ_TILT_STOP) { strcpy(pCmd, "PTZ_TILT_STOP\r\n"); } else if(iCmd == PTZ_LEFT) { strcpy(pCmd, "PTZ_LEFT\r\n"); } else if(iCmd == PTZ_RIGHT) { strcpy(pCmd, "PTZ_RIGHT\r\n"); } else if(iCmd == PTZ_PAN_STOP) { strcpy(pCmd, "PTZ_PAN_STOP\r\n"); } else if(iCmd == PTZ_ZOOMIN) { strcpy(pCmd, "PTZ_ZOOMIN\r\n"); } else if(iCmd == PTZ_ZOOMOUT) { strcpy(pCmd, "PTZ_ZOOMOUT\r\n"); } else if(iCmd == PTZ_ZOOM_STOP) { strcpy(pCmd, "PTZ_ZOOM_STOP\r\n"); } else if(iCmd == PTZ_INIT) { strcpy(pCmd, "PTZ_INIT\r\n"); } else if(iCmd == PTZ_FOCUS_NEAR) { strcpy(pCmd, "PTZ_FOCUS_NEAR\r\n"); } else if(iCmd == PTZ_FOCUS_FAR) { strcpy(pCmd, "PTZ_FOCUS_FAR\r\n"); } else if(iCmd == PTZ_FOCUS_STOP) { strcpy(pCmd, "PTZ_FOCUS_STOP\r\n"); } return TRUE; } BOOL CPageControlPtz::ResetSetting() { m_ctrlCameraID.SetCurSel(0); // OnSelchangeComboCameraID(); OnSelendokComboCameraId(); // cjy, 07_0509 12:55 m_ctrlCameraID.EnableWindow(FALSE); m_cbCamType.SetCurSel(0); m_chkText.SetCheck(FALSE); m_cbComPort.SetCurSel(0); m_iPtzProtocol = 0; return TRUE; } void CPageControlPtz::OnKillfocusComboCameraId() { // TODO: Add your control notification handler code here OnSelendokComboCameraId(); } void CPageControlPtz::OnSelendokComboCameraId() { // TODO: Add your control notification handler code here // get //m_nCameraID = 1 + m_ctrlCameraID.GetCurSel(); CString text; m_ctrlCameraID.GetWindowText(text); int id = atoi(text); // change~ if(id != m_nCameraID) { m_nCameraID = id; CString strCameraID; strCameraID.Format("%d",m_nCameraID); WritePrivateProfileString("CAMERA_ID", "CameraID", strCameraID.operator LPCTSTR(), "Custom01CameraID.ini"); } } void CPageControlPtz::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if(nIDEvent == CYBER2_TIMER) { // send ptz packet ActButtonPtz(m_LastuID); // TRACE0("act\n"); } CDialog::OnTimer(nIDEvent); }