private void Control_Click(object sender, EventArgs e) { if (!mc.check.READY_AUTORUN(sender)) { return; } mc.check.push(sender, true); this.Enabled = false; if (sender.Equals(BT_USE_LASER)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod1, 0); } if (sender.Equals(BT_USE_PATTERN)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod1, 1); } if (sender.Equals(BT_TrayReverseCheck)) { if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { #region Laser Method //bool laserpreon; double hwLaserOffsetX = mc.coor.MP.TOOL.X.LASER.value + 11500; double hwLaserOffsetY = mc.coor.MP.TOOL.Y.LASER.value - 4500; double posX = mc.para.CV.trayReverseXPos.value - hwLaserOffsetX + mc.para.CAL.HDC_LASER.x.value; double posY = mc.para.CV.trayReverseYPos.value - hwLaserOffsetY + mc.para.CAL.HDC_LASER.y.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } //mc.OUT.HD.LS.ON(out laserpreon, out ret.message); // Laser Sensor ON //mc.OUT.HD.LS.ON(true, out ret.message); // Check Laser Sensor //mc.OUT.HD.LS.ON(out ret.b, out ret.message); //if (ret.b) { //mc.OUT.HD.LS.ZERO(true, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; ret.d = mc.AIN.Laser(); if (ret.d < -10) { ret.d = -1; } //mc.IN.LS.ALM(out ret.b1, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; //mc.IN.LS.FAR(out ret.b2, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; //mc.IN.LS.NEAR(out ret.b3, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; } QueryTimer dwell = new QueryTimer(); dwell.Reset(); // Compare Result if ((int)mc.para.CV.trayReverseResult.value == 1) { while (dwell.Elapsed < 10000) { //mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (/*ret.b1 && */ ret.d != 10) { break; } } mc.idle(10); ret.d = mc.AIN.Laser(); //MessageBox.Show("검사시간 : " + Math.Round(dwell.Elapsed).ToString() + "[us]\n" + "검사결과 : " + Math.Round(ret.d, 3).ToString() + "[mm]"); FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.INFORMATION, String.Format(textResource.MB_CV_TRAY_REV_CHECK_RESULT, Math.Round(dwell.Elapsed), Math.Round(ret.d, 3))); } else { // 정확한 측정을 위해 4초 뒤에 측정 //if (laserpreon) // mc.idle(20); //else // mc.idle(4000); //mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (/*ret.b1 == false && */ ret.d == 10) { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, textResource.MB_CV_TRAY_REV_CHECK_ERROR); //MessageBox.Show("트레이가 검사되지 않습니다."); } } #endregion } else { #region Pattern Method double posX = mc.para.CV.trayReverseXPos.value; double posY = mc.para.CV.trayReverseYPos.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } double rX = 0; double rY = 0; double rT = 0; mc.hdc.LIVE = false; #region HDC.req if (mc.para.HDC.modelTrayReversePattern1.isCreate.value == (int)BOOL.TRUE) { mc.hdc.reqMode = REQMODE.FIND_MODEL; mc.hdc.reqModelNumber = (int)HDC_MODEL.TRAY_REVERSE_SHAPE1; } else { mc.hdc.reqMode = REQMODE.GRAB; } mc.hdc.lighting_exposure(mc.para.HDC.light[(int)LIGHTMODE_HDC.TRAY], mc.para.HDC.exposure[(int)LIGHTMODE_HDC.TRAY]); mc.hdc.triggerMode = TRIGGERMODE.SOFTWARE; mc.hdc.req = true; #endregion mc.main.Thread_Polling(); #region HDC result if (mc.para.HDC.modelTrayReversePattern1.isCreate.value == (int)BOOL.TRUE) { rX = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultX; rY = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultY; rT = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultAngle; mc.log.debug.write(mc.log.CODE.ETC, "X : " + Math.Round(rX, 3).ToString() + ", Y : " + Math.Round(rY, 3).ToString()); } else { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.FAILURE, "Tray Reverse Pattern Model(#1) is not created!!"); } #endregion #endregion } } if (sender.Equals(BT_TrayReverseTeach)) { mc.hd.tool.jogMove(mc.para.CV.trayReverseXPos.value, mc.para.CV.trayReverseYPos.value, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } FormJogPad ff = new FormJogPad(); ff.dataX = mc.para.CV.trayReverseXPos; ff.dataY = mc.para.CV.trayReverseYPos; if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { ff.jogMode = JOGMODE.LASER_TRAYREVERSE; ff.ShowDialog(); } else { ff.jogMode = JOGMODE.PATTERN_TRAYREVERSE1; ff.Show(); while (true) { mc.idle(100); if (ff.IsDisposed) { break; } } } mc.para.setting(ref mc.para.CV.trayReverseXPos, ff.dataX.value); mc.para.setting(ref mc.para.CV.trayReverseYPos, ff.dataY.value); } if (sender.Equals(BT_USE_LASER2)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod2, 0); } if (sender.Equals(BT_USE_PATTERN2)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod2, 1); } if (sender.Equals(BT_TrayReverseCheck2)) { if ((int)mc.para.CV.trayReverseCheckMethod2.value == 0) { #region Laser Method bool laserpreon; // move to Laser Check Position(Head Camera Position) //double posX = mc.para.CV.trayReverseXPos.value - mc.coor.MP.TOOL.X.LASER.value - mc.para.CAL.HDC_LASER.x.value; //double posY = mc.para.CV.trayReverseYPos.value - mc.coor.MP.TOOL.Y.LASER.value - mc.para.CAL.HDC_LASER.y.value; double posX = mc.para.CV.trayReverseXPos2.value - mc.coor.MP.TOOL.X.LASER.value + mc.para.CAL.HDC_LASER.x.value; double posY = mc.para.CV.trayReverseYPos2.value - mc.coor.MP.TOOL.Y.LASER.value + mc.para.CAL.HDC_LASER.y.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } mc.OUT.HD.LS.ON(out laserpreon, out ret.message); // Laser Sensor ON //mc.OUT.HD.LS mc.OUT.HD.LS.ON(true, out ret.message); // Check Laser Sensor mc.OUT.HD.LS.ON(out ret.b, out ret.message); if (ret.b) { mc.OUT.HD.LS.ZERO(true, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } ret.d = mc.AIN.Laser(); if (ret.d < -10) { ret.d = -1; } mc.IN.LS.ALM(out ret.b1, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } mc.IN.LS.FAR(out ret.b2, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } mc.IN.LS.NEAR(out ret.b3, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } } QueryTimer dwell = new QueryTimer(); dwell.Reset(); // Compare Result if ((int)mc.para.CV.trayReverseResult2.value == 1) { while (dwell.Elapsed < 10000) { mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (ret.b1 && ret.d != 10) { break; } } mc.idle(10); ret.d = mc.AIN.Laser(); //MessageBox.Show("검사시간 : " + Math.Round(dwell.Elapsed).ToString() + "[us]\n" + "검사결과 : " + Math.Round(ret.d, 3).ToString() + "[mm]"); FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.INFORMATION, String.Format(textResource.MB_CV_TRAY_REV_CHECK_RESULT, Math.Round(dwell.Elapsed), Math.Round(ret.d, 3))); } else { // 정확한 측정을 위해 4초 뒤에 측정 if (laserpreon) { mc.idle(20); } else { mc.idle(4000); } mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (ret.b1 == false && ret.d == 10) { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, textResource.MB_CV_TRAY_REV_CHECK_ERROR); //MessageBox.Show("트레이가 검사되지 않습니다."); } } #endregion } else { #region Pattern Method double posX = mc.para.CV.trayReverseXPos2.value; double posY = mc.para.CV.trayReverseYPos2.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } double rX = 0; double rY = 0; double rT = 0; mc.hdc.LIVE = false; #region HDC.req if (mc.para.HDC.modelTrayReversePattern2.isCreate.value == (int)BOOL.TRUE) { mc.hdc.reqMode = REQMODE.FIND_MODEL; mc.hdc.reqModelNumber = (int)HDC_MODEL.TRAY_REVERSE_SHAPE2; } else { mc.hdc.reqMode = REQMODE.GRAB; } mc.hdc.lighting_exposure(mc.para.HDC.light[(int)LIGHTMODE_HDC.TRAY], mc.para.HDC.exposure[(int)LIGHTMODE_HDC.TRAY]); mc.hdc.triggerMode = TRIGGERMODE.SOFTWARE; mc.hdc.req = true; #endregion mc.main.Thread_Polling(); #region HDC result if (mc.para.HDC.modelTrayReversePattern2.isCreate.value == (int)BOOL.TRUE) { rX = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultX; rY = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultY; rT = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultAngle; mc.log.debug.write(mc.log.CODE.ETC, "X : " + Math.Round(rX, 3).ToString() + ", Y : " + Math.Round(rY, 3).ToString()); } else { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.FAILURE, "Tray Reverse Pattern Model(#2) is not created!!"); } #endregion #endregion } } if (sender.Equals(BT_TrayReverseTeach2)) { mc.hd.tool.jogMove(mc.para.CV.trayReverseXPos2.value, mc.para.CV.trayReverseYPos2.value, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } FormJogPad ff = new FormJogPad(); ff.dataX = mc.para.CV.trayReverseXPos2; ff.dataY = mc.para.CV.trayReverseYPos2; if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { ff.jogMode = JOGMODE.LASER_TRAYREVERSE2; ff.ShowDialog(); } else { ff.jogMode = JOGMODE.PATTERN_TRAYREVERSE2; ff.Show(); while (true) { mc.idle(100); if (ff.IsDisposed) { break; } } } mc.para.setting(ref mc.para.CV.trayReverseXPos2, ff.dataX.value); mc.para.setting(ref mc.para.CV.trayReverseYPos2, ff.dataY.value); } EXIT: mc.para.write(out ret.b); if (!ret.b) { mc.message.alarm("para write error"); } refresh(); mc.main.Thread_Polling(); mc.check.push(sender, false); this.Enabled = true; }
private void Control_Click(object sender, EventArgs e) { //if (!mc.check.READY_AUTORUN(sender)) return; mc.check.push(sender, true); #region BT_PUSHER_CALIBRATION if (sender.Equals(BT_PUSHER_CALIBRATION)) { posX = mc.ps.pos.PUSH; jogMode = JOGMODE.PUSHER; mc.ps.jogMove(posX, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarm("Motion Error : " + ret.message.ToString()); goto EXIT; } FormJogPad ff = new FormJogPad(); ff.jogMode = JOGMODE.PUSHER; ff.dataX = mc.para.UD.PusherPos; ff.ShowDialog(); mc.para.UD.PusherPos.value = ff.dataX.value; mc.para.setting(ref mc.para.UD.PusherPos, ff.dataX.value); } #endregion #region BT_MAGAZINE_CALIBRATION if (sender.Equals(BT_MAGAZINE_CALIBRATION)) { if (unitCodeBoatMGSelect == UnitCodeBoatMGSelect.MG2) { if (unitCodeSlotSelect == UnitCodeSlotSelect.START) { posZ = (double)MP_MG_Z.MG2_READY; } else { posZ = (double)MP_MG_Z.MG2_END; } } else if (unitCodeBoatMGSelect == UnitCodeBoatMGSelect.MG3) { if (unitCodeSlotSelect == UnitCodeSlotSelect.START) { posZ = (double)MP_MG_Z.MG3_READY; } else { posZ = (double)MP_MG_Z.MG3_END; } } else { if (unitCodeSlotSelect == UnitCodeSlotSelect.START) { posZ = (double)MP_MG_Z.MG1_READY; } else { posZ = (double)MP_MG_Z.MG1_END; } } posZ += mc.para.UD.MagazinePos[(int)unitCodeBoatMGSelect, (int)unitCodeSlotSelect].z.value; mc.ps.jogMove(mc.ps.pos.READY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarm("Motion Error : " + ret.message.ToString()); goto EXIT; } mc.unloader.Elev.jogMove(posZ, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarm("Motion Error : " + ret.message.ToString()); goto EXIT; } FormJogPadZ ff = new FormJogPadZ(); ff.mode = MP_HD_Z_MODE.MAGAZINE_CAL; ff.mgSelect = unitCodeBoatMGSelect; ff.slotSelect = unitCodeSlotSelect; ff.dataZ = mc.para.UD.MagazinePos[(int)unitCodeBoatMGSelect, (int)unitCodeSlotSelect].z; ff.ShowDialog(); mc.para.setting(ref mc.para.UD.MagazinePos[(int)unitCodeBoatMGSelect, (int)unitCodeSlotSelect].z, ff.dataZ.value); } #endregion #region BT_MAGAZINE_READY if (sender.Equals(BT_MAGAZINE_READY_POS_CALIBRATION)) { posZ = mc.unloader.Elev.pos.READY; mc.ps.jogMove(mc.ps.pos.READY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarm("Motion Error : " + ret.message.ToString()); goto EXIT; } mc.unloader.Elev.jogMove(posZ, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarm("Motion Error : " + ret.message.ToString()); goto EXIT; } FormJogPadZ ff = new FormJogPadZ(); ff.mode = MP_HD_Z_MODE.MAGAZINE_READY; ff.dataZ = mc.para.UD.ReadyPos; ff.ShowDialog(); mc.para.setting(ref mc.para.UD.ReadyPos, ff.dataZ.value); } #endregion if (sender.Equals(BT_MG_PITCH)) { double tmpPitch1 = (mc.unloader.Elev.pos.MG1_END - mc.unloader.Elev.pos.MG1_READY) / (mc.para.UD.slotCount.value - 1); //double tmpPitch2 = (mc.mg.Elev.pos.MG2_END - mc.mg.Elev.pos.MG2_READY) / (mc.para.UD.slotCount.value - 1); //double tmpPitch3 = (mc.mg.Elev.pos.MG3_END - mc.mg.Elev.pos.MG3_READY) / (mc.para.UD.slotCount.value - 1); mc.para.UD.slotPitch.value = Math.Round(Math.Abs(tmpPitch1 / 1000), 2); } EXIT: bool r; mc.para.write(out r); if (!r) { mc.message.alarm("para write error"); } refresh(); mc.error.CHECK(); mc.check.push(sender, false); }