Example #1
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);
            }
        }
        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);
            }
        }
Example #3
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);
                    }
                }
            }
        }
Example #4
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);
            }
        }
Example #5
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);
            }
        }
Example #6
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);
            }
        }
Example #7
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);
            }
        }
Example #8
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));
        }
Example #9
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)));
        }
Example #10
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);
            //}
        }
Example #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);
        }
Example #12
0
        private string PreTranslateAtCommand(string atCommand)
        {
            string newAtCommand = atCommand;
            Match  match        = Regex.Match(atCommand, @"{([0-9a-zA-Z_]+)}");

            for (int i = 1; i < match.Groups.Count; i++)
            {
                string key   = match.Groups[i].ToString();
                string value = configGv.Get(key);

                if (string.IsNullOrEmpty(value))
                {
                    throw new BaseException("null value in GlobalVaribles");
                }

                newAtCommand = newAtCommand.Replace("{" + key + "}", value);
            }

            return(newAtCommand);
        }
Example #13
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));
        }
Example #14
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));
        }
Example #15
0
        private string PreTranslateCheckInfo(string checkInfo)
        {
            string newCheckInfo = checkInfo;
            Match  match        = Regex.Match(checkInfo, pattern);

            for (int i = 1; i < match.Groups.Count; i++)
            {
                string key = match.Groups[i].ToString();
                newCheckInfo = configGv.Get(key);
            }

            return(newCheckInfo);
        }
Example #16
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));
        }
Example #17
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);
            }
        }
Example #18
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));
        }
Example #19
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);
            //}
        }
Example #20
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);
        }
Example #21
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));
        }
Example #22
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));
        }
Example #23
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ConnectSsiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

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


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

            string ssid = string.Format(config.SSID, mac);

            Wifi g_wifi;

            try
            {
                //WlanClient client = new WlanClient();
                //foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                //{

                WlanClient client = new WlanClient();
                foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                {
                    wlanIface.Scan();
                }
                Thread.Sleep(1000);
                g_wifi = new Wifi();

                List <AccessPoint> wifiList = g_wifi.GetAccessPoints();
                foreach (AccessPoint item in wifiList)
                {
                    if (item.Name == ssid)
                    {
                        hasSsid = true;

                        if (!item.IsConnected)
                        {
                            AuthRequest authRequest = new AuthRequest(item);
                            bool        bConnect    = item.Connect(authRequest);
                            if (bConnect)
                            {
                                log.Info(string.Format("连接网络成功"));
                                configGv.Add("ObjWifi", g_wifi);
                            }
                        }
                        else
                        {
                            log.Info(string.Format("网络已处于连接状态,无需连接"));
                            configGv.Add("ObjWifi", g_wifi);
                        }
                        break;
                    }
                }
                //    wlanIface.Scan();
                //}

                if (!hasSsid)
                {
                    throw new BaseException(string.Format("未扫描到SSID:{0}", ssid));
                }

                ////WlanClient client = new WlanClient();
                //foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                //{
                //    wlanIface.Scan();
                //}



                //#region
                //WlanClient client = new WlanClient();
                //WIFISSID targetSSID;
                //foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                //{
                //    // Lists all networks with WEP security
                //    Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles);
                //    foreach (Wlan.WlanAvailableNetwork network in networks)
                //    {
                //        //ssids.Add(targetSSID);
                //        //wifiListOKADDitem(GetStringForSSID(network.dot11Ssid), network.dot11DefaultCipherAlgorithm.ToString(),
                //        //    network.dot11DefaultAuthAlgorithm.ToString(), (int)network.wlanSignalQuality);
                //        if (GetStringForSSID(network.dot11Ssid).Equals(ssid))
                //        {
                //            //var obj = new wifiSo(targetSSID, config.Key);

                //            targetSSID = new WIFISSID();

                //            targetSSID.wlanInterface = wlanIface;
                //            targetSSID.wlanSignalQuality = (int)network.wlanSignalQuality;
                //            targetSSID.SSID = GetStringForSSID(network.dot11Ssid);
                //            //targetSSID.SSID = Encoding.Default.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
                //            targetSSID.dot11DefaultAuthAlgorithm = network.dot11DefaultAuthAlgorithm.ToString();
                //            targetSSID.dot11DefaultCipherAlgorithm = network.dot11DefaultCipherAlgorithm.ToString();

                //            ConnectToSSID(targetSSID, config.Key);
                //            hasSsid = true;
                //            log.Info(string.Format("连接网络成功"));
                //            return;
                //            //Thread wificonnect = new Thread(obj.ConnectToSSID);
                //            //wificonnect.Start();

                //            //WifiSocket wifiscoket = new WifiSocket();
                //            //wifiscoket.fuwu();
                //            //wifiscoket.kehuduan();


                //            //wifiso.ConnectToSSID(targetSSID, "ZMZGZS520");//连接wifi
                //            //connectWifiOK.Text = GetStringForSSID(network.dot11Ssid);
                //            //Image img = new Bitmap(Environment.CurrentDirectory + "/image/wifi.png");//这里是你要替换的图片。当然你必须事先初始化出来图
                //            //pictureBoxW.BackgroundImage = img;
                //            //Console.WriteLine(">>>>>>>>>>>>>>>>>开始连接网络!" + targetSSID.SSID + GetStringForSSID(network.dot11Ssid) + GetStringForSSID(network.dot11Ssid).Equals("DZSJ1"));
                //        }

                //    }
                //    wlanIface.Scan();

                //}
                //if (!hasSsid)
                //{
                //    throw new BaseException(string.Format("未扫描到SSID:{0}", ssid));

                //}
                //#endregion
            }
            catch (Exception ex)
            {
                throw new Exception("连接热点出错," + ex.Message);
            }
        }
