コード例 #1
0
        private Hashtable GetXmlData(string type)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("CamSettingsConfig.xml");
            var camsElements = xmlDoc.SelectNodes("/SettingItem/" + type + "/illumination");

            Hashtable listStr = new Hashtable();

            foreach (XmlNode xn in camsElements)
            {
                if (type.Equals("Infrared"))
                {
                }
                else
                {
                    CameraParam cp = new CameraParam()
                    {
                        iris    = Convert.ToInt32(xn.Attributes["iris"].Value),
                        shutter = Convert.ToInt32(xn.Attributes["shutter"].Value),
                        agc     = Convert.ToInt32(xn.Attributes["agc"].Value)
                    };
                    listStr.Add(Model.ToString() + xn.Attributes["value"].Value, cp);
                }
            }
            return(listStr);
        }
コード例 #2
0
        /// <summary>
        /// 读取端口
        /// </summary>
        /// <param name="modle">BrightType</param>
        /// <param name="Ip">摄像机的Ip</param>
        public void ReadPort(object obj)
        {
            OpenPort();
            int count = 0;

            int[] arrInt = new int[5];
            while (true)
            {
                try
                {
                    int temp = Convert.ToInt32(sp.ReadLine());
                    if (count == 5)
                    {
                        int         good   = (GetBestValue(arrInt.ToArray()) / 4 + 5) / 10 * 10;         //获得中间值
                        CameraParam setVal = new CameraParam();
                        setVal = GetSettingString(Model.ToString() + good.ToString(), Model.ToString()); //获得相匹配的字符串
                        if (setVal != null)
                        {
                            this.SettingCamera(setVal);                //设置相机
                        }
                        count = 0;
                        sp.Close();
                        Thread.Sleep(2500);
                    }
                    else
                    {
                        arrInt[count++] = temp;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Erro Message:" + ex.Message);
                }
                Thread.Sleep(1500);
                OpenPort();
            }
        }
コード例 #3
0
 public SetCamera(CameraParam ccp, string Ip)
 {
     cp  = ccp;
     url = string.Format("http://{0}", Ip);
 }
コード例 #4
0
        /// <summary>
        /// 设置照相机
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="Ip"></param>
        private void SettingCamera(CameraParam cp)
        {
            SetCamera sd = new SetCamera(cp, Ip);

            sd.Connect();
        }
コード例 #5
0
 public SetCamera(CameraParam ccp, string Ip)
 {
     cp = ccp;
     url = string.Format("http://{0}",Ip);
 }
コード例 #6
0
 /// <summary>
 /// 设置照相机
 /// </summary>
 /// <param name="cp"></param>
 /// <param name="Ip"></param>
 private void SettingCamera(CameraParam cp)
 {
     SetCamera sd = new SetCamera(cp, Ip);
        sd.Connect();
 }
コード例 #7
0
        private Hashtable GetXmlData(string type)
        {
            XmlDocument xmlDoc = new XmlDocument();
               xmlDoc.Load("CamSettingsConfig.xml");
               var camsElements = xmlDoc.SelectNodes("/SettingItem/" + type + "/illumination");

               Hashtable listStr = new Hashtable();
               foreach (XmlNode xn in camsElements)
               {
               if (type.Equals("Infrared"))
               {

               }
               else
               {
                   CameraParam cp = new CameraParam()
                   {
                       iris = Convert.ToInt32(xn.Attributes["iris"].Value),
                       shutter = Convert.ToInt32(xn.Attributes["shutter"].Value),
                       agc = Convert.ToInt32(xn.Attributes["agc"].Value)
                   };
                   listStr.Add(Model.ToString() + xn.Attributes["value"].Value, cp);
               }
               }
               return listStr;
        }
コード例 #8
0
 /// <summary>
 /// 读取端口
 /// </summary>
 /// <param name="modle">BrightType</param>
 /// <param name="Ip">摄像机的Ip</param>
 public void ReadPort(object obj)
 {
     OpenPort();
        int count = 0;
        int[] arrInt = new int[5];
        while (true)
        {
        try
        {
            int temp = Convert.ToInt32(sp.ReadLine());
            if (count == 5)
            {
                int good =(GetBestValue(arrInt.ToArray()) / 4 + 5)/10*10;//获得中间值
                CameraParam setVal = new CameraParam();
                setVal = GetSettingString(Model.ToString() + good.ToString(), Model.ToString());//获得相匹配的字符串
                if (setVal != null) this.SettingCamera(setVal); //设置相机
                count = 0;
                sp.Close();
                Thread.Sleep(2500);
            }
            else
            {
                arrInt[count++] = temp;
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Erro Message:" + ex.Message);
        }
        Thread.Sleep(1500);
        OpenPort();
        }
 }