Example #1
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);
            }
        }
Example #2
0
        /// <summary>
        /// 移出一个产品配方
        /// </summary>
        /// <param name="categoty"></param>
        /// <param name="recipeID"></param>
        /// <returns></returns>
        public IJFRecipe RemoveRecipe(string categoty, string recipeID)
        {
            if (string.IsNullOrEmpty(categoty))
            {
                return(null);
            }
            if (string.IsNullOrEmpty(recipeID))
            {
                return(null);
            }

            IJFRecipe ret = GetRecipe(categoty, recipeID);

            if (ret == null) //已已存在同名Recipe
            {
                return(ret);
            }

            Dictionary <string, JFCommonRecipe> dctInMmry = _dctRecipes[categoty];

            dctInMmry.Remove(recipeID);
            if (dctInMmry.Count == 0)
            {
                _dctRecipes.Remove(categoty);
            }


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

            for (int i = 0; i < lstIDAndTxt.Count; i++)
            {
                if (lstIDAndTxt[i][0] == recipeID)
                {
                    lstIDAndTxt.RemoveAt(i);
                    break;
                }
            }

            if (lstIDAndTxt.Count == 0)
            {
                dctRecipesInCfg.Remove(categoty);
                List <string> lstCatesInCfg = _cfg.GetItemValue("Categoties") as List <string>;
                lstCatesInCfg.Remove(categoty);
            }
            return(ret);
        }
Example #3
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;
        }