Ejemplo n.º 1
0
        private bool _get_calib_value(CalibNightVisionItemInfo calibItem)
        {
            try {
                bool ret   = false;
                int  count = 0;

                stationVariable.myTesting.logSystem += string.Format("......camera {0}\n", calibItem.macEthernet);
                calibItem.verifyResult = "...";

                //login telnet to camera
                count = 0;
RE_LOGIN:
                count++;
                Common.Dut.IPCamera <TestingInformation> camera_indoor = new Common.Dut.IPCamera <TestingInformation>(stationVariable.myTesting, calibItem.ipAddress, stationVariable.mySetting.cameraTelnetUser, stationVariable.mySetting.cameraTelnetPassword);
                camera_indoor.Login();
                ret = camera_indoor.IsConnected();
                stationVariable.myTesting.logSystem += string.Format(".........login to {0} is {1}\n", calibItem.ipAddress, ret);
                if (!ret)
                {
                    if (count < 3)
                    {
                        Thread.Sleep(500); goto RE_LOGIN;
                    }
                    else
                    {
                        camera_indoor.Close();
                        calibItem.verifyResult = "null,null";
                        return(false);
                    }
                }

                //verify after calib
                count = 0;
RE_CALIB:
                count++;
                string data = camera_indoor.getCalibNightVisionValue();
                ret = data.Contains("lowthreshold") && data.Contains("highthreshold");
                stationVariable.myTesting.logSystem += string.Format(".........calib value {0}, result {1}\n", data, ret);
                if (!ret)
                {
                    if (count < 3)
                    {
                        Thread.Sleep(500); goto RE_CALIB;
                    }
                    else
                    {
                        camera_indoor.Close();
                        calibItem.verifyResult = "null,null";
                        return(false);
                    }
                }

                camera_indoor.Close();
                string sssssssssssssss = data.Replace("\r", "")
                                         .Replace("\n", "")
                                         .Replace("cat /usr/conf/nightvision.cfg", "")
                                         .Replace("~ #", "")
                                         .Trim();

                string[] buffer = sssssssssssssss.Split(',');
                calibItem.verifyResult = buffer[1].Replace("\"", "").Replace("threshold", "").Trim() + "," + buffer[2].Replace("\"", "").Replace("threshold", "").Trim();

                return(true);
            }
            catch {
                calibItem.verifyResult = "null,null";
                return(false);
            }
        }