Пример #1
0
        /// <summary>
        /// 设置工站使能
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="enable"></param>
        public void SetStationEnabled(string stationName, bool enable)
        {
            if (!_initorStationNames().Contains(stationName))
            {
                throw new ArgumentException("stationName = \"" + stationName + "\" is not included by Station-Name List");
            }
            if (!_dictStationEnabled.ContainsKey(stationName))
            {
                _dictStationEnabled.Add(stationName, enable);
                return;
            }
            else
            {
                _dictStationEnabled[stationName] = enable;
            }
            IJFStation station = GetStation(stationName);

            if (enable)
            {
                station.WorkStatusChanged   += StationWorkStatusChanged;
                station.CustomStatusChanged += StationCustomStatusChanged;
                if (station is JFCmdWorkBase)
                {
                    (station as JFCmdWorkBase).WorkMsg2Outter += StationTxtMsg;
                }
                if (station is JFStationBase)
                {
                    (station as JFStationBase).EventCustomizeMsg    += StationCustomizeMsg;
                    (station as JFStationBase).EventProductFinished += StationProductFinished;
                }
            }
            else
            {
                station.WorkStatusChanged   -= StationWorkStatusChanged;
                station.CustomStatusChanged -= StationCustomStatusChanged;
                if (station is JFCmdWorkBase)
                {
                    (station as JFCmdWorkBase).WorkMsg2Outter -= StationTxtMsg;
                }

                if (station is JFStationBase)
                {
                    (station as JFStationBase).EventCustomizeMsg    -= StationCustomizeMsg;
                    (station as JFStationBase).EventProductFinished -= StationProductFinished;
                }
            }
            _cfg.Save();
        }
Пример #2
0
        ///// <summary>
        ///// 添加一个产品类别
        ///// </summary>
        ///// <param name="recipeCategoty"></param>
        //void AddRecipeCategoty(string categoty);

        /// <summary>
        /// 移除一个类别(下的所有RecipeID)
        /// </summary>
        /// <param name="recipeCategoty"></param>
        public void RemoveCategoty(string categoty)
        {
            if (!_cfg.ContainsItem("Categoties"))
            {
                return;
            }
            //移除配置参数
            List <string> categoties = _cfg.GetItemValue("Categoties") as List <string>;

            if (!categoties.Contains(categoty))
            {
                return;
            }
            categoties.Remove(categoty);
            JFXmlDictionary <string, List <string[]> > recipesInCfg = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            if (recipesInCfg.ContainsKey(categoty))
            {
                recipesInCfg.Remove(categoty);
            }

            //移除内存对象
            if (_dctRecipes.ContainsKey(categoty))
            {
                _dctRecipes.Remove(categoty);
            }
        }
Пример #3
0
        /// <summary>
        /// 更新VisionCfgName
        /// </summary>
        private bool UpdateVisionCfgNames()
        {
            int startIndex = 0;
            int endIndex   = 0;
            int fovCount   = _visionCfgParams.Keys.Count;

            for (int m = 0; m < fovCount; m++)
            {
                JFXmlDictionary <string, JFXmlDictionary <string, string> > dicFovVisionCfgName = _visionCfgParams[m.ToString()];
                foreach (string fovname in dicFovVisionCfgName.Keys)
                {
                    JFXmlDictionary <string, string> visionCfgNames = dicFovVisionCfgName[fovname];
                    endIndex = startIndex + visionCfgNames.Keys.Count;

                    visionCfgNames.Clear();
                    for (int i = startIndex; i < endIndex; i++)
                    {
                        if (dgvVisionCfg.Rows[i].Cells[1].Value.ToString() == "")
                        {
                            MessageBox.Show(string.Format("当前行{0}的Task名称不可为空", i));
                            return(false);
                        }
                        if (visionCfgNames.ContainsKey(dgvVisionCfg.Rows[i].Cells[1].Value.ToString()))
                        {
                            MessageBox.Show(string.Format("视野名称为{0}的光源配置名{1}已存在", fovname, dgvVisionCfg.Rows[i].Cells[1].Value.ToString()));
                            return(false);
                        }
                        visionCfgNames.Add(dgvVisionCfg.Rows[i].Cells[1].Value.ToString(), dgvVisionCfg.Rows[i].Cells[2].Value.ToString());
                    }
                    startIndex = endIndex;
                }
            }
            return(true);
        }
