示例#1
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as CheckTempProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            string strNbTemp = configGv.Get("NBTemp");
            float  floatNbTemp;

            try
            {
                floatNbTemp = float.Parse(strNbTemp);
                if (floatNbTemp > config.MaxValue)
                {
                    log.Fail(string.Format("NB 温度传感器检查:\r\n模块温度传感器温度值:{0},大于设定最大值:{1} FAIL \r\n", floatNbTemp, config.MaxValue));
                    throw new BaseException(string.Format("NB 温度传感器检查:\r\n模模块温度传感器温度值:{0},大于设定最大值:{1} FAIL \r\n", floatNbTemp, config.MaxValue));
                }
                else if (floatNbTemp < config.MinValue)
                {
                    log.Fail(string.Format("NB 温度传感器检查:\r\n模模块温度传感器温度值:{0},小于设定最小值:{1} FAIL \r\n", floatNbTemp, config.MinValue));
                    throw new BaseException(string.Format("NB 信号强度检查:\r\n模块温度传感器温度值:{0},小于设定最小值:{1} FAIL \r\n", floatNbTemp, config.MinValue));
                }

                log.Info(string.Format("NB 温度传感器检查:\r\n模模块温度传感器温度值:{0},在设定范围:{1} ~ {2}之间 PASS \r\n", floatNbTemp, config.MinValue, config.MaxValue));
            }
            catch (Exception ex)
            {
                throw new Exception("NB 温度传感器检查出错," + ex.Message);
            }
        }
示例#2
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config   = properties as FilterOutCharsProperties;
            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            log      = globalDic[typeof(ILog).ToString()] as ILog;

            if (config.GlobalVariblesKey != null)
            {
                for (int i = 0; i < config.GlobalVariblesKey.Length; i++)
                {
                    if (!string.IsNullOrEmpty(config.GlobalVariblesKey[i]))
                    {
                        Match matchKey = Regex.Match(config.GlobalVariblesKey[i], this.pattern);
                        if (!matchKey.Success)
                        {
                            throw new BaseException(string.Format("read info {0} key fail", i));
                        }
                        string key = matchKey.Groups[1].ToString();

                        string value = configGv.Get(key);
                        for (int j = 0; j < config.FilterOutChars.Length; j++)
                        {
                            value = value.Replace(config.FilterOutChars[j], "");
                        }
                        configGv.Add(key, value);
                    }
                }
            }
        }
示例#3
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";
            FormScanCode formScanCode = new FormScanCode()
            {
                //DutName = config.DutName,
                //ShowInTaskbar = true,
                //StartPosition = FormStartPosition.CenterScreen
            };
            DialogResult dialogResult = DialogResult.None;

            lock (myLock)
            {
                dialogResult = formScanCode.ShowDialog();
            }
            if (dialogResult != DialogResult.OK)
            {
                //sync.CountDown("ScanCodeExecuter");
                throw new BaseException("user discard scan code");
            }
            configGv.Add(GlobalVaribles.LABEL_SN, formScanCode.LabelSn);
        }
示例#4
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as SocketConnectProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                Socket    socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPAddress ip     = IPAddress.Parse(config.Ip);
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 2500);
                socket.Connect(ip, Convert.ToInt16(config.Port));
                if (!socket.Connected)
                {
                    throw new Exception(string.Format("Socke连接服务器失败,{0}:{1}\r\n连接状态为false", config.Ip, config.Port));
                }
                log.Info(string.Format("Socke连接服务器连接成功,{0}:{1}", config.Ip, config.Port));
                configGv.Add("ObjSocket", socket);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Socke连接服务器失败,{0}:{1}\r\n详情:{2}", config.Ip, config.Port, ex.Message));
            }
        }
