コード例 #1
0
        private bool _calib_dark(CalibNightVisionItemInfo calibItem)
        {
            try {
                bool ret   = false;
                int  count = 0;

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

                //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.calibDarkResult = "Failed";
                        return(false);
                    }
                }

                //calib dark
                count = 0;
RE_CALIB:
                count++;
                ret = camera_indoor.calibNightVisionModeDark();
                stationVariable.myTesting.logSystem += string.Format(".........calib low threshold result {0}\n", ret);
                if (!ret)
                {
                    if (count < 3)
                    {
                        Thread.Sleep(500); goto RE_CALIB;
                    }
                    else
                    {
                        camera_indoor.Close();
                        calibItem.calibDarkResult = "Failed";
                        return(false);
                    }
                }

                camera_indoor.Close();
                calibItem.calibDarkResult = "Passed";
                return(true);
            }
            catch {
                calibItem.calibDarkResult = "Failed";
                return(false);
            }
        }
コード例 #2
0
        //login
        private bool _item_test_login(ref Common.Dut.IPCamera <TestingInformation> camera_indoor)
        {
            bool r = false;

            stationVariable.myTesting.logSystem += "\n+++++++++++++++++++++++++++++++++++++++\n";
            stationVariable.myTesting.logSystem += "LOGIN VÀO IP CAMERA\n";
            stationVariable.myTesting.logSystem += string.Format("...IP \"{0}\", telnet user \"{1}\", telnet pass \"{2}\"\n", stationVariable.mySetting.cameraIP, stationVariable.mySetting.cameraTelnetUser, stationVariable.mySetting.cameraTelnetPassword);
            camera_indoor = new Common.Dut.IPCamera <TestingInformation>(stationVariable.myTesting, stationVariable.mySetting.cameraIP, stationVariable.mySetting.cameraTelnetUser, stationVariable.mySetting.cameraTelnetPassword);
            camera_indoor.Login();
            r = camera_indoor.IsConnected();
            stationVariable.myTesting.logSystem += string.Format("...Kết quả: {0}\n", r ? "Passed" : "Failed");
            return(r);
        }
コード例 #3
0
        //login
        private bool _item_test_login(ref Common.Dut.IPCamera <TestingInformation> camera_indoor)
        {
            bool r = false;

            stationVariable.myTesting.logSystem += "\n+++++++++++++++++++++++++++++++++++++++\n";
            stationVariable.myTesting.logSystem += "LOGIN VÀO IP CAMERA\n";
            stationVariable.myTesting.logSystem += string.Format("...Cổng {0}, tốc độ baud {1}\n", stationVariable.mySetting.SerialPortName, stationVariable.mySetting.SerialBaudRate);
            camera_indoor = new Common.Dut.IPCamera <TestingInformation>(stationVariable.myTesting, stationVariable.mySetting.SerialPortName, int.Parse(stationVariable.mySetting.SerialBaudRate), 8);
            camera_indoor.Login();
            r = camera_indoor.IsConnected();
            stationVariable.myTesting.logSystem += string.Format("...Kết quả: {0}\n", r ? "Passed" : "Failed");
            return(r);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        private bool _change_ip_camera(int index)
        {
            try {
                bool ret   = false;
                int  count = 0;

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

                //get camera mac ethernet
                string mac_ethernet = camera_indoor.getMacEthernet();
                stationVariable.myTesting.logSystem += string.Format("......get mac {0} is {1}\n", stationVariable.mySetting.cameraIP, mac_ethernet);

                //check same mac or not
                bool   macExisted = false;
                string tmpIP      = "";
                Application.Current.Dispatcher.Invoke(new Action(() => {
                    foreach (var item in stationVariable.myCalibNightVisionInfo)
                    {
                        if (item.macEthernet.ToLower().Contains(mac_ethernet.ToLower()))
                        {
                            macExisted = true;
                            tmpIP      = item.ipAddress;
                            break;
                        }
                    }
                }));

                //change ip address
                string new_ip_address = "";
                if (macExisted == false)
                {
                    string[] buffer = stationVariable.mySetting.cameraIPCalibFrom.Split('.');
                    new_ip_address = string.Format("{0}.{1}.{2}.{3}", buffer[0], buffer[1], buffer[2], int.Parse(buffer[3]) + index);
                }
                else
                {
                    new_ip_address = tmpIP;
                }

                stationVariable.myTesting.logSystem += string.Format("......gen new ip {0} is {1}\n", mac_ethernet, new_ip_address);
                camera_indoor.changeIPWithoutSave(new_ip_address);

                //wait after change ip
                count = 0;
RE_WAIT:
                count++;
                ret = globalUtility.pingNetwork(new_ip_address);
                if (!ret)
                {
                    if (count < 30)
                    {
                        Thread.Sleep(500); goto RE_WAIT;
                    }
                    else
                    {
                        stationVariable.myTesting.logSystem += string.Format("......change to new ip {0} is {1}\n", new_ip_address, ret);
                        return(false);
                    }
                }
                stationVariable.myTesting.logSystem += string.Format("......change to new ip {0} is {1}\n", new_ip_address, ret);

                //add camera to collection
                if (macExisted == false)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => {
                        stationVariable.myCalibNightVisionInfo.Add(new CalibNightVisionItemInfo()
                        {
                            macEthernet      = mac_ethernet,
                            ipAddress        = new_ip_address,
                            changeIPResult   = "Passed",
                            calibDarkResult  = "-",
                            calibLightResult = "-",
                            verifyResult     = "-",
                            Result           = "Waiting..."
                        });
                    }));
                }

                return(true);
            }
            catch { return(false); }
        }
