Пример #1
0
        private HoleDto getUseTip(string suckType)
        {
            HoleDto dto = null;

            foreach (string rackName in tipBoxRackDict.Keys)
            {
                TipBoxRackModel rackModel = tipBoxRackDict[rackName];
                if (!suckType.Equals(rackModel.RackType.ToString()))
                {
                    continue;
                }
                List <int> list = rackModel.RackDataList;
                for (int i = 0; i < list.Count; i++)
                {
                    if (0.Equals(list[i]))
                    {
                        continue;
                    }
                    dto = new HoleDto(rackModel.RackName, i, 1);
                    return(dto);
                }
            }
            return(dto);
        }
Пример #2
0
        public object Execute(int eventCode, object message)
        {
            object obj = null;

            switch (eventCode)
            {
            //获取当前板架模型
            case TipBoxRackEventCode.GETCURRENTRACKMODEL:
            {
                if (tipBoxRackDict.ContainsKey(currentRackName))
                {
                    obj = tipBoxRackDict[currentRackName];
                }
            }
            break;

            //获取板架模型
            case TipBoxRackEventCode.GETRACKMODEL:
            {
                if (tipBoxRackDict.ContainsKey(message.ToString()))
                {
                    obj = tipBoxRackDict[message.ToString()];
                }
            }
            break;

            //设置当前板架
            case TipBoxRackEventCode.SETCURRENTRACK:
            {
                if (!message.ToString().Equals(currentRackName) && WindowStartViewController.Instance != null && WindowStartViewController.Instance.PageSuckerRack != null)
                {
                    //设置当前板架名称
                    currentRackName = message.ToString();
                    PageTipBoxRackView view = WindowStartViewController.Instance.PageSuckerRack as PageTipBoxRackView;
                    //更新当前板架信息
                    view.ViewModel.Model.UpdateCurrentRack(tipBoxRackDict[currentRackName]);
                }
            }
            break;

            //设置孔信息
            case TipBoxRackEventCode.SETHOLE:
            {
                HoleDto         dto   = message as HoleDto;
                TipBoxRackModel model = null;
                if ("CurrentTipRack".Equals(dto.RackName))
                {
                    model = tipBoxRackDict[currentRackName];
                }
                else
                {
                    model = tipBoxRackDict[dto.RackName];
                }
                model.RackDataList[dto.Index] = dto.Hole;

                //通知界面更新
                if (WindowStartViewController.Instance != null && WindowStartViewController.Instance.PageSuckerRack != null)
                {
                    PageTipBoxRackView view = WindowStartViewController.Instance.PageSuckerRack as PageTipBoxRackView;
                    if ("CurrentTipRack".Equals(dto.RackName))
                    {
                        view.ViewModel.Model.UpdateCurrentRack(tipBoxRackDict[currentRackName]);
                        view.ViewModel.Model.UpdateRack(tipBoxRackDict[currentRackName]);
                    }
                    else
                    {
                        view.ViewModel.Model.UpdateRack(tipBoxRackDict[currentRackName]);
                    }
                }
            }
            break;

            //设置大吸头板
            case TipBoxRackEventCode.SETBIGRACK:
            {
                tipBoxRackDict[currentRackName].RackType = 0;
                CurrentRackAndSelRackUpdate();
            }
            break;

            //设置小吸头板
            case TipBoxRackEventCode.SETSMALLRACK:
            {
                tipBoxRackDict[currentRackName].RackType = 2;
                CurrentRackAndSelRackUpdate();
            }
            break;

            //填满吸头板
            case TipBoxRackEventCode.FULLRACK:
            {
                List <int> dataList = tipBoxRackDict[currentRackName].RackDataList;
                for (int i = 0; i < dataList.Count; i++)
                {
                    dataList[i] = 1;
                }
                CurrentRackAndSelRackUpdate();
            }
            break;

            //清空吸头板
            case TipBoxRackEventCode.CLEARRACK:
            {
                List <int> dataList = tipBoxRackDict[currentRackName].RackDataList;
                for (int i = 0; i < dataList.Count; i++)
                {
                    dataList[i] = 0;
                }
                CurrentRackAndSelRackUpdate();
            }
            break;

            //保存配置文件
            case TipBoxRackEventCode.SAVEFILE:
            {
                saveFile();
            }
            break;

            //获取一个可用吸头
            case TipBoxRackEventCode.GETUSETIP:
            {
                obj = getUseTip(message.ToString());
            }
            break;

            case TipBoxRackEventCode.SETNOHOLE:
            {
                HoleDto         dto   = message as HoleDto;
                TipBoxRackModel model = null;

                //if ("CurrentTipRack".Equals(dto.RackName))
                //    model = tipBoxRackDict[currentRackName];
                //else
                model = tipBoxRackDict[dto.RackName];
                model.RackDataList[dto.Index] = 0;

                //通知界面更新
                if (WindowStartViewController.Instance != null && WindowStartViewController.Instance.PageSuckerRack != null)
                {
                    PageTipBoxRackView view = WindowStartViewController.Instance.PageSuckerRack as PageTipBoxRackView;
                    if (currentRackName.Equals(dto.RackName))
                    {
                        view.ViewModel.Model.UpdateCurrentRack(tipBoxRackDict[currentRackName]);
                        view.ViewModel.Model.UpdateRack(tipBoxRackDict[currentRackName]);
                    }
                    else
                    {
                        view.ViewModel.Model.UpdateRack(tipBoxRackDict[dto.RackName]);
                    }
                }
            }
            break;

            default:
                break;
            }
            return(obj);
        }