Пример #4
0
 /// <summary>
 /// 查询点表触发源
 /// </summary>
 /// <param name="value"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 private int GetTCmprIdleSource(int encChn, out int value, out int index)
 {
     value = 0;
     index = 0;
     if (chnTcmpr.ContainsKey(encChn))
     {
         value = chnTcmpr[encChn];
         foreach (int outindex in tcmpSource.Keys)
         {
             if (tcmpSource[outindex] == value)
             {
                 index = outindex;
                 return((int)ErrorDef.Success);
             }
         }
         return((int)ErrorDef.TrgTcmpSrcError);
     }
     else
     {
         for (int i = 0; i < TrigChannels; i++)
         {
             if (!tcmprUsed[i])
             {
                 index = i;
                 value = tcmpSource[i];
                 chnTcmpr.Add(encChn, value);
                 return((int)ErrorDef.Success);
             }
         }
     }
     return((int)ErrorDef.TrgTcmpSrcError);
 }
Пример #5
0
        /// <summary>
        /// 添加一个产品/配方
        /// </summary>
        /// <param name="categoty"></param>
        /// <param name="recipeID"></param>
        /// <param name="recipe"></param>
        public bool AddRecipe(string categoty, string recipeID, IJFRecipe recipe = null)
        {
            if (string.IsNullOrEmpty(categoty))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(recipeID))
            {
                return(false);
            }
            if (recipe != null && recipe.GetType() != typeof(JFCommonRecipe))
            {
                return(false);
            }
            if (GetRecipe(categoty, recipeID) != null) //已已存在同名Recipe
            {
                return(false);
            }


            JFCommonRecipe cmRecipe = recipe as JFCommonRecipe;

            if (null == cmRecipe)
            {
                cmRecipe = new JFCommonRecipe();
            }
            cmRecipe.ID       = recipeID;
            cmRecipe.Categoty = categoty;

            List <string> lstCatesInCfg = _cfg.GetItemValue("Categoties") as List <string>;

            if (!lstCatesInCfg.Contains(categoty))
            {
                lstCatesInCfg.Add(categoty);
            }

            JFXmlDictionary <string, List <string[]> > dctRecipesInCfg = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            if (!dctRecipesInCfg.ContainsKey(categoty))
            {
                dctRecipesInCfg.Add(categoty, new List <string[]>());
            }
            List <string[]> lstIDAndTxt = dctRecipesInCfg[categoty];

            lstIDAndTxt.Add(new string[] { recipeID, cmRecipe.Dict.ToString() });

            if (!_dctRecipes.ContainsKey(categoty))
            {
                _dctRecipes.Add(categoty, new Dictionary <string, JFCommonRecipe>());
            }
            Dictionary <string, JFCommonRecipe> dctInMmry = _dctRecipes[categoty];

            dctInMmry.Add(recipeID, cmRecipe);
            return(true);
        }
Пример #6
0
        /// <summary>
        /// 获取指定类别下的所有产品/配方 ID
        /// </summary>
        /// <returns></returns>
        public string[] AllRecipeIDsInCategoty(string categoty)
        {
            JFXmlDictionary <string, List <string[]> > cateRecipes = _cfg.GetItemValue("Cate-Recipes") as JFXmlDictionary <string, List <string[]> >;

            if (!cateRecipes.ContainsKey(categoty))
            {
                return(null);
            }
            List <string[]> recipes = cateRecipes[categoty];
            List <string>   ret     = new List <string>();

            foreach (string[] sa in recipes)
            {
                ret.Add(sa[0]);
            }
            return(ret.ToArray());
        }
