예제 #1
0
        void CalculateProductItems()
        {
            if (_Products.Count == 0)
            {
                return;
            }
            Product product = _Products[0];

            if (product.CurrentOP == 7)
            {
                foreach (var item in product.Items.Keys)
                {
                    int  key         = Global.DictItemID[item];
                    Item productItem = null;

                    switch (Global.ListItemType[key])
                    {
                    case TYPE_ITEM.NORMAL:
                        productItem = new ItemNormal(Global.ListItemParameter[key].Name, Global.ListItemParameter[key].UserMin, Global.ListItemParameter[key].UserMax);
                        break;

                    case TYPE_ITEM.DIFF:
                        productItem = new ItemDiff(Global.ListItemParameter[key].Name, Global.ListItemParameter[key].UserMin, Global.ListItemParameter[key].UserMax);
                        break;

                    case TYPE_ITEM.MULTI:
                        productItem = new ItemMulti(Global.ListItemParameter[key].Name, Global.ListItemParameter[key].UserMin, Global.ListItemParameter[key].UserMax);
                        break;

                    case TYPE_ITEM.BETWEEN:
                        Logger.Fatal("Create item between fail.");
                        break;

                    default:
                        Logger.Fatal("Create item default fail.");
                        break;
                    }
                    if (item == 8 || item == 9 || item == 21)
                    {
                        // 这三个检测项加上检测项1的结果
                        product.Items[item][0] += (double)product.ListValue[0];
                    }
                    if (item == 6)
                    {
                        // 6加上22补偿
                        //product.Items[item][0] += product.Compensation[22][0];
                    }
                    if (item == 12)
                    {
                        // 12加上23补偿
                        product.Items[item][0] += product.Compensation[23][0];
                    }
                    productItem.Excute(product.Items[item]);
                    product.ListValue[Global.DictItemID[item]]  = productItem.Result;
                    product.ListResult[Global.DictItemID[item]] = productItem.IsOK;
                }
            }
        }
예제 #2
0
        public List <string> Process(Dictionary <int, List <double> > dict)
        {
            List <string> data = new List <string>();
            Item          item = null;

            for (int i = 0; i < Global.ListItemIDCalibration.Count; i++)
            {
                switch (Global.ListItemTypeCalibration[i])
                {
                case TYPE_ITEM.NORMAL:
                    item = new ItemNormal(Global.ListItemNameCalibration[i], Global.ListItemParameterCalibration[i].UserMin, Global.ListItemParameterCalibration[i].UserMax);
                    break;

                case TYPE_ITEM.MULTI:
                    item = new ItemMulti(Global.ListItemNameCalibration[i], Global.ListItemParameterCalibration[i].UserMin, Global.ListItemParameterCalibration[i].UserMax);
                    break;

                case TYPE_ITEM.DIFF:
                    item = new ItemDiff(Global.ListItemNameCalibration[i], Global.ListItemParameterCalibration[i].UserMin, Global.ListItemParameterCalibration[i].UserMax);
                    break;

                case TYPE_ITEM.BETWEEN:
                    item = new ItemBtween(Global.ListItemNameCalibration[i], Global.ListItemParameterCalibration[i].UserMin, Global.ListItemParameterCalibration[i].UserMax);
                    break;

                default:
                    break;
                }
                item.Excute(dict[Global.DictItemCalibration[i]]);
                //if (Global.ListItemID[i] == 7)
                //{
                //    item.Excute(plc[Global.ListItemID[i]]);
                //}
                //else
                //{
                //    item.Excute(vision[Global.ListItemID[i]]);
                //}

                if (null == _IsCalibrated)
                {
                    _IsCalibrated = item.IsOK;
                }
                else
                {
                    _IsCalibrated &= item.IsOK;
                }
                data.Add(item.Result.ToString());
            }
            return(data);
        }