Beispiel #1
0
        /// <summary>
        /// Calculates the distance from zero of a given angle.
        /// </summary>
        /// <param name="angle">angle to calculate</param>
        /// <returns>an angle in the range (-180,180]</returns>
        private int AngleDistanceFromZero(int angle)
        {
            angle = (int)FCCircularTrackbar.FitValueToCircle((int)angle);
            if (angle > 180)
            {
                angle = -(360 - angle);
            }

            return(angle);
        }
Beispiel #2
0
        /// <summary>
        /// Dispatches a move request from a PTZ Overlay Control to the camera control client
        /// </summary>
        private void PTZOverlayControl_MoveRequested(object sender, PTZMoveRequestEventArgs e)
        {
            if (client == null)
            {
                return;
            }

            try
            {
                Debug.WriteLine("Got Move Request: " + e.Pan + ", " + e.Tilt + ", " + e.Zoom);

                if (e.IsAbsolute)
                {
                    client.PanTiltAbsolute(e.Pan, e.Tilt);
                    if (e.Zoom != 0)
                    {
                        client.ZoomAbsolute(e.Zoom);
                    }
                }
                else
                {
                    double newPan = FCCircularTrackbar.FitValueToCircle(ptzControl.PanAngle + e.Pan);

                    double newTilt = ptzControl.TiltAngle + e.Tilt;

                    if (newTilt > StreamViewerControl.SourceInfo.CameraControl.Capabilities.TiltMaxAngle)
                    {
                        newTilt = StreamViewerControl.SourceInfo.CameraControl.Capabilities.TiltMaxAngle;
                    }
                    else if (newTilt < StreamViewerControl.SourceInfo.CameraControl.Capabilities.TiltMinAngle)
                    {
                        newTilt = StreamViewerControl.SourceInfo.CameraControl.Capabilities.TiltMinAngle;
                    }

                    client.PanTiltAbsolute(newPan, newTilt);
                    if (e.Zoom != 0)
                    {
                        client.ZoomAbsolute(ptzControl.ZoomLevel + e.Zoom);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.DumpToDebug(ex);
                Stop();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Calculates the shortest distance in degrees between two angles
 /// </summary>
 /// <param name="from">starting angle</param>
 /// <param name="to">ending angle</param>
 private void CalcPanAngleDelta(int from, int to)
 {
     PanAngleDelta = -1 * (FCCircularTrackbar.FitValueToCircle((from + 180.0 - to)) - 180);
 }