Пример #7
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
            {
            }
        }
        /// <summary>
        /// 根据Station中声明的设备通道变量布局界面
        /// </summary>
        void AdjustStationView()
        {
            tabControlCF1.TabPages.Clear();
            _isEditting          = false;
            btEditCancel.Enabled = false;
            btEditSave.Text      = "编辑";
            if (null == _station)
            {
                lbStationName.Text = "未设置";
                btEditSave.Enabled = false;
                return;
            }
            lbStationName.Text = _station.Name;
            btEditSave.Enabled = true;
            JFXmlDictionary <NamedChnType, List <List <string> > > devChns = _station.DeclearedDevChnMapping;

            ///工站声明的轴
            if (devChns.ContainsKey(NamedChnType.Axis))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Axis];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Axis");
                    tp.Tag = NamedChnType.Axis;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "轴名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = locAndGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }

            ///工站声明的DI
            if (devChns.ContainsKey(NamedChnType.Di))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Di];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("DI");
                    tp.Tag = NamedChnType.Di;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "DI名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = locAndGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }

            ///工站声明的DO
            if (devChns.ContainsKey(NamedChnType.Do))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Do];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("DO");
                    tp.Tag = NamedChnType.Do;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "DO名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = locAndGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }

            ///工站声明的Cmr
            if (devChns.ContainsKey(NamedChnType.Camera))
            {
                List <List <string> > cmrMapping = devChns[NamedChnType.Camera];
                if (null != cmrMapping && cmrMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Camera");
                    tp.Tag = NamedChnType.Camera;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "相机名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> cmrLocGlobName in cmrMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = cmrLocGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (cmrLocGlobName.Count > 1)
                        {
                            cellGlobName.Value = cmrLocGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }

            ///工站声明的光源
            if (devChns.ContainsKey(NamedChnType.Light))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Light];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Light");
                    tp.Tag = NamedChnType.Light;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "开关光源名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = locAndGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }
            ///工站声明的(光源)触发通道
            if (devChns.ContainsKey(NamedChnType.Trig))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Trig];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Trig");
                    tp.Tag = NamedChnType.Trig;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "触发光源名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = chnMapping[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }
            ///工站声明的比较触发器
            if (devChns.ContainsKey(NamedChnType.CmpTrig))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.CmpTrig];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("CmpTrig");
                    tp.Tag = NamedChnType.CmpTrig;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "位置比较触发器名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = chnMapping[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }
            ///工站声明的AI
            if (devChns.ContainsKey(NamedChnType.Ai))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Ai];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Ai");
                    tp.Tag = NamedChnType.Ai;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "Ai名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = locAndGlobName[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (chnMapping.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }
            ///工站声明的AO
            if (devChns.ContainsKey(NamedChnType.Ao))
            {
                List <List <string> > chnMapping = devChns[NamedChnType.Ao];
                if (null != chnMapping && chnMapping.Count > 0)
                {
                    TabPage tp = new TabPage("Ao");
                    tp.Tag = NamedChnType.Ao;
                    tabControlCF1.TabPages.Add(tp);
                    tp.AutoScroll = true;

                    DataGridView dgv = new DataGridView();
                    dgv.Columns.Add(new DataGridViewTextBoxColumn());
                    dgv.Columns.Add(new DataGridViewComboBoxColumn());
                    dgv.Columns[0].HeaderText = "Ao名/站内";
                    dgv.Columns[0].Width      = 200;
                    dgv.Columns[0].ReadOnly   = true;
                    dgv.Columns[1].HeaderText = "全局标识名";
                    dgv.Columns[1].Width      = 300;
                    dgv.Columns[1].ReadOnly   = true;
                    dgv.Dock                  = DockStyle.Fill;
                    dgv.ReadOnly              = true;
                    dgv.AllowUserToAddRows    = false;
                    dgv.AllowUserToDeleteRows = false;
                    dgv.AllowUserToResizeRows = false;
                    dgv.RowHeadersVisible     = false;
                    tp.Controls.Add(dgv);
                    foreach (List <string> locAndGlobName in chnMapping)
                    {
                        DataGridViewRow         row         = new DataGridViewRow();
                        DataGridViewTextBoxCell cellLocName = new DataGridViewTextBoxCell();
                        cellLocName.Value = chnMapping[0];
                        DataGridViewComboBoxCell cellGlobName = new DataGridViewComboBoxCell();
                        if (locAndGlobName.Count > 1)
                        {
                            cellGlobName.Value = locAndGlobName[1];
                        }
                        //cellGlobName.Items.Add()
                        row.Cells.Add(cellLocName);
                        row.Cells.Add(cellGlobName);
                        dgv.Rows.Add(row);
                    }
                }
            }

            LoadStation();
        }