コード例 #6
0
        private bool _change_ip_camera(int index)
        {
            try {
                bool ret   = false;
                int  count = 0;

                //ping to camera
                count = 0;
                int c = 0;
RE_PING:
                count++;
                ret = globalUtility.pingNetwork(stationVariable.mySetting.cameraIP);
                stationVariable.myTesting.logSystem += string.Format("......ping {0} is {1}\n", stationVariable.mySetting.cameraIP, ret);
                if (!ret)
                {
                    if (count < 3)
                    {
                        Thread.Sleep(500); goto RE_PING;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    c++;
                    if (c < 3)
                    {
                        Thread.Sleep(500); goto RE_PING;
                    }
                }

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

                //get camera mac ethernet
                count = 0;
RE_GETMAC:
                count++;
                string mac_ethernet = camera_indoor.getMacEthernet();
                stationVariable.myTesting.logSystem += string.Format("......get mac {0} is {1}\n", stationVariable.mySetting.cameraIP, mac_ethernet);
                ret = !(string.IsNullOrEmpty(mac_ethernet) || string.IsNullOrWhiteSpace(mac_ethernet));
                if (!ret)
                {
                    if (count < 3)
                    {
                        Thread.Sleep(500); goto RE_GETMAC;
                    }
                    else
                    {
                        return(false);
                    }
                }


                //check same mac or not
                bool   macExisted = false;
                string tmpIP      = "";
                Application.Current.Dispatcher.Invoke(new Action(() => {
                    foreach (var item in stationVariable.myUploadFWInfo)
                    {
                        if (item.macEthernet.ToLower().Contains(mac_ethernet.ToLower()))
                        {
                            macExisted = true;
                            tmpIP      = item.ipAddress;
                            break;
                        }
                    }
                }));

                //change ip address
                string new_ip_address = "";
                if (macExisted == false)
                {
                    string[] buffer = stationVariable.mySetting.cameraIPFwBusinessFrom.Split('.');
                    new_ip_address = string.Format("{0}.{1}.{2}.{3}", buffer[0], buffer[1], buffer[2], int.Parse(buffer[3]) + index);
                }
                else
                {
                    new_ip_address = tmpIP;
                }

                stationVariable.myTesting.logSystem += string.Format("......gen new ip {0} is {1}\n", mac_ethernet, new_ip_address);
                camera_indoor.changeIPWithoutSave(new_ip_address);

                //wait after change ip
                count = 0;
RE_WAIT:
                count++;
                ret = globalUtility.pingNetwork(new_ip_address);
                if (!ret)
                {
                    if (count < 30)
                    {
                        Thread.Sleep(500); goto RE_WAIT;
                    }
                    else
                    {
                        stationVariable.myTesting.logSystem += string.Format("......change to new ip {0} is {1}\n", new_ip_address, ret);
                        return(false);
                    }
                }
                stationVariable.myTesting.logSystem += string.Format("......change to new ip {0} is {1}\n", new_ip_address, ret);

                //add camera to collection
                if (macExisted == false && index < int.Parse(stationVariable.myTesting.cameraQuantity))
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => {
                        stationVariable.myUploadFWInfo.Add(new UploadFwItemInfo()
                        {
                            macEthernet = mac_ethernet,
                            ipAddress   = new_ip_address,
                            totalResult = "Waiting..."
                        });
                    }));
                }

                //call thread control upload FW or verify firmware
                UploadFwItemInfo itemInfo = null;
                Application.Current.Dispatcher.Invoke(new Action(() => {
                    foreach (var item in stationVariable.myUploadFWInfo)
                    {
                        if (item.macEthernet.ToLower().Equals(mac_ethernet.ToLower()))
                        {
                            itemInfo = item;
                            break;
                        }
                    }
                }));

                if (itemInfo != null && itemInfo.totalResult.Equals("Waiting..."))
                {
                    if (macExisted == false && stationVariable.mySetting.IsUploadFirmwareBusiness == true)
                    {
                        Thread t = new Thread(new ThreadStart(() => {
                            bool r         = false;
                            var ex_upfw_tm = new exUploadFWBusiness <UploadFwItemInfo, SettingInformation>(itemInfo, stationVariable.mySetting);
                            r = ex_upfw_tm.excuteTelnet();
                            if (!r)
                            {
                                itemInfo.totalResult = "Failed";
                                //save log
                                saveLog(itemInfo);
                            }
                            else
                            {
                                if (!stationVariable.mySetting.isTestFunction())
                                {
                                    itemInfo.totalResult = "Passed";
                                    //save log
                                    saveLog(itemInfo);
                                }
                            }
                        }));
                        t.IsBackground = true;
                        t.Start();
                    }
                    else
                    {
                        Thread t = new Thread(new ThreadStart(() => {
                            bool r             = false;
                            var ex_testfunc_tm = new exTestFunctionBusiness <UploadFwItemInfo, SettingInformation>(itemInfo, stationVariable.mySetting);
                            r = ex_testfunc_tm.excuteTelnet();
                            itemInfo.totalResult = r ? "Passed" : "Failed";
                            //save log
                            saveLog(itemInfo);
                        }));
                        t.IsBackground = true;
                        t.Start();
                    }
                }
                return(true);
            }
            catch { return(false); }
        }