Example #24
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ScanBindBtProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            string DevBt_MAC = configGv.Get(config.MacGlobalVaribles);
            //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));


            BluetoothRadio radio = BluetoothRadio.PrimaryRadio;//获取当前PC的蓝牙适配器

            //CheckForIllegalCrossThreadCalls = false;//不检查跨线程调用
            radio.Mode = RadioMode.Discoverable;
            if (radio == null)//检查该电脑蓝牙是否可用
            {
                throw new BaseException("本机电脑蓝牙不可用!");
            }


            BluetoothClient Blueclient = new BluetoothClient();

            BluetoothDeviceInfo[] devices = Blueclient.DiscoverDevices();
            bool             hasScanded   = false;
            BluetoothAddress btMac        = null;
            string           btName       = "";

            foreach (BluetoothDeviceInfo item in devices)
            {
                log.Info(string.Format("设备名:{0}\t\t地址:{1}", item.DeviceName, item.DeviceAddress));
                if (item.DeviceAddress.ToString() == DevBt_MAC)//"1895526CCD7B"
                {
                    hasScanded = true;
                    btMac      = item.DeviceAddress;
                    btName     = item.DeviceName;
                }
            }
            //Dictionary<string, BluetoothAddress> deviceAddresses = new Dictionary<string, BluetoothAddress>();
            //BluetoothRadio BuleRadio = BluetoothRadio.PrimaryRadio;
            //BuleRadio.Mode = RadioMode.Connectable;
            //BluetoothDeviceInfo[] Devices = Blueclient.DiscoverDevices();
            ////lsbDevices.Items.Clear();
            //deviceAddresses.Clear();
            //foreach (BluetoothDeviceInfo device in Devices)
            //{
            //    //循环将所有搜索到的设备添加进来。
            //    //lsbDevices.Items.Add(device.DeviceName);
            //    deviceAddresses[device.DeviceName] = device.DeviceAddress;
            //}
            if (!hasScanded)
            {
                throw new BaseException(string.Format("未扫描到指定MAC的蓝牙信号 \r\n"));
            }
            if (btMac == null)
            {
                throw new BaseException(string.Format("btMac为空,未扫描到指定MAC的蓝牙 \r\n"));
            }
            log.Info(string.Format("检测蓝牙RF信号PASS,MAC:{0}", btMac));


            //Guid mGUID2 = Guid.Parse("00001101-0000-1000-8000-00805F9B34FB");
            //Guid mGUID = Guid.Parse("0000fff4-0000-1000-8000-00805F9B34FB");//蓝牙串口服务的uuiid
            //配对:
            //Blueclient.SetPin(btMac, mGUID2);
            //Blueclient.SetPin(btMac, mGUID);

            //Blueclient.Connect(btMac, mGUID);
            if (config.ConnectionPairing)
            {
                Blueclient.Connect(btMac, BluetoothService.Handsfree);

                log.Info(string.Format("配对连接测试成功,{0}", btName));
                //Blueclient.Connect(btMac, mGUID2);
                //Blueclient.
                //Thread.Sleep(10000);
            }
            Blueclient.Close();
        }