Пример #9
0
        public int SetEncoderTrigBind(int encChn, int[] trigChns)
        {
            int Param_Value = 0;
            int err         = 0;

            if (encChn < 0 || encChn >= EncoderChannels)
            {
                throw new ArgumentOutOfRangeException("SetEncoderTrigBind(encChn ,...) fialed By:encChn = " + encChn + " is outof range:0~" + (EncoderChannels - 1));
            }
            if (trigChns == null)
            {
                return((int)ErrorDef.InvokeFailed);
            }

            for (int i = 0; i < chnTrig[encChn].Length; i++)
            {
                if (trigChns[i] < 0 || trigChns[i] >= TrigChannels)
                {
                    throw new ArgumentOutOfRangeException("SetEncoderTrigBind(encChn ,...) fialed By:trigChns = " + trigChns[i] + " is outof range:0~" + (TrigChannels - 1));
                }
            }

            bool exist = false;
            bool equal = false;

            if (chnTrig.ContainsKey(encChn))
            {
                exist = true;
                if (chnTrig[encChn] == trigChns)
                {
                    equal = true;
                }
            }

            if (exist && !equal)
            {
                if (chnTrig.ContainsKey(encChn))
                {
                    chnTrig[encChn] = trigChns;
                }
                else
                {
                    chnTrig.Add(encChn, trigChns);
                }



                for (int i = 0; i < TrigChannels; i++)
                {
                    if (APS168.APS_reset_trigger_count(BoardID, i) != 0)//reset count
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    if (SetTrigEnable(i, false) != (int)ErrorDef.Success)//disable trig
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    if (APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_SRC + i, 0) != 0)//Trig source bind
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    if (SetTrigEnable(i, trigEnables[i]) != (int)ErrorDef.Success)//enable or disable trig
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }
                }

                if (SaveParamsToFlash() != 0)
                {
                    return((int)ErrorDef.InvokeFailed);
                }

                for (int i = 0; i < EncoderChannels; i++)
                {
                    if (!chnTrig.ContainsKey(i))
                    {
                        continue;
                    }
                    if (chnTrig[i].Length <= 0)
                    {
                        continue;
                    }
                    int[] TrigChns = new int[chnTrig[i].Length];
                    TrigChns = chnTrig[i];
                    if (SetEncoderTrigBind(i, TrigChns) != (int)ErrorDef.Success) //循环调用???????????????????? BobY
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }
                }
                _jf168Cfg.Save();
                return((int)ErrorDef.Success);
            }

            //encoder和trig源进行绑定
            Param_Value = 0;
            for (int i = 0; i < trigChns.Length; i++)
            {
                JFCompareTrigMode jFCompareTrigMode;
                if (GetTrigMode(encChn, out jFCompareTrigMode) != (int)ErrorDef.Success)
                {
                    return((int)ErrorDef.InvokeFailed);
                }

                int value = 0;
                int index = 0;

                #region JFCompareTrigMode.liner
                if (jFCompareTrigMode == JFCompareTrigMode.liner)
                {
                    if (GetLCmprIdleSource(encChn, out value, out index) != (int)ErrorDef.Success)//get Ideal LCMP source
                    {
                        return((int)ErrorDef.TrgLcmpSrcError);
                    }
                    err = APS168.APS_set_trigger_param(BoardID, value, encChn);//Param:TGR_LCMP0_SRC
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    //Trigger output 0 (TRG0) source Bit( 1:On, 0:Off)  Bit 0: Manual  Bit 1:Reserved Bit  2:TCMP0  Bit 3:TCMP1  Bit 4:LCMP0  Bit 5:LCMP1 Bit 6:MCMP
                    //Bit 7:TCMP2 Bit 8:TCMP3 Bit 9:LCMP2 Bit 10:LCMP3
                    Param_Value = 0;
                    //获取TRGSRC与TCMP已建立的绑定关系
                    List <int> triglcmpsrc = new List <int>();
                    if (trigLCmprSource.ContainsKey(trigChns[i]))
                    {
                        triglcmpsrc = trigLCmprSource[trigChns[i]] as List <int>;
                        for (int m = 0; m < triglcmpsrc.Count; m++)
                        {
                            if (triglcmpsrc[m] < 2)
                            {
                                Param_Value = Param_Value + (1 << (4 + triglcmpsrc[m]));
                            }
                            else
                            {
                                Param_Value = Param_Value + (1 << (9 + triglcmpsrc[m] - 2));
                            }
                        }
                    }
                    if (!triglcmpsrc.Contains(index))
                    {
                        if (index < 2)
                        {
                            Param_Value = Param_Value + (1 << (4 + trigChns[i]));
                        }
                        else
                        {
                            Param_Value = Param_Value + (1 << (9 + trigChns[i] - 2));
                        }
                    }

                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_SRC + trigChns[i], Param_Value);
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_PWD + trigChns[i], 250000); //  pulse width=  value * 0.02 us
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }
                    //TRG 1 logic  0: Not inverse  1:Inverse
                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_LOGIC + trigChns[i], 0);
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    //TrigSRC与LCMPSRC进行绑定信息保存
                    triglcmpsrc = new List <int>();
                    if (trigLCmprSource.ContainsKey(trigChns[i]))
                    {
                        triglcmpsrc = trigTCmprSource[trigChns[i]] as List <int>;
                        if (!triglcmpsrc.Contains(index))
                        {
                            triglcmpsrc.Add(index);
                        }
                        trigLCmprSource[trigChns[i]] = triglcmpsrc;
                    }
                    else
                    {
                        triglcmpsrc.Add(index);
                        trigLCmprSource.Add(trigChns[i], triglcmpsrc);
                    }

                    if (lcmprUsed.ContainsKey(index))
                    {
                        lcmprUsed[index] = true;
                    }
                    else
                    {
                        lcmprUsed.Add(index, true);
                    }
                }
                #endregion

                #region JFCompareTrigMode.table
                else if (jFCompareTrigMode == JFCompareTrigMode.table)
                {
                    if (GetTCmprIdleSource(encChn, out value, out index) != (int)ErrorDef.Success)//get Ideal TCMP source
                    {
                        return((int)ErrorDef.TrgLcmpSrcError);
                    }
                    err = APS168.APS_set_trigger_param(BoardID, value, encChn);//Param:TGR_TCMP0_SRC
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    err = APS168.APS_set_trigger_param(BoardID, tcmpDir[index], 2);//Param:TGR_TCMP0_DIR
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    //Trigger output 0 (TRG0) source Bit( 1:On, 0:Off)    Bit 0: Manual  Bit 1:Reserved Bit  2:TCMP0  Bit 3:TCMP1  Bit 4:LCMP0  Bit 5:LCMP1 Bit 6:MCMP
                    //Bit 7:TCMP2 Bit 8:TCMP3 Bit 9:LCMP2 Bit 10:LCMP3
                    Param_Value = 0;
                    //获取TRGSRC与TCMP已建立的绑定关系
                    List <int> trigtcmpsrc = new List <int>();
                    if (trigTCmprSource.ContainsKey(trigChns[i]))
                    {
                        trigtcmpsrc = trigTCmprSource[trigChns[i]] as List <int>;
                        for (int m = 0; m < trigtcmpsrc.Count; m++)
                        {
                            if (trigtcmpsrc[m] < 2)
                            {
                                Param_Value = Param_Value + (1 << (2 + trigtcmpsrc[m]));
                            }
                            else
                            {
                                Param_Value = Param_Value + (1 << (7 + trigtcmpsrc[m] - 2));
                            }
                        }
                    }
                    if (!trigtcmpsrc.Contains(index))
                    {
                        if (index < 2)
                        {
                            Param_Value = (1 << (2 + trigChns[i]));
                        }
                        else
                        {
                            Param_Value = (1 << (7 + trigChns[i] - 2));
                        }
                    }
                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_SRC + trigChns[i], Param_Value);
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_PWD + trigChns[i], 250000); //  pulse width=  value * 0.02 us
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }
                    //TRG 1 logic  0: Not inverse  1:Inverse
                    err = APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_LOGIC + trigChns[i], 0);
                    if (err != 0)
                    {
                        return((int)ErrorDef.InvokeFailed);
                    }

                    //TrigSRC与TCMPSRC进行绑定信息保存
                    trigtcmpsrc = new List <int>();
                    if (trigTCmprSource.ContainsKey(trigChns[i]))
                    {
                        trigtcmpsrc = trigTCmprSource[trigChns[i]] as List <int>;
                        if (!trigtcmpsrc.Contains(index))
                        {
                            trigtcmpsrc.Add(index);
                        }
                        trigTCmprSource[trigChns[i]] = trigtcmpsrc;
                    }
                    else
                    {
                        trigtcmpsrc.Add(index);
                        trigTCmprSource.Add(trigChns[i], trigtcmpsrc);
                    }

                    if (tcmprUsed.ContainsKey(index))
                    {
                        tcmprUsed[index] = true;
                    }
                    else
                    {
                        tcmprUsed.Add(index, true);
                    }
                }
            }
            #endregion

            if (chnTrig.ContainsKey(encChn))
            {
                chnTrig[encChn] = trigChns;
            }
            else
            {
                chnTrig.Add(encChn, trigChns);
            }

            if (trigModes[encChn] == JFCompareTrigMode.liner)
            {
                if (SetTrigLiner(encChn, trigLiners[encChn]) != (int)ErrorDef.Success)
                {
                    return((int)ErrorDef.InvokeFailed);
                }
            }
            else if (trigModes[encChn] == JFCompareTrigMode.table)
            {
                if (SetTrigTable(encChn, trigTables[encChn]) != (int)ErrorDef.Success)
                {
                    return((int)ErrorDef.InvokeFailed);
                }
            }



            _jf168Cfg.Save();
            if (SaveParamsToFlash() != 0)
            {
                return((int)ErrorDef.InvokeFailed);
            }

            return((int)ErrorDef.Success);
        }
