Exemple #1
0
        private static AxisCameraConfigType GetConfig(XDocument configDoc, string selectConfig)
        {
            AxisCameraConfigType ctSelected = null;

            XElement root = configDoc.Root;

            XmlSerializer xmlConfigReader = new XmlSerializer(typeof(AxisCameraConfigSet));

            AxisCameraConfigSet configSet = (AxisCameraConfigSet)xmlConfigReader.Deserialize(root.CreateReader());

            var config = (from ct in configSet.Items
                          where ct.ConfigName == selectConfig
                          select ct).FirstOrDefault();

            ctSelected = config as AxisCameraConfigType;

            if (ctSelected == null)
            {
                var configDefault = (from ct in configSet.Items
                                     where ct.ConfigName == configSet.DefaultConfig
                                     select ct).FirstOrDefault();

                ctSelected = configDefault as AxisCameraConfigType;
            }

            return(ctSelected);
        }
        // Parameters from
        // http://www.axis.com/techsup/cam_servers/dev/cam_http_api_2.php#api_blocks_image_video_mjpg_video_cgi

        //public string Address;
        //public string Resolution = null;
        //public int Camera = -1; // no point in the quad option
        //public int Compression = -1;

        //public int UseColor = -1;
        //public int ColorLevel = -1;

        //public int ShowClock = -1;
        //public int ShowDate = -1;

        //public int ShowText = -1;
        //public string Text = null;
        //public string TextColor = null;
        //public string TextBackGround = null;
        //public string TextPosition = null;

        //public int ShowOverlay = -1;
        //public string OverlayPosition = null;

        //public int Fps = -1;
        //public int SquarePixel = -1;

        //public int Rotation = -1;

        //public string UserName = null;
        //public string Password = null;

        //public string delimiter = "--myboundary";
        //public string frameFormat = null;


        //public string MjpgParameterString()
        //{
        //   string parameters =
        //      /*"http://" +*/ this.Address + "/axis-cgi/mjpg/video.cgi?" +
        //     ((this.Fps != -1) ? "fps=" + this.Fps : "") +
        //     ((this.Resolution != null) ? "&resolution=" + this.Resolution : "") +
        //     ((this.Compression != -1) ? "&compression=" + this.Compression : "") +
        //     ((this.UseColor != -1) ? "&color=" + this.UseColor : "") +
        //     ((this.ShowClock != -1) ? "&clock=" + this.ShowClock : "") +
        //     ((this.ShowDate != -1) ? "&date=" + this.ShowDate : "") +
        //     ((this.ShowText != -1) ? "&text=" + this.ShowText : "") +
        //     ((this.TextColor != null) ? "&textcolor=" + this.TextColor : "") +
        //     ((this.TextBackGround != null) ? "&textbackgroundcolor=" + this.TextBackGround : "") +
        //     ((this.TextPosition != null) ? "&textposition=" + this.TextPosition : "") +
        //     ((this.Text != null) ? "&textstring=" + this.Text : "") +
        //     ((this.Rotation != -1) ? ("&rotation=" + this.Rotation) : "") +
        //     ((this.Camera != -1) ? "&camera=" + this.Camera : "") +
        //     ((this.ColorLevel != -1) ? "&colorlevel=" + this.ColorLevel : "") +
        //     ((this.ShowOverlay != -1) ? "&overlayimage=" + this.ShowOverlay : "") +
        //     ((this.OverlayPosition != null) ? "&overlayposition=" + this.OverlayPosition : "")
        //     ;

        //   return parameters;
        //}

        public static string MjpgParameterString(AxisCameraConfigType config)
        {
            string strResolution = config.Resolution.ToString();

            strResolution = strResolution.Contains("Item") ? strResolution.Remove(0, 4) : strResolution;

            string parameters =
                /*"http://" +*/ config.Address + "/axis-cgi/mjpg/video.cgi?" +
                ((config.FramerateSpecified) ? "fps=" + config.Framerate : "") +
                ((config.ResolutionSpecified) ? "&resolution=" + strResolution : "") +
                ((config.CompressionSpecified) ? "&compression=" + config.Compression : "") +
                ((config.ShowClockSpecified) ? "&clock=" + config.ShowClock : "") +
                ((config.ShowDateSpecified) ? "&date=" + config.ShowDate : "") +
                ((config.ShowTextSpecified) ? "&text=" + config.ShowText : "") +
                ((config.TextColorSpecified) ? "&textcolor=" + config.TextColor : "") +
                ((config.TextBackgroundColorSpecified) ? "&textbackgroundcolor=" + config.TextBackgroundColor : "") +
                ((config.TextPositionSpecified) ? "&textposition=" + config.TextPosition : "") +
                ((config.Text != null) ? "&textstring=" + config.Text : "") +
                ((config.RotationSpecified) ? ("&rotation=" + config.Rotation) : "") +
                ((config.CameraSpecified) ? "&camera=" + (int)config.Camera : "") +
                ((config.ColorLevelSpecified) ? "&colorlevel=" + config.ColorLevel : "") +
                ((config.ShowOverlaySpecified) ? "&overlayimage=" + config.ShowOverlay : "") +
                ((config.OverlayPosition != null) ? "&overlayposition=" + config.OverlayPosition : "")
            ;

            return(parameters);
        }