Example #25
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;
            //String mapFileString = globalDic[typeof(String).ToString()] as String;

            String mapFileString = configGv.Get("MapFileStringMacUpdate");

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

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

            moudleWifiMap = moudleWifiMap.Replace("0x", "").Replace(" ", "");

            //for (int j = 4; j < moudleWifiMap.Length; j = j + 4)
            //{
            //    moudleWifiMap = moudleWifiMap.Insert(j, " ");
            //    j = j + 1;
            //}

            for (int i = 32; i < moudleWifiMap.Length; i = i + 32)
            {
                //if (moudleWifiMap[i])
                //{

                //}
                moudleWifiMap = moudleWifiMap.Insert(i, "\r\n");
                i             = i + 2;
            }

            string[] splits             = { "\r\n" };
            string[] moudleWifiMapLines = moudleWifiMap.Split(splits, StringSplitOptions.RemoveEmptyEntries);

            string tempMoudleWifiMap = "";

            for (int i = 0; i < moudleWifiMapLines.Length; i++)
            {
                for (int j = 4; j < moudleWifiMapLines[i].Length; j = j + 4)
                {
                    if (j != 39)
                    {
                        moudleWifiMapLines[i] = moudleWifiMapLines[i].Insert(j, " ");
                        j = j + 1;
                        //拼接完整
                    }
                }
                tempMoudleWifiMap += moudleWifiMapLines[i] + "\r\n";
            }

            if (tempMoudleWifiMap != mapFileString)
            {
                log.Fail(string.Format("WIFI MAP核验:\r\n读出模组WIFI MAP:\r\n{0}\r\n文件 WIFI MAP:\r\n{1}\r\n不一致 \r\n", tempMoudleWifiMap, mapFileString));
                throw new Exception(string.Format("WIFI MAP核验:不一致 \r\n"));
            }
            //string moudleBtMac = configGv.Get("");
            log.Pass(string.Format("WIFI MAP核验:\r\n读出模组WIFI MAP:\r\n{0}\r\n文件 WIFI MAP:\r\n{1}\r\n一致 \r\n", tempMoudleWifiMap, mapFileString));
        }