示例#5
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as CheckBtRssiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            string strMoudleBtRssi = configGv.Get("RSSI");
            int    intMoudleBtRssi;

            try
            {
                intMoudleBtRssi = int.Parse(strMoudleBtRssi);
                if (intMoudleBtRssi > config.MaxValue)
                {
                    log.Fail(string.Format("信号强度检查:\r\n模块信号强度:{0},大于设定最大值:{1} FAIL \r\n", intMoudleBtRssi, config.MaxValue));
                    throw new BaseException(string.Format("信号强度检查:\r\n模块信号强度:{0},大于设定最大值:{1} FAIL \r\n", intMoudleBtRssi, config.MaxValue));
                }
                else if (intMoudleBtRssi < config.MinValue)
                {
                    log.Fail(string.Format("信号强度检查:\r\n模块信号强度:{0},小于设定最小值:{1} FAIL \r\n", intMoudleBtRssi, config.MinValue));
                    throw new BaseException(string.Format("信号强度检查:\r\n模块信号强度:{0},小于设定最小值:{1} FAIL \r\n", intMoudleBtRssi, config.MinValue));
                }

                log.Info(string.Format("信号强度检查:\r\n模块信号强度:{0},在设定范围:{1} ~ {2}之间 PASS \r\n", intMoudleBtRssi, config.MinValue, config.MaxValue));
            }
            catch (Exception ex)
            {
                throw new Exception("信号强度检查出错," + ex.Message);
            }
        }
示例#6
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as CheckBtRssiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                string strBtMac       = configGv.Get("MAC_BT");
                string strMoudleBtMac = configGv.Get("MoudleBtMac");
                if (string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))
                {
                    configGv.Add("MAC", strMoudleBtMac);
                }
                else if (!string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
                {
                    configGv.Add("MAC", strMoudleBtMac);
                }
                else if (!string.IsNullOrEmpty(strBtMac) && string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
                {
                    configGv.Add("MAC", strBtMac);
                }
                else
                {
                    log.Fail(string.Format("LOG MAC设置为BT MAC失败\r\n,取号BT MAC{0},模块BT MAC:{1} \r\n", strBtMac, strMoudleBtMac));
                }
                log.Info(string.Format("LOG MAC设置为BT MAC:\r\n{0} PASS \r\n", strMoudleBtMac));
            }
            catch (Exception ex)
            {
                throw new Exception("LOG MAC设置为BT MAC出错," + ex.Message);
            }
        }
示例#7
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as CheckRangeValueProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            string strMoudleBtRssi = configGv.Get(config.GlobalVarible);
            double intMoudleBtRssi;

            try
            {
                intMoudleBtRssi = double.Parse(strMoudleBtRssi);
                if (intMoudleBtRssi > config.MaxValue)
                {
                    //log.Fail(string.Format("{0}:{1},大于设定最大值:{2} FAIL \r\n", config.TestValueName, intMoudleBtRssi, config.MaxValue));
                    throw new BaseException(string.Format("{0}:{1},大于设定最大值:{2} FAIL \r\n", config.TestValueName, intMoudleBtRssi, config.MaxValue));
                }
                else if (intMoudleBtRssi < config.MinValue)
                {
                    //log.Fail(string.Format("{0}:{1},小于设定最小值:{2} FAIL \r\n", config.TestValueName,intMoudleBtRssi, config.MinValue));
                    throw new BaseException(string.Format("{0}:{1},小于设定最小值:{2} FAIL \r\n", config.TestValueName, intMoudleBtRssi, config.MinValue));
                }

                log.Info(string.Format("{0}:{1},在设定范围:{2} ~ {3}之间 PASS \r\n", config.TestValueName, intMoudleBtRssi, config.MinValue, config.MaxValue));
            }
            catch (Exception ex)
            {
                throw new Exception("检查出错," + ex.Message);
            }
        }
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as CheckBtRssiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                string labImei = configGv.Get("IMEI");
                string nbImei  = configGv.Get("NBIMEI");
                if (string.IsNullOrEmpty(labImei) && !string.IsNullOrEmpty(nbImei))
                {
                    configGv.Add("IMEI", nbImei);
                }
                else if (!string.IsNullOrEmpty(labImei))//有标签BT MAC,则肯定经过一致性检查
                {
                    configGv.Add("IMEI", nbImei);
                }
                else
                {
                    log.Fail(string.Format("打印标签的IMEI 设置为NB IMEI失败\r\n,NB IMEI:{0} \r\n", nbImei));
                }
                log.Info(string.Format("打印标签的IMEI 设置为NB IMEI:\r\n{0} PASS \r\n", nbImei));
            }
            catch (Exception ex)
            {
                throw new Exception("打印标签的IMEI 设置为NB IMEI出错," + ex.Message);
            }
        }
