Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            count++;
            if (ShownForm == false && count > 3)
            {
                toolStripButton_Click(主页Bt, null);
                ShownForm = true;
            }

            TimerCheck();
            if (IOControl != null)
            {
                IOControl.ValueChangedRefresh();
            }
            //控制器状态
            if (DeviceRsDef.MotionCard.netSucceed)
            {
                tlssll_ControllerStatus.Text      = "板卡:ONLine" + "(" + DeviceRsDef.MotionCard.ScanfTime.ToString() + "ms" + ")";
                tlssll_ControllerStatus.BackColor = SystemColors.Control;
            }
            else
            {
                MachineAlarm.SetAlarm(AlarmLevelEnum.Level3, "控制器掉线");
                for (int i = 0; i < DeviceRsDef.AxisList.Count; i++)
                {
                    DeviceRsDef.AxisList[i].MC_Stop();
                }
                tlssll_ControllerStatus.Text      = "板卡:OFFLine";
                tlssll_ControllerStatus.BackColor = Color.Red;
            }

            //tlssll_CameraUp.Text = VisionProject.Instance.Camera[0].Connected ? "上相机:ONLine" : "上相机:OFFLine";
            //tlssll_CameraUp.BackColor = VisionProject.Instance.Camera[0].Connected ? SystemColors.Control : Color.Red;

            //tlssll_CameraDown.Text = VisionProject.Instance.Camera[1].Connected ? "下相机:ONLine" : "下相机:OFFLine";
            //tlssll_CameraDown.BackColor = VisionProject.Instance.Camera[1].Connected ? SystemColors.Control : Color.Red;

            cnt++;
            if (cnt >= 500)
            {
                cnt = 0;
                ClearMemory();
            }

            //tsslbl_AxisCurrpos1.Text = "X:" + DeviceRsDef.Axis_X.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos2.Text = "Y:" + DeviceRsDef.Axis_Y.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos3.Text = "Z1:" + DeviceRsDef.Axis_Z1.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos4.Text = "Z2:" + DeviceRsDef.Axis_Z2.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos5.Text = "R1:" + DeviceRsDef.Axis_R1.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos6.Text = "R2:" + DeviceRsDef.Axis_R2.currPos.ToString("0.00");
            //tsslbl_AxisCurrpos7.Text = "X:" + DeviceRsDef.Axis_BeltFeed.currPos.ToString("0.00");
        }
