コード例 #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>
        /// 更新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);
        }
コード例 #3
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);
 }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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;
        }