示例#9
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as CheckWifiProbeProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            string strNbProbe = configGv.Get("NBWIFIPROBE");
            int    intNbProbe;

            try
            {
                intNbProbe = int.Parse(strNbProbe);
                if (intNbProbe > config.MaxValue)
                {
                    log.Fail(string.Format("WIFI探针-信号强度检查:\r\n信号强度:{0},大于设定最大值:{1} FAIL \r\n", intNbProbe, config.MaxValue));
                    throw new BaseException(string.Format("NB 探针强度检查:\r\n信号强度:{0},大于设定最大值:{1} FAIL \r\n", intNbProbe, config.MaxValue));
                }
                else if (intNbProbe < config.MinValue)
                {
                    log.Fail(string.Format("WIFI探针-信号强度检查:\r\n信号强度:{0},小于设定最小值:{1} FAIL \r\n", intNbProbe, config.MinValue));
                    throw new BaseException(string.Format("WIFI 探针强度检查:\r\n信号强度:{0},小于设定最小值:{1} FAIL \r\n", intNbProbe, config.MinValue));
                }

                log.Info(string.Format("WIFI探针-信号强度检查:\r\n信号强度:{0},在设定范围:{1} ~ {2}之间 PASS \r\n", intNbProbe, config.MinValue, config.MaxValue));
            }
            catch (Exception ex)
            {
                throw new Exception("WIFI探针-信号强度检查出错," + ex.Message);
            }
        }
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as FindDeviceProperties;
            ComDut comDut = globalDic[typeof(ComDut).ToString()] as ComDut;
            ILog   log    = globalDic[typeof(ILog).ToString()] as ILog;

            //int ret = -1;
            //string returnString = "";
            string endLine = config.EndLine;

            TimeUtils.Execute(() =>
            {
                comDut.Write(config.TestPowerOnAT + endLine);
                //comDut.Write("AT+CSQ\r\n");

                Thread.Sleep(config.AtCommandInterval);
                string response = comDut.ReadExisting();
                //comDut.DtrEnable = false;
                //comDut.RtsEnable = false;

                //log.Info("AT Response=" + response);


                if (!string.IsNullOrEmpty(config.AtCommandOk))
                {
                    if (response.Contains(config.AtCommandOk))
                    {
                        log.Info(string.Format("检测到产品上电,AT response=[{0}]  contain =[{1}]", response, config.AtCommandOk));
                        //跳出循环执行
                        return(true);
                        //throw new BaseException(string.Format("AT response=[{0}] not contain error=[{1}]", response, config.AtCommandOk));
                    }
                }


                ////ret = ExeCommand(config, out returnString);
                //if (ret != 0)
                //{
                //    log.Fail(string.Format("详情:{0},检测设备失败 \r\n", returnString));
                //    //throw new BaseException(string.Format("详情:{0},检测设备失败,FAIL\r\n", returnString));

                //}
                //if (returnString.Contains("\tdevice\r\n\r\n"))
                //{
                //    log.Info(string.Format("详情:{0},检测到设备 \r\n", returnString));
                //    //跳出循环执行
                //    return true;
                //}



                //继续循环执行
                return(false);
            }, config.Timeout);
        }