Example #26
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as WriteWifiMapProperties;
            ComDut comDut = globalDic[typeof(ComDut).ToString()] as ComDut;
            ILog   log    = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            String mapFileString = configGv.Get("MapFileStringMacUpdate");

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

            //循环写
            string[] splits  = { "\r", "\n", "\r\n" };
            string[] mapLine = mapFileString.Split(splits, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < mapLine.Length; i++)
            {
                //TimeUtils.Execute(() =>
                //{
                //循环写SSS
                int  retry      = 5;
                int  retryCount = 0;
                bool result     = false;
                do
                {
                    //Thread.Sleep(100);
                    comDut.Write(string.Format(config.WriteMapAtCommand, Convert.ToString(i * 0x10, 16), mapLine[i].Replace(" ", "")) + "\r\n");
                    Thread.Sleep(config.AtCommandInterval);
                    string response = comDut.ReadExisting();

                    if (!string.IsNullOrEmpty(config.AtCommandOk))
                    {
                        if (response.Contains(config.AtCommandOk) && !response.Contains(config.AtCommandError) && !response.Contains("FAIL") && !response.Contains("error"))
                        {
                            //log.Info(string.Format(",AT response=[{0}]  not contain =[{1}]", response, config.AtCommandOk));
                            //跳出循环执行
                            //return true;
                            //throw new BaseException(string.Format("AT response=[{0}] not contain error=[{1}]", response, config.AtCommandOk));
                            log.Info(string.Format("写入第{0}行MAP \r\nAT response:\r\n[{1}] \r\ncontain OK=[{2}] \r\nnot contain ERROR=[{3}] [FAIL]", i + 1, response, config.AtCommandOk, config.AtCommandError));
                            result = true;
                            break;
                        }
                        //else
                        //{
                        //    if (reTryCnt > 3)
                        //    {
                        //        throw new Exception(string.Format("写入错误 行数={0} \r\n串口返回:\r\n{1}", i + 1, response));
                        //    }
                        //}
                    }
                    Thread.Sleep(config.RetryInterval);
                    retry--;
                    retryCount++;
                    if (retry >= 0)
                    {
                        log.Info(string.Format("写入第{0}行MAP错误 \r\nAT response:\r\n[{1}] \r\ncontain OK=[{2}] \r\nnot contain ERROR=[{3}] [FAIL]", i + 1, response, config.AtCommandOk, config.AtCommandError));
                        log.Warn("重试第" + retryCount + "次");
                    }
                } while (retry >= 0);
                if (!result)
                {
                    throw new Exception(string.Format("写入错误 行数={0} \r\n", i + 1));
                }

                //comDut.Write(string.Format(config.WriteMapAtCommand, 0x00 + i * 0x10, mapLine[i].Replace(" ", "")) + "\r\n");
                //Thread.Sleep(config.AtCommandInterval);
                //string response = comDut.ReadExisting();

                //if (!string.IsNullOrEmpty(config.AtCommandOk))
                //{
                //    if (response.Contains(config.AtCommandOk) && !response.Contains(config.AtCommandError) && !response.Contains("FAIL") && !response.Contains("error"))
                //    {
                //        //log.Info(string.Format(",AT response=[{0}]  not contain =[{1}]", response, config.AtCommandOk));
                //        //跳出循环执行
                //        //return true;
                //        //throw new BaseException(string.Format("AT response=[{0}] not contain error=[{1}]", response, config.AtCommandOk));
                //        log.Info(string.Format("写入第{0}行MAP \r\nAT response:\r\n[{1}] \r\ncontain OK=[{2}] \r\nnot contain ERROR=[{3}] [FAIL]", i + 1, response, config.AtCommandOk, config.AtCommandError));

                //        //continue;
                //        //跳出循环执行
                //    }
                //    else
                //    {
                //        if (reTryCnt > 3)
                //        {
                //            throw new Exception(string.Format("写入错误 行数={0} \r\n串口返回:\r\n{1}", i + 1, response));
                //        }
                //    }
                //}



                //    //继续循环执行
                //    return false;
                //}, config.Timeout);
            }
        }