Exemple #3
0
        ///// <summary>
        ///// Registers a node with a sensor.
        ///// </summary>
        ///// <param name="configDoc">The configuration XML document.</param>
        ///// <param name="selectConfig">String identifying the configuration item to use.</param>
        //public void Register(XmlDocument configDoc, string selectConfig)
        //{
        //   // validate the xml
        //   configDoc.Schemas.Add(this.configSchema);
        //   configDoc.Validate(null);

        //   // parse the settings from the xml


        //   this.camParams = AxisParameters.ParseConfig(configDoc, selectConfig);
        //   if (this.camParams == null)
        //   {
        //      throw new ApplicationException("StatusChanged parsing config");
        //   }

        //   this.registered = true;
        //}

        #endregion
        /// <summary>
        /// Registers a node with a sensor.
        /// </summary>
        /// <param name="config">The configuration XML document.</param>
        /// <param name="selectConfig">String identifying the configuration item to use.</param>
        public void Register(XDocument config, string selectConfig)
        {
            // validate the xml
            XmlSchemaSet schemas = new XmlSchemaSet();

            schemas.Add(this.configSchema);
            config.Validate(schemas, null);

            //this.camParams = AxisParameters.ParseConfig(configDoc, selectConfig);
            this.cameraConfig = AxisCamera.GetConfig(config, selectConfig);

            if (this.cameraConfig == null)
            {
                throw new ScallopException("Error when tryin to parse config");
            }


            this.registered = true;
        }
        /// <summary>
        /// Registers a node with a sensor.
        /// </summary>
        /// <param name="config">The configuration XML document.</param>
        /// <param name="selectConfig">String identifying the configuration item to use.</param>
        public void Register(XDocument config, string selectConfig)
        {
            // validate the xml
             XmlSchemaSet schemas = new XmlSchemaSet();
             schemas.Add(this.configSchema);
             config.Validate(schemas, null);

             //this.camParams = AxisParameters.ParseConfig(configDoc, selectConfig);
             this.cameraConfig = AxisCamera.GetConfig(config, selectConfig);

             if (this.cameraConfig == null)
             {
            throw new ScallopException("Error when tryin to parse config");
             }

             this.registered = true;
        }
        // Parameters from
        // http://www.axis.com/techsup/cam_servers/dev/cam_http_api_2.php#api_blocks_image_video_mjpg_video_cgi
        //public string Address;
        //public string Resolution = null;
        //public int Camera = -1; // no point in the quad option
        //public int Compression = -1;
        //public int UseColor = -1;
        //public int ColorLevel = -1;
        //public int ShowClock = -1;
        //public int ShowDate = -1;
        //public int ShowText = -1;
        //public string Text = null;
        //public string TextColor = null;
        //public string TextBackGround = null;
        //public string TextPosition = null;
        //public int ShowOverlay = -1;
        //public string OverlayPosition = null;
        //public int Fps = -1;
        //public int SquarePixel = -1;
        //public int Rotation = -1;
        //public string UserName = null;
        //public string Password = null;
        //public string delimiter = "--myboundary";
        //public string frameFormat = null;
        //public string MjpgParameterString()
        //{
        //   string parameters =
        //      /*"http://" +*/ this.Address + "/axis-cgi/mjpg/video.cgi?" +
        //     ((this.Fps != -1) ? "fps=" + this.Fps : "") +
        //     ((this.Resolution != null) ? "&resolution=" + this.Resolution : "") +
        //     ((this.Compression != -1) ? "&compression=" + this.Compression : "") +
        //     ((this.UseColor != -1) ? "&color=" + this.UseColor : "") +
        //     ((this.ShowClock != -1) ? "&clock=" + this.ShowClock : "") +
        //     ((this.ShowDate != -1) ? "&date=" + this.ShowDate : "") +
        //     ((this.ShowText != -1) ? "&text=" + this.ShowText : "") +
        //     ((this.TextColor != null) ? "&textcolor=" + this.TextColor : "") +
        //     ((this.TextBackGround != null) ? "&textbackgroundcolor=" + this.TextBackGround : "") +
        //     ((this.TextPosition != null) ? "&textposition=" + this.TextPosition : "") +
        //     ((this.Text != null) ? "&textstring=" + this.Text : "") +
        //     ((this.Rotation != -1) ? ("&rotation=" + this.Rotation) : "") +
        //     ((this.Camera != -1) ? "&camera=" + this.Camera : "") +
        //     ((this.ColorLevel != -1) ? "&colorlevel=" + this.ColorLevel : "") +
        //     ((this.ShowOverlay != -1) ? "&overlayimage=" + this.ShowOverlay : "") +
        //     ((this.OverlayPosition != null) ? "&overlayposition=" + this.OverlayPosition : "")
        //     ;
        //   return parameters;
        //}
        public static string MjpgParameterString(AxisCameraConfigType config)
        {
            string strResolution = config.Resolution.ToString();

               strResolution = strResolution.Contains("Item") ? strResolution.Remove(0, 4) : strResolution;

               string parameters =
              /*"http://" +*/ config.Address + "/axis-cgi/mjpg/video.cgi?" +
             ((config.FramerateSpecified) ? "fps=" + config.Framerate : "") +
             ((config.ResolutionSpecified) ? "&resolution=" + strResolution : "") +
             ((config.CompressionSpecified) ? "&compression=" + config.Compression : "") +
             ((config.ShowClockSpecified) ? "&clock=" + config.ShowClock : "") +
             ((config.ShowDateSpecified) ? "&date=" + config.ShowDate : "") +
             ((config.ShowTextSpecified) ? "&text=" + config.ShowText : "") +
             ((config.TextColorSpecified) ? "&textcolor=" + config.TextColor : "") +
             ((config.TextBackgroundColorSpecified) ? "&textbackgroundcolor=" + config.TextBackgroundColor : "") +
             ((config.TextPositionSpecified) ? "&textposition=" + config.TextPosition : "") +
             ((config.Text != null) ? "&textstring=" + config.Text : "") +
             ((config.RotationSpecified) ? ("&rotation=" + config.Rotation) : "") +
             ((config.CameraSpecified) ? "&camera=" + (int)config.Camera : "") +
             ((config.ColorLevelSpecified) ? "&colorlevel=" + config.ColorLevel : "") +
             ((config.ShowOverlaySpecified) ? "&overlayimage=" + config.ShowOverlay : "") +
             ((config.OverlayPosition != null) ? "&overlayposition=" + config.OverlayPosition : "")
             ;

               return parameters;
        }