Example #2
0
        protected override void LogicImpl()
        {
            //报警等级为2
            if (MachineAlarm.AlarmLever == AlarmLevelEnum.Level2)
            {
                this.Manager.FSM.Change(FSMStaDef.ALARM);
            }
            else if (MachineAlarm.AlarmLever > AlarmLevelEnum.Level2)
            {
                this.Manager.FSM.Change(FSMStaDef.ERROR);
            }

            for (int i = 0; i < DeviceRsDef.AxisList.Count; i++)
            {
                if (DeviceRsDef.AxisList[i].status == Device.AxState.AXSTA_ERRSTOP)
                {
                    string alarmMessage = DeviceRsDef.AxisList[i].errMesg;
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level3, alarmMessage);
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            //控制器状态
            if (DeviceRsDef.MotionCard.netSucceed)
            {
                toolStripLabel1.Text      = "卡1:ON" + "(" + DeviceRsDef.MotionCard.ScanfTime.ToString() + "ms" + ")";
                toolStripLabel1.BackColor = SystemColors.Control;
            }
            else
            {
                MachineAlarm.SetAlarm(AlarmLevelEnum.Level3, "控制器1掉线");
                for (int i = 0; i < DeviceRsDef.AxisList.Count; i++)
                {
                    DeviceRsDef.AxisList[i].MC_Stop();
                }
                toolStripLabel1.Text      = "卡1:OFF";
                toolStripLabel1.BackColor = Color.Red;
            }
            if (DeviceRsDef.MotionCard1.netSucceed)
            {
                toolStripLabel2.Text      = "卡2:ON" + "(" + DeviceRsDef.MotionCard1.ScanfTime.ToString() + "ms" + ")";
                toolStripLabel2.BackColor = SystemColors.Control;
            }
            else
            {
                MachineAlarm.SetAlarm(AlarmLevelEnum.Level3, "控制器2掉线");
                for (int i = 0; i < DeviceRsDef.AxisList.Count; i++)
                {
                    DeviceRsDef.AxisList[i].MC_Stop();
                }
                toolStripLabel2.Text      = "卡2:OFF";
                toolStripLabel2.BackColor = Color.Red;
            }

            //tlssll_CameraUp.Text = VisionProject.Instance.Camera[0].Connected ? "上相机:ONLine" : "上相机:OFFLine";
            //tlssll_CameraUp.BackColor = VisionProject.Instance.Camera[0].Connected ? SystemColors.Control : Color.Red;

            //tlssll_CameraDown.Text = VisionProject.Instance.Camera[1].Connected ? "下相机:ONLine" : "下相机:OFFLine";
            //tlssll_CameraDown.BackColor = VisionProject.Instance.Camera[1].Connected ? SystemColors.Control : Color.Red;
        }
        //private int whichNuzzle;
        public void Logic(RunModeDef runMode)
        {
            LG.Start();
            switch (LG.step)
            {
            case 1:    //走剥膜长度
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.FeedLable) == 0)
                {
                    MotionCard.MotionFun.OutputON((int)OutputName.Q_Suck);
                    if (MotionCard.MotionFun.InputGet((int)InputName.I_LableCheck_1) == false)
                    {
                        MotionCard.MotionFun.MC_MoveRel((int)AxisName.FeedLable, Para.speed, Para.labelLength);
                        LG.TonRst();
                        LG.step = 2;
                    }
                    else
                    {
                        LG.step = 4;
                    }
                }
                break;

            case 2:    //检测感应
                if (LG.Ton(MotionCard.MotionFun.InputGet((int)InputName.I_LableCheck_1) || MotionCard.MotionFun.InputGet((int)InputName.I_LableCheck_2), Para.checkDelay))
                {
                    MotionCard.MotionFun.MC_Stop((int)AxisName.FeedLable);
                    LG.step = 3;
                }
                else if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.FeedLable) == 0)
                {
                    LG.count++;
                    if (runMode == RunModeDef.NORMAL)
                    {
                        if (LG.count > Para.StripNumAlrm)
                        {
                            LG.count = 0;
                            LG.step  = 0xfe;
                            if (Para.StripNumAlrm > 0)
                            {
                                MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, "剥标失败,请检查卷料是否用完");
                            }
                        }
                        else
                        {
                            LG.step = 1;
                        }
                    }
                    else
                    {
                        LG.step = 3;
                    }
                }
                break;

            case 3:    //
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.FeedLable) == 0)
                {
                    MotionCard.MotionFun.MC_MoveRel((int)AxisName.FeedLable, Para.speed, -Para.LableSupplyBack);
                    LG.step = 4;
                }
                break;

            case 4:    //
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.FeedLable) == 0)
                {
                    LG.step = 0xff;
                }
                break;

            case 0xfe:
                LG.ErrorStop();
                break;

            case 0xff:
                LG.End();
                break;

            default:
                break;
            }
        }
        public void Logic(RunModeDef runMode)
        {
            LG.Start();
            switch (LG.step)
            {
            case 1:     //Z轴抬起到安全高度
                if (Para.OverTake == 1)
                {
                    whichNuzzle = (int)LogicDef.NuzzleNum - 1;
                }
                else
                {
                    whichNuzzle = 0;
                }

                //if (AllAxisArrive())
                {
                    for (int i = 0; i < (int)LogicDef.NuzzleNum; i++)
                    {
                        MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Z, Para.SafePos_Z);
                    }
                    LG.step = 2;
                }
                break;

            case 2:     //xy到取标位置
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.Z) == 0)
                {
                    //取标的时候将吹气关
                    for (int i = 0; i < (int)LogicDef.NuzzleNum; i++)
                    {
                        MotionCard.MotionFun.OutputOFF((int)OutputName.Q_Suck_1);
                    }
                    //确定哪一个吸嘴是禁用的
                    if (Para.OverTake == 1)
                    {
                        if (Functions.GetBitValue(Para.NuzzleSwitch, (ushort)whichNuzzle) == false)
                        {
                            if (whichNuzzle > 0)
                            {
                                whichNuzzle--;
                            }
                            else
                            {
                                LG.step = 9;
                            }
                        }
                        else
                        {
                            MotionCard.MotionFun.MC_MoveAbs((int)AxisName.X, Para.PointData.X);
                            MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Y, Para.PointData.Y);
                            for (int i = 0; i < (int)LogicDef.NuzzleNum; i++)
                            {
                                if (Functions.GetBitValue(Para.NuzzleSwitch, (ushort)i) == true)
                                {
                                    MotionCard.MotionFun.MC_MoveAbs((int)AxisName.R, Para.PointData.R);
                                }
                            }
                            LG.step = 3;
                        }
                    }
                    else
                    {
                        for (int i = whichNuzzle; i < (int)LogicDef.NuzzleNum; i++)
                        {
                            if (Functions.GetBitValue(Para.NuzzleSwitch, (ushort)i) == false)
                            {
                                whichNuzzle++;
                            }
                            else
                            {
                                break;
                            }
                        }

                        if (whichNuzzle < (int)LogicDef.NuzzleNum)
                        {
                            MotionCard.MotionFun.MC_MoveAbs((int)AxisName.X, Para.PointData.X);
                            MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Y, Para.PointData.Y);
                            for (int i = 0; i < (int)LogicDef.NuzzleNum; i++)
                            {
                                if (Functions.GetBitValue(Para.NuzzleSwitch, (ushort)i) == true)
                                {
                                    MotionCard.MotionFun.MC_MoveAbs((int)AxisName.R, Para.PointData.R);
                                }
                            }
                            LG.step = 3;
                        }
                        else
                        {
                            LG.step = 9;
                        }
                    }
                }
                break;

            case 3:    //XY到位后判断缓取,开始下压时打开吸嘴
                if (AllAxisArrive())
                {
                    MotionCard.MotionFun.OutputON((int)OutputName.Q_Suck_1);
                    if (Para.TakeSlowDistance_Z > 0)
                    {
                        MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Z, Para.TakePos_Z - Para.TakeSlowDistance_Z);
                        LG.step = 4;
                    }
                    else
                    {
                        MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Z, Para.TakePos_Z);
                        LG.step = 5;
                    }
                }
                break;

            case 4:    //Z轴缓慢到取标高度
                if (AllAxisArrive())
                {
                    MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Z, Para.TakeSlowSpeed_Z, Para.TakePos_Z);
                    LG.step = 5;
                }
                break;

            case 5:    //Z轴到达
                if (AllAxisArrive() && MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.Y) == 0)
                {
                    LG.step = 6;
                }
                break;

            case 6:    //取标延时后Z轴抬起(缓抬)
                if (LG.TCnt((uint)Para.TakeDelay))
                {
                    LG.step = 7;
                }
                break;

            case 7:    //取标延时后Z轴抬起
                if (AllAxisArrive())
                {
                    MotionCard.MotionFun.MC_MoveAbs((int)AxisName.Z, Para.SafePos_Z);

                    LG.step = 8;
                }
                break;

            case 8:    //检测真空
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.Z) == 0)
                {
                    if (MotionCard.MotionFun.InputGet((int)InputName.I_VacuoCheck) == false && Para.CheckVacuumEn == 1)
                    {
                        LG.step = 9;
                        //判断是否在老化模式
                        if (runMode == RunModeDef.NORMAL)
                        {
                            LG.count++;
                            if (LG.count >= 2)
                            {
                                LG.step = 9;
                                MotionCard.MotionFun.OutputON((int)OutputName.Q_Suck_2);
                                MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, "取料失败,请检查真空和真空感应");
                            }
                            else
                            {
                                LG.step = 3;
                            }
                        }
                    }
                    else
                    {
                        LG.step = 9;
                    }
                }
                break;


            case 9:    //结束
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.Z) == 0)
                {
                    LG.count = 0;
                    if (Para.OverTake == 1)
                    {
                        if (whichNuzzle > 0)
                        {
                            whichNuzzle--;
                            LG.step = 3;
                        }
                        else
                        {
                            LG.step = 10;
                        }
                    }
                    else
                    {
                        whichNuzzle++;
                        if (whichNuzzle < (int)LogicDef.NuzzleNum)
                        {
                            LG.step = 3;
                        }
                        else
                        {
                            LG.step = 10;
                        }
                    }
                }
                break;


            case 10:
                if (MotionCard.MotionFun.MC_AxGetStatus((int)AxisName.Z) == 0)
                {
                    //确定哪一个吸嘴是禁用的
                    for (int i = 0; i < (int)LogicDef.NuzzleNum; i++)
                    {
                        if (Functions.GetBitValue(Para.NuzzleSwitch, (ushort)i) == false)
                        {
                            whichNuzzle++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                LG.step = 0xff;
                break;

            case 0xff:
                LG.End();
                break;
            }
        }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, "停止报警");

            label7.Text = new Random().Next().ToString();
        }