Example #27
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)
        {
            AutoToUserModeProperties config     = properties as AutoToUserModeProperties;
            List <ComDut>            comDutList = globalDic[typeof(List <ComDut>).ToString()] as List <ComDut>;
            //ComDut comDut = globalDic[typeof(ComDut).ToString()] as ComDut;
            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));
            }



            //OpenPhoneProperties configOpenPhone = globalDic[typeof(OpenPhoneProperties).ToString()] as OpenPhoneProperties;
            List <OpenPhoneProperties> configList      = globalDic[typeof(List <OpenPhoneProperties>).ToString()] as List <OpenPhoneProperties>;
            OpenPhoneProperties        configOpenPhone = null;

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

            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

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

            string endLine = configOpenPhone.EndLine;

            if (!string.IsNullOrEmpty(endLine))
            {
                endLine = Parse_r_n(endLine);
            }
            //if (config.CommandType == AtCommandProperties.EnumCommandType.String)
            string response = configGv.Get("PowerOnLog");
            {
                string atCommand = PreTranslateAtCommand(config.AtCommand);

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

                log.Info("PowerOnLog=" + response);

                if (!response.Contains("The driver is for MP"))
                {
                    log.Info("无需转换模式");
                    return;
                }
                //包含的话,需要转模式

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

                comDut.DtrEnable = configOpenPhone.Dtr;
                comDut.RtsEnable = configOpenPhone.Rts;
                comDut.Write(atCommand + endLine);

                Thread.Sleep(config.AtCommandInterval);
                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));
                            }
                            log.Info(string.Format("contain check info=[{0}]", checkInfo));
                        }
                    }
                }

                if (config.GlobalVariblesKey != null && config.GlobalVariblesKeyPattern != null)
                {
                    if (config.GlobalVariblesKey.Length != config.GlobalVariblesKeyPattern.Length)
                    {
                        throw new BaseException("请保持GlobalVariblesKey与GlobalVariblesKeyPattern成对存在");
                    }
                    for (int i = 0; i < config.GlobalVariblesKey.Length; i++)
                    {
                        string pattern    = Parse_r_n(config.GlobalVariblesKeyPattern[i]);
                        Match  matchValue = Regex.Match(response, pattern);
                        if (!matchValue.Success)
                        {
                            throw new BaseException("read info value fail");
                        }

                        string value = matchValue.Groups[1].ToString();

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

                        string key = matchKey.Groups[1].ToString();

                        configGv.Add(key, value);
                    }
                }
            }
            //else if (config.CommandType == AtCommandProperties.EnumCommandType.Hex)
            //{
            //    byte[] atCommand = strToToHexByte(config.AtCommand);
            //    //string atCommand = PreTranslateAtCommand(config.AtCommand);
            //    log.Info("AT Commond=" + config.AtCommand);

            //    comDut.DtrEnable = configOpenPhone.Dtr;
            //    comDut.RtsEnable = configOpenPhone.Rts;
            //    comDut.Write(atCommand, 0, atCommand.Length);
            //    log.Info("Tx:" + config.AtCommand);

            //    Thread.Sleep(config.AtCommandInterval);
            //    int length = comDut.ReadBufferSize;
            //    byte[] byteArray = new byte[length];
            //    comDut.Read(byteArray, 0, length);

            //    string hexStr = byteToHexStr(byteArray);
            //    log.Info("Rx:" + hexStr);
            //    string response = System.Text.Encoding.ASCII.GetString(byteArray);
            //    response = response.Replace("\0", "~");
            //    //string response = comDut.ReadExisting();
            //    //byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(response);
            //    configGv.Add("RetBytes", byteArray);

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

            //    log.Info("Response:\r\n" + 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 (config.GlobalVariblesKey != null && config.GlobalVariblesKeyPattern != null)
            //    {
            //        if (config.GlobalVariblesKey.Length != config.GlobalVariblesKeyPattern.Length)
            //        {
            //            throw new BaseException("请保持GlobalVariblesKey与GlobalVariblesKeyPattern成对存在");
            //        }
            //        for (int i = 0; i < config.GlobalVariblesKey.Length; i++)
            //        {
            //            string pattern = "-([0-9]{2}) ";
            //            Match matchValue = Regex.Match(response, pattern);
            //            if (!matchValue.Success)
            //            {
            //                throw new BaseException("read info value fail");
            //            }

            //            string value = matchValue.Groups[1].ToString();

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

            //            string key = matchKey.Groups[1].ToString();

            //            configGv.Add(key, value);
            //        }
            //    }
            //}
        }
Example #28
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ReadMapProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            string binFileString = "";
            //查询MAC对应的bin文件
            //第一种方法
            string mac = configGv.Get(GlobalVaribles.MAC);

            try
            {
                var files = Directory.GetFiles(config.BinFolderPath, "*.bin");
                foreach (var file in files)
                {
                    if (file.Contains(mac))
                    {
                        binFileString = ReadBinery(file);
                        break;
                    }
                }
                configGv.Add("BinFileString", binFileString);
                if (string.IsNullOrEmpty(binFileString))
                {
                    throw new Exception(string.Format("读取License文件失败,未读到该MAC:{0}的binFile", mac));
                }

                #region 从服务器download文件下来 http://10.42.1.4:9999/midea_hi3861_license/847C9B7E6287.bin
                //HttpTools.Download("http://10.42.1.4:9999/midea_hi3861_license/847C9B7E6.bin", "E:/testDownLoadBin/847C9B7E6287.bin");

                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("读取License文件失败,异常:{0}", ex.Message));
            }
            log.Info(string.Format("读取License文件成功:\r\n{0}", binFileString));

            //try
            //{
            //    binFileString = Read(config.MapFilePath);
            //}
            //catch (Exception ex)
            //{

            //    throw new Exception(string.Format("读取License文件失败,异常:{0}", ex.Message));
            //}

            //log.Info(string.Format("读取License文件成功:\r\n{0}", binFileString));
            ////更新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");
            //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);
        }