示例#11
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ReadMapProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            //int ret = -1;
            string mapFileString = "";

            try
            {
                mapFileString = Read(config.MapFilePath);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("读取MAP文件失败,异常:{0}", ex.Message));
            }

            log.Info(string.Format("读取MAP文件成功:\r\n{0}", mapFileString));
            //更新MAP内存中的MAC地址
            string[] splits             = { "\r\n" };
            string[] mapFileStringLines = mapFileString.Split(splits, StringSplitOptions.RemoveEmptyEntries);

            //IMES获取的MAC***************
            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            string macFromImes = configGv.Get("MAC");

            //更新MAP
            //byte[] bytesMac = strToToHexByte(macFromImes);
            //byte[] bytesReverseMac = bytesConvert(bytesMac);
            //string stringReverseMac = byteToHexStr(bytesReverseMac);
            //string reverseMacAddSpace = AddSpaceEachTwoBtye(stringReverseMac);


            string reverseMacAddSpace = AddSpaceEachTwoBtye(macFromImes);

            string mapFileStringMacUpdate = "";

            for (int i = 0; i < mapFileStringLines.Length; i++)
            {
                if (i == 17)
                {
                    //前面固定部分+反转并添加空格的MAC
                    mapFileStringLines[i] = mapFileStringLines[i].Substring(0, 25) + reverseMacAddSpace;
                }
                mapFileStringMacUpdate += mapFileStringLines[i] + "\r\n";
            }

            //存为byte数组应该会好些,这样可以定位地址,当MAC的偏移地址发生变化时,只需改地址值
            log.Info(string.Format("更新MAP文件中的MAC成功:\r\n{0}", mapFileStringMacUpdate));
            GlobalVaribles configGv1 = globalDic.Get <GlobalVaribles>();

            configGv1.Add("MapFileStringMacUpdate", mapFileStringMacUpdate);
            //globalDic.Add(typeof(OpenPhoneProperties).ToString(), config);
        }
示例#12
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as CheckNbVersionProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;


            string devVersion = configGv.Get(config.GlobalVarible);

            if (devVersion != config.Version)
            {
                throw new BaseException(string.Format("关键字检查:{0},配置关键字:{1}不一致", devVersion, config.Version));
            }
            log.Info(string.Format("关键字检查:{0},配置关键字:{1}一致", devVersion, config.Version));
        }
示例#13
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as LabelGetAndCheckProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            string[] data   = configGv.Get(GlobalVaribles.LABEL_SN).Split(new[] { ',' });
            string   gimiSn = data[0];

            CheckSn(gimiSn);

            gimiSn = gimiSn.Insert(config.InsertIndex, config.Value);
            configGv.Add("GimiSn", gimiSn);

            log.Info(string.Format("标签:{0}\r\n插入内容后:{1}", data[0], gimiSn));

            //try
            //{

            //    string strBtMac = configGv.Get("MAC_BT");
            //    string strMoudleBtMac = configGv.Get("MoudleBtMac");
            //    if (string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))
            //    {
            //        configGv.Add("MAC", strMoudleBtMac);
            //    }
            //    else if (!string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
            //    {
            //        configGv.Add("MAC", strMoudleBtMac);
            //    }
            //    else if (!string.IsNullOrEmpty(strBtMac) && string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
            //    {
            //        configGv.Add("MAC", strBtMac);
            //    }
            //    else
            //    {
            //        log.Fail(string.Format("LOG MAC设置为BT MAC失败\r\n,取号BT MAC{0},模块BT MAC:{1} \r\n", strBtMac, strMoudleBtMac));
            //    }
            //    log.Info(string.Format("LOG MAC设置为BT MAC:\r\n{0} PASS \r\n", strMoudleBtMac));


            //}
            //catch (Exception ex)
            //{
            //    throw new Exception("LOG MAC设置为BT MAC出错," + ex.Message);
            //}
        }
示例#14
0
        internal static List <Options> GetDicOptions(string dicType)
        {
            Dictionary <string, List <base_dics> > diclist = FreelyListCache.Cache_DicsList;
            List <Options> options = new List <Options>();

            if (!diclist.ContainsKey(dicType))
            {
                Type typeenum = GlobalDic.GetType(dicType);
                if (typeenum != null)                         //枚举字典中存在
                {
                    options = GlobalDic.GetEnumList(dicType); //获取枚举字典选项
                    foreach (Options op in options)
                    {
                        if (!diclist.ContainsKey(dicType))
                        {
                            diclist.Add(dicType, new List <base_dics>()
                            {
                                new base_dics()
                                {
                                    dicname = op.text, dicvalue = op.id, dictype = dicType
                                }
                            });
                        }
                        else
                        {
                            diclist[dicType].Add(new base_dics()
                            {
                                dicname = op.text, dicvalue = op.id, dictype = dicType
                            });
                        }
                    }
                    return(options);
                }
            }
            if (diclist.ContainsKey(dicType))
            {
                foreach (base_dics dic in diclist[dicType])
                {
                    options.Add(new Options()
                    {
                        id = dic.dicvalue, text = dic.dicname
                    });
                }
            }
            return(options);
        }