Пример #10
0
        /// <summary>运动控制卡Compare Trigger初始化 </summary>
        internal void Open()
        {
            if (IsOpen)
            {
                return;
            }

            int StartAxisId = 0, TotalAxis = 0, CardName = 0;

            APS168.APS_get_first_axisId(BoardID, ref StartAxisId, ref TotalAxis);
            APS168.APS_get_card_name(BoardID, ref CardName);
            if (/*CardName != (Int32)APS_Define.DEVICE_NAME_PCI_825458 && */ CardName != (Int32)APS_Define.DEVICE_NAME_AMP_20408C)
            {
                throw new Exception(string.Format("AMP204MC.Initialize Failed :运动控制卡型号不是204C或208C!"));
            }

            if (CardName == (Int32)APS_Define.DEVICE_NAME_AMP_20408C && TotalAxis == 4)
            {
                TrigChannels    = 2;
                EncoderChannels = 4;
                for (int i = 0; i < TrigChannels; i++)
                {
                    if (!lcmpSource.ContainsKey(i))
                    {
                        lcmpSource.Add(i, (Int32)APS_Define.TGR_LCMP0_SRC + i);
                        tcmpSource.Add(i, (Int32)APS_Define.TGR_TCMP0_SRC + i);
                        tcmpDir.Add(i, (Int32)APS_Define.TGR_TCMP0_DIR + i);
                    }
                }
            }
            if (CardName == (Int32)APS_Define.DEVICE_NAME_AMP_20408C && TotalAxis == 8)
            {
                TrigChannels    = 4;
                EncoderChannels = 8;
                for (int i = 0; i < TrigChannels; i++)
                {
                    if (i < 2)
                    {
                        if (!lcmpSource.ContainsKey(i))
                        {
                            lcmpSource.Add(i, (Int32)APS_Define.TGR_LCMP0_SRC + i);
                            tcmpSource.Add(i, (Int32)APS_Define.TGR_TCMP0_SRC + i);
                            tcmpDir.Add(i, (Int32)APS_Define.TGR_TCMP0_DIR + i);
                        }
                    }
                    else
                    {
                        if (!lcmpSource.ContainsKey(i))
                        {
                            lcmpSource.Add(i, (Int32)APS_Define.TGR_LCMP2_SRC + i);
                            tcmpSource.Add(i, (Int32)APS_Define.TGR_TCMP2_SRC + i);
                            tcmpDir.Add(i, (Int32)APS_Define.TGR_TCMP2_DIR + i);
                        }
                    }
                }
            }

            #region Dictionary 初始化
            lock (_jf168Cfg)
            {
                if (!_jf168Cfg.ContainsItem("Card_" + BoardID))
                {
                    _jf168Cfg.AddItem("Card_" + BoardID, new JFXmlDictionary <string, object>());
                }
                _dictCT = _jf168Cfg.GetItemValue("Card_" + BoardID) as JFXmlDictionary <string, object>;

                if (_dictCT.ContainsKey(TrigTablesKeyName))
                {
                    trigTables = _dictCT[TrigTablesKeyName] as JFXmlDictionary <int, double[]>;
                }
                else
                {
                    for (int i = 0; i < EncoderChannels; i++)
                    {
                        if (trigTables.ContainsKey(i))
                        {
                            trigTables[i] = new double[0];
                        }
                        else
                        {
                            trigTables.Add(i, new double[0]);
                        }
                    }
                    _dictCT.Add(TrigTablesKeyName, trigTables);
                }


                if (_dictCT.ContainsKey(TrigLinersKeyName))
                {
                    trigLiners = _dictCT[TrigLinersKeyName] as JFXmlDictionary <int, JFCompareTrigLinerParam>;
                }
                else
                {
                    for (int i = 0; i < EncoderChannels; i++)
                    {
                        if (trigLiners.ContainsKey(i))
                        {
                            trigLiners[i] = new JFCompareTrigLinerParam();
                        }
                        else
                        {
                            trigLiners.Add(i, new JFCompareTrigLinerParam());
                        }
                    }
                    _dictCT.Add(TrigLinersKeyName, trigLiners);
                }

                if (_dictCT.ContainsKey(TrigModesKeyName))
                {
                    trigModes = _dictCT[TrigModesKeyName] as JFXmlDictionary <int, JFCompareTrigMode>;
                }
                else
                {
                    for (int i = 0; i < EncoderChannels; i++)
                    {
                        if (trigModes.ContainsKey(i))
                        {
                            trigModes[i] = JFCompareTrigMode.disable;
                        }
                        else
                        {
                            trigModes.Add(i, JFCompareTrigMode.disable);
                        }
                    }
                    _dictCT.Add(TrigModesKeyName, trigModes);
                }

                if (_dictCT.ContainsKey(ChnTrigKeyName))
                {
                    chnTrig = _dictCT[ChnTrigKeyName] as JFXmlDictionary <int, int[]>;
                }


                if (_dictCT.ContainsKey(TrigEnableKeyName))
                {
                    trigEnables = _dictCT[TrigEnableKeyName] as JFXmlDictionary <int, bool>;
                }
                else
                {
                    for (int i = 0; i < TrigChannels; i++)
                    {
                        if (trigEnables.ContainsKey(i))
                        {
                            trigEnables[i] = false;
                        }
                        else
                        {
                            trigEnables.Add(i, false);
                        }
                    }
                    _dictCT.Add(TrigEnableKeyName, trigEnables);
                }

                if (_dictCT.ContainsKey(LCmprUsedKeyName))
                {
                    lcmprUsed = _dictCT[LCmprUsedKeyName] as JFXmlDictionary <int, bool>;
                }
                else
                {
                    for (int i = 0; i < TrigChannels; i++)
                    {
                        if (lcmprUsed.ContainsKey(i))
                        {
                            lcmprUsed[i] = false;
                        }
                        else
                        {
                            lcmprUsed.Add(i, false);
                        }
                    }
                    _dictCT.Add(LCmprUsedKeyName, lcmprUsed);
                }

                if (_dictCT.ContainsKey(TCmprUsedKeyName))
                {
                    tcmprUsed = _dictCT[TCmprUsedKeyName] as JFXmlDictionary <int, bool>;
                }
                else
                {
                    for (int i = 0; i < TrigChannels; i++)
                    {
                        if (tcmprUsed.ContainsKey(i))
                        {
                            tcmprUsed[i] = false;
                        }
                        else
                        {
                            tcmprUsed.Add(i, false);
                        }
                    }
                    _dictCT.Add(TCmprUsedKeyName, tcmprUsed);
                }

                if (_dictCT.ContainsKey(TrigLCmprKeyName))
                {
                    trigLCmprSource = _dictCT[TrigLCmprKeyName] as JFXmlDictionary <int, List <int> >;
                }

                if (_dictCT.ContainsKey(TrigTCmprKeyName))
                {
                    trigTCmprSource = _dictCT[TrigTCmprKeyName] as JFXmlDictionary <int, List <int> >;
                }


                if (_dictCT.ContainsKey(ChnTCmprKeyName))
                {
                    chnTcmpr = _dictCT[ChnTCmprKeyName] as JFXmlDictionary <int, int>;
                }

                if (_dictCT.ContainsKey(ChnLCmprKeyName))
                {
                    chnLcmpr = _dictCT[ChnLCmprKeyName] as JFXmlDictionary <int, int>;
                }

                if (!_dictCT.ContainsKey("PulseFactor"))
                {
                    pulseFactors = new double[TotalAxis];
                    for (int i = 0; i < TotalAxis; i++)
                    {
                        pulseFactors[i] = 1;
                    }
                }
                else
                {
                    pulseFactors = _dictCT["PulseFactor"] as double[];
                    if (pulseFactors.Length < TotalAxis)
                    {
                        _dictCT.Remove("PulseFactor");
                        pulseFactors = new double[TotalAxis];
                        for (int i = 0; i < TotalAxis; i++)
                        {
                            pulseFactors[i] = 1;
                        }
                        _dictCT.Add("PulseFactor", pulseFactors);
                    }
                }



                _jf168Cfg.Save();
            }

            #endregion

            for (int i = 0; i < TrigChannels; i++)
            {
                if (APS168.APS_reset_trigger_count(BoardID, i) != 0)//reset count
                {
                    throw new Exception(string.Format("AMP204MC.APS_reset_trigger_count Failed :重置触发通道{0}计数器失败!", i));
                }


                if (APS168.APS_set_trigger_param(BoardID, (Int32)APS_Define.TGR_TRG0_SRC + i, 0) != 0)//Trig source bind
                {
                    throw new Exception(string.Format("AMP204MC.APS_set_trigger_param Failed :接触触发通道{0}绑定关系!", i));
                }

                //if (SetTrigEnable(i, trigEnables[i]) != (int)ErrorDef.Success)//enable or disable trig    //调用慢,先屏蔽   remarked by Boby
                //    throw new Exception(string.Format("AMP204MC.SetTrigEnable Failed :设置触发通道{0}使能状态失败!", i));
            }

            for (int i = 0; i < EncoderChannels; i++)
            {
                if (!chnTrig.ContainsKey(i))
                {
                    continue;
                }
                if (chnTrig[i].Length <= 0)
                {
                    continue;
                }
                int[] TrigChns = new int[chnTrig[i].Length];
                TrigChns = chnTrig[i];
                //if(SetEncoderTrigBind(i, TrigChns)!=(int)ErrorDef.Success)    //调用慢,先屏蔽 remarked by Boby
                //    throw new Exception(string.Format("AMP204MC.SetEncoderTrigBind Failed :绑定编码器{0}和触发通道{1}失败!",i, chnTrig[i]));
            }
            IsOpen = true;
        }