private static void Alarm_Light() { if (Alarm_Light_Time_EN == false) { Alarm_Light_Time_EN = true; Gg.SetDo(0, 3, 0); //蜂鸣器 Gg.SetDo(0, 0, 1); //红色指示灯 Gg.SetDo(0, 1, 0); //黄色指示灯 Gg.SetDo(0, 2, 0); //绿色指示灯 Alarm_Light_Time_N1 = API.GetTickCount(); } if (API.GetTickCount() - Alarm_Light_Time_N1 > 500) { if (API.GetTickCount() - Alarm_Light_Time_N2 > 500) { Alarm_Light_Time_EN = false; } Gg.SetDo(0, 3, 0); //蜂鸣器 Gg.SetDo(0, 0, 0); //红色指示灯 } else { Alarm_Light_Time_N2 = API.GetTickCount(); } }
public static void LightStatus() { switch (PVar.LampStatus) { case 10: //异常报警 Alarm_Light(); //报警模式闪灯 break; case 20: //设备初始化完毕 IntOK_Light(); //初始化完成黄灯常亮 break; case 30: //机器工作正常 Gg.SetDo(0, 3, 0); //蜂鸣器 Gg.SetDo(0, 0, 0); //红色指示灯 Gg.SetDo(0, 1, 0); //黄色指示灯 Gg.SetDo(0, 2, 1); //绿色指示灯 break; case 40: //机器空跑 Run_Light(); //空跑工作闪灯 break; case 50: //开机无报警 Int_Light(); //开机无报警,黄灯闪,等待初始化 break; } Buzzer(); }
/// <summary> /// 参数:[0板卡,1扩展模块],[板卡号0-2],[模块号0-3],[输出端口号0-15] /// </summary> /// <param name="CardType"></param> /// <param name="CardNum"></param> /// <param name="Mdl"></param> /// <param name="Index"></param> /// <returns></returns> /// <remarks></remarks> public static bool NSetDO(int CardType, int CardNum, int Mdl, int Index) { try { switch (CardType) { case 0: if (Gg.GetDo((short)CardNum, (short)Index) == 1) { Gg.SetDo((short)CardNum, (short)Index, (short)0); } else { Gg.SetDo((short)CardNum, (short)Index, (short)1); } break; case 1: if (Gg.GetExDo((short)CardNum, (short)Mdl, (short)Index) == 1) { Gg.SetExDo((short)CardNum, (short)Mdl, (short)Index, (short)0); } else { Gg.SetExDo((short)CardNum, (short)Mdl, (short)Index, (short)1); } break; } } catch (Exception) { return(false); } return(true); }
private void btn_Cylinder_Trigger(Bool obj) { if (Gg.GetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀) == 1) { Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); btn_Cylinder.Checked = false; } else { Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1); btn_Cylinder.Checked = true; } }
private static int OpenFixtureVocume() { int n = -1; for (int i = 1; i <= 4; i++) { if (Convert.ToInt32(Frm_Engineering.fEngineering.Label_Sta1.Text) == i) { Gg.SetDo(0, 4 + i * 2, 1); //打开真空吸 Gg.SetDo(0, 5 + i * 2, 0); //关闭破真空 n = i; } } return(n); }
private static void Buzzer() { if (PVar.Ring_EN) { PVar.Ring_EN = false; Buzzer_Time_EN = true; //Gg.SetExDo(0, 0, 13, 1); Gg.SetDo(0, Gg.OutPutMMS0.警示蜂鸣器, 1); Buzzer_Time_N = API.GetTickCount(); } if (Buzzer_Time_EN) { if (API.GetTickCount() - Buzzer_Time_N > 500) { Buzzer_Time_EN = false; Buzzer_Time_N = 0; //Gg.SetExDo(0, 0, 13, 0); Gg.SetDo(0, Gg.OutPutMMS0.警示蜂鸣器, 0); } } }
private static void IntOK_Light() { if (IntOK_Light_Time_EN == false) { IntOK_Light_Time_EN = true; Gg.SetDo(0, 3, 0); //蜂鸣器 Gg.SetDo(0, 0, 0); //红色指示灯 Gg.SetDo(0, 1, 1); //黄色指示灯 Gg.SetDo(0, 2, 0); //绿色指示灯 IntOK_Light_Time_N1 = API.GetTickCount(); } if (API.GetTickCount() - IntOK_Light_Time_N1 > 500) { if (API.GetTickCount() - IntOK_Light_Time_N2 > 500) { IntOK_Light_Time_EN = false; } //Gg.SetDo(0, 1, 0); //黄色指示灯'开启变成闪亮 } else { IntOK_Light_Time_N2 = API.GetTickCount(); } }
public void HomeSub() { switch (StepHome) { case 10: Reset.State = true; AddList("设备初始化开始,请等待!"); Gg.SetDo(0, Gg.OutPut0.载具真空吸1, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸2, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸3, 0); Gg.SetDo(0, Gg.OutPut0.载具真空吸4, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空1, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空2, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空3, 0); Gg.SetDo(0, Gg.OutPut0.载具破真空4, 0); Gg.SetDo(0, Gg.OutPut0.保压站刹车继电器, 0); Gg.SetDo(0, Gg.OutPut0.警示蜂鸣器, 0); Gg.SetDo(0, Gg.OutPut0.装配站刹车继电器, 0); Gg.SetDo(0, Gg.OutPut1.取料吸嘴破真空, 0); Gg.SetDo(0, Gg.OutPut1.取料吸嘴真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.NG蜂鸣器, 0); Gg.SetExDo(0, 0, Gg.OutPut2.NG指示灯, 0); Gg.SetExDo(0, 0, Gg.OutPut2.OK指示灯, 0); Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.除底摸平移气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.除底膜吸嘴气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.拉料无杆干气缸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸右, 0); Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸左, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取底膜真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料破真空, 0); Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 0); Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0); ////界面 Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_ProgressBar.IsShowProgresBar(true); InitTimeOut = API.GetTickCount(); StepHome = 20; break; case 20: Frm_ProgressBar.SetValueProgressBar(10); //初始化进度条的进度更新显示 if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0 //&& Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 0 && Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 0) { InitTimeOut = API.GetTickCount(); StepHome = 30; } if (API.GetTickCount() - InitTimeOut > 2000) { if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 1) { AddList("1#载具真空检测1异常,请检查!"); ShowList("1#载具真空检测1异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 1) { AddList("2#载具真空检测2异常,请检查!"); ShowList("2#载具真空检测2异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 1) { AddList("3#载具真空检测3异常,请检查!"); ShowList("3#载具真空检测3异常,请检查!"); } if (Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 1) { AddList("4#载具真空检测3异常,请检查!"); ShowList("4#载具真空检测3异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1) { AddList("撕摸升降气缸缩回信号异常,请检查!"); ShowList("撕摸升降气缸缩回信号异常,请检查!"); } //if (Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 1) // { // AddList("复检气缸缩回信号异常,请检查!"); // ShowList("复检气缸缩回信号异常,请检查!"); // } if (Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 1) { AddList("保压升降气缸缩回信号异常,请检查!"); ShowList("保压升降气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 1) { AddList("除底摸平移气缸缩回信号异常,请检查!"); ShowList("除底摸平移气缸缩回信号异常,请检查!"); } if (Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 1) { AddList("除底膜吸嘴气缸缩回信号异常,请检查!"); ShowList("除底膜吸嘴气缸缩回信号异常,请检查!"); } StepHome = 1000; } break; case 30: AddList("组装Z轴开始回原点…"); AddList("保压Z轴开始回原点…"); GoHome.Instance.AxisHome[0, 3].Result = false; GoHome.Instance.AxisHome[0, 8].Result = false; GoHome.Instance.AxisHome[0, 3].Enable = true; GoHome.Instance.AxisHome[0, 8].Enable = true; GoHome.Instance.AxisHome[0, 3].Step = 10; GoHome.Instance.AxisHome[0, 8].Step = 10; InitTimeOut = API.GetTickCount(); Frm_ProgressBar.SetValueProgressBar(30); StepHome = 40; break; case 40: GotoHome(0, 3, 20, -1000, 10, 1, 10); GotoHome(0, 8, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 3].Step == 0 && GoHome.Instance.AxisHome[0, 3].Enable) { GoHome.Instance.AxisHome[0, 3].Enable = false; if (GoHome.Instance.AxisHome[0, 3].Result) { AddList("组装Z轴回原点成功!"); } else { AddList("组装Z轴回原点失败!"); ShowList("组装Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 8].Step == 0 && GoHome.Instance.AxisHome[0, 8].Enable) { GoHome.Instance.AxisHome[0, 8].Enable = false; if (GoHome.Instance.AxisHome[0, 8].Result) { AddList("保压Z轴回原点成功!"); } else { AddList("保压Z轴回原点失败!"); ShowList("保压Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 3].Result && GoHome.Instance.AxisHome[0, 8].Result) { Frm_ProgressBar.SetValueProgressBar(50); InitTimeOut = API.GetTickCount(); StepHome = 50; } break; case 50: AddList("组装X轴开始回原点…"); AddList("组装Y轴开始回原点…"); AddList("组装R轴开始回原点…"); GoHome.Instance.AxisHome[0, 1].Result = false; GoHome.Instance.AxisHome[0, 2].Result = false; GoHome.Instance.AxisHome[0, 4].Result = false; GoHome.Instance.AxisHome[0, 1].Enable = true; GoHome.Instance.AxisHome[0, 2].Enable = true; GoHome.Instance.AxisHome[0, 4].Enable = true; GoHome.Instance.AxisHome[0, 1].Step = 10; GoHome.Instance.AxisHome[0, 2].Step = 10; GoHome.Instance.AxisHome[0, 4].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 60; break; case 60: GotoHome(0, 1, 20, -1000, 10, 1, 10); GotoHome(0, 2, 20, -1000, 10, 1, 10); GotoHome(0, 4, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable) { GoHome.Instance.AxisHome[0, 1].Enable = false; if (GoHome.Instance.AxisHome[0, 1].Result) { AddList("组装X轴回原点成功!"); } else { AddList("组装X轴回原点失败!"); ShowList("组装X轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 2].Step == 0 && GoHome.Instance.AxisHome[0, 2].Enable) { GoHome.Instance.AxisHome[0, 2].Enable = false; if (GoHome.Instance.AxisHome[0, 2].Result) { AddList("组装Y轴回原点成功!"); } else { AddList("组装Y轴回原点失败!"); ShowList("组装Y轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 4].Step == 0 && GoHome.Instance.AxisHome[0, 4].Enable) { GoHome.Instance.AxisHome[0, 4].Enable = false; if (GoHome.Instance.AxisHome[0, 4].Result) { AddList("组装R轴回原点成功!"); } else { AddList("组装R轴回原点失败!"); ShowList("组装R轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 1].Result && GoHome.Instance.AxisHome[0, 2].Result && GoHome.Instance.AxisHome[0, 4].Result) { Frm_ProgressBar.SetValueProgressBar(70); InitTimeOut = API.GetTickCount(); StepHome = 70; } break; case 70: AddList("上料Z轴开始回原点…"); AddList("平移Y轴开始回原点…"); AddList("拉料Z轴开始回原点…"); GoHome.Instance.AxisHome[0, 5].Result = false; GoHome.Instance.AxisHome[0, 6].Result = false; GoHome.Instance.AxisHome[0, 7].Result = false; GoHome.Instance.AxisHome[0, 5].Enable = true; GoHome.Instance.AxisHome[0, 6].Enable = true; GoHome.Instance.AxisHome[0, 7].Enable = true; GoHome.Instance.AxisHome[0, 5].Step = 10; GoHome.Instance.AxisHome[0, 6].Step = 10; GoHome.Instance.AxisHome[0, 7].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 80; break; case 80: GotoHome(0, 5, 20, -1000, 10, 1, 10); GotoHome(0, 6, 20, -1000, 10, 1, 30); GotoHome(0, 7, 20, -1000, 10, 1, 10); if (GoHome.Instance.AxisHome[0, 5].Step == 0 && GoHome.Instance.AxisHome[0, 5].Enable) { GoHome.Instance.AxisHome[0, 5].Enable = false; if (GoHome.Instance.AxisHome[0, 5].Result) { AddList("上料Z轴回原点成功!"); } else { AddList("上料Z轴回原点失败!"); ShowList("上料Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 6].Step == 0 && GoHome.Instance.AxisHome[0, 6].Enable) { GoHome.Instance.AxisHome[0, 6].Enable = false; if (GoHome.Instance.AxisHome[0, 6].Result) { AddList("平移Y轴回原点成功!"); } else { AddList("平移Y轴回原点失败!"); ShowList("平移Y轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 7].Step == 0 && GoHome.Instance.AxisHome[0, 7].Enable) { GoHome.Instance.AxisHome[0, 7].Enable = false; if (GoHome.Instance.AxisHome[0, 7].Result) { AddList("拉料Z轴回原点成功!"); } else { AddList("拉料Z轴回原点失败!"); ShowList("拉料Z轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[0, 5].Result && GoHome.Instance.AxisHome[0, 6].Result && GoHome.Instance.AxisHome[0, 7].Result) { Frm_ProgressBar.SetValueProgressBar(80); InitTimeOut = API.GetTickCount(); StepHome = 90; } break; case 90: AddList("转盘R轴开始回原点…"); GoHome.Instance.AxisHome[1, 2].Result = false; GoHome.Instance.AxisHome[1, 1].Enable = true; GoHome.Instance.AxisHome[1, 1].Step = 10; InitTimeOut = API.GetTickCount(); StepHome = 100; break; case 100: GotoHome(1, 1, 30, -360, 5, mFunction.Pos.TeachAxis1[2, 0], 30); if (GoHome.Instance.AxisHome[1, 1].Step == 0 && GoHome.Instance.AxisHome[1, 1].Enable) { GoHome.Instance.AxisHome[1, 1].Enable = false; if (GoHome.Instance.AxisHome[1, 1].Result) { AddList("转盘R轴回原点成功!"); } else { AddList("转盘R轴回原点失败!"); ShowList("转盘R轴回原点失败!"); StepHome = 1000; } } if (GoHome.Instance.AxisHome[1, 1].Result) { Frm_ProgressBar.SetValueProgressBar(90); InitTimeOut = API.GetTickCount(); StepHome = 150; } break; case 150: AddList("各轴开始回待机位置…"); //组装站 Gg.AbsMotion(0, 1, mFunction.Pos.TeachAxis1[0, 0], 20); Gg.AbsMotion(0, 2, mFunction.Pos.TeachAxis2[0, 0], 20); Gg.AbsMotion(0, 3, mFunction.Pos.TeachAxis3[0, 0], 20); Gg.AbsMotion(0, 4, mFunction.Pos.TeachAxis4[0, 0], 20); //保压站 Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 0], 20); //保压初始位置 Tools.AxisTmplPos[1, 1] = 0; //供料 Gg.AbsMotion(0, 5, mFunction.Pos.TeachAxis2[3, 4], 50); //供料起始位置 Gg.AbsMotion(0, 6, mFunction.Pos.TeachAxis1[3, 6], 100); //避让位置 Gg.AbsMotion(0, 7, mFunction.Pos.TeachAxis3[3, 7], 50); //换料位置 InitTimeOut = API.GetTickCount(); StepHome = 160; break; case 160: if (Gg.ZSPD(0, 1) && Gg.ZSPD(0, 2) && Gg.ZSPD(0, 3) && Gg.ZSPD(0, 4) && Gg.ZSPD(0, 5) && Gg.ZSPD(0, 6) && Gg.ZSPD(0, 7) && Gg.ZSPD(0, 8) && Gg.ZSPD(1, 1)) { AddList("各轴回待机位置完成!"); InitTimeOut = API.GetTickCount(); StepHome = 170; } else { if ((API.GetTickCount() - InitTimeOut) > 10000) { if (Gg.ZSPD(0, 1) == false) { AddList("组装X轴回待机位置失败!"); ShowList("组装X轴回待机位置失败!"); } if (Gg.ZSPD(0, 2) == false) { AddList("组装Y轴回待机位置失败!"); ShowList("组装Y轴回待机位置失败!"); } if (Gg.ZSPD(0, 3) == false) { AddList("组装Z轴回待机位置失败!"); ShowList("组装Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 4) == false) { AddList("组装R轴回待机位置失败!"); ShowList("组装R轴回待机位置失败!"); } if (Gg.ZSPD(0, 5) == false) { AddList("上料Z轴回待机位置失败!"); ShowList("上料Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 6) == false) { AddList("平移Y轴回待机位置失败!"); ShowList("平移Y轴回待机位置失败!"); } if (Gg.ZSPD(0, 7) == false) { AddList("拉料Z轴回待机位置失败!"); ShowList("拉料Z轴回待机位置失败!"); } if (Gg.ZSPD(0, 8) == false) { AddList("保压Z轴回待机位置失败!"); ShowList("保压Z轴回待机位置失败!"); } if (Gg.ZSPD(1, 1) == false) { AddList("转盘R轴回待机位置失败!"); ShowList("转盘R轴回待机位置失败!"); } StepHome = 1000; } } break; case 170: if (API.GetTickCount() - InitTimeOut > 500) { //gts.GT_SetPrfPos(1, 1, 0); //规划器置零 //gts.GT_SetEncPos(1, 1, 0); //编码器置零 //gts.GT_SynchAxisPos(1, 1 << 0); //将当前轴进行位置同步 InitTimeOut = API.GetTickCount(); StepHome = 800; } break; case 800: AddList("初始化完成"); ShowList("初始化完成"); PVar.LampStatus = 20; PVar.Stop_Flag = true; PVar.AutoRunFlag = false; PVar.MacHold = false; PVar.CPKDoneCounts = 0; PVar.WorkMode = 0; Frm_Main.fMain.Panel_CPK.Visible = false; Frm_Engineering.fEngineering.Btn_SelectMaterial.Enabled = true; //按钮初始化 Frm_Main.fMain.Btn_Start.Enabled = true; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.Enabled = true; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_SelectedBtn; //'主页面初始化和自动运行按钮 Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Engineering.fEngineering.TabPage3.Parent = Frm_Engineering.fEngineering.TabControl1; Frm_Engineering.fEngineering.TabPage4.Parent = Frm_Engineering.fEngineering.TabControl1; Frm_ProgressBar.IsShowProgresBar(false); //'初始化进度条显示 Frm_Engineering.fEngineering.Home_Timer.Enabled = false; for (int i = 0; i <= 4; i++) { PVar.Sta_Work[i].State = false; PVar.Sta_Work[i].Result = false; PVar.Sta_Work[i].IsHaveHSG = false; PVar.Sta_Work[i].Step = 0; } Mod_ErrorCode.CheckSystemTimeStep = 0; GoHome.Instance.Reset.State = false; GoHome.Instance.Reset.Result = true; StepHome = 0; break; case 1000: PVar.LampStatus = 10; PVar.MacHold = false; PVar.Stop_Flag = true; Frm_Engineering.fEngineering.Btn_SelectMaterial.Enabled = false; //按钮初始化 Frm_Main.fMain.Btn_Start.Enabled = true; Frm_Main.fMain.Btn_Pause.Enabled = false; Frm_Main.fMain.Btn_Stop.Enabled = false; Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_UnselectedBtn; //主页面初始化和自动运行按钮 Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn; Frm_Main.fMain.Btn_Stop.BZ_BackColor = PVar.BZColor_SelectedEndBtn; Frm_Engineering.fEngineering.Home_Timer.Enabled = false; Frm_ProgressBar.IsShowProgresBar(false); //初始化进度条显示 GoHome.Instance.Reset.Result = false; GoHome.Instance.Reset.State = false; StepHome = 0; break; } }
/// <summary> /// 自动运行 /// </summary> private void AutoRun() { #region Switch switch (AutoRunstep) { case 10: SetStep("CLEAR", Mycolor.None); TaskIsWorking = true; EventShowResult(EnumShowResult.Empty); SetStep("测试工站开始...", Mycolor.None); AutoRunstep = 20; break; #region run to test postion case 20: //运动到测试位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); SetStep("测试Y轴运动到测试点开始", Mycolor.None); AutoRunstep = 30; break; case 30: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试Y轴运动到达测试位置", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 70 : 40; } break; case 40: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1); SetStep("定位气缸打开", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 50; break; case 50: if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1) { SetStep("定位气缸到定位位置", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 60; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常"); AutoRunstep = 8000; } break; case 60: if (API.GetTickCount() - TimeOut > 300) { SetStep("延时300ms", Mycolor.None); AutoRunstep = 70; } break; #endregion #region start test & collect data case 70: //if (Globals.settingFunc.打开SSH通信 && Globals.SSHconnSt)//SSH打开,且SSH连接成功! { //SSH.Instance.ExecuteCommand("/Users/gdlocal/Desktop/MMS/" + Globals.settingPara.SSH脚本名字);//运行mini脚本 SetStep("Send SSH command-start to move Motor!", Mycolor.None); DAQ.Instance.PCI9222StartCollect(); //开始收集高度数据 SetStep("测试开始,开始收集数据", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 80; } //else //{ // SetStep("SSH功能没打开,或SSH连接失败!", Mycolor.ErrorRed); // SetStep("请确定SSH,退出测试!", Mycolor.ErrorRed); // TimeOut = API.GetTickCount(); // AutoRunstep = 290; //} break; case 80: //if (API.GetTickCount() - TimeOut > Globals.settingPara.测试超时) if (API.GetTickCount() - TimeOut > 2000) { SetStep("测试超时,退出测试!", Mycolor.ErrorRed); TimeOut = API.GetTickCount(); DAQ.Instance.PCI9222StopCollect(); AutoRunstep = 90; } //if (Globals.SSHstring.Contains("Motor Run Complete"))//SSH feedback string //{ // SetStep("收到SSH的Motor Run Complete,测试结束!", Mycolor.None); // DAQ.Instance.PCI9222Clear();//stop collect the 9222 data // TimeOut = API.GetTickCount(); // AutoRunstep = 90; //} break; case 90: //save the raw data ls.Clear(); string[] stringheader = new string[] { "Time", "laer_p0", "laer_p1", "laer_p2", "laer_p3", "laer_p4" }; ls.Add(stringheader); for (int i = 0; i < DAQ.Instance.listArray[0].Count - 2; i++) //最后两组数据不要 { string[] strarr = new string[6]; strarr[0] = DAQ.Instance.listArray[0][i].X.ToString(); //time strarr[1] = DAQ.Instance.listArray[0][i].Y.ToString(); //laser_p0 strarr[2] = DAQ.Instance.listArray[1][i].Y.ToString(); //laser_p1 strarr[3] = DAQ.Instance.listArray[2][i].Y.ToString(); //laser_p2 strarr[4] = DAQ.Instance.listArray[3][i].Y.ToString(); //laser_p3 strarr[5] = DAQ.Instance.listArray[4][i].Y.ToString(); //laser_p4 ls.Add(strarr); } string path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\RAW Displacement Data\\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } Globals.csv.WriteCSV(path + DataManager.Instance.CurrentCheckData.SN + "_" + DateTime.Now.ToString("HH_mm_ss_fff") + "_raw.csv", ls); ls.Clear(); AutoRunstep = 100; break; case 100: AutoRunstep = 110; break; case 110: AutoRunstep = 120; break; case 120: AutoRunstep = 200; break; case 200: AutoRunstep = 210; break; case 210: SetStep("显示测试数据", Mycolor.None); #region 产生数据 1tray // "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis" DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd"); DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss"); Random rd = new Random(); double m_A = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double m_x = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double m_y = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; if (tempi % 2 == 1) { DataManager.Instance.CurrentCheckData.PASS = true; DataManager.Instance.CurrentCheckData.PDCAPASS = true; SetStep("the result is Passed", Color.LimeGreen); EventShowResult(EnumShowResult.OK); DataManager.Instance.currentyield.AddOneResult(true); //update the current yield and month yield } else { DataManager.Instance.CurrentCheckData.PASS = false; DataManager.Instance.CurrentCheckData.PDCAPASS = false; SetStep("the result is Failed", Color.Red); EventShowResult(EnumShowResult.NG); DataManager.Instance.currentyield.AddOneResult(false); //update the current yield and month yield } DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 DataManager.Instance.uph.UPHupdate(); //UPH update by hour if (OnCurrentInf != null) { OnCurrentInf(DataManager.Instance.CurrentCheckData); //给工程界面的数据显示 } if (OnFlashDataPage != null) { OnFlashDataPage(); } tempi++; #endregion AutoRunstep = 220; break; case 220: //PDCA DataManager.Instance.CurrentCheckData.Operator_ID = "0"; DataManager.Instance.CurrentCheckData.Mode = "0"; DataManager.Instance.CurrentCheckData.TestSeriesID = "'201805070859"; DataManager.Instance.CurrentCheckData.Prioriyt = "0"; PDCA_data[0] = DataManager.Instance.CurrentCheckData.Mod_Brc_X.ToString(); PDCA_data[1] = DataManager.Instance.CurrentCheckData.Mod_Brc_Y.ToString(); PDCA_data[2] = DataManager.Instance.CurrentCheckData.Mod_Brc_A.ToString(); PDCA_data[3] = DataManager.Instance.CurrentCheckData.Mod_Brc_CC.ToString(); PDCA_data[4] = DataManager.Instance.CurrentCheckData.Operator_ID.ToString(); PDCA_data[5] = DataManager.Instance.CurrentCheckData.Mode.ToString(); PDCA_data[6] = DataManager.Instance.CurrentCheckData.TestSeriesID.ToString(); PDCA_data[7] = DataManager.Instance.CurrentCheckData.Prioriyt.ToString(); PDCA_Step = 10; AutoRunstep = 240; break; case 230: //PDCA if (PDCA_Bali(PDCA_data) == FunctionStatus.Finish) { DataManager.Instance.CurrentCheckData.PDCAPASS = true; AutoRunstep = 240; } else if (PDCA_Bali(PDCA_data) == FunctionStatus.Error) { DataManager.Instance.CurrentCheckData.PDCAPASS = false; AutoRunstep = 240; } break; case 240: #region 从测试数据中取值,保留生产数据 path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\PDCA Data\\" + DateTime.Now.ToString("yyyyMM") + "\\"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Clear(); stringBuilder.Append("" + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartDate + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartTime + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.SN + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.PASS + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.PDCAPASS + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_X + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_Y + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_A + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_CC + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Operator_ID + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mode + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.TestSeriesID + ","); stringBuilder.Append(DataManager.Instance.CurrentCheckData.Prioriyt + ","); string pathtemp = path + DateTime.Now.ToString("yyyyMMdd") + "_PDCA_Data.csv"; #region save the csv header if (File.Exists(pathtemp) == false) { StringBuilder stringBuilderHeader = new StringBuilder(); stringBuilderHeader.Clear(); stringBuilderHeader.Append(" ,StartDate,StartTime,SN,Result,PDCA_Result,X,Y,A,CC,Operator_ID,Mode,TestSeriesID,Prioriyt,\t\n"); stringBuilderHeader.Append("Upper Limit,NA,NA,NA,NA,NA,1,2,3,4,\t\n"); stringBuilderHeader.Append("Lower Limit,NA,NA,NA,NA,NA,-1,-2,-3,-4,\t\n"); stringBuilderHeader.Append("Units,NA,NA,NA,NA,NA,mm,mm,mm,mm,"); CsvServer.Instance.WriteLine(pathtemp, stringBuilderHeader.ToString()); stringBuilderHeader.Clear(); } #endregion CsvServer.Instance.WriteLine(pathtemp, stringBuilder.ToString()); stringBuilder.Clear(); #endregion AutoRunstep = 290; break; case 290: DAQ.Instance.PCI9222StopCollect(); AutoRunstep = 300; break; #endregion #region back to wait postion case 300: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 320 : 310; break; case 310: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); AutoRunstep = 320; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); AutoRunstep = 8000; } break; case 320: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 330; break; case 330: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 2000; } break; #endregion case 2000: StaStop = false; StopWatch_Stop(); //stop the CT count AutoRunstep = 0; TaskIsWorking = false; SetStep("SAVE", Mycolor.None); PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode break; case 8000: DAQ.Instance.PCI9222Clear(); SetStep("此步为异常,退出循环", Mycolor.None); AutoRunstep = 0; StopWatch_Stop(); //stop the CT count TaskIsWorking = false; SetStep("SAVE", Mycolor.None); return; } SetStepNum(AutoRunstep); Task_StopWatchElapsedMilliseconds();//获取CT #endregion }
/// <summary> /// 空跑 /// </summary> private void DryRun() { #region Switch switch (AutoRunstep) { case 10: SetStep("CLEAR", Mycolor.None); TaskIsWorking = true; EventShowResult(EnumShowResult.Empty); SetStep("AutoRun Setp10", Mycolor.None); AutoRunstep = 20; break; case 20: SetStep("AutoRun Setp20", Mycolor.None); AutoRunstep = 30; break; case 30: Thread.Sleep(1); SetStep("AutoRun Setp30", Mycolor.None); AutoRunstep = 40; break; case 40: Thread.Sleep(10); SetStep("AutoRun Setp40", Mycolor.None); AutoRunstep = 50; break; case 50: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 60; break; case 60: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 70; } break; case 70: if (API.GetTickCount() - TimeOut > 300) { AutoRunstep = 80; } break; case 80: //测试位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 90; break; case 90: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到测试位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 100; } break; case 100: if (API.GetTickCount() - TimeOut > 300) { AutoRunstep = 110; } break; case 110: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1); SetStep("定位气缸打开......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 120; break; case 120: if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1) { SetStep("定位气缸到定位位置", Mycolor.None); AutoRunstep = 150; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常"); AutoRunstep = 8000; } break; case 150: SetStep("测试开始.....", Mycolor.None); Thread.Sleep(2000); AutoRunstep = 180; break; case 180: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 190; break; case 190: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); AutoRunstep = 200; } else if (API.GetTickCount() - TimeOut > 2000) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); AutoRunstep = 8000; } break; case 200: uint pck; uint pck2; gts.GT_GetClockHighPrecision(0, out pck); Thread.Sleep(5); gts.GT_GetClockHighPrecision(0, out pck2); uint ctt = pck2 - pck; SetStep("AutoRun Setp60", Mycolor.None); AutoRunstep = 210; break; case 210: Thread.Sleep(1000); SetStep("AutoRun Setp70", Mycolor.None); #region 产生数据 1tray // "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis" DataManager.Instance.CurrentCheckData.SN = "SNXXXXXXX"; DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd"); DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss"); Random rd = new Random(); if (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) { double left1 = DataManager.Instance.CurrentCheckData.IPD_Left1 = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double left2 = DataManager.Instance.CurrentCheckData.IPD_Right1 = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double Right1 = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double Right2 = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; DataManager.Instance.chartData.Adddata(left1.ToString() + "," + Right1.ToString() + "," + left2.ToString() + "," + Right2.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 } else { double m_A = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00; double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00; double m_x = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; double m_y = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00; DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西 } if (tempi % 2 == 1) { DataManager.Instance.CurrentCheckData.PASS = true; DataManager.Instance.CurrentCheckData.PDCAPASS = true; SetStep("the result is Passed", Color.LimeGreen); EventShowResult(EnumShowResult.OK); DataManager.Instance.currentyield.AddOneResult(true); //update the current yield and month yield } else { DataManager.Instance.CurrentCheckData.PASS = false; DataManager.Instance.CurrentCheckData.PDCAPASS = false; SetStep("the result is Failed", Color.Red); EventShowResult(EnumShowResult.NG); DataManager.Instance.currentyield.AddOneResult(false); //update the current yield and month yield } DataManager.Instance.uph.UPHupdate(); //UPH update by hour if (OnCurrentInf != null) { OnCurrentInf(DataManager.Instance.CurrentCheckData); //给工程界面的数据显示 } if (OnFlashDataPage != null) { OnFlashDataPage(); } tempi++; #endregion AutoRunstep = 220; break; case 220: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); AutoRunstep = 230; break; case 230: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); TimeOut = API.GetTickCount(); AutoRunstep = 2000; } break; case 2000: Thread.Sleep(100); SetStep("AutoRun Setp80", Mycolor.None); StaStop = false; StopWatch_Stop(); //stop the CT count AutoRunstep = 0; TaskIsWorking = false; SetStep("SAVE", Mycolor.None); PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode break; case 8000: Thread.Sleep(1); SetStep("AutoRun Setp8000", Mycolor.None); AutoRunstep = 0; StopWatch_Stop(); //stop the CT count TaskIsWorking = false; return; } SetStepNum(AutoRunstep); Task_StopWatchElapsedMilliseconds();//获取CT #endregion }
private FunctionStatus InitHoming() { switch (InitHomingStep) { case 10: AutoRunstep = 0; Gg.Set_Servo(0, BVar.MMSY, true); //open servo on Thread.Sleep(200); SetStep("开始回零.......", Mycolor.None); InitHomingStep = 15; break; case 15: Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0); SetStep("定位气缸复位......", Mycolor.None); InitHomingDelay.InitialTime(); InitHomingStep = 20; break; case 20: if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1) { SetStep("定位气缸在缩回位置", Mycolor.None); InitHomingStep = 30; } else if (InitHomingDelay.TimeIsUp(2000)) { SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed); PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常"); InitHomingStep = 8000; } break; case 30: SetStep("测试y轴开始回原点…", Mycolor.None); GoHome.Instance.AxisHome[0, 1].Result = false; GoHome.Instance.AxisHome[0, 1].Enable = true; GoHome.Instance.AxisHome[0, 1].Step = 10; TimeOut = API.GetTickCount(); InitHomingStep = 40; break; case 40: GoHome.GotoHome(0, 1, 30, -1000, 5, 1, 10); if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable) { GoHome.Instance.AxisHome[0, 1].Enable = false; if (GoHome.Instance.AxisHome[0, 1].Result) { SetStep("测试y轴回原点成功…", Mycolor.None); InitHomingStep = 50; } else { SetStep("测试y轴回原点失败…", Mycolor.ErrorRed); InitHomingStep = 8000; } } break; case 50: //等待位置 Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]); TimeOut = API.GetTickCount(); InitHomingStep = 60; break; case 60: if (Gg.ZSPD(0, BVar.MMSY)) { SetStep("测试y轴运动到初始位置成功…", Mycolor.None); InitHomingStep = 2000; } break; case 2000: InitHomingStep = 0; SetStep("MMS测试工站复位OK!", Mycolor.None); SetState(XTaskState.WAITRUN); SetStepNum(InitHomingStep); HomeOK = true; PVar.LampStatus = 20; PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST"); //for errorcode return(FunctionStatus.Finish); case 8000: InitHomingStep = 0; PVar.LampStatus = 10; return(FunctionStatus.Error); } SetStepNum(InitHomingStep); return(FunctionStatus.Working); }