示例#1
0
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                if (ID <= 1)
                {
                    Axis.PolishZ[ID].MC_MoveAbs(ProjectData.Instance.SaveData.PolishData[ID].SafeZ);
                    LG.ImmediateStepNext(2);
                }
                else if (ID > 1)
                {
                    Axis.SolderZ[ID - 2].MC_MoveAbs(ProjectData.Instance.SaveData.SolderData[ID - 2].SafeZ);
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:
                if (ID <= 1 && Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.X);
                    Axis.PolishY[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.Y);
                    LG.ImmediateStepNext(3);
                }
                else if (ID > 1 && Axis.SolderX[ID - 2].status == 0 && Axis.SolderY[ID - 2].status == 0 && Axis.SolderZ[ID - 2].status == 0)
                {
                    Axis.SolderX[ID - 2].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.X);
                    Axis.SolderY[ID - 2].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:
                if (ID <= 1 && Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.R);
                    Axis.PolishZ[ID].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.Z);
                    LG.ImmediateStepNext(4);
                }
                else if (ID > 1 && Axis.SolderX[ID - 2].status == 0 && Axis.SolderY[ID - 2].status == 0)
                {
                    Axis.SolderR[ID - 2].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.R);
                    Axis.SolderZ[ID - 2].MC_MoveAbs(ProjectData.Instance.SaveData.processdata.LocatedPointPos.Z);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:
                if (ID <= 1 && Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    LG.End();
                }
                else if (ID > 1 && Axis.SolderR[ID - 2].status == 0 && Axis.SolderZ[ID - 2].status == 0)
                {
                    LG.End();
                }
                break;
            }
        }
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                LG.ImmediateStepNext(2);
                break;

            case 2:
                LG.End();
                break;
            }
        }
示例#3
0
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                TaskManager.Default.FindTask("皮带流程").Start();
                LG.ImmediateStepNext(2);
                break;

            case 2:
                if (TaskManager.Default.FindTask("皮带流程").Status)
                {
                    TaskManager.Default.FindTask("左打磨平台").Start();
                    TaskManager.Default.FindTask("右打磨平台").Start();
                    TaskManager.Default.FindTask("右焊锡平台").Start();
                    TaskManager.Default.FindTask("左焊锡平台").Start();
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:
                if (
                    TaskManager.Default.FindTask("左打磨平台").Status &&
                    TaskManager.Default.FindTask("右打磨平台").Status &&
                    TaskManager.Default.FindTask("右焊锡平台").Status &&
                    TaskManager.Default.FindTask("左焊锡平台").Status
                    )
                {
                    LG.ImmediateStepNext(0xef);
                }
                break;

            case 0xef:
                if (TaskManager.Default.FSM.MODE == 1 && LG.Delay(2000))
                {
                    LG.ImmediateStepNext(1);
                }
                else
                {
                    LG.End();
                    TaskManager.Default.FSM.Change(FSMStaDef.STOP);
                }
                break;
            }
        }
