Пример #1
0
        // 1 - up
        // 2 - down
        // 3 - left
        // 4 - right
        // 5 - stop
        public void MoveSimple(PTZDirection direction)
        {
            int commandStart = 5;
            int commandEnd   = 5;

            if ((direction & PTZDirection.Up) > 0)
            {
                commandStart = 1;
            }
            else if ((direction & PTZDirection.Down) > 0)
            {
                commandStart = 2;
            }
            else if ((direction & PTZDirection.Left) > 0)
            {
                commandStart = 3;
            }
            else if ((direction & PTZDirection.Right) > 0)
            {
                commandStart = 4;
            }
            Util.HttpPost("http://" + camSpec.ptz_hostName + "/cgi-bin/cmd.cgi", "opType=set&cmd=ptz&ptz_cmd=" + commandStart + "&protocol=1&band=2400&speed=60&addr=1");
            Thread.Sleep(500);
            Util.HttpPost("http://" + camSpec.ptz_hostName + "/cgi-bin/cmd.cgi", "opType=set&cmd=ptz&ptz_cmd=" + commandEnd + "&protocol=1&band=2400&speed=60&addr=1");
        }
Пример #2
0
        /*
         * -- PANTILTCONTROL.CGI
         * -- Movement Table
         * -- 0 = UP/LEFT
         * -- 1 = UP
         * -- 2 = UP/RIGHT
         * -- 3 = LEFT
         * -- 4 = HOME (RESET)
         * -- 5 = RIGHT
         * -- 6 = DOWN/LEFT
         * -- 7 = DOWN
         * -- 8 = DOWN/RIGHT
         * -- MUST USE HTTP POST REQ, NOT GET
         * -- Ex. os.execute("curl -d 'PanSingleMoveDegree=1&TiltSingleMoveDegree=1&PanTiltSingleMove=1' http://myusername:mypassword@ipaddress/PANTILTCONTROL.CGI")
         * -- PanSingleMoveDegree=x   This is for the pan function, where x is the step size
         * -- TiltSingleMoveDegree=x    This is for the tilt function, where x is the step size
         * -- PanTiltSingleMove=x         This is for the movement variable, where x is the direction from above table
         * -- If moving in any single direction pan or tilt, the other command is not required.
         */
        public void MoveSimple(PTZDirection direction)
        {
            int PanSingleMoveDegree  = 5;
            int TiltSingleMoveDegree = 5;
            int PanTiltSingleMove    = 4;

            if ((direction & PTZDirection.Up) > 0 && (direction & PTZDirection.Left) > 0)
            {
                PanTiltSingleMove = 0;
            }
            else if ((direction & PTZDirection.Up) > 0 && (direction & PTZDirection.Right) > 0)
            {
                PanTiltSingleMove = 2;
            }
            else if ((direction & PTZDirection.Down) > 0 && (direction & PTZDirection.Left) > 0)
            {
                PanTiltSingleMove = 6;
            }
            else if ((direction & PTZDirection.Down) > 0 && (direction & PTZDirection.Right) > 0)
            {
                PanTiltSingleMove = 8;
            }
            else if ((direction & PTZDirection.Up) > 0)
            {
                PanTiltSingleMove = 1;
            }
            else if ((direction & PTZDirection.Left) > 0)
            {
                PanTiltSingleMove = 3;
            }
            else if ((direction & PTZDirection.Right) > 0)
            {
                PanTiltSingleMove = 5;
            }
            else if ((direction & PTZDirection.Down) > 0)
            {
                PanTiltSingleMove = 7;
            }
            string s = Util.HttpPost("http://" + camSpec.ptz_hostName + "/PANTILTCONTROL.CGI", "PanSingleMoveDegree=" + PanSingleMoveDegree + "&TiltSingleMoveDegree=" + TiltSingleMoveDegree + "&PanTiltSingleMove=" + PanTiltSingleMove, credentials: new System.Net.NetworkCredential(camSpec.ptz_username, camSpec.ptz_password));

            Console.WriteLine(s);
        }
Пример #3
0
        public void MoveSimple(PTZDirection direction)
        {
            int x = 500;
            int y = 500;

            if (direction == PTZDirection.Up || direction == PTZDirection.UpLeft || direction == PTZDirection.UpRight)
            {
                y = 250;
            }
            if (direction == PTZDirection.Down || direction == PTZDirection.DownLeft || direction == PTZDirection.DownRight)
            {
                y = 750;
            }
            if (direction == PTZDirection.Left || direction == PTZDirection.UpLeft || direction == PTZDirection.DownLeft)
            {
                x = 250;
            }
            if (direction == PTZDirection.Right || direction == PTZDirection.UpRight || direction == PTZDirection.DownRight)
            {
                x = 750;
            }

            HttpPost(url, GetPTZJSONString("34323638666239302D396463362D3131", 497, 569, 0, 0, false));
        }
Пример #4
0
        public void MoveSimple(PTZDirection direction)
        {
            PTZProfile profile = GetProfile();

            if (profile == null)
            {
                return;
            }
            if (typeof(PTZSpecV1) == profile.spec.GetType())
            {
                PTZSpecV1 spec = (PTZSpecV1)profile.spec;
                string    url;
                int       waitTime;
                if (direction == PTZDirection.Up)
                {
                    waitTime = spec.TiltRunTimeMs;
                    url      = spec.up;
                }
                else if (direction == PTZDirection.Down)
                {
                    waitTime = spec.TiltRunTimeMs;
                    url      = spec.down;
                }
                else if (direction == PTZDirection.Left)
                {
                    waitTime = spec.PanRunTimeMs;
                    url      = spec.left;
                }
                else if (direction == PTZDirection.Right)
                {
                    waitTime = spec.PanRunTimeMs;
                    url      = spec.right;
                }
                else if (spec.EnableDiagonals)
                {
                    if (direction == PTZDirection.UpLeft)
                    {
                        url = spec.upleft;
                    }
                    else if (direction == PTZDirection.DownLeft)
                    {
                        url = spec.downleft;
                    }
                    else if (direction == PTZDirection.UpRight)
                    {
                        url = spec.upright;
                    }
                    else if (direction == PTZDirection.DownRight)
                    {
                        url = spec.downright;
                    }
                    else
                    {
                        return;
                    }

                    waitTime = Math.Min(spec.PanRunTimeMs, spec.TiltRunTimeMs);
                }
                else
                {
                    return;
                }

                SimpleProxy.GetData(urlBase + url, camSpec.ptz_username, camSpec.ptz_password);

                if (spec.SendStopCommandAfterPanTilt && !string.IsNullOrWhiteSpace(spec.stopPanTilt))
                {
                    Thread.Sleep(waitTime);
                    SimpleProxy.GetData(urlBase + spec.stopPanTilt, camSpec.ptz_username, camSpec.ptz_password);
                }
            }
        }