Exemplo n.º 1
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
            {
            }
        }