コード例 #1
0
        /// <summary>
        /// 将配置数据转化为内存对象
        /// </summary>
        /// <param name="errorInfo"></param>
        /// <returns></returns>
        bool _load(out string errorInfo)
        {
            _dctRecipes.Clear();
            JFXmlDictionary <string, List <string[]> > cateRecipeInCfg = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            foreach (KeyValuePair <string, List <string[]> > cr in cateRecipeInCfg)
            {
                if (!_dctRecipes.ContainsKey(cr.Key))
                {
                    _dctRecipes.Add(cr.Key, new Dictionary <string, JFCommonRecipe>());
                }
                Dictionary <string, JFCommonRecipe> dctInCate = _dctRecipes[cr.Key];
                foreach (string[] idAndTxt in cr.Value)
                {
                    JFCommonRecipe recipe = new JFCommonRecipe();
                    recipe.Categoty = cr.Key;
                    recipe.ID       = idAndTxt[0];
                    try
                    {
                        recipe.Dict = JFFunctions.FromXTString(idAndTxt[1], recipe.Dict.GetType()) as JFXmlDictionary <string, object>;
                    }
                    catch (Exception ex)
                    {
                        errorInfo = "Categoty = " + cr.Key + ", RecipeID = " + idAndTxt[0] + " FromXTString() Exception:" + ex.Message;
                        return(false);
                    }

                    dctInCate.Add(idAndTxt[0], recipe);
                }
            }
            errorInfo = "Success";
            return(true);
        }
コード例 #2
0
        /// <summary>
        ///设置取指定名称的初始化参数的当前值
        /// </summary>
        /// <param name="name">参数名称,如果参数名称不在InitParamNames中,将会抛出一个ArgumentException异常</param>
        /// <param name="value">参数值</param>
        /// <returns>操作成功返回True,失败返回false,可通过GetInitErrorInfo()获取错误信息</returns>
        public bool SetInitParamValue(string name, object value)
        {
            _CheckInitName(name, "SetInitParamValue(name, value)");
            if (null == value)
            {
                throw new Exception("SetInitParamValue(name, value) failed By: value = null");
            }

            if (!GetInitParamDescribe(name).ParamType.IsAssignableFrom(value.GetType()))
            {
                throw new ArgumentException(string.Format("SetInitParamValue(name = {0}, value) faile By: value's Type = {1} can't Assignable to InitParam's Type:{2}", name, value.GetType(), GetInitParamDescribe(name).ParamType.Name));
            }
            if (name == "IP")
            {
                string tmp = value as string;
                if (!JFFunctions.IsIPAddress(tmp))
                {
                    _initErrorInfo = string.Format("SetInitParamValue(string name = {0},...) failed By: name isnot Legal ip address", name);
                    return(false);
                }
                _cmrIP         = tmp;
                _initErrorInfo = "Success";
                return(true);
            }
            _initErrorInfo = string.Format("SetInitParamValue(string name = {0},...) failed By: name  is not included by InitParamNames:{1}", name, string.Join("|", InitParamNames));
            return(false);
        }
コード例 #3
0
        public void Save()
        {
            if (!IsInitOK)
            {
                return;
            }
            JFXmlDictionary <string, List <string[]> > dctRecipesInCfg = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            foreach (string categoty in _dctRecipes.Keys)
            {
                Dictionary <string, JFCommonRecipe> dctMmry = _dctRecipes[categoty]; //所有recipe内存对象
                List <string[]> lstInCfg = dctRecipesInCfg[categoty];
                foreach (KeyValuePair <string, JFCommonRecipe> kv in dctMmry)
                {
                    foreach (string[] idAndTxt in lstInCfg)
                    {
                        if (idAndTxt[0] == kv.Key)
                        {
                            string xmlTxt  = null;
                            string typeTxt = null;
                            JFFunctions.ToXTString(kv.Value.Dict, out xmlTxt, out typeTxt);
                            idAndTxt[1] = xmlTxt;
                            break;
                        }
                    }
                }
            }
            _cfg.Save();
        }
コード例 #4
0
        public virtual bool Action()
        {
            _actionStartCpuCount = JFFunctions.PerformanceCounter();
            bool isOK = innerFlow.Action();

            _actionStopCpuCount = JFFunctions.PerformanceCounter();
            return(isOK);
        }