Example #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     MachineAlarm.SetAlarm(AlarmLevelEnum.Level1, "启动报警");
 }
        protected override void LogicImpl()
        {
            var ProcessData = ProjectData.Instance.SaveData.processdata;

            switch (LG.Step)
            {
            case 1:    //RZ到位
                ProcessData.SolderList[ID].Clear();
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    NUM = 0;
                    Axis.SolderR[ID].MC_MoveAbs(0);
                    Axis.SolderZ[ID].MC_MoveAbs(ProjectData.Instance.SaveData.SolderData[ID].SafeZ);
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:    //XY到位
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    if (ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].Ban)
                    {
                        NUM++;
                        break;
                    }
                    Axis.SolderX[ID].MC_MoveAbs(ProcessData.SolderCTPos[ID][NUM].X);
                    Axis.SolderY[ID].MC_MoveAbs(ProcessData.SolderCTPos[ID][NUM].Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //拍照
                if (Axis.SolderX[ID].status == 0 && Axis.SolderY[ID].status == 0 && LG.Delay(ProjectData.Instance.SaveData.SolderData[ID].CTDelay))
                {
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //获取相机数据
                if (/*VisionProject.Instance.visionApi.TrigComplete()||*/ TaskManager.Default.FSM.MODE == 1)
                {
                    if (TaskManager.Default.FSM.MODE == 1)
                    {
                        SolderPosData _pos = new SolderPosData();
                        _pos.Pos.X = ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].X;
                        _pos.Pos.Y = ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].Y;
                        _pos.Pos.R = 0;
                        if (ProjectData.Instance.SaveData.processdata.Agingdataforsolder == null)
                        {
                            ProjectData.Instance.SaveData.processdata.Agingdataforsolder = new SolderDef();
                        }
                        ProjectData.Instance.SaveData.processdata.Agingdataforsolder.Z = 25;

                        _pos.Pos        = IOandAxisFun.CameraToSolderPos(ID, _pos.Pos);
                        _pos.SolderData = ProjectData.Instance.SaveData.processdata.Agingdataforsolder;
                        ProcessData.SolderList[ID].Add(_pos);    //增加到list里
                        NUM++;
                        if (NUM < ProjectData.Instance.SaveData.processdata.SolderCTPos[ID].Count)
                        {
                            LG.ImmediateStepNext(2);    //还有打磨拍照点继续打磨i拍照
                        }
                        else
                        {
                            NUM = 0;
                            LG.ImmediateStepNext(5);
                        }
                    }
                    else if (true)
                    {
                        foreach (var p in VisionInteraction.Instance.WhichSolder(ID).listModel)
                        {
                            int type = p.modelindex;
                            int num  = 0;
                            foreach (var item in ProjectData.Instance.SaveData.processdata.WhichSolderMedol(ID))
                            {
                                float Tx = 0;
                                float Ty = 0;
                                float Tr = 0;

                                float x    = 0;
                                float y    = 0;
                                float cAng = (float)(p.ListPos[num].R * Math.PI / 180);
                                if (ProjectData.Instance.SaveData.SolderPlatform[ID].UseR)    //使用旋转中心
                                {
                                    x = p.ModelPos.X + ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].X;
                                    y = p.ModelPos.Y + ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].Y;

                                    IOandAxisFun.Transorm(ID, x, y, x + p.ListPos[num].X, y + p.ListPos[num].Y, cAng, out Tx, out Ty);
                                }
                                else
                                {
                                    Tx = p.ListPos[num].X + ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].X;
                                    Ty = p.ListPos[num].Y + ProjectData.Instance.SaveData.processdata.SolderCTPos[ID][NUM].Y;
                                    Tr = 0;
                                }
                                SolderPosData _pos = new SolderPosData();
                                _pos.Pos.X      = Tx;
                                _pos.Pos.Y      = Ty;
                                _pos.Pos.R      = Tr;
                                _pos.Pos        = IOandAxisFun.CameraToSolderPos(ID, _pos.Pos);
                                _pos.SolderData = ProjectData.Instance.SaveData.processdata.WhichSolderMedol(ID)[type].solderdata[num].Clone();
                                num++;
                                SolderOrderList.Add(_pos);    //增加到list里
                            }
                        }
                        foreach (SolderPosData data in SolderOrderList.OrderBy(a => a.Pos.X).ThenBy(a => a.Pos.Y)) //排序
                        {
                            ProcessData.SolderList[ID].Add(data);                                                  //加到上锡位置
                        }
                        NUM++;
                        if (ProcessData.SolderCTPos[ID].Count() > NUM)
                        {
                            LG.ImmediateStepNext(2);    //去下一个拍照位置
                        }
                        else
                        {
                            LG.ImmediateStepNext(5);
                        }
                    }
                }
                break;

            case 5:    //判断上锡列表里的数据
                if (ProcessData.SolderList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else if (TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else
                {
                    string mes = ID.ToString() + "平台无上锡点";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(0xef, FSMStaDef.RUN);
                }
                break;

            case 0xef:    //结束
                LG.End();
                break;
            }
        }
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                if (DeviceRsDef.Axis_Belt.currPos == 0 && FromReset)
                {
                    DeviceRsDef.Q_BeltLocatedCyl.ON();
                    if (TaskManager.Default.FSM.MODE == 1 && DeviceRsDef.I_CylLocked.Value)
                    {
                        LG.ImmediateStepNext(7);
                        FromReset = false;
                    }
                    else if (DeviceRsDef.I_CylLocked.Value)
                    {
                        LG.ImmediateStepNext(0xef);
                        FromReset = false;
                    }
                }
                else
                {
                    DeviceRsDef.Q_BeltLocatedCyl.OFF();    //打开环形导轨的定位气缸
                    LG.ImmediateStepNext(10);
                }
                break;

            case 10:
                if (LG.Delay(100) && DeviceRsDef.I_CylUnLocked.Value)
                {
                    if (DeviceRsDef.I_material1.value)    //环形定位气缸打开状态且有零件
                    {
                        LG.ImmediateStepNext(2);
                    }
                    else if (TaskManager.Default.FSM.MODE == 1 && DeviceRsDef.I_CylUnLocked.Value)
                    {
                        LG.ImmediateStepNext(2);
                    }
                    else
                    {
                        MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, "零件未放入,零件感应1未感应到物料");
                        LG.StepNextWithOut(2, FSMStaDef.ALARM);
                    }
                }
                break;

            case 2:
                if (
                    LG.Delay(500) &&          //气缸延时200ms
                    TaskManager.Default.FindTask("左打磨平台").Status &&
                    TaskManager.Default.FindTask("右打磨平台").Status &&
                    TaskManager.Default.FindTask("左焊锡平台").Status &&
                    TaskManager.Default.FindTask("右焊锡平台").Status
                    )
                {
                    DeviceRsDef.Axis_Belt.MC_MoveRel(230);    //传送带向前走230mm
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:
                if (LG.Delay(100) && DeviceRsDef.Axis_Belt.status == 0) //延时100
                {
                    DeviceRsDef.Axis_Belt.MC_Stop();                    //传送带停止
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:
                if (DeviceRsDef.Axis_Belt.status == Device.AxState.AXSTA_READY) //皮带轴停止
                {
                    DeviceRsDef.Q_BeltLocatedCyl.ON();                          //打开皮带的定位气缸
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:
                if (LG.Delay(150) && DeviceRsDef.I_CylLocked.value) //环形定位气缸已经锁定,延时150ms
                {
                    if (TaskManager.Default.FSM.MODE == 1)          //老化模式
                    {
                        LG.ImmediateStepNext(7);
                    }
                    else
                    {
                        LG.ImmediateStepNext(0xef);
                    }
                }
                break;

            case 7:
                if (LG.Delay(50))
                {
                    LG.End();    //老化模式下不进行平台的数据传递
                }
                break;

            case 0xef:
                if (LG.Delay(50))
                {
                    LG.End();
                    ProjectData.Instance.SaveData.processdata.PlatformData[0].IsTined = true;                    //第一个工位有料
                    for (int i = ProjectData.Instance.SaveData.processdata.PlatformData.Count() - 1; i > 0; i--) //工位信息传递
                    {
                        ProjectData.Instance.SaveData.processdata.PlatformData[i].SetLastPlatformData(ProjectData.Instance.SaveData.processdata.PlatformData[i - 1]);
                    }
                }
                break;
            }
        }
        protected override void LogicImpl()
        {
            var Para        = ProjectData.Instance.SaveData.PolishData[ID];
            var ProcessData = ProjectData.Instance.SaveData.processdata;

            switch (LG.Step)
            {
            case 1:     // 有打磨点
                if (ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(2);
                }
                else if (TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else
                {
                    string mes = ID.ToString() + "平台无打磨点";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(0xef, FSMStaDef.RUN);
                }
                break;

            case 2:    //ZR抬高
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(0);
                    Axis.PolishZ[ID].MC_MoveAbs(Para.SafeZ);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //到打磨点XY
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    PointPolishtimes = 0;
                    Axis.PolishX[ID].MC_MoveAbs(ProcessData.PolishList[ID][0].Pos.X);
                    Axis.PolishY[ID].MC_MoveAbs(ProcessData.PolishList[ID][0].Pos.Y);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //到打磨点RZ
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(ProcessData.PolishList[ID][0].Pos.R);
                    Axis.PolishZ[ID].MC_MoveAbs(ProcessData.PolishList[ID][0].polishData.Z + Para.TotalReimburse);
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //判断打磨方式
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    //打磨方式
                    switch (ProcessData.PolishList[ID][0].polishData.mode)
                    {
                    case 0:
                        LG.ImmediateStepNext(6);        //一字前后
                        break;

                    case 1:
                        LG.ImmediateStepNext(7);        //一字左右
                        break;

                    case 2:
                        LG.ImmediateStepNext(8);        //二字前后
                        break;

                    case 3:
                        LG.ImmediateStepNext(9);        //二字左右
                        break;
                    }
                }
                break;

                #region 一字前后
            case 6:
                Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                LG.ImmediateStepNext(61);
                break;

            case 61:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(62);
                }
                break;

            case 62:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(10);
                }
                break;

                #endregion
                #region 一字左右
            case 7:
                Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                LG.ImmediateStepNext(71);
                break;

            case 71:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(72);
                }
                break;

            case 72:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(10);
                }
                break;

                #endregion
                #region 二字前后
            case 8:
                Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                LG.ImmediateStepNext(81);
                break;

            case 81:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(82);
                }
                break;

            case 82:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(83);
                }
                break;

            case 83:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.PolishInterval);
                    Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(84);
                }
                break;

            case 84:
                if (Axis.PolishY[ID].status == 0 && Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(85);
                }
                break;

            case 85:
                if (Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(10);
                }
                break;

                #endregion
                #region 二字左右
            case 9:
                Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                LG.ImmediateStepNext(91);
                break;

            case 91:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(92);
                }
                break;

            case 92:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(93);
                }
                break;

            case 93:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishY[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.PolishInterval);
                    Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(94);
                }
                break;

            case 94:
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(-2 * ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(95);
                }
                break;

            case 95:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(ProcessData.PolishList[ID][0].polishData.GoBackRange);
                    LG.ImmediateStepNext(10);
                }
                break;

                #endregion
            case 10:    //判断打磨次数
                PointPolishtimes++;
                if (ProcessData.PolishList[ID][0].polishData.GoBackTimes > PointPolishtimes && Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    LG.ImmediateStepNext(5);    //打磨次数未够,再次打磨
                }
                else
                {
                    PointPolishtimes = 0;
                    LG.ImmediateStepNext(11);     //打磨下一个点
                }
                Para.SumPolishTimes++;            //总的打磨次数用于更换打磨头
                PolishTimes++;
                if (PolishTimes >= Para.Interval) //达到打磨补偿的次数
                {
                    PolishTimes          = 0;
                    Para.TotalReimburse += Para.Reimburse;
                }
                break;

            case 11:     //移打磨列表里第一个点
                if (Axis.PolishZ[ID].status == 0)
                {
                    Para.PolishNum++;
                    Axis.PolishZ[ID].MC_MoveAbs(ProcessData.PolishList[ID][0].polishData.LiftHeight); //抬起到设定高度
                    ProcessData.PolishList[ID].RemoveAt(0);
                    LG.ImmediateStepNext(0xef);                                                       //打磨结束
                }
                break;

            case 0xef:
                if (Axis.PolishZ[ID].status == 0)
                {
                    LG.End();
                }
                break;
            }
        }
        protected override void LogicImpl()
        {
            var para = ProjectData.Instance.SaveData.SolderPlatform[ID];

            switch (LG.Step)
            {
            case 1:    //平台到位
                stick1SpendTime.Restart();
                if (Axis.SolderPlatFormIsHave[ID].value && ProjectData.Instance.SaveData.processdata.PlatformData[ID * 4 + 1].IsHave &&
                    ProjectData.Instance.SaveData.processdata.PlatformData[ID * 4 + 1].IsPolished || TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(2);
                }
                else
                {
                    string mes = ID.ToString() + "平台未有料或未打磨";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(2, FSMStaDef.RUN);
                }
                break;

            case 2:    //开始上锡拍照
                if (DeviceRsDef.I_CylLocked.value || TaskManager.Default.FSM.MODE == 1)
                {
                    SolderCT.Start();
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //开始上锡
                if (SolderCT.GetSta() == 0 && SolderClean.GetSta() == 0)
                {
                    Solder.Start();
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //上锡结束是否清洗
                if (Solder.GetSta() == 0 && ProjectData.Instance.SaveData.SolderData[ID].SolderNum % para.PerTimesClean == 0 && ProjectData.Instance.SaveData.processdata.SolderList[ID].Count() > 0)
                {
                    ProjectData.Instance.SaveData.SolderData[ID].SolderNum = 0;
                    SolderClean.Start();
                    LG.ImmediateStepNext(3);
                    para.SolderSum++;
                }
                else if (Solder.GetSta() == 0 && ProjectData.Instance.SaveData.processdata.SolderList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(3);
                    para.SolderSum++;
                }
                else if (Solder.GetSta() == 0 && ProjectData.Instance.SaveData.processdata.SolderList[ID].Count() == 0)
                {
                    SolderClean.Start();
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //ZR回到既定高度
                if (Axis.SolderZ[ID].status == 0 && Axis.SolderR[ID].status == 0 && SolderClean.GetSta() == 0)
                {
                    Axis.SolderZ[ID].MC_MoveAbs(para.EndPos.Z);
                    Axis.SolderR[ID].MC_MoveAbs(para.EndPos.R);
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:    //ZR回到既定高度
                if (Axis.SolderZ[ID].status == 0 && Axis.SolderR[ID].status == 0)
                {
                    Axis.SolderX[ID].MC_MoveAbs(para.EndPos.X);
                    Axis.SolderY[ID].MC_MoveAbs(para.EndPos.Y);
                    LG.ImmediateStepNext(0xef);
                }
                break;

            case 0xef:
                if (Axis.SolderX[ID].status == 0 && Axis.SolderY[ID].status == 0)
                {
                    LG.End();
                    stick1SpendTime.Stop();
                    para.SolderSpendTime = stick1SpendTime.ElapsedMilliseconds;
                    ProjectData.Instance.SaveData.processdata.PlatformData[ID * 4 + 1].IsTined = true;
                }
                break;
            }
        }
        protected override void LogicImpl()
        {
            var ProcessData = ProjectData.Instance.SaveData.processdata;

            switch (LG.Step)
            {
            case 1:    //上锡列表里是否有上锡点
                if (ProcessData.SolderList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(2);
                }
                else if (TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else
                {
                    string mes = ID.ToString() + "平台无焊锡点";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(0xef, FSMStaDef.RUN);
                }
                break;

            case 2:    //RZ抬高
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderR[ID].MC_MoveAbs(0);
                    Axis.SolderZ[ID].MC_MoveAbs(ProjectData.Instance.SaveData.SolderData[ID].SafeZ);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //XY到第一个上锡点位
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderX[ID].MC_MoveAbs(ProcessData.SolderList[ID][0].Pos.X);
                    Axis.SolderY[ID].MC_MoveAbs(ProcessData.SolderList[ID][0].Pos.Y);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //第一段送锡
                if (Axis.SolderX[ID].status == 0 && Axis.SolderY[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed, ProcessData.SolderList[ID][0].SolderData.FrontLen);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed, ProcessData.SolderList[ID][0].SolderData.FrontLen);
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //第一段退锡
                if (Axis.SolderS[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed, ProcessData.SolderList[ID][0].SolderData.BackLen);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed, ProcessData.SolderList[ID][0].SolderData.BackLen);
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:    //RZ到上锡点位
                if (Axis.SolderS[ID].status == 0)
                {
                    Axis.SolderR[ID].MC_MoveAbs(ProcessData.SolderList[ID][0].Pos.R);
                    Axis.SolderZ[ID].MC_MoveAbs(ProcessData.SolderList[ID][0].SolderData.Z);
                    LG.ImmediateStepNext(7);
                }
                break;

            case 7:    //第二段送锡
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed2, ProcessData.SolderList[ID][0].SolderData.FrontLen2);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed2, ProcessData.SolderList[ID][0].SolderData.FrontLen2);
                    LG.ImmediateStepNext(8);
                }
                break;

            case 8:    //第二段退锡
                if (Axis.SolderS[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed2, ProcessData.SolderList[ID][0].SolderData.BackLen2);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed2, ProcessData.SolderList[ID][0].SolderData.BackLen2);
                    LG.ImmediateStepNext(9);
                }
                break;

            case 9:    //第三段送锡
                if (Axis.SolderS[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed3, ProcessData.SolderList[ID][0].SolderData.FrontLen3);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.FrontSpeed3, ProcessData.SolderList[ID][0].SolderData.FrontLen3);
                    LG.ImmediateStepNext(10);
                }
                break;

            case 10:    //第三段退锡
                if (Axis.SolderS[ID].status == 0)
                {
                    Axis.SolderS[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed3, ProcessData.SolderList[ID][0].SolderData.BackLen3);
                    Axis.SolderS[ID + 1].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.BsckSpeed3, ProcessData.SolderList[ID][0].SolderData.BackLen3);
                    LG.ImmediateStepNext(11);
                }
                break;

            case 11:    //判断是否开启抖动及抖动的模式
                if (Axis.SolderS[ID].status == 0 && LG.Delay(1000))
                {
                    if (ProcessData.SolderList[ID][0].SolderData.Shake)
                    {
                        //开启抖动
                        switch (ProcessData.SolderList[ID][0].SolderData.mode)
                        {
                        //case 0:
                        //    LG.StepNext(12, FSMStaDef.RUN);//上下
                        //    break;
                        case 1:
                            LG.ImmediateStepNext(13);        //左右
                            break;

                        case 2:
                            LG.ImmediateStepNext(14);        //前后
                            break;
                        }
                    }
                    else
                    {
                        //不开启抖动
                        LG.ImmediateStepNext(15);
                    }
                }
                break;

                #region 左右
            case 13:
                Axis.SolderX[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, ProcessData.SolderList[ID][0].SolderData.interval);
                Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                LG.ImmediateStepNext(131);
                break;

            case 131:
                if (Axis.SolderX[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderX[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, -2 * ProcessData.SolderList[ID][0].SolderData.interval);
                    Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                    LG.ImmediateStepNext(132);
                }

                break;

            case 132:
                if (Axis.SolderX[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderX[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, ProcessData.SolderList[ID][0].SolderData.interval);
                    Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                    LG.ImmediateStepNext(15);
                }
                break;

                #endregion
                #region 前后
            case 14:
                Axis.SolderY[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, ProcessData.SolderList[ID][0].SolderData.interval);
                Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                LG.ImmediateStepNext(141);
                break;

            case 141:
                if (Axis.SolderY[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderY[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, -2 * ProcessData.SolderList[ID][0].SolderData.interval);
                    Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                    LG.ImmediateStepNext(142);
                }

                break;

            case 142:
                if (Axis.SolderY[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderY[ID].MC_MoveRel(ProcessData.SolderList[ID][0].SolderData.speed, ProcessData.SolderList[ID][0].SolderData.interval);
                    Axis.SolderZ[ID].MC_MoveRel(-ProcessData.SolderList[ID][0].SolderData.height / 3.0f);
                    LG.ImmediateStepNext(15);
                }
                break;

                #endregion
            case 15:    //Z抬起到设定高度
                if (Axis.SolderY[ID].status == 0 && Axis.SolderZ[ID].status == 0 && LG.Delay(ProjectData.Instance.SaveData.SolderPlatform[ID].TimeforTin))
                {
                    Axis.SolderZ[ID].MC_MoveRel(100, ProcessData.SolderList[ID][0].SolderData.LiftHeight);
                    LG.ImmediateStepNext(16);
                }
                break;

            case 16:    //移除第一个点
                if (Axis.SolderZ[ID].status == 0)
                {
                    ProjectData.Instance.SaveData.SolderData[ID].SolderNum++;
                    ProcessData.SolderList[ID].RemoveAt(0);
                    ProjectData.Instance.Product.ProductCount();
                    LG.ImmediateStepNext(0xef);
                }
                break;

            case 0xef:
                LG.End();
                break;
            }
        }
        protected override void LogicImpl()
        {
            var para = ProjectData.Instance.SaveData.PolishData[ID];

            switch (LG.Step)
            {
            case 1:    //RZ到拍照位
                ProjectData.Instance.SaveData.processdata.PolishList[ID].Clear();
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    NUM = 0;
                    Axis.PolishR[ID].MC_MoveAbs(0);
                    Axis.PolishZ[ID].MC_MoveAbs(para.SafeZ);
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:    //XY到拍照位
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    if (ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].Ban)
                    {
                        NUM++;
                        break;
                    }
                    Axis.PolishX[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].X);
                    Axis.PolishY[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //延时拍照
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0 && LG.Delay(para.CTDelay))
                {
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //获取相机数据
                if (/*VisionInteraction.Instance.TriggerCamera(ID)*/ true)
                {
                    if (TaskManager.Default.FSM.MODE == 1)
                    {
                        PolishPosData _pos = new PolishPosData();
                        _pos.Pos.X = ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].X;
                        _pos.Pos.Y = ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].Y;
                        _pos.Pos.R = 0;
                        //_pos.Pos = IOandAxisFun.CameraToPolisherPos(ID, _pos.Pos);
                        if (ProjectData.Instance.SaveData.processdata.Agingdataforpolish == null)
                        {
                            ProjectData.Instance.SaveData.processdata.Agingdataforpolish = new PolishDef();
                        }
                        _pos.Pos = IOandAxisFun.CameraToPolisherPos(ID, _pos.Pos);
                        ProjectData.Instance.SaveData.processdata.Agingdataforpolish.Z = 20;
                        _pos.polishData = ProjectData.Instance.SaveData.processdata.Agingdataforpolish;
                        NUM++;

                        ProjectData.Instance.SaveData.processdata.PolishList[ID].Add(_pos);
                        if (NUM < ProjectData.Instance.SaveData.processdata.PolishCTPos[ID].Count)
                        {
                            LG.ImmediateStepNext(2);    //还有打磨拍照点继续打磨i拍照
                        }
                        else
                        {
                            NUM = 0;
                            LG.ImmediateStepNext(5);
                        }
                    }
                    else if (true)
                    {
                        foreach (var p in VisionInteraction.Instance.WhichPolish(ID).listModel)
                        {
                            int type = p.modelindex;
                            int num  = 0;
                            foreach (var item in ProjectData.Instance.SaveData.processdata.WhichPolishMedol(ID))
                            {
                                PolishPosData _pos = new PolishPosData();
                                _pos.Pos.X      = p.ListPos[num].X + ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].X;
                                _pos.Pos.Y      = p.ListPos[num].Y + ProjectData.Instance.SaveData.processdata.PolishCTPos[ID][NUM].Y;
                                _pos.Pos.R      = p.ListPos[num].R;
                                _pos.polishData = ProjectData.Instance.SaveData.processdata.WhichPolishMedol(ID)[type].polishData[num].Clone();
                                _pos.Pos        = IOandAxisFun.CameraToPolisherPos(ID, _pos.Pos);
                                num++;
                                PolishOrderList.Add(_pos);    //增加到list里
                            }
                        }
                        foreach (PolishPosData data in PolishOrderList.OrderBy(a => a.Pos.X).ThenBy(a => a.Pos.Y)) //对list里的点进行排序
                        {
                            ProjectData.Instance.SaveData.processdata.PolishList[ID].Add(data);                    //把排列好的点写进打磨list里
                        }

                        if (NUM < ProjectData.Instance.SaveData.processdata.PolishCTPos[ID].Count)
                        {
                            LG.ImmediateStepNext(2);    //还有打磨拍照点继续打磨i拍照
                        }
                        else
                        {
                            NUM = 0;
                            LG.ImmediateStepNext(5);
                        }
                    }
                }
                break;

            case 5:    //判断打磨列表里的数据
                if (ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else if (TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(0xef);
                }
                else
                {
                    string mes = ID.ToString() + "平台没有打磨点";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(0xef, FSMStaDef.RUN);
                }
                break;

            case 0xef:    //结束
                LG.End();
                break;
            }
        }
        protected override void LogicImpl()
        {
            var para = ProjectData.Instance.SaveData.PolishPlatform[ID];

            switch (LG.Step)
            {
            case 1:    //平台到位
                stick1SpendTime.Restart();
                if (Axis.PolishPlatFormIsHave[ID].value && ProjectData.Instance.SaveData.processdata.PlatformData[1].IsHave || TaskManager.Default.FSM.MODE == 1)
                {
                    LG.ImmediateStepNext(2);
                }
                else
                {
                    string mes = ID.ToString() + "平台无料";
                    MachineAlarm.SetAlarm(AlarmLevelEnum.Level2, mes);
                    LG.StepNext(2, FSMStaDef.RUN);
                }
                break;

            case 2:    //开始打磨拍照
                if (DeviceRsDef.I_CylLocked.value || TaskManager.Default.FSM.MODE == 1)
                {
                    PolishCT.Start();
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //开始打磨
                if (PolishCT.Status && PolishClean.Status)
                {
                    Polish.Start();
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //打磨结束
                if (Polish.Status && ProjectData.Instance.SaveData.PolishData[ID].PolishNum % para.PerTtimesClean == 0 && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0)
                {
                    ProjectData.Instance.SaveData.PolishData[ID].PolishNum = 0;
                    PolishClean.Start();
                    LG.ImmediateStepNext(3);
                    para.PolishSum++;
                }
                else if (Polish.Status && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() > 0)
                {
                    LG.ImmediateStepNext(3);
                    para.PolishSum++;
                }
                else if (Polish.Status && ProjectData.Instance.SaveData.processdata.PolishList[ID].Count() == 0)
                {
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //打磨结束RZ回零
                if (Axis.PolishZ[ID].status == 0 && Axis.PolishR[ID].status == 0)
                {
                    Axis.PolishZ[ID].MC_MoveAbs(para.EndPos.Z);
                    Axis.PolishR[ID].MC_MoveAbs(para.EndPos.R);
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:    //打磨结束XY回零
                if (Axis.PolishZ[ID].status == 0 && Axis.PolishR[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveAbs(para.EndPos.X);
                    Axis.PolishY[ID].MC_MoveAbs(para.EndPos.Y);
                    if (TaskManager.Default.FSM.MODE == 1)    //老化模式
                    {
                        LG.ImmediateStepNext(7);
                    }
                    else
                    {
                        LG.ImmediateStepNext(0xef);
                    }
                }
                break;

            case 7:
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    stick1SpendTime.Stop();
                    para.PolishSpendTime = stick1SpendTime.ElapsedMilliseconds;
                    LG.End();    //老化模式下不进行平台数据的传递
                }
                break;

            case 0xef:
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    stick1SpendTime.Stop();
                    para.PolishSpendTime = stick1SpendTime.ElapsedMilliseconds;
                    LG.End();
                    ProjectData.Instance.SaveData.processdata.PlatformData[ID * 4 + 1].IsPolished = true;
                }
                break;
            }
        }