示例#4
0
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                DeviceRsDef.Ax_顶升.MC_MoveAbs(RiseSnapPos);
                LG.ImmediateStepNext(2);
                snapCount = 0;
                break;

            case 2:
                if (DeviceRsDef.Ax_顶升.status == Device.AxState.AXSTA_READY)
                {
                    DeviceRsDef.Ax_相机X轴.MC_MoveAbs(XYSnapPos[snapCount].X);
                    DeviceRsDef.Ax_相机Y轴.MC_MoveAbs(XYSnapPos[snapCount].Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:
                if (DeviceRsDef.Ax_相机X轴.status == Device.AxState.AXSTA_READY && DeviceRsDef.Ax_相机Y轴.status == Device.AxState.AXSTA_READY)
                {
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //相机触发
                if (LG.TCnt(50))
                {
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:
                //相机触发结果
                LG.ImmediateStepNext(6);
                break;

            case 6:

                break;
            }
        }
示例#5
0
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                DeviceRsDef.Ax_刮锡膏.MC_MoveAbs(StartPos);
                LG.ImmediateStepNext(2);
                DeviceRsDef.Q_刮刀1.OFF();
                DeviceRsDef.Q_刮刀2.OFF();
                break;

            case 2:
                if (DeviceRsDef.Ax_刮锡膏.status == AxState.AXSTA_READY)
                {
                    DeviceRsDef.Q_刮刀1.ON();
                    DeviceRsDef.Q_刮刀2.ON();
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:
                if (LG.TCnt(Delay))
                {
                    DeviceRsDef.Ax_刮锡膏.MC_MoveAbs(EndPos);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:
                if (DeviceRsDef.Ax_刮锡膏.status == AxState.AXSTA_READY)
                {
                    DeviceRsDef.Q_刮刀1.OFF();
                    DeviceRsDef.Q_刮刀2.OFF();
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:
                LG.End();
                break;
            }
        }
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:    //z抬高到翻转位置
                if (DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.ReversZ);
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:    //XR到达工作的位置
                if (DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Axis_X5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.WorkPos.X);
                    DeviceRsDef.Axis_R5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.WorkPos.R);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //Z到达工作的位置
                if (DeviceRsDef.Axis_X5.status == 0 && DeviceRsDef.Axis_R5.status == 0)
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.WorkPos.Z);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //夹紧气缸打开
                if (DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Q_BeforeTurnCyl.Value = true;
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //Z轴到翻转位置
                if (LG.Delay(50) && DeviceRsDef.I_BeforeTurnCylClosed.value)
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.ReversZ);
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:    //R轴旋转
                if (DeviceRsDef.I_BeforeTurnCylClosed.value && DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Axis_R5.MC_MoveSpd(1);
                    LG.ImmediateStepNext(7);
                }
                break;

            case 7:    //转到180度停止R
                if (DeviceRsDef.I_BeforeTurnCylClosed.value && DeviceRsDef.I_TurnCyl180.value)
                {
                    DeviceRsDef.Axis_R5.MC_Stop();
                    LG.ImmediateStepNext(8);
                }
                break;

            case 8:    //Z轴下降到工作位置
                if (DeviceRsDef.I_BeforeTurnCylClosed.value && DeviceRsDef.I_TurnCyl180.value && DeviceRsDef.Axis_R5.status == 0)
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.WorkPos.Z);
                    LG.ImmediateStepNext(9);
                }
                break;

            case 9:    //夹紧气缸打开
                if (DeviceRsDef.I_BeforeTurnCylClosed.value && DeviceRsDef.I_TurnCyl180.value && DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Q_BeforeTurnCyl.Value = false;
                    LG.ImmediateStepNext(11);
                }
                break;

            case 11:    //Z轴回到翻转位
                if (LG.Delay(50))
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.ReversZ);
                    LG.ImmediateStepNext(12);
                }
                break;

            case 12:    //R轴回零度
                if (LG.Delay(50) && DeviceRsDef.Axis_Z5.status == 0)
                {
                    DeviceRsDef.Axis_R5.MC_MoveSpd(-1);
                    LG.ImmediateStepNext(13);
                }
                break;

            case 13:    //回零到位
                if (DeviceRsDef.I_TurnCyl.value)
                {
                    DeviceRsDef.Axis_R5.MC_Stop();
                    LG.ImmediateStepNext(14);
                }
                break;

            case 14:    //XZ到结束位置
                if (DeviceRsDef.Axis_R5.status == 0)
                {
                    DeviceRsDef.Axis_Z5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.EndPos.Z);
                    DeviceRsDef.Axis_X5.MC_MoveAbs(ProjectData.Instance.SaveData.ReverseData.EndPos.X);
                    LG.ImmediateStepNext(15);
                }
                break;

            case 15:    //结束
                if (DeviceRsDef.Axis_X5.status == 0 && DeviceRsDef.Axis_Z5.status == 0)
                {
                    LG.ImmediateStepNext(0xef);
                    ProjectData.Instance.SaveData.processdata.PlatformData[4].Isreversed = true;
                }
                break;

            case 0xef:
                LG.End();
                break;
            }
        }
