본문 바로가기
IT/C#

[한화 비전 - SUNAPI] Zoom, Focus

by rimilove 2023. 7. 6.
반응형

- Zoom : nZoomValuer값에 따라 - (Near), + (Far) 동작.

public void PTZ_Zoom(int nZoomValue)
        {       
            String strPreURI = "http://";
            String strIPAddress = _strDeviceIP;
            String strPort = _nDeviceHttpPort.ToString();
            String strFunction = "/stw-cgi/ptzcontrol.cgi?msubmenu=absolute&action=control&Zoom=" + nZoomValue.ToString();
            String strQuery = strPreURI + strIPAddress + ":" + strPort + strFunction;
            String strUserID = _strUserID;
            String strUserPWD = _strUserPWD;

            Console.WriteLine(strQuery);    // Query 출력

            WebRequest request = WebRequest.Create(strQuery);   // WebRequest 생성.
            request.Credentials = new NetworkCredential(strUserID, strUserPWD); // 계정 생성.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();  // Response 호출.

            Console.WriteLine(response.StatusDescription);  // 응답 결과 출력

            response.Close();
        }

 

- Focus Mode  : Manual, Auto, OneShotAutoFocus

public void Focus_Mode(eSUNAPI_FocusMode eModeValue)
        {
            String strModeValue = "";

            if (eModeValue == eSUNAPI_FocusMode.OneShotAutoFocus)
                strModeValue = "OneShotAutoFocus";
            else if (eModeValue == eSUNAPI_FocusMode.Manual)
                strModeValue = "Manual";
            else
                strModeValue = "Auto";

            String strPreURI = "http://";
            String strIPAddress = _strDeviceIP;
            String strPort = _nDeviceHttpPort.ToString();

            String strFunction = "/stw-cgi/image.cgi?msubmenu=focus&action=set&Mode=" + strModeValue;
            String strQuery = strPreURI + strIPAddress + ":" + strPort + strFunction;
            String strUserID = _strUserID;
            String strUserPWD = _strUserPWD;

            Console.WriteLine(strQuery);    // Query 출력

            WebRequest request = WebRequest.Create(strQuery);   // WebRequest 생성.
            request.Credentials = new NetworkCredential(strUserID, strUserPWD); // 계정 생성.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();  // Response 호출.

            Console.WriteLine(response.StatusDescription);  // 응답 결과 출력
            response.Close();
        }

 

- Focus Continuous : Near, Far, Stop

public void Focus_Continuous(eSUNAPI_FocusContinuous eFocusValue)
        {
            String strFocusValue = "";

            if(eFocusValue == eSUNAPI_FocusContinuous.Far)
                strFocusValue = "Far";
            else if (eFocusValue == eSUNAPI_FocusContinuous.Near)
                strFocusValue = "Near";
            else
                strFocusValue = "Stop";

            String strPreURI = "http://";
            String strIPAddress = _strDeviceIP;
            String strPort = _nDeviceHttpPort.ToString();
            String strFunction = "/stw-cgi/ptzcontrol.cgi?msubmenu=continuous&action=control&Focus=" + strFocusValue.ToString();
            String strQuery = strPreURI + strIPAddress + ":" + strPort + strFunction;
            String strUserID = _strUserID;
            String strUserPWD = _strUserPWD;

            Console.WriteLine(strQuery);    // Query 출력

            WebRequest request = WebRequest.Create(strQuery);   // WebRequest 생성.
            request.Credentials = new NetworkCredential(strUserID, strUserPWD); // 계정 생성.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();  // Response 호출.

            Console.WriteLine(response.StatusDescription);  // 응답 결과 출력
            response.Close();
        }

 

반응형