示例#15
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            //取存储的关键字为MoudleBtMac的value值
            string labelImei  = configGv.Get("IMEI");
            string moudleImei = configGv.Get("NBIMEI");

            if (labelImei != moudleImei)
            {
                log.Fail(string.Format("NB IMEI检查:\r\n模块IMEI:{0},与标签IMEI:{1} 不一致 \r\n", moudleImei, labelImei));
                throw new BaseException(string.Format("NB IMEI检查:\r\n模块IMEI:{0},与标签IMEI:{1} 不一致 \r\n", moudleImei, labelImei));
            }
            log.Info(string.Format("NB IMEI检查:\r\n模块IMEI:{0},与标签IMEI:{1} 一致 \r\n", moudleImei, labelImei));
        }
示例#16
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //取存储的关键字为MoudleBtMac的value值
            string DevWifi_MAC = configGv.Get("DevWifi_MAC");

            DevWifi_MAC = DevWifi_MAC.Replace(":", "").Replace(":", "");
            string labelMAC = configGv.Get(GlobalVaribles.MAC);

            if (DevWifi_MAC != labelMAC)
            {
                throw new BaseException(string.Format("WIFI MAC:{0},与标签MAC:{1} 不一致 FAIL\r\n", DevWifi_MAC, labelMAC));
            }
            log.Info(string.Format(string.Format("WIFI MAC:{0},与标签MAC:{1} 一致 PASS\r\n", DevWifi_MAC, labelMAC)));
        }
示例#17
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as CheckBtRssiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            //string[] data = configGv.Get(GlobalVaribles.LABEL_SN).Split(new[] { ',' });
            //configGv.Add("GimiSn", data[0]);
            //log.Info(string.Format("Sn={0}", configGv.Get("GimiSn")));
            configGv.Add("MAC", configGv.Get("GimiSn"));
            log.Info(string.Format("设置LOG的Mac={0}成功", configGv.Get("GimiSn")));

            //try
            //{

            //    string strBtMac = configGv.Get("MAC_BT");
            //    string strMoudleBtMac = configGv.Get("MoudleBtMac");
            //    if (string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))
            //    {
            //        configGv.Add("MAC", strMoudleBtMac);
            //    }
            //    else if (!string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
            //    {
            //        configGv.Add("MAC", strMoudleBtMac);
            //    }
            //    else if (!string.IsNullOrEmpty(strBtMac) && string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
            //    {
            //        configGv.Add("MAC", strBtMac);
            //    }
            //    else
            //    {
            //        log.Fail(string.Format("LOG MAC设置为BT MAC失败\r\n,取号BT MAC{0},模块BT MAC:{1} \r\n", strBtMac, strMoudleBtMac));
            //    }
            //    log.Info(string.Format("LOG MAC设置为BT MAC:\r\n{0} PASS \r\n", strMoudleBtMac));


            //}
            //catch (Exception ex)
            //{
            //    throw new Exception("LOG MAC设置为BT MAC出错," + ex.Message);
            //}
        }
示例#18
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config   = properties as ToggleCaseProperties;
            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            log      = globalDic[typeof(ILog).ToString()] as ILog;
            string preGlobalVaribles = configGv.Get(config.PreGlobalVaribles);
            string value             = "";

            if (config.ToggleCase == ToggleCaseProperties.CaseEnum.ToLower)
            {
                value = preGlobalVaribles.ToLower();
            }
            else if (config.ToggleCase == ToggleCaseProperties.CaseEnum.ToUper)
            {
                value = preGlobalVaribles.ToUpper();
            }

            configGv.Add(config.AfterGlobalVaribles, value);
        }
示例#19
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as DisableAdapterProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //NetWorkList();
            if (NetWorkState(config.NICname))
            {
                if (!DisableNetWork(NetWork(config.NICname)))
                {
                    throw new BaseException("禁用网卡失败");
                }
                log.Info("禁用网卡成功");
            }
            else
            {
                log.Info(string.Format("未找到该网卡:{0},网卡已禁用", config.NICname));
            }
        }
