コード例 #1
0
        private void saveLog(UploadFwItemInfo itemInfo)
        {
            //save log telnet
            new LogTelnet(
                globalParameter.LogStationName.FwBusiness.ToString(),
                itemInfo.macEthernet,
                itemInfo.totalResult
                )
            .saveDataToLogFile(itemInfo.logTelnet);

            //save log system
            new LogSystem(
                globalParameter.LogStationName.FwBusiness.ToString(),
                itemInfo.macEthernet,
                itemInfo.totalResult
                )
            .saveDataToLogFile(itemInfo.logSystem);

            //save log total
            new LogTotal(
                globalParameter.LogStationName.FwBusiness.ToString()
                )
            .saveDataToLogFile(
                "macEthernet", itemInfo.macEthernet,
                "serialNumber", itemInfo.serialNumber,
                "uidCode", itemInfo.uidCode,
                "firmwareBuildTime", itemInfo.firmwareBuildTime,
                "hardwareVersion", itemInfo.hardwareVersion,
                "uploadResult", itemInfo.uploadResult,
                "firmwareResult", itemInfo.firmwareResult,
                "macResult", itemInfo.macResult,
                "serialResult", itemInfo.serialResult,
                "uidResult", itemInfo.uidResult,
                "hardwareResult", itemInfo.hardwareResult,
                "TotalResult", itemInfo.totalResult
                );
        }
コード例 #2
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); }
        }