Example #29
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)
        {
            GetBtRssiAtCommandProperties config = properties as GetBtRssiAtCommandProperties;

            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("MoudleBtMac");
            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 (!string.IsNullOrEmpty(config.GlobalVariblesKey) && !string.IsNullOrEmpty(config.GlobalVariblesKeyPattern))
            {
                string pattern = Parse_r_n(config.GlobalVariblesKeyPattern);//"E000E64CCACE:RSSI:([0-9-]{3,4})[:]"     E000E64CCACE:RSSI:-052:
                pattern = moudleBtMac + pattern;
                Match matchValue = Regex.Match(response, pattern);
                if (!matchValue.Success)
                {
                    throw new BaseException("read info value fail");
                }

                string value = matchValue.Groups[1].ToString();

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

                string key = matchKey.Groups[1].ToString();

                configGv.Add(key, value);
            }
        }
Example #30
0
        private List <byte> buffer = new List <byte>(4096);       //uart 接受数据buffer 未做任何处理

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



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

            SkgQueryCheckProperties config = properties as SkgQueryCheckProperties;

            //解析是否收到正确的包,包头,命令,校验位
            //起始标志 数据长度 保留字     命令字     数据内容    异或校验码
            //0XA5C3    9+N     0x0000      0x0037      Data        异或
            //2 字节  2 字节    2 字节      2 字节      N 字节     1 字节
            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            byte[] dataArry = (byte[])configGv.GetObject(config.GlobalVariblesKey);



            //string fireWareVersion = config.FirewareVersion;
            //string softwareVersion = config.SoftwareVersion;
            //string firmwareName = config.FirmwareName;
            #region
            //是否完成过PCBA 0x01:已完成过 其他值:未完成过
            if (config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过PCBA测试 ||
                config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.全检
                )
            {
                if (dataArry[0] == 0x00)
                {
                    log.Info("完成过PCBA测试");
                }
                else
                {
                    //if (config.IfCheckFinishTest== SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过PCBA测试)
                    //{
                    throw new BaseException("未完成过PCBA测试");
                    //}
                    //log.Info("未完成过PCBA测试");
                }
            }

            //查询是否完成过整机测试  0x01:已完成过 其他值:未完成过
            if (config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过整机测试 ||
                config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.全检
                )
            {
                if (dataArry[1] == 0x00)
                {
                    log.Info("完成过整机测试");
                }
                else
                {
                    //if (config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过整机测试)
                    //{
                    throw new BaseException("未完成过整机测试");
                    //}

                    //log.Info("未完成过整机测试");
                }
            }

            //查询是否完成过老化测试  0x01:已完成过 其他值:未完成过
            if (config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过老化测试 ||
                config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.全检
                )
            {
                if (dataArry[2] == 0x00)
                {
                    log.Info("完成过老化测试");
                }
                else
                {
                    //if (config.IfCheckFinishTest == SkgQueryCheckProperties.EnumIfCheckFinishTest.检查是否完成过老化测试)
                    //{
                    throw new BaseException("未完成过老化测试");
                    //}

                    //log.Info("未完成过老化测试");
                }
            }


            //硬件版本号(高位) 0x00 硬件版本号(高位)
            if (!string.IsNullOrEmpty(config.FirewareVersion))
            {
                byte[] dataFirmwareVersion = new byte[2];
                Array.Copy(dataArry, 3, dataFirmwareVersion, 0, 2);
                string strFirmwareVersion = byteToHexStr(dataFirmwareVersion);
                //strFirmwareVersion = System.Text.Encoding.Unicode.GetString(dataFirmwareVersion);//ASCII
                //string strFirmwareVersion = byteToHexStr(dataFirmwareVersion);
                if (strFirmwareVersion != config.FirewareVersion)
                {
                    throw new BaseException(string.Format("硬件版本号:{0},与设置版本号:{1}不一致", strFirmwareVersion, config.FirewareVersion));
                }
                log.Info(string.Format("硬件版本号:{0},与设置版本号:{1}一致", strFirmwareVersion, config.FirewareVersion));
            }


            //软件版本号(高位) 0x00 软件版本号 6
            //软件版本号 0x01 软件版本号 7
            //软件版本号 0x02 软件版本号 8
            //软件版本号(低位) 0x03 软件版本号(低位)
            if (!string.IsNullOrEmpty(config.SoftwareVersion))
            {
                byte[] dataSoftwareVersion = new byte[4];
                Array.Copy(dataArry, 5, dataSoftwareVersion, 0, 4);
                string strSoftwareVersion = byteToHexStr(dataSoftwareVersion);
                //strSoftwareVersion = System.Text.Encoding.ASCII.GetString(dataSoftwareVersion);
                //string strSoftwareVersion = byteToHexStr(dataSoftwareVersion);
                if (strSoftwareVersion != config.SoftwareVersion)
                {
                    throw new BaseException(string.Format("软件版本号:{0},与设置版本号:{1}不一致", strSoftwareVersion, config.SoftwareVersion));
                }
                log.Info(string.Format("软件版本号:{0},与设置版本号:{1}一致", strSoftwareVersion, config.SoftwareVersion));
            }

            //MCU ID
            byte[] dataMcuId = new byte[12];
            Array.Copy(dataArry, 9, dataMcuId, 0, 12);
            //ASCII码的方式
            //string strDataMcuId = System.Text.Encoding.ASCII.GetString(dataMcuId);
            //MCU ID:1F39A109高位在前1F,39的直接16进制拼接方式
            string strDataMcuId = byteToHexStr(dataMcuId);
            log.Info(string.Format("MCU ID:{0}", strDataMcuId));

            //BLE MAC
            byte[] dataBleMac = new byte[6];
            Array.Copy(dataArry, 21, dataBleMac, 0, 6);
            //ASCII码的方式
            //string strDataMcuId = System.Text.Encoding.ASCII.GetString(dataMcuId);
            //BLE MAC:1F39A109,低位在前0x09,0xA1的直接16进制拼接方式
            string strDataBleMac = byteToHexStrReverse(dataBleMac);
            log.Info(string.Format("BLE MAC:{0}", strDataBleMac));
            configGv.Add(GlobalVaribles.MAC, strDataBleMac);
            //电池电压
            //长度 2字节
            if (!(config.VolMaxValue == 0 && config.VolMinValue == 0))
            {
                byte high = dataArry[27];
                byte low  = dataArry[28];
                int  vol  = (high & 0xFF) << 8 | low;
                CheckRange("电压值(mV):", vol, config.VolMaxValue, config.VolMinValue);
            }

            //NTC温度
            //长度 2字节
            if (!(config.Ntc1MaxValue == 0 && config.Ntc1MinValue == 0))
            {
                byte high = dataArry[29];
                if (high == 0x80)
                {
                    throw new BaseException(string.Format("NTC1 开路或短路,NTC温度输出 0x8000"));
                }

                byte low = dataArry[30];
                int  ntc = (high & 0xFF) << 8 | low;
                CheckRange("NTC1温度值(单位0.1摄氏度):", ntc, config.Ntc1MaxValue, config.Ntc1MinValue);
            }

            //PCBA-ID
            if (config.CheckNumberInFlash == SkgQueryCheckProperties.EnumCheckNumberInFlash.检查是否写入过PCBA_ID)
            {
                if (dataArry[30] > 0x18)
                {
                    throw new BaseException(string.Format("PCBID 有效长度:{0}不在0~24的合理范围内,未授权过", dataArry[31]));
                }
                byte[] dataPcbaId = new byte[24];
                Array.Copy(dataArry, 31, dataPcbaId, 0, 24);
                //ASCII码的方式
                //string strDataMcuId = System.Text.Encoding.ASCII.GetString(dataMcuId);
                //MCU ID:1F39A109高位在前1F,39的直接16进制拼接方式


                string strDataPcbaId = Encoding.ASCII.GetString(dataPcbaId);//byteToHexStr(dataPcbaId);
                strDataPcbaId = strDataPcbaId.Replace("\0", "");
                log.Info(string.Format("读取的PCBA-ID:{0}", strDataPcbaId));
                //int型处理
                string preSnPcbaId = configGv.Get(GlobalVaribles.LABEL_SN);
                if (preSnPcbaId != strDataPcbaId)
                {
                    throw new BaseException(string.Format("预写PCBIDA-ID :{0}与写入的PCBA-ID :{1},不一致", preSnPcbaId, strDataPcbaId));
                }
                log.Info(string.Format("预写PCBIDA-ID :{0}与写入的PCBA-ID :{1},一致", preSnPcbaId, strDataPcbaId));
                //configGv.Add("ReadPcbaId", strDataPcbaId);
            }
            else if (config.CheckNumberInFlash == SkgQueryCheckProperties.EnumCheckNumberInFlash.检查是否写入过SN)
            {
                if (dataArry[56] > 0x18)//31
                {
                    throw new BaseException(string.Format("SN 有效长度:{0}不在0~24的合理范围内,未授权过", dataArry[31]));
                }

                byte[] dataSn = new byte[24];
                Array.Copy(dataArry, 57, dataSn, 0, 24);//32
                //ASCII码的方式
                //string strDataMcuId = System.Text.Encoding.ASCII.GetString(dataMcuId);
                //MCU ID:1F39A109高位在前1F,39的直接16进制拼接方式
                //不足的,需要判断补0?
                //string strDataSn = byteToHexStr(dataSn);
                string strDataSn = Encoding.ASCII.GetString(dataSn);//byteToHexStr(dataPcbaId);
                strDataSn = strDataSn.Replace("\0", "");

                log.Info(string.Format("读取的SN:{0}", strDataSn));

                //int型处理
                string preSn = configGv.Get(GlobalVaribles.LABEL_SN);
                if (preSn != strDataSn)
                {
                    throw new BaseException(string.Format("预写SN :{0}与写入的SN :{1},不一致", preSn, strDataSn));
                }

                //configGv.Add("ReadSn", strDataSn);
            }
            else if (config.CheckNumberInFlash == SkgQueryCheckProperties.EnumCheckNumberInFlash.检查是否写入过蓝牙广播信息)
            {
                //预留-查询返回信息中没有蓝牙广播信息
            }
            else if (config.CheckNumberInFlash == SkgQueryCheckProperties.EnumCheckNumberInFlash.检查)
            {
                //跳过
            }

            //固件名称
            if (!string.IsNullOrEmpty(config.FirmwareName))
            {
                //byte[] dataFirmwareName = new byte[8];
                //Array.Copy(dataArry, 81, dataFirmwareName, 0, 8);

                byte[] dataFirmwareName = new byte[5];
                Array.Copy(dataArry, 80, dataFirmwareName, 0, 5);

                string strDataFirmwareName = System.Text.Encoding.ASCII.GetString(dataFirmwareName);
                strDataFirmwareName = strDataFirmwareName.Replace("\0", " ");
                //string strSoftwareVersion = byteToHexStr(dataSoftwareVersion);
                //log.Info("固件名称:" + strDataFirmwareName);
                if (strDataFirmwareName != config.FirmwareName)
                {
                    throw new BaseException(string.Format("固件名称:{0},与设置固件名称:{1}不一致", strDataFirmwareName, config.FirmwareName));
                }
                log.Info(string.Format("固件名称:{0},与设置固件名称:{1}一致", strDataFirmwareName, config.FirmwareName));
            }
            //电机转速
            if (!(config.MotorSpeedMaxValue == 0 && config.MotorSpeedMinValue == 0))
            {
                byte high       = dataArry[89];
                byte low        = dataArry[90];
                int  motorSpeed = (high & 0xFF) << 8 | low;
                CheckRange("电机转速:", motorSpeed, config.MotorSpeedMaxValue, config.MotorSpeedMinValue);
            }

            //NTC2温度
            if (!(config.Ntc2MaxValue == 0 && config.Ntc2MinValue == 0))
            {
                byte high = dataArry[91];
                if (high == 0x80)
                {
                    throw new BaseException(string.Format("NTC2 开路或短路,NTC温度输出 0x8000"));
                }

                byte low = dataArry[92];
                int  ntc = (high & 0xFF) << 8 | low;
                CheckRange("NTC2温度值(单位0.1摄氏度):", ntc, config.Ntc2MaxValue, config.Ntc2MinValue);
            }

            //NTC3温度
            if (!(config.Ntc3MaxValue == 0 && config.Ntc3MinValue == 0))
            {
                byte high = dataArry[93];
                if (high == 0x80)
                {
                    throw new BaseException(string.Format("NTC3 开路或短路,NTC温度输出 0x8000"));
                }

                byte low = dataArry[94];
                int  ntc = (high & 0xFF) << 8 | low;
                CheckRange("NTC3温度值(单位0.1摄氏度):", ntc, config.Ntc3MaxValue, config.Ntc3MinValue);
            }

            #endregion
        }