public void PrintSocketState() { for (int i = 0; i < SocketMgr.GetInstance().socketArr.Length; i++) { Info(i.ToString() + ":" + SocketMgr.GetInstance().socketArr[i].socketState.ToString()); } }
protected override void StationWork(int step) { WaranResult waranResult; switch (step) { case (int)StationStep.step_init: //retry_init: //IOMgr.GetInstace().WriteIoBit("上料真空吸电磁阀", true); //waranResult = CheckIobyName("上料吸嘴真空检测", false, "上料站: 上料吸嘴可能被堵住,请拿开"); //if (waranResult == WaranResult.Retry) // goto retry_init; PushMultStep((int)StationStep.step_CheckAllFinish); DelCurrentStep(); userTimerCT.ResetStartTimer(); oldTime = 0; break; case (int)StationStep.step_CheckAllFinish: if (SocketMgr.GetInstance().socketArr[(int)SocketType.load].socketState == SocketState.Have && (SocketMgr.GetInstance().socketArr[(int)SocketType.stick1].socketState == SocketState.None || SocketMgr.GetInstance().socketArr[(int)SocketType.stick1].socketState == SocketState.HaveHaftOK) && (SocketMgr.GetInstance().socketArr[(int)SocketType.stick2].socketState == SocketState.None || SocketMgr.GetInstance().socketArr[(int)SocketType.stick2].socketState == SocketState.HaveOK) && (SocketMgr.GetInstance().socketArr[(int)SocketType.press].socketState == SocketState.None || SocketMgr.GetInstance().socketArr[(int)SocketType.press].socketState == SocketState.HaveOK) && (SocketMgr.GetInstance().socketArr[(int)SocketType.unload].socketState == SocketState.None ) ) { if (CheckLineIO()) { Info("Socket流水线:各站准备完成开始流动"); MoveSocketLine(); if (ParamSetMgr.GetInstance().GetIntParam("保压屏蔽") != 1) { KeepPressure(); } CurrentTime = userTimerCT.NowTime; CTmsCounts = CurrentTime - oldTime; oldTime = CurrentTime; ParamSetMgr.GetInstance().SetDoubleParam("CT", CTmsCounts / 1000.00); } } break; } }
protected override bool InitStation() { ParamSetMgr.GetInstance().SetBoolParam("Socket流水线初始化完成", false); SocketMgr.GetInstance().ResetAllSocket(); AlarmMgr.GetIntance().DoWhenAlarmEvent += DoSomethingWhenalarm; WaranResult waranResult; Info("Y轴气缸伸出"); check_cyliderYout: IOMgr.GetInstace().WriteIoBit("Y轴气缸电磁阀", true); waranResult = CheckIobyName("Y轴气缸1到位", true, "Socket流水站:流水线自检 Y轴气缸移动伸出, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderYout; } waranResult = CheckIobyName("Y轴气缸2到位", true, "Socket流水站:流水线自检 Y轴气缸移动伸出, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderYout; } Info("Y轴气缸退回"); check_cyliderYback: IOMgr.GetInstace().WriteIoBit("Y轴气缸电磁阀", false); waranResult = CheckIobyName("Y轴气缸1原位", true, "Socket流水站:流水线自检 Y轴气缸移动退回, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderYback; } waranResult = CheckIobyName("Y轴气缸2原位", true, "Socket流水站:流水线自检 Y轴气缸移动退回, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderYback; } Info("X轴气缸伸出"); check_cyliderXout: IOMgr.GetInstace().WriteIoBit("X轴气缸电磁阀", true); waranResult = CheckIobyName("X轴气缸1到位", true, "Socket流水站: 流水线自检 X轴气缸伸出, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderXout; } waranResult = CheckIobyName("X轴气缸2到位", true, "Socket流水站: 流水线自检 X轴气缸伸出, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderXout; } Info("X轴气缸退回"); check_cyliderXback: IOMgr.GetInstace().WriteIoBit("X轴气缸电磁阀", false); waranResult = CheckIobyName("Y轴气缸1原位", true, "Socket流水站: 流水线自检 X轴气缸退回, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderXback; } waranResult = CheckIobyName("X轴气缸2原位", true, "Socket流水站:流水线自检 X轴气缸退回, 没到位可能卡住,,请拿开"); if (waranResult == WaranResult.Retry) { goto check_cyliderXback; } PushMultStep((int)StationStep.step_init); ParamSetMgr.GetInstance().SetBoolParam("Socket流水线初始化完成", true); return(true); }
public void KeepPressure(bool bmanual = false) { WaranResult waranResult; if (SocketMgr.GetInstance().socketArr[(int)SocketType.press].socketState == SocketState.HaveOK || bmanual) { retry_press_up2: IOMgr.GetInstace().WriteIoBit("保压气缸电磁阀", false); waranResult = CheckIobyName("保压上下气缸原位", true, "流水线站:保压上下气缸原位 没有到位,请检查感应器,气缸,气压,线路等", bmanual); if (waranResult == WaranResult.Retry) { goto retry_press_up2; } retry_messureA: waranResult = dowhileCheckA.doSomething(this, dowhileCheckA, bmanual, null); if (waranResult != WaranResult.Run) { waranResult = AlarmMgr.GetIntance().WarnWithDlg("保压时 ,A模块读不出数据 ", this, CommonDlg.DlgWaranType.Waran_Stop_Retry); if (waranResult == WaranResult.Retry) { goto retry_messureA; } } retry_messureB: waranResult = dowhileCheckB.doSomething(this, dowhileCheckA, bmanual, null); if (waranResult != WaranResult.Run) { waranResult = AlarmMgr.GetIntance().WarnWithDlg("保压时 ,B模块读不出数据 ", this, CommonDlg.DlgWaranType.Waran_Stop_Retry); if (waranResult == WaranResult.Retry) { goto retry_messureB; } } for (int i = 0; i < 4; i++) { pressvals[i] = press1[i]; pressvals[4 + i] = press2[i]; } retry_press_down: IOMgr.GetInstace().WriteIoBit("保压气缸电磁阀", true); waranResult = CheckIobyName("保压上下气缸到位", true, "流水线站:保压上下气缸到位 没有到位,请检查感应器,气缸,气压,线路等", bmanual); if (waranResult == WaranResult.Retry) { goto retry_press_down; } Thread.Sleep(ParamSetMgr.GetInstance().GetIntParam("保压时间")); retry_messureA2: waranResult = dowhileCheckA.doSomething(this, dowhileCheckA, bmanual, null); if (waranResult != WaranResult.Run) { waranResult = AlarmMgr.GetIntance().WarnWithDlg("保压时 ,A模块读不出数据 ", this, CommonDlg.DlgWaranType.Waran_Stop_Retry); if (waranResult == WaranResult.Retry) { goto retry_messureA2; } } retry_messureB2: waranResult = dowhileCheckB.doSomething(this, dowhileCheckA, bmanual, null); if (waranResult != WaranResult.Run) { waranResult = AlarmMgr.GetIntance().WarnWithDlg("保压时 ,B模块读不出数据 ", this, CommonDlg.DlgWaranType.Waran_Stop_Retry); if (waranResult == WaranResult.Retry) { goto retry_messureB2; } } for (int i = 0; i < 4; i++) { pressvals[i] = Math.Abs(pressvals[i] - press1[i]); pressvals[4 + i] = Math.Abs(pressvals[i + 4] - press2[i]); } Thread.Sleep(500); Weighing.GetInstance().Update(new int[] { pressvals[0], pressvals[1], pressvals[2], pressvals[3] }, new int[] { pressvals[4], pressvals[5], pressvals[6], pressvals[7] }); retry_press_up: IOMgr.GetInstace().WriteIoBit("保压气缸电磁阀", false); waranResult = CheckIobyName("保压上下气缸原位", true, "流水线站:保压上下气缸原位 没有到位,请检查感应器,气缸,气压,线路等", bmanual); if (waranResult == WaranResult.Retry) { goto retry_press_up; } } }
public void MoveSocketLine(bool bmanual = false) { WaranResult waranResult; Info("各站都已经完成,开始移动"); Info("XY轴气缸移动前 Socket 状态:"); PrintSocketState(); Info("X轴气缸退回"); check_cyliderXback: IOMgr.GetInstace().WriteIoBit("X轴气缸电磁阀", false); waranResult = CheckIobyName("X轴气缸1原位", true, "Socket流水站: X轴气缸退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXback; } waranResult = CheckIobyName("X轴气缸2原位", true, "Socket流水站: X轴气缸退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXback; } Info("Y轴气缸伸出"); check_cyliderYout: IOMgr.GetInstace().WriteIoBit("Y轴气缸电磁阀", true); waranResult = CheckIobyName("Y轴气缸1到位", true, "Socket流水站: Y轴气缸移动伸出, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderYout; } waranResult = CheckIobyName("Y轴气缸2到位", true, "Socket流水站: Y轴气缸移动伸出, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderYout; } Info("Y轴气缸退回"); check_cyliderYback: IOMgr.GetInstace().WriteIoBit("Y轴气缸电磁阀", false); waranResult = CheckIobyName("Y轴气缸1原位", true, "Socket流水站: Y轴气缸移动退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderYback; } waranResult = CheckIobyName("Y轴气缸2原位", true, "Socket流水站: Y轴气缸移动退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderYback; } Info("X轴气缸伸出"); check_cyliderXout: IOMgr.GetInstace().WriteIoBit("X轴气缸电磁阀", true); waranResult = CheckIobyName("X轴气缸1到位", true, "Socket流水站: X轴气缸伸出, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXout; } waranResult = CheckIobyName("X轴气缸2到位", true, "Socket流水站: X轴气缸伸出, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXout; } SocketMgr.GetInstance().MoveNext(); Info("X轴气缸退回"); check_cyliderXback2: IOMgr.GetInstace().WriteIoBit("X轴气缸电磁阀", false); waranResult = CheckIobyName("X轴气缸1原位", true, "Socket流水站: X轴气缸退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXback2; } waranResult = CheckIobyName("X轴气缸2原位", true, "Socket流水站: X轴气缸退回, 没到位可能卡住,,请拿开", bmanual); if (waranResult == WaranResult.Retry) { goto check_cyliderXback2; } Info("XY轴气缸移动后 Socket 状态:"); PrintSocketState(); }
public StationStep StepGoSnap(VisionControl visionControl, bool bmanual = false) { StationStep step = StationStep.Step_Stop; //拍照识别是否有料,计算偏差(6月后做) ParamSetMgr.GetInstance().SetBoolParam("启动点胶", true); //开始点胶(优先实现画轨迹) //获取当前夹取位置是A工位还是B工位 int StationIndex = TableData.GetInstance().GetSocketNum(1, 0.5) - 1; PathHelper.Disp_ID = StationIndex; string stationAAName = StationIndex == 0 ? "A" : "B"; ParamSetMgr.GetInstance().SetBoolParam($"{stationAAName}工位点胶", true); double CenterX = ParamSetMgr.GetInstance().GetDoubleParam("产品点胶X轴半径"); double CenterY = ParamSetMgr.GetInstance().GetDoubleParam("产品点胶Y轴半径"); double DelZ = ParamSetMgr.GetInstance().GetDoubleParam("点胶Z轴上升高度偏差"); int DispDelay = ParamSetMgr.GetInstance().GetIntParam("出胶延迟"); double DispRunAngle = ParamSetMgr.GetInstance().GetDoubleParam("画胶角度"); double DispEndAngle = ParamSetMgr.GetInstance().GetDoubleParam("收胶角度"); bool DispEnable = ParamSetMgr.GetInstance().GetBoolParam("屏蔽点胶"); bool DispPhoto = ParamSetMgr.GetInstance().GetBoolParam("点胶相机拍照定位"); double SafeZ = GetStationPointDic()[$"安全位置"].pointZ; double X = 0; double Y = 0; double DispPhotoX = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointX; double DispPhotoY = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointY; double DispPhotoZ = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointZ; double DispPosX = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointX; double DispPosY = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointY; double DispPosZ = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointZ; double x1 = GetStationPointDic()["安全位置"].pointX; CameraBase cam = null; if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机")) { cam = CameraMgr.GetInstance().GetCamera("Top"); cam.BindWindow(visionControl); Task.Run(() => { cam.StopGrap(); cam.SetTriggerMode(CameraModeType.Software); cam.SetGain(ParamSetMgr.GetInstance().GetIntParam("点胶相机增益")); cam.SetExposureTime(ParamSetMgr.GetInstance().GetIntParam("点胶相机曝光")); cam.StartGrab(); }); } IOMgr.GetInstace().WriteIoBit($"相机光源", true); retry_uplens: IOMgr.GetInstace().WriteIoBit($"{stationAAName}Lens升降气缸", true); WaranResult waranResult1 = CheckIobyName($"{stationAAName}Lens上升到位", true, $"{stationAAName}Lens上升到位", bmanual); if (waranResult1 == WaranResult.Retry) { goto retry_uplens; } MoveSigleAxisPosWaitInpos(AxisZ, SafeZ, (double)SpeedType.High, 0.005, bmanual, this); MoveY(DispPhotoY, SpeedType.High); MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this); HObject img = null; if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机")) { img = cam.GetImage(); if (img == null || !img.IsInitialized()) { img = cam.GetImage(); } else { ImageHelper.Instance.SaveImage($"{PathHelper.ImagePathDisp}{DateTime.Now.ToString("HHmmssfff")}.bmp", "bmp", img.Clone()); } } IOMgr.GetInstace().WriteIoBit($"相机光源", false); //去画胶 Task.Run(() => { if (ParamSetMgr.GetInstance().GetBoolParam("是否选择程控电源")) { double valueVoltage = ParamSetMgr.GetInstance().GetDoubleParam("程控电源电压"); OtherDevices.ckPower.SetVoltage(StationIndex + 1, valueVoltage); double valueCurrent = ParamSetMgr.GetInstance().GetDoubleParam("程控电源电流"); OtherDevices.ckPower.SetCurrent(StationIndex + 1, valueCurrent); } IOMgr.GetInstace().WriteIoBit($"{stationAAName}模组上电", true); IOMgr.GetInstace().WriteIoBit($"12V开启", ParamSetMgr.GetInstance().GetBoolParam("是否开启非程控12V")); }); if (DispEnable) { step = StationStep.Step_CheckIpos; MoveSigleAxisPosWaitInpos(AxisZ, SafeZ, (double)SpeedType.High, 0.005, bmanual, this); TableData.GetInstance().SetStationResult("A_UnLoadLoad", true); TableData.GetInstance().SetStationResult("B_UnLoadLoad", true); return(step); } if (DispPhoto) { ////MoveY(DispPhotoY, SpeedType.High); ////MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this); //拍照计算 +半径 double CenterdelX = 0; double CenterdelY = 0; X = CenterX + CenterdelX; Y = CenterdelY; DispPosX = DispPhotoX - X; DispPosY = DispPhotoY + CenterdelY; } else { X = CenterX; Y = 0; } // IOMgr.GetInstace().WriteIoBit("点胶机", false); bool brtnExc = true; MotionMgr.GetInstace().AddAxisToGroup("点胶群组", 2, new int[] { AxisX, AxisY }); MoveY(DispPosY, SpeedType.High); MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPosX, DispPosZ + DelZ + 10 }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this); // MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this); IOMgr.GetInstace().WriteIoBit("点胶机", false); MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + DelZ }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this); if (ParamSetMgr.GetInstance().GetStringParam("点胶轨迹") == "Circle") { DateTime dateTime = DateTime.Now; if (DispDelay >= 0) { IOMgr.GetInstace().WriteIoBit("点胶机", true); Thread.Sleep(DispDelay); } else { Task.Run(() => { while (true) { if ((DateTime.Now - dateTime).TotalSeconds > Math.Abs(DispDelay) / 1000.0) { IOMgr.GetInstace().WriteIoBit("点胶机", true); break; } Thread.Sleep(10); } }); } //走 brtnExc &= MotionMgr.GetInstace().ClearBufMove("点胶群组"); brtnExc &= MotionMgr.GetInstace().RestGpErr("点胶群组"); // GpState gps = MotionMgr.GetInstace().GetGpState("点胶群组"); brtnExc &= MotionMgr.GetInstace().AddBufMove("点胶群组", BufMotionType.buf_Arc2dAbsAngleCW, 1, 2, (double)SpeedType.Mid, (double)SpeedType.Mid, new double[2] { X, Y }, new double[2] { DispPosZ, 0 }); brtnExc &= MotionMgr.GetInstace().BufTrans("点胶群组");//M314没有buf运动,所以放在这里star brtnExc &= MotionMgr.GetInstace().BufStart("点胶群组"); Thread.Sleep(400); if (!WaitXY(DispPosX, DispPosY)) { IOMgr.GetInstace().WriteIoBit("点胶机", false); return(step); } IOMgr.GetInstace().WriteIoBit("点胶机", false); } else { IOMgr.GetInstace().WriteIoBit("点胶机", true); Thread.Sleep(DispDelay); MoveY(DispPosY + CenterY * 10, SpeedType.Mid); MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX + CenterX * 2 }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this); MoveY(DispPosY - CenterY * 10, SpeedType.Mid); MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this); MoveY(DispPosY, SpeedType.Mid); IOMgr.GetInstace().WriteIoBit("点胶机", false); } IOMgr.GetInstace().WriteIoBit($"相机光源", true); MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + 3 }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this); MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + 10 }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this); if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机")) { MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this); // MoveSigleAxisPosWaitInpos(AxisX, DispPhotoX, (double)SpeedType.High, 0.005, bmanual, this); MoveY(DispPhotoY, SpeedType.High); HObject img2 = cam.GetImage(); if (img2 == null || !img2.IsInitialized()) { img2 = cam.GetImage(); } else { ImageHelper.Instance.SaveImage($"{PathHelper.ImagePathDisp}{DateTime.Now.ToString("HHmmssfff")}.bmp", "bmp", img2.Clone()); } } IOMgr.GetInstace().WriteIoBit($"相机光源", false); MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { SafeZ }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this); MoveSigleAxisPosWaitInpos(AxisX, x1, (double)SpeedType.High, 0.005, bmanual, this); step = StationStep.Step_CheckIpos; //if (DialogResult.OK!= MessageBox.Show("请确定点胶效果是否OK,OK按确定", "Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)) //{ // ParamSetMgr.GetInstance().SetBoolParam("重新上料", true); // return step; //} ParamSetMgr.GetInstance().SetBoolParam("重新上料", false); SocketMgr.GetInstance().SetSocketState(SocketNumOfUnloadLoad, SocketState.Have); TableData.GetInstance().SetStationResult("A_UnLoadLoad", true); TableData.GetInstance().SetStationResult("B_UnLoadLoad", true); ParamSetMgr.GetInstance().SetBoolParam("点胶完成", true); return(step); }
public StationStep StepCheckIpos(bool bmanual = false) { StationStep step = StationStep.Step_CheckIpos; bool dEnableA = ParamSetMgr.GetInstance().GetBoolParam("屏蔽A工位"); bool dEnableB = ParamSetMgr.GetInstance().GetBoolParam("屏蔽B工位"); bool bA_UnLoadLoadStart = TableData.GetInstance().GetStationStartCmd("A_UnLoadLoad") && !dEnableA; bool bB_UnLoadLoadStart = TableData.GetInstance().GetStationStartCmd("B_UnLoadLoad") && !dEnableB; if (bA_UnLoadLoadStart || bB_UnLoadLoadStart || ParamSetMgr.GetInstance().GetBoolParam("重新上料")) { ParamSetMgr.GetInstance().SetBoolParam("重新上料", false); TableData.GetInstance().ResetStartCmd("A_UnLoadLoad"); TableData.GetInstance().ResetStartCmd("B_UnLoadLoad"); strStationName = TableData.GetInstance().GetStationName(); if (strStationName == "A_Pick" || strStationName == "B_Pick") { TableData.GetInstance().SetStationResult("A_UnLoadLoad", true); TableData.GetInstance().SetStationResult("B_UnLoadLoad", true); return(step); } SocketNumOfUnloadLoad = TableData.GetInstance().GetSocketNum(1, 0.5) - 1; if (SocketNumOfUnloadLoad == 0 && dEnableA) { TableData.GetInstance().SetStationResult("A_UnLoadLoad", true); TableData.GetInstance().SetStationResult("B_UnLoadLoad", true); return(step); } if (SocketNumOfUnloadLoad == 1 && dEnableB) { TableData.GetInstance().SetStationResult("A_UnLoadLoad", true); TableData.GetInstance().SetStationResult("B_UnLoadLoad", true); return(step); } IOMgr.GetInstace().WriteIoBit("NG指示红灯", false); IOMgr.GetInstace().WriteIoBit("OK指示绿灯", true); Info("开始上下料,安全光栅开始屏蔽"); ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", false); ParamSetMgr.GetInstance().SetBoolParam("可以上下料", true); SocketState state = SocketMgr.GetInstance().socketArr[SocketNumOfUnloadLoad].socketState; if (state == SocketState.HaveOK || state == SocketState.HaveNG) { string lightColor = state == SocketState.HaveOK ? "OK指示绿灯" : "NG指示红灯"; string fp = state == SocketState.HaveOK ? "P" : "F"; UserTest.TestResultAB[SocketNumOfUnloadLoad].SocketerNumber = SocketNumOfUnloadLoad == 0 ? "A" : "B"; #region 计算CT赋值 if (UserTest.ProductCount.CountCTAll == 0) { UserTest.ProductCount.StarCTTime = DateTime.Now; UserTest.ProductCount.EndCTTime = DateTime.Now; UserTest.ProductCount.CountCTTime = 0; } else { UserTest.ProductCount.CountCTTime += (DateTime.Now - UserTest.ProductCount.EndCTTime).TotalSeconds; UserTest.ProductCount.EndCTTime = DateTime.Now; if ((DateTime.Now - UserTest.ProductCount.StarCTTime).TotalMinutes > ParamSetMgr.GetInstance().GetDoubleParam("UPH计算时长")) { if (UserTest.ProductCount.CountCTAll > ParamSetMgr.GetInstance().GetDoubleParam("UPH计算时长范围内最少个数")) { UserTest.ProductCount.UPH = (UserTest.ProductCount.CountCTAll) * 3600 / UserTest.ProductCount.CountCTTime; } //清除 UserTest.ProductCount.CountCTAll = -1; } } UserTest.ProductCount.CountCTAll++; if (SocketNumOfUnloadLoad == 0) { if (fp == "P") { UserTest.ProductCount.OKA++; } else { UserTest.ProductCount.NGA++; if (!UserTest.FailResultAB.Play) { UserTest.ProductCount.PlayFailA++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Tilt = true; } if (!UserTest.FailResultAB.OC) { UserTest.ProductCount.OCFailA++; UserTest.FailResultAB.Play = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Tilt = true; } if (!UserTest.FailResultAB.Tilt) { UserTest.ProductCount.TiltFailA++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Play = true; } if (!UserTest.FailResultAB.SFR) { UserTest.ProductCount.SFRFailA++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.Play = true; UserTest.FailResultAB.Tilt = true; } if (UserTest.FailResultAB.Play && UserTest.FailResultAB.OC && UserTest.FailResultAB.Tilt && UserTest.FailResultAB.SFR) { UserTest.ProductCount.OtherFailA++; } } } else { if (fp == "P") { UserTest.ProductCount.OKB++; } else { UserTest.ProductCount.NGB++; if (!UserTest.FailResultAB.Play) { UserTest.ProductCount.PlayFailB++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Tilt = true; } if (!UserTest.FailResultAB.OC) { UserTest.ProductCount.OCFailB++; UserTest.FailResultAB.Play = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Tilt = true; } if (!UserTest.FailResultAB.Tilt) { UserTest.ProductCount.TiltFailB++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.SFR = true; UserTest.FailResultAB.Play = true; } if (!UserTest.FailResultAB.SFR) { UserTest.ProductCount.SFRFailB++; UserTest.FailResultAB.OC = true; UserTest.FailResultAB.Play = true; UserTest.FailResultAB.Tilt = true; } if (UserTest.FailResultAB.Play && UserTest.FailResultAB.OC && UserTest.FailResultAB.Tilt && UserTest.FailResultAB.SFR) { UserTest.ProductCount.OtherFailB++; } } } #endregion Form_Auto.EvenShowCT(SocketNumOfUnloadLoad + 1); UserTest.TestResultAB[SocketNumOfUnloadLoad].Result = fp == "P" ? true : false; if (fp == "P") { UserTest.TestResultAB[SocketNumOfUnloadLoad].FailStep = "Pass"; } UserTest.TestResultAB[SocketNumOfUnloadLoad].EndTime = DateTime.Now; UserTest.TestResultAB[SocketNumOfUnloadLoad].TestTime = (UserTest.TestResultAB[SocketNumOfUnloadLoad].EndTime - UserTest.TestResultAB[SocketNumOfUnloadLoad].StarTime).TotalSeconds; string errCsv = CSVHelper.Instance.SaveToCSVPath(PathHelper.TestResultCsvPath, UserTest.TestResultAB[SocketNumOfUnloadLoad]); IOMgr.GetInstace().WriteIoBit("OK指示绿灯", false); IOMgr.GetInstace().WriteIoBit("NG指示红灯", false); IOMgr.GetInstace().WriteIoBit(lightColor, true); Info($"保存OK结果:cvs={errCsv}."); if (SocketNumOfUnloadLoad == 0) { IOMgr.GetInstace().WriteIoBit($"ALens升降气缸", true); } else { IOMgr.GetInstace().WriteIoBit($"BLens升降气缸", true); } //PlaceToSocket(SocketNumOfUnloadLoad); UserTest.CTTestAB[SocketNumOfUnloadLoad].Star = false; UserTest.CTTestAB[SocketNumOfUnloadLoad].End = false; UserTest.CTTestAB[SocketNumOfUnloadLoad].Show = true; } //同意下料接口 SysFunConfig.LodUnloadPatten.ULoad(SocketNumOfUnloadLoad == 0? "A":"B", bmanual); retry_check_Start: ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", false); WaranResult waranResult = doWhileCheckStartSignal.doSomething(this, doWhileCheckStartSignal, false, new object[] { this }); if (waranResult == WaranResult.Retry) { goto retry_check_Start; } IOMgr.GetInstace().WriteIoBit($"相机光源", true); IOMgr.GetInstace().WriteIoBit("启动按钮灯", false); IOMgr.GetInstace().WriteIoBit("OK指示绿灯", false); IOMgr.GetInstace().WriteIoBit("NG指示红灯", false); if (!IOMgr.GetInstace().ReadIoInBit($"点胶液位感应") && ParamSetMgr.GetInstance().GetBoolParam("点胶液位检测")) { MessageBox.Show($"点胶液位感应有信号,胶水已经用完!请更换,或者屏蔽[点胶液位检测]。", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); goto retry_check_Start; } Form_Auto.EvenGetSN(SocketNumOfUnloadLoad); if (UserTest.TestResultAB[SocketNumOfUnloadLoad].SerialNumber == "NOSN") { MessageBox.Show("请输入SN 或者屏蔽SN,重新启动", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); goto retry_check_Start; } if (SocketNumOfUnloadLoad == 0) { UserTest.ProductCount.CompeteA++; } else { UserTest.ProductCount.CompeteB++; } ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true); ParamSetMgr.GetInstance().SetBoolParam("可以上下料", false); ParamSetMgr.GetInstance().SetBoolParam("AA完成", false); ParamSetMgr.GetInstance().SetBoolParam("点胶完成", false); ParamSetMgr.GetInstance().SetBoolParam("启动AA", false); ParamSetMgr.GetInstance().SetBoolParam("启动点胶", false); Info("开始上下料,安全光栅开始启用"); ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true); UserTest.CTTestAB[SocketNumOfUnloadLoad].Star = true; UserTest.CTTestAB[SocketNumOfUnloadLoad].End = false; UserTest.CTTestAB[SocketNumOfUnloadLoad].Show = false; step = StationStep.Step_GoSnap; } return(step); }