示例#20
0
        //private string pattern;

        //public ReverseNumberExecuter()
        //{
        //    this.pattern = GlobalVaribles.PATTERN;
        //}

        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ReverseNumberProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            try
            {
                string number = configGv.Get(config.PreGlobalVariable);
                //string mac = configGv.Get(GlobalVaribles.MAC);
                byte[] byteMac = strToToHexByte(number);
                Array.Reverse(byteMac);

                string reverseMac = byteToHexStr(byteMac);
                configGv.Add(config.AfterGlobalVariable, reverseMac);

                log.Info(string.Format("倒序16进制Number成功:{0}", reverseMac));
            }
            catch (Exception ex)
            {
                throw new BaseException(string.Format("倒序16进制Number转换失败,{0}", ex));
            }


            //string reverseMac = mac.Substring(0, 12);
            //string reScanLabelMac = reScanLabel.Substring(12, 12);


            //string macLabel = configGv.Get(GlobalVaribles.MAC);
            //if (!(reScanLabelFixedPart == config.FixedPart))
            //{
            //    throw new BaseException(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}不一致", reScanLabelFixedPart, config.FixedPart));
            //}
            //log.Info(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}一致", reScanLabelFixedPart, config.FixedPart));

            //if (!(reScanLabelMac == macLabel))
            //{
            //    throw new BaseException(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}不一致", reScanLabelMac, macLabel));
            //}
            //log.Info(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}一致", reScanLabelMac, macLabel));
        }
示例#21
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac   = configGv.Get("MoudleBtMac");
            string btMacFromImes = configGv.Get("MAC_BT");; //configGv.Get("MAC_BT");

            if (moudleBtMac != btMacFromImes)
            {
                log.Fail(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
                throw new BaseException(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 \r\n", moudleBtMac, btMacFromImes));
            }
            //string moudleBtMac = configGv.Get("");
            log.Info(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 一致,PASS \r\n", moudleBtMac, btMacFromImes));
        }
示例#22
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac   = configGv.Get(GlobalVaribles.MAC);
            string btMacFromImes = configGv.Get(GlobalVaribles.LABEL_SN);; //configGv.Get("MAC_BT");

            if (moudleBtMac != btMacFromImes)
            {
                //log.Fail(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
                throw new BaseException(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} \r\n不一致 \r\n", moudleBtMac, btMacFromImes));
            }
            //string moudleBtMac = configGv.Get("");
            log.Info(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} \r\n一致 \r\n", moudleBtMac, btMacFromImes));
        }
示例#23
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as EnableAdapterProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //NetWorkList();
            if (NetWorkState(config.NICname))
            {
                if (!EnableNetWork(NetWork(config.NICname)))
                {
                    throw new BaseException(string.Format("开启网卡:{0},失败", config.NICname));
                }
                log.Info(string.Format("开启网卡:{0},成功", config.NICname));
            }
            else
            {
                log.Info(string.Format("未找到该网卡:{0},网卡已启用", config.NICname));
            }

            //EnableAdapter(out mac, config.NICname);
        }
示例#24
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ShowBtMacQrCodeProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac = configGv.Get("MoudleBtMac");

            QrCodeForm qrCodeForm = new QrCodeForm(moudleBtMac, config.ShowTime);

            qrCodeForm.ShowDialog();
            //if (moudleBtMac != btMacFromImes)
            //{
            //    log.Fail(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
            //    throw new BaseException(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 \r\n", moudleBtMac, btMacFromImes));
            //}
            ////string moudleBtMac = configGv.Get("");
            //log.Info(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 一致,PASS \r\n", moudleBtMac, btMacFromImes));
        }