コード例 #5
0
        public void SaveStationParams()
        {
            try
            {
                string recipeID = (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID");
                //工站参数
                SetCfgParamValue(mwidth, width.D);
                SetCfgParamValue(mheight, height.D);
                SetCfgParamValue(mRunMode, RunMode);
                SetCfgParamValue(mNum_Camera, Num_Camera);
                SetCfgParamValue(mSelectIndex, SelectedIndex);
                SetCfgParamValue(mZ_safe, Z_safe);

                //工站中默认的参数
                AddDictItem(mgenMapStartX, genMapStartX);
                AddDictItem(mgenMapStartY, genMapStartY);
                AddDictItem(mgenMapEndX, genMapEndX);
                AddDictItem(mgenMapEndY, genMapEndY);
                AddDictItem(msameSpace, sameSpace);
                AddDictItem(mlctScoreThresh, lctScoreThresh);
                AddDictItem(mcheckMdlMethod, checkMdlMethod);
                AddDictItem(musedoubleCheck, usedoubleCheck);
                //AddDictItem(mZFocus, ZFocus);

                double value = hv_dieWidth.D;
                AddDictItem(mdieWidth, value);
                value = hv_dieHeight.D;
                AddDictItem(mdieHeight, value);

                AddDictItem(mref_x, ref_x);
                AddDictItem(mref_y, ref_y);
                AddDictItem(mref_z, ref_z);
                AddDictItem(mscanRowNum, scanRowNum);
                AddDictItem(mscanColNum, scanColNum);
                AddDictItem(mclipPosNum, clipPosNum);
                AddDictItem(mscanPosNum, scanPosNum);

                string xmlTxt  = null;
                string typeTxt = null;
                JFFunctions.ToXTString(visionCfgParams, out xmlTxt, out typeTxt);
                AddDictItem(mVisionCfgName, xmlTxt);

                AddDictItem(mFovRow, ICFovRow);
                AddDictItem(mFovCol, ICFovCol);

                JFFunctions.ToXTString(Dict, out xmlTxt, out typeTxt);

                //若工站xml配置中不需要保存参数,则注释该行即可,那么工站参数仅会保存在Recipe manager中;
                SetCfgParamValue(recipeID, xmlTxt);

                jFDLAFProductRecipe.AutoMappingStationProInf = xmlTxt;
                jFDLAFProductRecipe.SaveParamsToCfg();
                JFHubCenter.Instance.RecipeManager.Save();
            }
            catch
            {
            }
        }
コード例 #6
0
 /// <summary>
 /// 对象初始化
 /// </summary>
 /// <returns>操作成功返回True,失败返回false,可通过GetInitErrorInfo()获取错误信息</returns>
 public bool Initialize()
 {
     if (!JFFunctions.IsIPAddress(_cmrIP))
     {
         _initErrorInfo = "Initialize()failed by IP = \"" + _cmrIP + "\" is not legal ip address";
         IsInitOK       = false;
         return(false);
     }
     IsInitOK       = true;
     _initErrorInfo = "Success";
     return(true);
 }
コード例 #7
0
ファイル: OptLightCtrl.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 对象初始化
        /// </summary>
        /// <returns>操作成功返回True,失败返回false,可通过GetInitErrorInfo()获取错误信息</returns>
        public bool Initialize()
        {
            if (IsDeviceOpen)
            {
                CloseDevice();
            }
            if (linkMode == null)
            {
                _initError = "Initialize Failed By:LinkMode is not set";
                IsInitOK   = false;
                return(false);
            }

            if (linkMode == linkModeParamRange[0] as string) //串口连接
            {
                if (JFFunctions.IsSerialPortName(linkParam))
                {
                    _initError = "Success";
                    IsInitOK   = true;
                    return(true);
                }
                _initError = "LinkParam = " + linkParam + " is not a legal serial-port name";
                IsInitOK   = false;
                return(false);
            }
            else if (linkMode == linkModeParamRange[1] as string)//TCP/IP
            {
                if (JFFunctions.IsIPAddress(linkParam))
                {
                    _initError = "Success";
                    IsInitOK   = true;
                    return(true);
                }
                _initError = "LinkParam = " + linkParam + " is not a legal ip address";
                IsInitOK   = false;
                return(false);
            }
            else if (linkMode == linkModeParamRange[2] as string) //SN
            {
                if (!string.IsNullOrWhiteSpace(linkParam))
                {
                    _initError = "Success";
                    IsInitOK   = true;
                    return(true);
                }
                _initError = "LinkParam =  null or whitespace when linkmode = SN";
                IsInitOK   = false;
                return(false);
            }
            _initError = "Initialize Failed By:LinkMode = " + linkMode + " is not included in the values{0:使用串口 1:使用TCP 2:使用SN}";
            IsInitOK   = false;
            return(false);
        }
コード例 #8
0
 public bool Action()
 {
     _startPfCnt = JFFunctions.PerformanceCounter();
     _endPfCnt   = _startPfCnt;
     if (string.IsNullOrEmpty(_filePath))
     {
         _actionErrorInfo = "图片文件路径未设置";
         _endPfCnt        = JFFunctions.PerformanceCounter();
         return(false);
     }
     if (!File.Exists(_filePath))
     {
         _actionErrorInfo = "Failed By: _filePath = \"" + _filePath + "\" is not existed";
         _endPfCnt        = JFFunctions.PerformanceCounter();
         return(false);
     }
     //if(_image != null)
     //{
     //    _image.Dispose();
     //    _image = null;
     //}
     try
     {
         HObject ho;
         HOperatorSet.ReadImage(out ho, _filePath);
         _image = new JFImage_Hlc(ho, 0);
     }
     catch (Exception ex)
     {
         _actionErrorInfo = "Failed By:Exception =" + ex.ToString();
         _endPfCnt        = JFFunctions.PerformanceCounter();
         return(false);
     }
     _endPfCnt        = JFFunctions.PerformanceCounter();
     _actionErrorInfo = "Success";
     return(true);
 }
コード例 #9
0
        public bool Action()
        {
            _startPfCnt = JFFunctions.PerformanceCounter();
            if (!IsInitOK)
            {
                _endPfCnt        = JFFunctions.PerformanceCounter();
                _actionErrorInfo = "初始化未完成";
                return(false);
            }
            IJFDevice dev = JFHubCenter.Instance.InitorManager.GetInitor(_devID) as IJFDevice;

            if (null == dev)
            {
                _endPfCnt        = JFFunctions.PerformanceCounter();
                _actionErrorInfo = "设备不存在,DevID = " + _devID;
                return(false);
            }

            int errCode = 0;

            if (_isOpen)
            {
                errCode = dev.OpenDevice();
            }
            else
            {
                errCode = dev.CloseDevice();
            }
            _endPfCnt = JFFunctions.PerformanceCounter();
            if (0 != errCode)
            {
                _actionErrorInfo = (_isOpen ? "打开" : "关闭") + "设备失败:" + dev.GetErrorInfo(errCode);
                return(false);
            }
            _actionErrorInfo = "Success";
            return(true);
        }
コード例 #10
0
ファイル: JFMethodFor.cs プロジェクト: xhyangxianjun/ASMZZZ
 public override double GetActionSeconds()
 {
     return((double)(_actionStopPerformance - _actionStartPerformance) / JFFunctions.PerformanceFrequency());
 }
コード例 #11
0
ファイル: JFMethodFor.cs プロジェクト: xhyangxianjun/ASMZZZ
        public override bool Action()
        {
            _actionStartPerformance = JFFunctions.PerformanceCounter();

            _status = 1;
            _eventCmd.Set();
            if (!IsInitOK)
            {
                _actionStopPerformance = JFFunctions.PerformanceCounter();
                _actionErrorInfo       = "Action failed by:is not init OK,initError:" + GetInitErrorInfo();
                _status = 0;
                return(false);
            }

            try
            {
                if (_isIncludeEnd)      //包含结束值
                {
                    if (_interval >= 0) //正向增加
                    {
                        for (_forValue = _startValue; _forValue <= _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }

                    else //负向递减
                    {
                        for (_forValue = _startValue; _forValue >= _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }
                }
                else//不包含结束值
                {
                    if (_interval >= 0) //正向增加
                    {
                        for (_forValue = _startValue; _forValue < _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }

                    else //负向递减
                    {
                        for (_forValue = _startValue; _forValue > _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }
                }
            }
            catch (JFBreakMethodFlowException) //Break 正常退出循环
            {
                _status = 0;
                _actionStopPerformance = JFFunctions.PerformanceCounter();
                _actionErrorInfo       = "Success - break while";
                return(true);
            }


            _actionStopPerformance = JFFunctions.PerformanceCounter();
            return(true);
        }
コード例 #12
0
 public virtual double GetActionSeconds()
 {
     return(((double)(_actionStopCpuCount - _actionStartCpuCount)) / JFFunctions.PerformanceFrequency());
 }
コード例 #13
0
ファイル: JFMethodBase.cs プロジェクト: xhyangxianjun/ASMZZZ
 protected void StopActionTimer()
 {
     _stopPerformanceCounter = JFFunctions.PerformanceCounter();
 }
コード例 #14
0
        internal void Init()
        {
            JFXmlSortedDictionary <string, List <object> > devInitParams = JFHubCenter.Instance.SystemCfg.GetItemValue(JFHubCenter.CK_InitDevParams) as JFXmlSortedDictionary <string, List <object> >;

            foreach (KeyValuePair <string, List <object> > kv in devInitParams)
            {
                IJFInitializable dev = JFHubCenter.Instance.InitorHelp.CreateInstance(kv.Value[0] as string); // as IJFDevice;
                dictInitors.Add(kv.Key, dev);
                try                                                                                           //尝试初始化
                {
                    string[] paramNames = dev.InitParamNames;
                    if (null != paramNames && paramNames.Length > 0)
                    {
                        for (int i = 0; i < paramNames.Length; i++)
                        {
                            object pr                   = i < kv.Value.Count - 1 ? kv.Value[i + 1] : null;
                            object relParamVal          = null;
                            Type   paramType            = dev.GetInitParamDescribe(paramNames[i]).ParamType;
                            SerializableAttribute[] sas = paramType.GetCustomAttributes(typeof(SerializableAttribute), false) as SerializableAttribute[];
                            if (sas != null && sas.Length > 0) //如果是可序列化的类型,直接保存序列化后的文本
                            {
                                relParamVal = JFFunctions.FromXTString(pr as string, paramType);
                            }
                            else
                            {
                                if (paramType.IsValueType || paramType == typeof(string)) //单值对象和字符串对象直接添加
                                {
                                    relParamVal = pr;
                                }
                                else //目前支持Array 和 List
                                {
                                    if (paramType.IsArray) //参数类型是数组
                                    {
                                        if (null == pr || string.Empty == pr as string)
                                        {
                                            relParamVal = null;
                                        }
                                        else
                                        {
                                            string[] elmts = (pr as string).Split(new char[] { '$' });
                                            relParamVal = GenArrayObject(paramType, elmts.Length);
                                            if (elmts.Length != 0)
                                            {
                                                for (int j = 0; j < elmts.Length; j++)
                                                {
                                                    (relParamVal as Array).SetValue(JFConvertExt.ChangeType(elmts[j], paramType.GetElementType()), j);
                                                }
                                            }
                                        }
                                    }
                                    else if (typeof(IList).IsAssignableFrom(paramType)) //队列类型
                                    {
                                        if (null == pr || string.Empty == pr as string)
                                        {
                                            relParamVal = null;
                                        }
                                        else
                                        {
                                            string[] elmts = (pr as string).Split(new char[] { '$' });
                                            relParamVal = GenListObject(paramType);
                                            if (elmts.Length != 0)
                                            {
                                                for (int j = 0; j < elmts.Length; j++)
                                                {
                                                    (relParamVal as IList).Add(JFConvertExt.ChangeType(elmts[j], paramType.GetElementType()));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            dev.SetInitParamValue(paramNames[i], relParamVal);
                        }
                    }
                    dev.Initialize();
                    if (dev is IJFDevice)
                    {
                        (dev as IJFDevice).OpenDevice();
                        Thread.Sleep(100);
                    }
                }
                catch
                {
                    //初始化发生异常
                }
                //dictInitors.Add(kv.Key, dev);
                //if (dev is IJFStation)
                //{
                //    (dev as IJFStation).WorkStatusChanged += JFHubCenter.Instance.StationMgr.StationWorkStatusChanged;
                //    (dev as IJFStation).CustomStatusChanged += JFHubCenter.Instance.StationMgr.StationCustomStatusChanged;
                //    if (dev is JFCmdWorkBase)
                //        (dev as JFCmdWorkBase).WorkMsg2Outter += JFHubCenter.Instance.StationMgr.StationWorkMsg;
                //}
            }
        }
コード例 #15
0
        public void InitStationParams()
        {
            try
            {
                Dict            = new JFXmlDictionary <string, object>();
                visionCfgParams = new JFXmlDictionary <string, JFXmlDictionary <string, JFXmlDictionary <string, string> > >();
                //系统参数
                imageFolder = (string)JFHubCenter.Instance.RecipeManager.GetInitParamValue((string)JFHubCenter.Instance.RecipeManager.InitParamNames[2]);
                ActivePdt   = (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID");

                formIniConfig = new IniFiles(imageFolder + "\\" + ActivePdt + "\\scanPoint.ini");
                //工站参数
                width         = (double)GetCfgParamValue(mwidth);
                height        = (double)GetCfgParamValue(mheight);
                _RunMode      = (int)GetCfgParamValue(mRunMode);
                Num_Camera    = (int)GetCfgParamValue(mNum_Camera);
                SelectedIndex = (int)GetCfgParamValue(mSelectIndex);
                Z_safe        = (double)GetCfgParamValue(mZ_safe);

                jFDLAFProductRecipe = ((JFDLAFProductRecipe)JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")));
                //Recipe参数
                if (jFDLAFProductRecipe != null)
                {
                    FrameLength     = jFDLAFProductRecipe.FrameLength;
                    RowNumber       = jFDLAFProductRecipe.RowNumber;
                    ColumnNumber    = jFDLAFProductRecipe.ColumnNumber;
                    BlockNumber     = jFDLAFProductRecipe.BlockNumber;
                    visionCfgParams = jFDLAFProductRecipe.visionCfgParams;
                    ZFocus          = jFDLAFProductRecipe.ZFocus;
                }
                else
                {
                    return;
                }

                if (jFDLAFProductRecipe.AutoMappingStationProInf != "")
                {
                    string xmlTxt = jFDLAFProductRecipe.AutoMappingStationProInf;
                    Dict = JFFunctions.FromXTString(xmlTxt, Dict.GetType()) as JFXmlDictionary <string, object>;

                    xmlTxt = Dict.ContainsKey(mVisionCfgName) ? (string)Dict[mVisionCfgName] : "";
                    if (xmlTxt != "")
                    {
                        visionCfgParams = JFFunctions.FromXTString(xmlTxt, visionCfgParams.GetType()) as JFXmlDictionary <string, JFXmlDictionary <string, JFXmlDictionary <string, string> > >;
                    }

                    //工站中默认的参数
                    genMapStartX   = Dict.ContainsKey(mgenMapStartX) ? (double)Dict[mgenMapStartX] : 0;
                    genMapStartY   = Dict.ContainsKey(mgenMapStartY) ? (double)Dict[mgenMapStartY] : 0;
                    genMapEndX     = Dict.ContainsKey(mgenMapEndX) ? (double)Dict[mgenMapEndX] : 0;
                    genMapEndY     = Dict.ContainsKey(mgenMapEndY) ? (double)Dict[mgenMapEndY] : 0;
                    sameSpace      = Dict.ContainsKey(msameSpace) ? (double)Dict[msameSpace] : 0;
                    lctScoreThresh = Dict.ContainsKey(mlctScoreThresh) ? (double)Dict[mlctScoreThresh] : 0;
                    checkMdlMethod = Dict.ContainsKey(mcheckMdlMethod) ? (int)Dict[mcheckMdlMethod] : 0;
                    usedoubleCheck = Dict.ContainsKey(musedoubleCheck) ? (int)Dict[musedoubleCheck] : 0;

                    //ZFocus = Dict.ContainsKey(mZFocus) ? (double)Dict[mZFocus] : 0;
                    hv_dieWidth  = Dict.ContainsKey(mdieWidth) ? (double)Dict[mdieWidth] : 0;
                    hv_dieHeight = Dict.ContainsKey(mdieHeight) ? (double)Dict[mdieHeight] : 0;
                    ref_x        = Dict.ContainsKey(mref_x) ? (double)Dict[mref_x] : 0;
                    ref_y        = Dict.ContainsKey(mref_y) ? (double)Dict[mref_y] : 0;
                    ref_z        = Dict.ContainsKey(mref_z) ? (double)Dict[mref_z] : 0;
                    scanRowNum   = Dict.ContainsKey(mscanRowNum) ? (int)Dict[mscanRowNum] : 0;
                    scanColNum   = Dict.ContainsKey(mscanColNum) ? (int)Dict[mscanColNum] : 0;
                    clipPosNum   = Dict.ContainsKey(mclipPosNum) ? (int)Dict[mclipPosNum] : 0;
                    scanPosNum   = Dict.ContainsKey(mscanPosNum) ? (int)Dict[mscanPosNum] : 0;

                    if (Dict.ContainsKey(mFovRow))
                    {
                        ICFovRow = (List <double>)Dict[mFovRow];
                    }
                    if (Dict.ContainsKey(mFovCol))
                    {
                        ICFovCol = (List <double>)Dict[mFovCol];
                    }
                }
                else
                {
                    if (Config.ContainsItem((string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")))
                    {
                        string xmlTxt = (string)GetCfgParamValue((string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"));
                        Dict = JFFunctions.FromXTString(xmlTxt, Dict.GetType()) as JFXmlDictionary <string, object>;

                        xmlTxt = Dict.ContainsKey(mVisionCfgName) ? (string)Dict[mVisionCfgName] : "";
                        if (xmlTxt != "")
                        {
                            visionCfgParams = JFFunctions.FromXTString(xmlTxt, visionCfgParams.GetType()) as JFXmlDictionary <string, JFXmlDictionary <string, JFXmlDictionary <string, string> > >;
                        }

                        //工站中默认的参数
                        genMapStartX   = Dict.ContainsKey(mgenMapStartX) ? (double)Dict[mgenMapStartX] : 0;
                        genMapStartY   = Dict.ContainsKey(mgenMapStartY) ? (double)Dict[mgenMapStartY] : 0;
                        genMapEndX     = Dict.ContainsKey(mgenMapEndX) ? (double)Dict[mgenMapEndX] : 0;
                        genMapEndY     = Dict.ContainsKey(mgenMapEndY) ? (double)Dict[mgenMapEndY] : 0;
                        sameSpace      = Dict.ContainsKey(msameSpace) ? (double)Dict[msameSpace] : 0;
                        lctScoreThresh = Dict.ContainsKey(mlctScoreThresh) ? (double)Dict[mlctScoreThresh] : 0;
                        checkMdlMethod = Dict.ContainsKey(mcheckMdlMethod) ? (int)Dict[mcheckMdlMethod] : 0;
                        usedoubleCheck = Dict.ContainsKey(musedoubleCheck) ? (int)Dict[musedoubleCheck] : 0;
                        //ZFocus = Dict.ContainsKey(mZFocus) ? (double)Dict[mZFocus] : 0;
                        hv_dieWidth  = Dict.ContainsKey(mdieWidth) ? (double)Dict[mdieWidth] : 0;
                        hv_dieHeight = Dict.ContainsKey(mdieHeight) ? (double)Dict[mdieHeight] : 0;
                        ref_x        = Dict.ContainsKey(mref_x) ? (double)Dict[mref_x] : 0;
                        ref_y        = Dict.ContainsKey(mref_y) ? (double)Dict[mref_y] : 0;
                        ref_z        = Dict.ContainsKey(mref_z) ? (double)Dict[mref_z] : 0;
                        scanRowNum   = Dict.ContainsKey(mscanRowNum) ? (int)Dict[mscanRowNum] : 0;
                        scanColNum   = Dict.ContainsKey(mscanColNum) ? (int)Dict[mscanColNum] : 0;
                        clipPosNum   = Dict.ContainsKey(mclipPosNum) ? (int)Dict[mclipPosNum] : 0;
                        scanPosNum   = Dict.ContainsKey(mscanPosNum) ? (int)Dict[mscanPosNum] : 0;

                        if (Dict.ContainsKey(mFovRow))
                        {
                            ICFovRow = (List <double>)Dict[mFovRow];
                        }
                        if (Dict.ContainsKey(mFovCol))
                        {
                            ICFovCol = (List <double>)Dict[mFovCol];
                        }
                    }
                }

                //else if(File.Exists(imageFolder + "\\" + ActivePdt + "\\scanPoint.ini"))
                //{
                //    formIniConfig.ReadDouble("ScanPoints", "genMapStartX", out genMapStartX);
                //    formIniConfig.ReadDouble("ScanPoints", "genMapStartY", out genMapStartY);
                //    formIniConfig.ReadDouble("ScanPoints", "genMapEndX", out genMapEndX);
                //    formIniConfig.ReadDouble("ScanPoints", "genMapEndY", out genMapEndY);
                //    formIniConfig.ReadDouble("ScanPoints", "sameSpace", out sameSpace);
                //    formIniConfig.ReadDouble("ScanPoints", "scaleFactor", out scaleFactor);
                //    formIniConfig.ReadDouble("ScanPoints", "lctScoreThresh", out lctScoreThresh);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosX", out checkPosX);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosY", out checkPosY);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosScoreThresh", out checkPosScoreThresh);
                //    formIniConfig.ReadDouble("ScanPoints", "widthFactor", out widthFactor);
                //    formIniConfig.ReadDouble("ScanPoints", "heightFactor", out heightFactor);
                //    formIniConfig.ReadInteger("ScanPoints", "CheckModelMethod", out checkMdlMethod);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosRX", out checkPosRX);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosRY", out checkPosRY);
                //    formIniConfig.ReadDouble("ScanPoints", "checkPosRScoreThresh", out checkPosRScoreThresh);
                //    formIniConfig.ReadInteger("ScanPoints", "useDoubleCheck", out usedoubleCheck);

                //    ICFovRow = new List<double>();
                //    ICFovCol = new List<double>();
                //}
            }
            catch
            {
            }
        }
コード例 #16
0
ファイル: JFMethodBase.cs プロジェクト: xhyangxianjun/ASMZZZ
 protected void StartActionTimer()
 {
     _startPerformanceCounter = JFFunctions.PerformanceCounter();
 }
コード例 #17
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (null == _mgr)
            {
                MessageBox.Show("无效操作,RecipeManager未设置");
                return;
            }

            if (!_mgr.IsInitOK)
            {
                MessageBox.Show("无效操作,RecipeManager未初始化,ErrorInfo:" + _mgr.GetInitErrorInfo());
                return;
            }

            if (string.IsNullOrWhiteSpace(cbGenCate.Text))
            {
                MessageBox.Show("参数项 Categoty 不能为空值!");
                return;
            }

            if (string.IsNullOrWhiteSpace(tbGenID.Text))
            {
                MessageBox.Show("参数项 RecipeID 不能为空值!");
                return;
            }

            string[] existIDs = _mgr.AllRecipeIDsInCategoty(cbGenCate.Text);
            if (null != existIDs && existIDs.Contains(tbGenID.Text))
            {
                MessageBox.Show("添加Recipe失败,Categoty = " + cbGenCate.Text + "已包含当前RecipeID = " + tbGenID.Text);
                return;
            }

            JFCommonRecipe newRecipe = new JFCommonRecipe();

            newRecipe.Categoty = cbGenCate.Text;
            newRecipe.ID       = tbGenID.Text;
            if (chkCopy.Checked) //以拷贝的方式创建新的Recipe
            {
                if (string.IsNullOrEmpty(cbCopyCate.Text))
                {
                    MessageBox.Show("请选择待拷贝的Categoty!");
                    return;
                }

                if (string.IsNullOrEmpty(cbCopyID.Text))
                {
                    MessageBox.Show("请选择待拷贝的RecipeID!");
                    return;
                }

                JFCommonRecipe recipe = _mgr.GetRecipe(cbCopyCate.Text, cbCopyID.Text) as JFCommonRecipe;
                string         xmlTxt;
                string         typeTxt;
                JFFunctions.ToXTString(recipe.Dict, out xmlTxt, out typeTxt);
                newRecipe.Dict = JFFunctions.FromXTString(xmlTxt, typeTxt) as JFXmlDictionary <string, object>;
            }


            _mgr.AddRecipe(cbGenCate.Text, tbGenID.Text, newRecipe);
            _mgr.Save();
            DialogResult = DialogResult.OK;
        }