示例#7
0
        protected override void LogicImpl()
        {
            switch (LG.Step)
            {
            case 1:
                for (int i = 0; i < 60; i++)
                {
                    //板卡输出去使能
                    DeviceRsDef.MotionCard.MotionFun.OutputOFF(i);
                    DeviceRsDef.MotionCard1.MotionFun.OutputOFF(i);
                }
                for (int i = 0; i < DeviceRsDef.AxisList.Count; i++)    //轴停止
                {
                    DeviceRsDef.AxisList[i].MC_Stop();
                }
                LogicMission.BeltFeedFun.FromReset = true;
                MachineAlarm.ClearAlarm();    //清除报警
                LG.ImmediateStepNext(10);
                break;

            case 10:
                if (LG.Delay(2000))
                {
                    //ZR轴回零
                    DeviceRsDef.Axis_Z1.MC_Home();
                    DeviceRsDef.Axis_Z2.MC_Home();
                    DeviceRsDef.Axis_Z3.MC_Home();
                    DeviceRsDef.Axis_Z4.MC_Home();
                    //DeviceRsDef.Axis_Z5.MC_Home();

                    DeviceRsDef.Axis_R1.MC_Home();
                    DeviceRsDef.Axis_R2.MC_Home();
                    DeviceRsDef.Axis_R3.MC_Home();
                    DeviceRsDef.Axis_R4.MC_Home();
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:
                if (Axis.allaixsarrive())
                {
                    DeviceRsDef.Axis_X1.MC_Home();
                    DeviceRsDef.Axis_X2.MC_Home();
                    DeviceRsDef.Axis_X3.MC_Home();
                    DeviceRsDef.Axis_X4.MC_Home();
                    //DeviceRsDef.Axis_X5.MC_Home();

                    DeviceRsDef.Axis_Y1.MC_Home();
                    DeviceRsDef.Axis_Y2.MC_Home();
                    DeviceRsDef.Axis_Y3.MC_Home();
                    DeviceRsDef.Axis_Y4.MC_Home();


                    //DeviceRsDef.Axis_R5.MC_Home();
                    //DeviceRsDef.Axis_X5.MC_Home();
                    DeviceRsDef.Axis_Belt.MC_Home();
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:
                if (Axis.allaixsarrive())
                {
                    for (int i = 0; i < 2; i++)
                    {
                        Axis.PolishX[i].MC_MoveAbs(ProjectData.Instance.SaveData.PolishPlatform[i].ResetPos.X);
                        Axis.PolishY[i].MC_MoveAbs(ProjectData.Instance.SaveData.PolishPlatform[i].ResetPos.Y);
                        Axis.PolishZ[i].MC_MoveAbs(ProjectData.Instance.SaveData.PolishPlatform[i].ResetPos.Z);
                        Axis.PolishR[i].MC_MoveAbs(ProjectData.Instance.SaveData.PolishPlatform[i].ResetPos.R);
                    }
                    for (int i = 0; i < 2; i++)
                    {
                        Axis.SolderX[i].MC_MoveAbs(ProjectData.Instance.SaveData.SolderPlatform[i].ResetPos.X);
                        Axis.SolderY[i].MC_MoveAbs(ProjectData.Instance.SaveData.SolderPlatform[i].ResetPos.Y);
                        Axis.SolderZ[i].MC_MoveAbs(ProjectData.Instance.SaveData.SolderPlatform[i].ResetPos.Z);
                        Axis.SolderR[i].MC_MoveAbs(ProjectData.Instance.SaveData.SolderPlatform[i].ResetPos.R);
                    }

                    LG.ImmediateStepNext(0xef);
                }
                break;

            case 0xef:
                if (Axis.allaixsarrive())
                {
                    LG.End();
                    TaskManager.Default.FSM.Change(FSMStaDef.STOP);
                }
                break;
            }
        }
示例#8
0
        protected override void LogicImpl()
        {
            var para = ProjectData.Instance.SaveData.SolderCleanData[ID];

            switch (LG.Step)
            {
            case 1:    //RZ抬起
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderR[ID].MC_MoveAbs(0);
                    Axis.SolderZ[ID].MC_MoveAbs(0);
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:    //XY到清洗位
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.SolderX[ID].MC_MoveAbs(para.CleanPos.X);
                    Axis.SolderY[ID].MC_MoveAbs(para.CleanPos.Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //RZ到清洗位
                if (Axis.SolderX[ID].status == 0 && Axis.SolderY[ID].status == 0)
                {
                    Axis.SolderR[ID].MC_MoveAbs(para.CleanPos.R);
                    Axis.SolderZ[ID].MC_MoveAbs(para.CleanPos.Z);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //打开吹气电磁阀
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    Axis.Soldervalve[ID].ON();
                    LG.ImmediateStepNext(5);
                }
                break;

            case 5:    //吹气清洗时间
                if (LG.Delay(para.CleanTime))
                {
                    Axis.Soldervalve[ID].OFF();
                    LG.ImmediateStepNext(6);
                }
                break;

            case 6:
                Axis.SolderR[ID].MC_MoveAbs(0);
                Axis.SolderZ[ID].MC_MoveAbs(0);
                LG.ImmediateStepNext(7);
                break;

            case 7:
                if (Axis.SolderR[ID].status == 0 && Axis.SolderZ[ID].status == 0)
                {
                    LG.ImmediateStepNext(0xef);
                }
                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 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;
            }
        }
示例#11
0
        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;
            }
        }
示例#13
0
        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.PolishCleanData;

            switch (LG.Step)
            {
            case 1:    //RZ抬起
                times = 0;
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(0);
                    Axis.PolishZ[ID].MC_MoveAbs(para[ID].SafeZ);    //Z抬起到安全位置
                    LG.ImmediateStepNext(2);
                }
                break;

            case 2:    //XY到清洗位
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveAbs(para[ID].CleanPos.X);
                    Axis.PolishY[ID].MC_MoveAbs(para[ID].CleanPos.Y);
                    LG.ImmediateStepNext(3);
                }
                break;

            case 3:    //RZ到清洗位
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(para[ID].CleanPos.R);
                    Axis.PolishZ[ID].MC_MoveAbs(para[ID].CleanPos.Z);
                    LG.ImmediateStepNext(4);
                }
                break;

            case 4:    //选择模式
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.Polishvalve[ID].ON();
                    switch (para[ID].Mode)
                    {
                    case 1:        //一字左右
                        LG.ImmediateStepNext(5);
                        break;

                    case 2:        //二字左右
                        LG.ImmediateStepNext(6);
                        break;
                    }
                }
                break;

                #region 一字左右
            case 5:
                Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                LG.ImmediateStepNext(51);
                break;

            case 51:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, -2 * para[ID].range);
                    LG.ImmediateStepNext(52);
                }
                break;

            case 52:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                    LG.ImmediateStepNext(53);
                }
                break;

            case 53:
                if (Axis.PolishX[ID].status == 0)
                {
                    times++;
                    if (para[ID].CleanTimes <= times)    //打磨次数足够
                    {
                        LG.ImmediateStepNext(7);
                        times = 0;
                    }
                    else
                    {
                        LG.ImmediateStepNext(5);    //打磨次数不够,继续打磨
                    }
                }
                break;

                #endregion
                #region 二字左右
            case 6:
                Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                LG.ImmediateStepNext(61);
                break;

            case 61:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, -2 * para[ID].range);
                    LG.ImmediateStepNext(62);
                }
                break;

            case 62:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                    LG.ImmediateStepNext(63);
                }
                break;

            case 63:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                    Axis.PolishY[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].interval);
                    LG.ImmediateStepNext(64);
                }

                break;

            case 64:
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, -2 * para[ID].range);
                    LG.ImmediateStepNext(65);
                }
                break;

            case 65:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveRel(para[ID].CleanSpeed, para[ID].range);
                    LG.ImmediateStepNext(66);
                }
                break;

            case 66:
                if (Axis.PolishX[ID].status == 0)
                {
                    times++;
                    if (para[ID].CleanTimes <= times)
                    {
                        times = 0;
                        LG.ImmediateStepNext(7);
                    }
                    else
                    {
                        LG.ImmediateStepNext(6);
                    }
                }
                break;

                #endregion
            case 7:
                if (Axis.PolishX[ID].status == 0)
                {
                    Axis.PolishR[ID].MC_MoveAbs(para[ID].CleanEndPos.R);
                    Axis.PolishZ[ID].MC_MoveAbs(para[ID].CleanEndPos.Z);
                    LG.ImmediateStepNext(8);
                }
                break;

            case 8:
                if (Axis.PolishR[ID].status == 0 && Axis.PolishZ[ID].status == 0)
                {
                    Axis.PolishX[ID].MC_MoveAbs(para[ID].CleanEndPos.X);
                    Axis.PolishY[ID].MC_MoveAbs(para[ID].CleanEndPos.Y);
                    LG.ImmediateStepNext(0xef);
                }
                break;

            case 0xef:
                if (Axis.PolishX[ID].status == 0 && Axis.PolishY[ID].status == 0)
                {
                    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;
            }
        }