示例#25
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as DisConnectSsiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                Wifi objWifi = configGv.GetObject("ObjWifi") as Wifi;
                if (objWifi != null)
                {
                    if (objWifi.ConnectionStatus == WifiStatus.Connected)
                    {
                        objWifi.Disconnect();
                        log.Info("断开WIFI连接成功");
                    }
                    else
                    {
                        throw new BaseException(string.Format("未连接WIFI热点,无法断开连接1"));
                    }
                }
                else
                {
                    throw new BaseException(string.Format("未连接WIFI热点,objWifi为空,无法断开连接"));
                }
                //if (!hasSsid)
                //{
                //    throw new BaseException(string.Format("未扫描到SSID:{0}", ssid));

                //}
            }
            catch (Exception ex)
            {
                throw new Exception("断开热点出错," + ex.Message);
            }
        }
示例#26
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)
        {
            FormTipAndUartCheckProperties config = properties as FormTipAndUartCheckProperties;
            ILog          log        = globalDic.Get <ILog>();
            List <ComDut> comDutList = globalDic[typeof(List <ComDut>).ToString()] as List <ComDut>;

            if (comDutList == null || comDutList.Count == 0)
            {
                throw new BaseException("COM为空");
            }
            ComDut comDut = null;

            foreach (var item in comDutList)
            {
                if (item.PortName == config.PortName)
                {
                    comDut = item;
                    break;
                }
            }
            if (comDut == null)
            {
                throw new BaseException(string.Format("ComDut No PortName:{0}", config.PortName));
            }


            TipAndCheckUartForm formUserConfirm = new TipAndCheckUartForm(config, log, comDut)
            {
            };

            formUserConfirm.ShowDialog();

            if (!formUserConfirm.Result)
            {
                throw new BaseException("Fail");
            }
        }
示例#27
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as SocketDisConnectProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                Socket objSocket = configGv.GetObject("ObjSocket") as Socket;
                if (objSocket != null)
                {
                    if (objSocket.Connected)
                    {
                        //objSocket.Disconnect(true);
                        objSocket.Close();
                        if (objSocket.Connected)
                        {
                            throw new BaseException(string.Format("断开连接失败,状态仍然为连接状态"));
                        }
                        log.Info("断开Soket连接成功");
                    }
                    else
                    {
                        throw new BaseException(string.Format("未连接Soket服务器,无法断开连接1"));
                    }
                }
                else
                {
                    throw new BaseException(string.Format("未连接Soket服务器,objSocket为空,无法断开连接"));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("断开Soket连接出错," + ex.Message);
            }
        }
示例#28
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //取存储的关键字为MoudleBtMac的value值
            string DevWifi_MAC = configGv.Get("DevWifi_MAC");
            string DevBt_MAC   = configGv.Get("DevBt_MAC");

            DevWifi_MAC = DevWifi_MAC.Replace(":", "").Replace(":", "").ToUpper();
            DevBt_MAC   = DevBt_MAC.Replace(":", "").Replace(":", "").ToUpper();
            if (Convert.ToInt64(DevWifi_MAC, 16) + 1 != Convert.ToInt64(DevBt_MAC, 16))
            {
                throw new BaseException(string.Format("WIFI MAC:{0},BT MAC:{1} 非+1关系,未通过校验 FAIL\r\n", DevWifi_MAC, DevBt_MAC));
            }
            log.Info(string.Format(string.Format("WIFI MAC:{0},BT MAC:{1} 通过 +1关系校验 PASS\r\n", DevWifi_MAC, DevBt_MAC)));

            string labelMAC = configGv.Get(GlobalVaribles.MAC);

            if (string.IsNullOrEmpty(labelMAC))
            {
                configGv.Add(GlobalVaribles.MAC, DevWifi_MAC);
            }
        }
示例#29
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as LabelVerifyProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            string reScanLabel          = configGv.Get(GlobalVaribles.LABEL_SN);
            string reScanLabelFixedPart = reScanLabel.Substring(0, 12);
            string reScanLabelMac       = reScanLabel.Substring(12, 12);

            string macLabel = configGv.Get(GlobalVaribles.MAC);

            if (!(reScanLabelFixedPart == config.FixedPart))
            {
                throw new BaseException(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}不一致", reScanLabelFixedPart, config.FixedPart));
            }
            log.Info(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}一致", reScanLabelFixedPart, config.FixedPart));

            if (!(reScanLabelMac == macLabel))
            {
                throw new BaseException(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}不一致", reScanLabelMac, macLabel));
            }
            log.Info(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}一致", reScanLabelMac, macLabel));
        }
示例#30
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)
        {
            AccessToMacProperties config = properties as AccessToMacProperties;

            ComDut comDut = globalDic[typeof(ComDut).ToString()] as ComDut;
            OpenPhoneProperties configOpenPhone = globalDic[typeof(OpenPhoneProperties).ToString()] as OpenPhoneProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            //string moudleBtMac = configGv.Get("MAC_BT");
            string endLine = configOpenPhone.EndLine;

            if (!string.IsNullOrEmpty(endLine))
            {
                endLine = Parse_r_n(endLine);
            }

            string atCommand = PreTranslateAtCommand(config.AtCommand);

            log.Info("AT Commond=" + atCommand);

            comDut.DtrEnable = configOpenPhone.Dtr;
            comDut.RtsEnable = configOpenPhone.Rts;
            comDut.Write(atCommand + endLine);
            Thread.Sleep(config.AtCommandInterval);
            string response = comDut.ReadExisting();

            comDut.DtrEnable = false;
            comDut.RtsEnable = false;

            log.Info("AT Response=" + response);

            if (!string.IsNullOrEmpty(config.AtCommandError))
            {
                if (response.Contains(config.AtCommandError))
                {
                    throw new BaseException(string.Format("AT response=[{0}] contain error=[{1}]", response, config.AtCommandError));
                }
            }

            if (!string.IsNullOrEmpty(config.AtCommandOk))
            {
                if (!response.Contains(config.AtCommandOk))
                {
                    throw new BaseException(string.Format("AT response=[{0}] not contain error=[{1}]", response, config.AtCommandOk));
                }
            }

            if (config.CheckInfo != null)
            {
                for (int i = 0; i < config.CheckInfo.Length; i++)
                {
                    if (!string.IsNullOrEmpty(config.CheckInfo[i]))
                    {
                        string checkInfo = PreTranslateCheckInfo(config.CheckInfo[i]);
                        if (!response.Contains(checkInfo))
                        {
                            throw new BaseException(string.Format("AT response=[{0}] not contain check info=[{1}]", response, checkInfo));
                        }
                    }
                }
            }
            if (!response.Contains("BLE MAC:"))
            {
                throw new BaseException("不包含BLE MAC:信息");
            }


            if (!string.IsNullOrEmpty(config.GlobalVariblesKey) && !string.IsNullOrEmpty(config.GlobalVariblesKeyPattern))
            {
                string pattern    = Parse_r_n(config.GlobalVariblesKeyPattern);
                Match  matchValue = Regex.Match(response, pattern);
                if (!matchValue.Success)
                {
                    //ble mac为空
                    //log.Info("BLE未写过MAC");
                    throw new BaseException("BLE未写过MAC,请在前面工序写BLE MAC");
                }
                else
                {
                    string value = matchValue.Groups[1].ToString();
                    if (value == "000000000000")
                    {
                        log.Info(string.Format("BLE未写过MAC:{0}", value));
                        throw new BaseException("BLE未写过MAC,请在前面工序写BLE MAC");
                        //configGv.Add(GlobalVaribles.MAC_BT, value);
                    }
                    else
                    {
                        log.Info(string.Format("BLE已写过MAC:{0}", value));
                        //预检查{MoudleBtMac}

                        Match matchKey = Regex.Match(config.GlobalVariblesKey, this.pattern);//this.pattern
                        if (!matchKey.Success)
                        {
                            throw new BaseException("read info key fail");
                        }

                        string key = matchKey.Groups[1].ToString();
                        //预检查
                        MesProcess.PreCheck(value);

                        //赋值BT MAC,WIFI MAC,取消取号
                        configGv.Add(key, value);
                        //configGv.Add(GlobalVaribles.MAC_BT, value);
                        UInt64 macUInt64 = Convert.ToUInt64(value, 16);
                        string macWifi   = string.Format("{0:X}", macUInt64 - 1).PadLeft(12, '0');
                        configGv.Add(GlobalVaribles.MAC, macWifi);

                        log.Info(string.Format("自动计算WIFI MAC号:{0}", macWifi));
                    }
                }
            }
        }