Beispiel #1
0
        private void LB_Force_FactorX_DoubleClick(object sender, EventArgs e)
        {
            FormUserMessage ff = new FormUserMessage();

            ff.SetDisplayItems(DIAG_SEL_MODE.YesNo, DIAG_ICON_MODE.QUESTION, "Do you want to calculate force level?");
            ff.ShowDialog();

            ret.usrDialog = FormUserMessage.diagResult;
            if (ret.usrDialog == DIAG_RESULT.Yes)
            {
                double step = (force.forceLevel[19].value - force.forceLevel[0].value) / 19;

                for (int i = 0; i < 20; i++)
                {
                    force.forceLevel[i].value = Math.Round(force.forceLevel[0].value + step * i, 2);
                }
            }
            refresh();
        }
Beispiel #2
0
            public void moveReadyPosition()
            {
                switch (sqc)
                {
                case 0:
                    Esqc = 0;
                    sqc++;
                    break;

                case 1:
                    if (mc.ps.RUNING)
                    {
                        break;
                    }
                    if (mc.ps.ERROR)
                    {
                        Esqc = sqc; sqc = SQC.ERROR; break;
                    }

                    if (!isAreaSafe())
                    {
                        errorCheck(ERRORCODE.MG, sqc, "", ALARM_CODE.E_MAGAZINE_IO_AREA_SENSOR_DETECT);
                        break;
                    }

                    if (!isConveyorSafe())
                    {
                        errorCheck(ERRORCODE.MG, sqc, "", ALARM_CODE.E_MAGAZINE_IO_BOAT_SENSOR_DETECT);
                        break;
                    }

                    #region Check Magazine Status
                    mc.UnloaderControl.readconfig();
                    if (MagazineIsFull())
                    {
                        sqc = 20;                       // 꽉 찼을 시 down sqc로 이동
                        break;
                    }
                    else
                    {
                        workMG = 0;
                        MagazineReadyPos(out workMG, out workSlot);
                    }

                    if (workMG == (int)MG_NUM.MG2)
                    {
                        posZ = pos.MG2_READY;
                    }
                    else if (workMG == (int)MG_NUM.MG3)
                    {
                        posZ = pos.MG3_READY;
                    }
                    else
                    {
                        posZ = pos.MG1_READY;
                    }
                    posZ -= workSlot * mc.para.UD.slotPitch.value * 1000;
                    #endregion

                    Z.move(posZ, out ret.message); if (mpiCheck(Z.config.axisCode, sqc, ret.message, "", false))
                    {
                        break;
                    }
                    dwell.Reset();
                    sqc++; break;

                case 2:
                    if (!Z_AT_TARGET)
                    {
                        break;
                    }
                    dwell.Reset();
                    sqc++; break;

                case 3:
                    if (!Z_AT_DONE)
                    {
                        break;
                    }
                    dwell.Reset();
                    sqc++; break;

                case 4:
                    if (mc.para.UD.MagazineInCheck.value == 0)
                    {
                        sqc = SQC.STOP;
                    }
                    else
                    {
                        if (dwell.Elapsed < 100)
                        {
                            break;
                        }
                        mc.IN.MG.MG_IN(out ret.b, out ret.message); if (ioCheck(sqc, ret.message))
                        {
                            break;
                        }
                        if (ret.b)
                        {
                            sqc = SQC.STOP;
                        }
                        else
                        {
                            sqc++;
                        }
                    }
                    break;

                case 5:
                    FormUserMessage ff = new FormUserMessage();
                    mc.OUT.MAIN.UserBuzzerCtl(true);
                    ff.SetDisplayItems(DIAG_SEL_MODE.RetrySkipCancel, DIAG_ICON_MODE.WARNING, "MG(#" + (workMG + 1).ToString() + ") 감지 에러 발생");
                    ff.ShowDialog();
                    DIAG_RESULT fResult = FormUserMessage.diagResult;

                    mc.OUT.MAIN.UserBuzzerCtl(false);
                    if (fResult == DIAG_RESULT.Retry)
                    {
                        dwell.Reset();
                        sqc--; break;
                    }
                    else if (fResult == DIAG_RESULT.Skip)
                    {
                        for (int i = 0; i < mc.UnloaderControl.MG_SLOT_COUNT; i++)
                        {
                            mc.UnloaderControl.MG_Status[workMG, i] = (int)MG_STATUS.SKIP;
                            EVENT.refreshEditMagazine(workMG, i);
                        }
                        mc.UnloaderControl.writeconfig();

                        sqc = 1; break;
                    }
                    else
                    {
                        errorCheck(ERRORCODE.MG, sqc, "", ALARM_CODE.E_MAGAGINE_NOT_EXIST);
                        break;
                    }

                case 20:
                    posZ = mc.unloader.Elev.pos.READY;
                    mc.unloader.Elev.Z.move(posZ, out ret.message);
                    if (mpiCheck(Z.config.axisCode, sqc, ret.message, "", false))
                    {
                        break;
                    }
                    dwell.Reset();
                    sqc++; break;

                case 21:
                    if (!Z_AT_TARGET)
                    {
                        break;
                    }
                    sqc++; dwell.Reset(); break;

                case 22:
                    if (!Z_AT_DONE)
                    {
                        break;
                    }
                    sqc++; break;

                case 23:
                    //mc.OUT.MG.MG_RESET(true, out ret.message);
                    errorCheck(ERRORCODE.MG, sqc, "", ALARM_CODE.E_MAGAGINE_STATUS_FULL); break;

                case SQC.ERROR:
                    sqc = SQC.STOP; break;

                case SQC.STOP:
                    sqc = SQC.END; break;
                }
            }
        private void Control_Click(object sender, EventArgs e)
        {
            if (!mc.check.READY_PUSH(sender))
            {
                return;
            }
            mc.check.push(sender, true);

            if (sender.Equals(TB_SFZSpeed))
            {
                mc.para.speedRate(UnitCode.SF, UnitCodeAxis.Z);
            }

            if (sender.Equals(TB_1stDownPitch))
            {
                mc.para.setting(mc.para.SF.firstDownPitch, out mc.para.SF.firstDownPitch);
            }
            if (sender.Equals(TB_1stDownVel))
            {
                mc.para.setting(mc.para.SF.firstDownVel, out mc.para.SF.firstDownVel);
            }
            if (sender.Equals(TB_2ndUpPitch))
            {
                mc.para.setting(mc.para.SF.secondUpPitch, out mc.para.SF.secondUpPitch);
            }
            if (sender.Equals(TB_2ndUpVel))
            {
                mc.para.setting(mc.para.SF.secondUpVel, out mc.para.SF.secondUpVel);
            }
            if (sender.Equals(TB_DownPitch))
            {
                mc.para.setting(mc.para.SF.downPitch, out mc.para.SF.downPitch);
            }
            if (sender.Equals(TB_DownVel))
            {
                mc.para.setting(mc.para.SF.downVel, out mc.para.SF.downVel);
            }
            if (sender.Equals(BT_UseBlow_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.SF.useBlow, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_UseBlow_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.SF.useBlow, (int)ON_OFF.OFF);
            }

            if (sender.Equals(BT_UseMGZ1_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.SF.useMGZ1, (int)ON_OFF.ON);
                if (mc.init.success.SF)
                {
                    FormUserMessage ff = new FormUserMessage();
                    ff.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, String.Format(textResource.MB_REQ_INIT, "Stack Feeder"));
                    ff.ShowDialog();
                    mc.init.success.SF = false;
                }
            }
            if (sender.Equals(BT_UseMGZ1_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.SF.useMGZ1, (int)ON_OFF.OFF);
            }
            if (sender.Equals(BT_UseMGZ2_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.SF.useMGZ2, (int)ON_OFF.ON);
                if (mc.init.success.SF)
                {
                    FormUserMessage ff = new FormUserMessage();
                    ff.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, String.Format(textResource.MB_REQ_INIT, "Stack Feeder"));
                    ff.ShowDialog();
                    mc.init.success.SF = false;
                }
            }
            if (sender.Equals(BT_UseMGZ2_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.SF.useMGZ2, (int)ON_OFF.OFF);
            }

            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);
        }
Beispiel #4
0
 private void BT_PositionSelect_Click(object sender, EventArgs e)
 {
     if (!mc.check.READY_PUSH(sender))
     {
         return;
     }
     mc.check.push(sender, true, (int)SelectedMenu.BOTTOM_RIGHT);
     #region PositionSelect
     if (sender.Equals(BT_PositionSelect_Tube1))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube1.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube2))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube2.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube3))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube3.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube4))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube4.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube5))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube5.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube6))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube6.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube7))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube7.Text;
     }
     if (sender.Equals(BT_PositionSelect_Tube8))
     {
         BT_PositionSelect.Text = BT_PositionSelect_Tube8.Text;
     }
     if (sender.Equals(BT_PositionSelect_MGZ1))
     {
         if (mc.para.SF.useMGZ1.value == 1)
         {
             BT_PositionSelect.Text = BT_PositionSelect_MGZ1.Text; mc.sf.readyPosition = 0;
         }
         else
         {
             FormUserMessage ff = new FormUserMessage();
             ff.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, String.Format(textResource.MB_SF_ONOFF, "MGZ#1"));
             ff.ShowDialog();
         }
     }
     if (sender.Equals(BT_PositionSelect_MGZ2))
     {
         if (mc.para.SF.useMGZ2.value == 1)
         {
             BT_PositionSelect.Text = BT_PositionSelect_MGZ2.Text; mc.sf.readyPosition = 1;
         }
         else
         {
             FormUserMessage ff = new FormUserMessage();
             ff.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, String.Format(textResource.MB_SF_ONOFF, "MGZ#2"));
             ff.ShowDialog();
         }
     }
     #endregion
     mc.main.Thread_Polling();
     mc.check.push(sender, false);
 }
Beispiel #5
0
        private void Control_Click(object sender, EventArgs e)
        {
            if (sender.Equals(BT_ESC))
            {
                if (threadForceCalibration != null)
                {
                    if (threadForceCalibration.IsAlive)
                    {
                        EVENT.userDialogMessage(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, "Auto Calibration is Working!!!");
                        return;
                    }
                }

                for (int i = 0; i < 20; i++)
                {
                    if (force.forceLevel[i].value != selectedToolForce.forceLevel[i].value || force.bottomForce[i].value != selectedToolForce.bottomForce[i].value ||
                        force.topForce[i].value != selectedToolForce.topForce[i].value || force.heightLevel[i].value != selectedToolForce.heightLevel[i].value)
                    {
                        calDataChanged = true;
                        break;                                          // 다른 것이 있는지 없는지 유무만 판단하므로.. 하나라도 다르면 Break;
                        // 사실 다른 것만 인덱스로 받아서 업데이트 시키면 되는데 귀찮아서 그냥 통짜로함.
                    }
                    else if (calDataChanged)
                    {
                        calDataChanged = false;                                                 // true 일 경우에만 false로 바꿈.
                    }
                }

                if (calDataChanged)
                {
                    FormUserMessage ff = new FormUserMessage();

                    ff.SetDisplayItems(DIAG_SEL_MODE.YesNoCancel, DIAG_ICON_MODE.QUESTION, textResource.MB_ETC_PARA_SAVE);
                    ff.ShowDialog();

                    ret.usrDialog = FormUserMessage.diagResult;
                    if (ret.usrDialog == DIAG_RESULT.Yes)
                    {
                        if (selectedHead == 0)
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                mc.para.CAL.Tool_Force1.forceLevel[i]  = force.forceLevel[i];
                                mc.para.CAL.Tool_Force1.bottomForce[i] = force.bottomForce[i];
                                mc.para.CAL.Tool_Force1.topForce[i]    = force.topForce[i];
                                mc.para.CAL.Tool_Force1.heightLevel[i] = force.heightLevel[i];
                            }
                        }
                        else
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                mc.para.CAL.Tool_Force2.forceLevel[i]  = force.forceLevel[i];
                                mc.para.CAL.Tool_Force2.bottomForce[i] = force.bottomForce[i];
                                mc.para.CAL.Tool_Force2.topForce[i]    = force.topForce[i];
                                mc.para.CAL.Tool_Force2.heightLevel[i] = force.heightLevel[i];
                            }
                        }

                        mc.para.HD.place.placeForceOffset[0].value = 0;         // clear
                        mc.para.HD.place.placeForceOffset[1].value = 0;         // clear
                    }
                }
                this.Close();
            }

            #region BT_AutoCalibration
            if (sender.Equals(BT_AutoCalibration))
            {
                if (threadForceCalibration != null)
                {
                    if (threadForceCalibration.IsAlive)
                    {
                        EVENT.userDialogMessage(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, "Auto Calibration is Working!!!");
                        return;
                    }
                }
                calDataChanged = true;

                reqThreadStop = false;

                BT_STOP.Enabled            = true;
                BT_AutoCalibration.Enabled = false;

                selectedHead = cb_selectedTool.SelectedIndex;
                double posX = mc.hd.tool.tPos.x[selectedHead].LOADCELL;
                double posY = mc.hd.tool.tPos.y[selectedHead].LOADCELL;
                mc.hd.tool.jogMove(posX, posY, out ret.message, true);
                if (ret.message == RetMessage.OK)
                {
                    threadForceCalibration          = new Thread(forceCalibraion);
                    threadForceCalibration.Priority = ThreadPriority.Normal;
                    threadForceCalibration.Name     = "forceCalibraion";
                    threadForceCalibration.Start();
                    mc.log.processdebug.write(mc.log.CODE.INFO, " forceCalibration");
                }
            }
            #endregion

            #region 0~19버튼 이벤트
            if (sender.Equals(TB_Input_Force_0))
            {
                mc.para.setting(force.forceLevel[0], out force.forceLevel[0]);
            }
            if (sender.Equals(TB_Input_Force_1))
            {
                mc.para.setting(force.forceLevel[1], out force.forceLevel[1]);
            }
            if (sender.Equals(TB_Input_Force_2))
            {
                mc.para.setting(force.forceLevel[2], out force.forceLevel[2]);
            }
            if (sender.Equals(TB_Input_Force_3))
            {
                mc.para.setting(force.forceLevel[3], out force.forceLevel[3]);
            }
            if (sender.Equals(TB_Input_Force_4))
            {
                mc.para.setting(force.forceLevel[4], out force.forceLevel[4]);
            }
            if (sender.Equals(TB_Input_Force_5))
            {
                mc.para.setting(force.forceLevel[5], out force.forceLevel[5]);
            }
            if (sender.Equals(TB_Input_Force_6))
            {
                mc.para.setting(force.forceLevel[6], out force.forceLevel[6]);
            }
            if (sender.Equals(TB_Input_Force_7))
            {
                mc.para.setting(force.forceLevel[7], out force.forceLevel[7]);
            }
            if (sender.Equals(TB_Input_Force_8))
            {
                mc.para.setting(force.forceLevel[8], out force.forceLevel[8]);
            }
            if (sender.Equals(TB_Input_Force_9))
            {
                mc.para.setting(force.forceLevel[9], out force.forceLevel[9]);
            }
            if (sender.Equals(TB_Input_Force_10))
            {
                mc.para.setting(force.forceLevel[10], out force.forceLevel[10]);
            }
            if (sender.Equals(TB_Input_Force_11))
            {
                mc.para.setting(force.forceLevel[11], out force.forceLevel[11]);
            }
            if (sender.Equals(TB_Input_Force_12))
            {
                mc.para.setting(force.forceLevel[12], out force.forceLevel[12]);
            }
            if (sender.Equals(TB_Input_Force_13))
            {
                mc.para.setting(force.forceLevel[13], out force.forceLevel[13]);
            }
            if (sender.Equals(TB_Input_Force_14))
            {
                mc.para.setting(force.forceLevel[14], out force.forceLevel[14]);
            }
            if (sender.Equals(TB_Input_Force_15))
            {
                mc.para.setting(force.forceLevel[15], out force.forceLevel[15]);
            }
            if (sender.Equals(TB_Input_Force_16))
            {
                mc.para.setting(force.forceLevel[16], out force.forceLevel[16]);
            }
            if (sender.Equals(TB_Input_Force_17))
            {
                mc.para.setting(force.forceLevel[17], out force.forceLevel[17]);
            }
            if (sender.Equals(TB_Input_Force_18))
            {
                mc.para.setting(force.forceLevel[18], out force.forceLevel[18]);
            }
            if (sender.Equals(TB_Input_Force_19))
            {
                mc.para.setting(force.forceLevel[19], out force.forceLevel[19]);
            }

            if (sender.Equals(TB_Bottom_Force_0))
            {
                mc.para.setting(force.bottomForce[0], out force.bottomForce[0]);
            }
            if (sender.Equals(TB_Bottom_Force_1))
            {
                mc.para.setting(force.bottomForce[1], out force.bottomForce[1]);
            }
            if (sender.Equals(TB_Bottom_Force_2))
            {
                mc.para.setting(force.bottomForce[2], out force.bottomForce[2]);
            }
            if (sender.Equals(TB_Bottom_Force_3))
            {
                mc.para.setting(force.bottomForce[3], out force.bottomForce[3]);
            }
            if (sender.Equals(TB_Bottom_Force_4))
            {
                mc.para.setting(force.bottomForce[4], out force.bottomForce[4]);
            }
            if (sender.Equals(TB_Bottom_Force_5))
            {
                mc.para.setting(force.bottomForce[5], out force.bottomForce[5]);
            }
            if (sender.Equals(TB_Bottom_Force_6))
            {
                mc.para.setting(force.bottomForce[6], out force.bottomForce[6]);
            }
            if (sender.Equals(TB_Bottom_Force_7))
            {
                mc.para.setting(force.bottomForce[7], out force.bottomForce[7]);
            }
            if (sender.Equals(TB_Bottom_Force_8))
            {
                mc.para.setting(force.bottomForce[8], out force.bottomForce[8]);
            }
            if (sender.Equals(TB_Bottom_Force_9))
            {
                mc.para.setting(force.bottomForce[9], out force.bottomForce[9]);
            }
            if (sender.Equals(TB_Bottom_Force_10))
            {
                mc.para.setting(force.bottomForce[10], out force.bottomForce[10]);
            }
            if (sender.Equals(TB_Bottom_Force_11))
            {
                mc.para.setting(force.bottomForce[11], out force.bottomForce[11]);
            }
            if (sender.Equals(TB_Bottom_Force_12))
            {
                mc.para.setting(force.bottomForce[12], out force.bottomForce[12]);
            }
            if (sender.Equals(TB_Bottom_Force_13))
            {
                mc.para.setting(force.bottomForce[13], out force.bottomForce[13]);
            }
            if (sender.Equals(TB_Bottom_Force_14))
            {
                mc.para.setting(force.bottomForce[14], out force.bottomForce[14]);
            }
            if (sender.Equals(TB_Bottom_Force_15))
            {
                mc.para.setting(force.bottomForce[15], out force.bottomForce[15]);
            }
            if (sender.Equals(TB_Bottom_Force_16))
            {
                mc.para.setting(force.bottomForce[16], out force.bottomForce[16]);
            }
            if (sender.Equals(TB_Bottom_Force_17))
            {
                mc.para.setting(force.bottomForce[17], out force.bottomForce[17]);
            }
            if (sender.Equals(TB_Bottom_Force_18))
            {
                mc.para.setting(force.bottomForce[18], out force.bottomForce[18]);
            }
            if (sender.Equals(TB_Bottom_Force_19))
            {
                mc.para.setting(force.bottomForce[19], out force.bottomForce[19]);
            }

            if (sender.Equals(TB_Top_Force_0))
            {
                mc.para.setting(force.topForce[0], out force.topForce[0]);
            }
            if (sender.Equals(TB_Top_Force_1))
            {
                mc.para.setting(force.topForce[1], out force.topForce[1]);
            }
            if (sender.Equals(TB_Top_Force_2))
            {
                mc.para.setting(force.topForce[2], out force.topForce[2]);
            }
            if (sender.Equals(TB_Top_Force_3))
            {
                mc.para.setting(force.topForce[3], out force.topForce[3]);
            }
            if (sender.Equals(TB_Top_Force_4))
            {
                mc.para.setting(force.topForce[4], out force.topForce[4]);
            }
            if (sender.Equals(TB_Top_Force_5))
            {
                mc.para.setting(force.topForce[5], out force.topForce[5]);
            }
            if (sender.Equals(TB_Top_Force_6))
            {
                mc.para.setting(force.topForce[6], out force.topForce[6]);
            }
            if (sender.Equals(TB_Top_Force_7))
            {
                mc.para.setting(force.topForce[7], out force.topForce[7]);
            }
            if (sender.Equals(TB_Top_Force_8))
            {
                mc.para.setting(force.topForce[8], out force.topForce[8]);
            }
            if (sender.Equals(TB_Top_Force_9))
            {
                mc.para.setting(force.topForce[9], out force.topForce[9]);
            }
            if (sender.Equals(TB_Top_Force_10))
            {
                mc.para.setting(force.topForce[10], out force.topForce[10]);
            }
            if (sender.Equals(TB_Top_Force_11))
            {
                mc.para.setting(force.topForce[11], out force.topForce[11]);
            }
            if (sender.Equals(TB_Top_Force_12))
            {
                mc.para.setting(force.topForce[12], out force.topForce[12]);
            }
            if (sender.Equals(TB_Top_Force_13))
            {
                mc.para.setting(force.topForce[13], out force.topForce[13]);
            }
            if (sender.Equals(TB_Top_Force_14))
            {
                mc.para.setting(force.topForce[14], out force.topForce[14]);
            }
            if (sender.Equals(TB_Top_Force_15))
            {
                mc.para.setting(force.topForce[15], out force.topForce[15]);
            }
            if (sender.Equals(TB_Top_Force_16))
            {
                mc.para.setting(force.topForce[16], out force.topForce[16]);
            }
            if (sender.Equals(TB_Top_Force_17))
            {
                mc.para.setting(force.topForce[17], out force.topForce[17]);
            }
            if (sender.Equals(TB_Top_Force_18))
            {
                mc.para.setting(force.topForce[18], out force.topForce[18]);
            }
            if (sender.Equals(TB_Top_Force_19))
            {
                mc.para.setting(force.topForce[19], out force.topForce[19]);
            }
            #endregion

            if (sender.Equals(BT_STOP))
            {
                reqThreadStop   = true;
                BT_STOP.Enabled = false;

                if (threadForceCalibration.IsAlive)
                {
                    mc.idle(10);
                }

                BT_AutoCalibration.Enabled = true;
            }

            if (sender.Equals(TB_Force_Test_Kilogram))
            {
                mc.para.setting(testKilogram, out testKilogram);
            }

EXIT:
            refresh();
        }
Beispiel #6
0
        private void Control_Click(object sender, EventArgs e)
        {
            mc.OUT.MAIN.UserBuzzerCtl(false);

            #region Move
            if (sender.Equals(BT_Corner_Move1)) // 첫번쨰 버튼 누르면
            {
                //mc.hdc.LIVE = true;
                if (BT_Corner_Move1.Text == "C1 Move") // 이름 비교해서 코너 1,2 번 중에 하나로 이동 시키고
                {
                    selectCornerNumber = 0;
                    Offset[selectCornerNumber].x.value = 0;
                    Offset[selectCornerNumber].y.value = 0;
                    mc.hd.tool.jogMove(mc.hd.tool.cPos.x.PADC1((int)mc.hd.tool.padX), mc.hd.tool.cPos.y.PADC1((int)mc.hd.tool.padY), out ret.message);
                    if (ret.message != RetMessage.OK)
                    {
                        mc.message.alarmMotion(ret.message);
                    }
                }
                else
                {
                    selectCornerNumber = 1;
                    Offset[selectCornerNumber].x.value = 0;
                    Offset[selectCornerNumber].y.value = 0;
                    mc.hd.tool.jogMove(mc.hd.tool.cPos.x.PADC2((int)mc.hd.tool.padX), mc.hd.tool.cPos.y.PADC2((int)mc.hd.tool.padY), out ret.message);
                    if (ret.message != RetMessage.OK)
                    {
                        mc.message.alarmMotion(ret.message);
                    }
                }
            }
            else if (sender.Equals(BT_Corner_Move2)) // 두번쨰 버튼 누르면
            {
                //mc.hdc.LIVE = true;
                if (BT_Corner_Move2.Text == "C3 Move") // 이름 비교해서 코너 3,4번 중에 하나로 이동 시키고
                {
                    selectCornerNumber = 2;
                    Offset[selectCornerNumber].x.value = 0;
                    Offset[selectCornerNumber].y.value = 0;
                    mc.hd.tool.jogMove(mc.hd.tool.cPos.x.PADC3((int)mc.hd.tool.padX), mc.hd.tool.cPos.y.PADC3((int)mc.hd.tool.padY), out ret.message);
                    if (ret.message != RetMessage.OK)
                    {
                        mc.message.alarmMotion(ret.message);
                    }
                }
                else
                {
                    selectCornerNumber = 3;
                    Offset[selectCornerNumber].x.value = 0;
                    Offset[selectCornerNumber].y.value = 0;
                    mc.hd.tool.jogMove(mc.hd.tool.cPos.x.PADC4((int)mc.hd.tool.padX), mc.hd.tool.cPos.y.PADC4((int)mc.hd.tool.padY), out ret.message);
                    if (ret.message != RetMessage.OK)
                    {
                        mc.message.alarmMotion(ret.message);
                    }
                }
            } // 버튼에 따라서 선택한 코너 위치 selectCornerNumber 에 저장 시키고
            #endregion

            #region Lighting
            else if (sender.Equals(BT_Corner_Lighting1))
            {
                if (selectCornerNumber == -1)
                {
                    MessageBox.Show("조명 조절을 진행할 코너를 선택하세요.");
                }
                else
                {
                    FormJogLighting ff = new FormJogLighting();
                    if (Corner13Teach)
                    {
                        ff.mode = LIGHTEXPOSUREMODE.HDC_JOGPADC1;
                    }
                    else
                    {
                        ff.mode = LIGHTEXPOSUREMODE.HDC_JOGPADC2;
                    }
                    ff.ShowDialog();
                }
            }

            else if (sender.Equals(BT_Corner_Lighting2))
            {
                if (selectCornerNumber == -1)
                {
                    MessageBox.Show("조명 조절을 진행할 코너를 선택하세요.");
                }
                else
                {
                    FormJogLighting ff = new FormJogLighting();
                    if (Corner13Teach)
                    {
                        ff.mode = LIGHTEXPOSUREMODE.HDC_JOGPADC3;
                    }
                    else
                    {
                        ff.mode = LIGHTEXPOSUREMODE.HDC_JOGPADC4;
                    }
                    ff.ShowDialog();
                }
            }
            #endregion

            #region Teaching Position Get
            else if (sender.Equals(BT_Get1))
            {
                if (selectCornerNumber == -1)
                {
                    MessageBox.Show("Teaching을 진행할 코너를 선택하세요.");
                }
                else
                {
                    if (Corner13Teach)
                    {
                        userMessageBox.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.QUESTION, "Corner[1] JogTeaching 값을 적용합니다.");
                        userMessageBox.ShowDialog();
                        if (FormUserMessage.diagResult == DIAG_RESULT.OK)
                        {
                            teachOK[0] = true;
                            HDCP1X     = Offset[0].x.value;
                            HDCP1Y     = Offset[0].y.value;
                        }
                    }
                    else
                    {
                        userMessageBox.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.QUESTION, "Corner[2] JogTeaching 값을 적용합니다.");
                        userMessageBox.ShowDialog();
                        if (FormUserMessage.diagResult == DIAG_RESULT.OK)
                        {
                            teachOK[0] = true;
                            HDCP1X     = Offset[1].x.value;
                            HDCP1Y     = Offset[1].y.value;
                        }
                    }
                }
            }

            else if (sender.Equals(BT_Get2))
            {
                if (selectCornerNumber == -1)
                {
                    MessageBox.Show("Teaching을 진행할 코너를 선택하세요.");
                }
                else
                {
                    if (Corner13Teach)
                    {
                        userMessageBox.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.QUESTION, "Corner[3] JogTeaching 값을 적용합니다.");
                        userMessageBox.ShowDialog();
                        if (FormUserMessage.diagResult == DIAG_RESULT.OK)
                        {
                            teachOK[1] = true;
                            HDCP2X     = Offset[2].x.value;
                            HDCP2Y     = Offset[2].y.value;
                        }
                    }
                    else
                    {
                        userMessageBox.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.QUESTION, "Corner[4] JogTeaching 값을 적용합니다.");
                        userMessageBox.ShowDialog();
                        if (FormUserMessage.diagResult == DIAG_RESULT.OK)
                        {
                            teachOK[1] = true;
                            HDCP2X     = Offset[3].x.value;
                            HDCP2Y     = Offset[3].y.value;
                        }
                    }
                }
            }
            #endregion

            #region speed
            else if (sender.Equals(BT_Speed)) // 단위 누르면
            {
                //if (speedType == SPEED_TYPE.LARGE)
                //{
                if (dX == 1)
                {
                    dX = 10;
                }
                else if (dX == 10)
                {
                    dX = 100;
                }
                else if (dX == 100)
                {
                    dX = 1000;
                }
                else if (dX == 1000)
                {
                    dX = 1;
                }
                else
                {
                    dX = 1;
                }
                dY = dX;  // X,Y 이동 범위 정하고                                Offset 없애버리고 HDCP1 X Y P2 X Y 로 만들어야겠다...
                refresh();
                //}
            }
            #endregion

            #region set, ignore, esc
            else if (sender.Equals(BT_Set))
            {
                if (teachOK[0] && teachOK[1])
                {
                    //mc.hdc.LIVE = false;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Teaching 이 모두 진행되지 않았습니다.");
                }
            }
            else if (sender.Equals(BT_IGNORE))
            {
                mc.hd.tool.jogTeachIgnore = true;
                //mc.hdc.LIVE = false;
                this.Close();
            }
            else if (sender.Equals(BT_ESC))
            {
                mc.hd.tool.jogTeachCancel = true;
                //mc.hdc.LIVE = false;
                this.Close();
            }
            refresh();
            #endregion
        }
Beispiel #7
0
        private void Control_Click(object sender, EventArgs e)
        {
            if (!mc.check.READY_PUSH(sender))
            {
                return;
            }
            mc.check.push(sender, true);

            #region search
            if (sender.Equals(BT_Search1st_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.search.enable, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_Search1st_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.search.enable, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_Search1st_Level))
            {
                mc.para.setting(mc.para.HD.pick.search.level, out mc.para.HD.pick.search.level);
            }
            if (sender.Equals(TB_Search1st_Speed))
            {
                mc.para.setting(mc.para.HD.pick.search.vel, out mc.para.HD.pick.search.vel);
            }
            if (sender.Equals(TB_Search1st_Delay))
            {
                mc.para.setting(mc.para.HD.pick.search.delay, out mc.para.HD.pick.search.delay);
            }
            #endregion
            #region search2
            if (sender.Equals(BT_Search2nd_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.search2.enable, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_Search2nd_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.search2.enable, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_Search2nd_Level))
            {
                mc.para.setting(mc.para.HD.pick.search2.level, out mc.para.HD.pick.search2.level);
            }
            if (sender.Equals(TB_Search2nd_Speed))
            {
                mc.para.setting(mc.para.HD.pick.search2.vel, out mc.para.HD.pick.search2.vel);
            }
            if (sender.Equals(TB_Search2nd_Delay))
            {
                mc.para.setting(mc.para.HD.pick.search2.delay, out mc.para.HD.pick.search2.delay);
            }
            #endregion
            #region delay
            if (sender.Equals(TB_Delay))
            {
                mc.para.setting(mc.para.HD.pick.delay, out mc.para.HD.pick.delay);
            }
            if (sender.Equals(TB_Force))
            {
                mc.para.setting(mc.para.HD.pick.force, out mc.para.HD.pick.force);
            }
            #endregion
            #region driver
            if (sender.Equals(BT_Drive1st_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.driver.enable, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_Drive1st_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.driver.enable, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_Drive1st_Level))
            {
                mc.para.setting(mc.para.HD.pick.driver.level, out mc.para.HD.pick.driver.level);
            }
            if (sender.Equals(TB_Drive1st_Speed))
            {
                mc.para.setting(mc.para.HD.pick.driver.vel, out mc.para.HD.pick.driver.vel);
            }
            if (sender.Equals(TB_Drive1st_Delay))
            {
                mc.para.setting(mc.para.HD.pick.driver.delay, out mc.para.HD.pick.driver.delay);
            }
            #endregion
            #region driver2
            if (sender.Equals(BT_Drive2nd_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.driver2.enable, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_Drive2nd_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.driver2.enable, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_Drive2nd_Level))
            {
                mc.para.setting(mc.para.HD.pick.driver2.level, out mc.para.HD.pick.driver2.level);
            }
            if (sender.Equals(TB_Drive2nd_Speed))
            {
                mc.para.setting(mc.para.HD.pick.driver2.vel, out mc.para.HD.pick.driver2.vel);
            }
            if (sender.Equals(TB_Drive2nd_Delay))
            {
                mc.para.setting(mc.para.HD.pick.driver2.delay, out mc.para.HD.pick.driver2.delay);
            }
            #endregion
            #region offset
            if (sender.Equals(BT_PositionOffset_SelectSF1))
            {
                slectOffsetSF = UnitCodeSF.SF1;
            }
            if (sender.Equals(BT_PositionOffset_SelectSF2))
            {
                slectOffsetSF = UnitCodeSF.SF2;
            }
            if (sender.Equals(BT_PositionOffset_SelectSF3))
            {
                if (mc.swcontrol.mechanicalRevision == 0)
                {
                    slectOffsetSF = UnitCodeSF.SF3;
                }
                else
                {
                    slectOffsetSF = UnitCodeSF.SF5;
                }
            }
            if (sender.Equals(BT_PositionOffset_SelectSF4))
            {
                if (mc.swcontrol.mechanicalRevision == 0)
                {
                    slectOffsetSF = UnitCodeSF.SF4;
                }
                else
                {
                    slectOffsetSF = UnitCodeSF.SF6;
                }
            }
            if (sender.Equals(BT_PositionOffset_SelectSF5))
            {
                slectOffsetSF = UnitCodeSF.SF5;
            }
            if (sender.Equals(BT_PositionOffset_SelectSF6))
            {
                slectOffsetSF = UnitCodeSF.SF6;
            }
            if (sender.Equals(BT_PositionOffset_SelectSF7))
            {
                slectOffsetSF = UnitCodeSF.SF7;
            }
            if (sender.Equals(BT_PositionOffset_SelectSF8))
            {
                slectOffsetSF = UnitCodeSF.SF8;
            }
            if (sender.Equals(TB_PositionOffset_X))
            {
                mc.para.setting(mc.para.HD.pick.offset[(int)slectOffsetSF].x, out mc.para.HD.pick.offset[(int)slectOffsetSF].x);
            }
            if (sender.Equals(TB_PositionOffset_Y))
            {
                mc.para.setting(mc.para.HD.pick.offset[(int)slectOffsetSF].y, out mc.para.HD.pick.offset[(int)slectOffsetSF].y);
            }
            //if (sender.Equals(TB_PositionOffset_Z)) mc.para.setting(mc.para.HD.pick.offset[(int)slectOffsetSF].z, out mc.para.HD.pick.offset[(int)slectOffsetSF].z);
            if (sender.Equals(BT_PositionOffset_Jog))
            {
                double posX, posY, posZ, posT;
                #region moving
                posX = mc.hd.tool.tPos.x[(int)UnitCodeHead.HD1].PICK(slectOffsetSF);
                posY = mc.hd.tool.tPos.y[(int)UnitCodeHead.HD1].PICK(slectOffsetSF);
                posZ = mc.hd.tool.tPos.z[(int)UnitCodeHead.HD1].PICK(slectOffsetSF);
                posT = mc.hd.tool.tPos.t[(int)UnitCodeHead.HD1].ZERO;
                mc.hd.tool.jogMove((int)UnitCodeHead.HD1, posX, posY, posZ, posT, out ret.message); if (ret.message != RetMessage.OK)
                {
                    mc.message.alarmMotion(ret.message); goto EXIT;
                }
                #endregion
                FormJogPadXYZ ff = new FormJogPadXYZ();
                #region jogMode
                if (slectOffsetSF == UnitCodeSF.SF1)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF1;
                }
                else if (slectOffsetSF == UnitCodeSF.SF2)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF2;
                }
                else if (slectOffsetSF == UnitCodeSF.SF3)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF3;
                }
                else if (slectOffsetSF == UnitCodeSF.SF4)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF4;
                }
                else if (slectOffsetSF == UnitCodeSF.SF5)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF5;
                }
                else if (slectOffsetSF == UnitCodeSF.SF6)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF6;
                }
                else if (slectOffsetSF == UnitCodeSF.SF7)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF7;
                }
                else if (slectOffsetSF == UnitCodeSF.SF8)
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF8;
                }
                else
                {
                    ff.jogMode = JOGXYZ_MODE.HD_PICK_OFFSET_SF1;
                }
                #endregion
                ff.dataX = mc.para.HD.pick.offset[(int)slectOffsetSF].x;
                ff.dataY = mc.para.HD.pick.offset[(int)slectOffsetSF].y;
                ff.dataZ = mc.para.HD.pick.offset[(int)slectOffsetSF].z;
                ff.ShowDialog();
                mc.para.setting(ref mc.para.HD.pick.offset[(int)slectOffsetSF].x, ff.dataX.value);
                mc.para.setting(ref mc.para.HD.pick.offset[(int)slectOffsetSF].y, ff.dataY.value);
                mc.para.setting(ref mc.para.HD.pick.offset[(int)slectOffsetSF].z, ff.dataZ.value);
                #region moving
                posX = mc.hd.tool.cPos.x.REF0;
                posY = mc.hd.tool.cPos.y.REF0;;
                posZ = mc.hd.tool.tPos.z[(int)UnitCodeHead.HD1].XY_MOVING;
                posT = mc.hd.tool.tPos.t[(int)UnitCodeHead.HD1].ZERO;
                mc.hd.tool.jogMove((int)UnitCodeHead.HD1, posX, posY, posZ, posT, out ret.message); if (ret.message != RetMessage.OK)
                {
                    mc.message.alarmMotion(ret.message); goto EXIT;
                }
                #endregion
            }
            if (sender.Equals(BT_PositionOffset_AllClear))
            {
                ret.usrDialog = FormMain.UserMessageBox(DIAG_SEL_MODE.OKCancel, DIAG_ICON_MODE.QUESTION, textResource.MB_HD_PICK_INIT_OFFSET_XYZ);
                //mc.message.OkCancel("모든 Pick Offset X,Y,Z 값은 초기화 됩니다. 계속 진행할까요?", out ret.dialog);
                if (ret.usrDialog == DIAG_RESULT.Cancel)
                {
                    goto EXIT;
                }
                for (int i = 0; i < 8; i++)
                {
                    mc.para.setting(ref mc.para.HD.pick.offset[i].x, 0);
                    mc.para.setting(ref mc.para.HD.pick.offset[i].y, 0);
                    mc.para.setting(ref mc.para.HD.pick.offset[i].z, 0);
                }
            }
            if (sender.Equals(BT_AutoPickCompenClear))
            {
                FormUserMessage ff = new FormUserMessage();
                ff.SetDisplayItems(DIAG_SEL_MODE.YesNo, DIAG_ICON_MODE.WARNING, textResource.MB_HD_PICK_INIT_AUTO_TRACK);
                ff.ShowDialog();

                ret.usrDialog = FormUserMessage.diagResult;
                if (ret.usrDialog == DIAG_RESULT.Yes)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        mc.para.HD.pick.pickPosComp[i].x.value = 0;
                        mc.para.HD.pick.pickPosComp[i].y.value = 0;
                    }
                    ff.SetDisplayItems(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.INFORMATION, textResource.MB_HD_PICK_INIT_FINISH);
                    ff.ShowDialog();
                }
            }
            if (sender.Equals(BT_PickOffsetZCal))
            {
                mc.log.debug.write(mc.log.CODE.CAL, "Pick Z Offset Calibration START");
                double   posX, posY, posZ, posT;
                int      moveCase;
                double   startZPos, sensor1Pos, sensor2Pos;
                bool     pos1Done;
                bool     pos2Done;
                bool     teachDone    = false;
                double[] tempval      = new double[5];
                int      stackFeedNum = 8;
                int      sfTemp       = 0;
                if (mc.swcontrol.mechanicalRevision == 1)
                {
                    stackFeedNum = 4;
                }
                for (int i = 0; i < stackFeedNum; i++)
                {
                    if (mc.swcontrol.mechanicalRevision == 1 && i >= 2)
                    {
                        sfTemp = i + 2;
                    }
                    mc.log.debug.write(mc.log.CODE.CAL, String.Format("Stack Feeder Move to {0} position", sfTemp + 1));
                    for (int k = 0; k < 5; k++)
                    {
                        #region move stack feeder
                        mc.sf.req           = true; mc.sf.reqMode = REQMODE.READY;
                        mc.sf.reqTubeNumber = (UnitCodeSF)sfTemp;
                        mc.main.Thread_Polling();                               // make stack feeder to be ready for picking
                        if (mc.sf.ERROR)
                        {
                            mc.log.debug.write(mc.log.CODE.ERROR, "CANNOT run calibration process. Stack Feeder Error");
                            goto EXIT;
                        }
                        #endregion

                        #region move to pick position
                        posX = mc.hd.tool.tPos.x[(int)UnitCodeHead.HD1].PICK((UnitCodeSF)sfTemp);
                        posY = mc.hd.tool.tPos.y[(int)UnitCodeHead.HD1].PICK((UnitCodeSF)sfTemp);
                        posZ = mc.hd.tool.tPos.z[(int)UnitCodeHead.HD1].RAWPICK;
                        posT = mc.hd.tool.tPos.t[(int)UnitCodeHead.HD1].ZERO;

                        mc.hd.tool.jogMove((int)UnitCodeHead.HD1, posX, posY, posZ, posT, out ret.message); if (ret.message != RetMessage.OK)
                        {
                            mc.message.alarmMotion(ret.message); goto EXIT;
                        }
                        mc.idle(100);
                        #endregion

                        #region sensor check
                        //mc.IN.HD.LOAD_CHK(out ret.b1, out ret.message);
                        //mc.IN.HD.LOAD_CHK2(out ret.b2, out ret.message);

                        if (ret.b1 == false && ret.b2 == true)
                        {
                            moveCase = 0;                                                                       // touch가 안되어 있거나 살짝 눌린 상태
                        }
                        else if (ret.b1 == true && ret.b2 == true)
                        {
                            moveCase = 1;                                                                       // 200~350um 눌린 상태
                        }
                        else if (ret.b1 == true && ret.b2 == false)
                        {
                            moveCase = 2;                                                                       // 350um이상 눌린 상태
                        }
                        else
                        {
                            moveCase = 3;                              // 몰라...이런 상태는 없어...
                            mc.message.alarm("Load Sensor Error : Sensor ALL OFF"); goto EXIT;
                        }
                        #endregion

                        if (moveCase > 0)
                        {
                            FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.FAILURE, "Pick Position이 너무 낮습니다.\nPick Position값을 먼저 설정해 주세요.");
                            //mc.message.alarm("Pick Position is too LOW. Please change pick position."); goto EXIT;
                        }

                        mc.hd.tool.Z[(int)UnitCodeHead.HD1].actualPosition(out startZPos, out ret.message);
                        teachDone = false;

                        for (int j = 0; j < 3; j++)
                        {
                            if (teachDone)
                            {
                                break;
                            }

                            mc.hd.tool.Z[(int)UnitCodeHead.HD1].move(posZ - 600 * (j + 1), mc.speed.checkSpeed, out ret.message);

                            dwell.Reset();
                            sensor1Pos = 0;
                            sensor2Pos = 0;
                            pos1Done   = false;
                            pos2Done   = false;
                            while (true)
                            {
//                              mc.IN.HD.LOAD_CHK(out ret.b1, out ret.message);
//                              mc.IN.HD.LOAD_CHK2(out ret.b2, out ret.message);
                                if (ret.b1 && !pos1Done)
                                {
                                    mc.hd.tool.Z[(int)UnitCodeHead.HD1].actualPosition(out sensor1Pos, out ret.message);
                                    pos1Done = true;
                                }
                                if (ret.b1 && !ret.b2 && !pos2Done)
                                {
                                    mc.hd.tool.Z[(int)UnitCodeHead.HD1].actualPosition(out sensor2Pos, out ret.message);
                                    pos2Done = true;
                                }
                                mc.hd.tool.Z[(int)UnitCodeHead.HD1].AT_TARGET(out ret.b, out ret.message); if (ret.message != RetMessage.OK)
                                {
                                    mc.message.alarmMotion(ret.message); goto EXIT;
                                }
                                if (ret.b)
                                {
                                    break;
                                }
                                if (dwell.Elapsed > 20000)
                                {
                                    ret.message = RetMessage.TIMEOUT; mc.message.alarmMotion(ret.message); goto EXIT;
                                }
                            }
                            if (sensor1Pos == 0)
                            {
                                mc.log.debug.write(mc.log.CODE.TRACE, "Cannot find in search " + (j + 1).ToString());
                            }
                            else
                            {
                                mc.log.debug.write(mc.log.CODE.TRACE, "1st Pos : " + Math.Round((startZPos - sensor1Pos), 3).ToString("f3") + ", 2nd Pos : " + Math.Round((startZPos - sensor2Pos), 3).ToString("f3"));
                            }
                            dwell.Reset();
                            while (true)
                            {
                                if (dwell.Elapsed > 500)
                                {
                                    ret.message = RetMessage.TIMEOUT; mc.message.alarmMotion(ret.message); goto EXIT;
                                }
                                mc.hd.tool.Z[(int)UnitCodeHead.HD1].AT_DONE(out ret.b, out ret.message); if (ret.message != RetMessage.OK)
                                {
                                    mc.message.alarmMotion(ret.message); goto EXIT;
                                }
                                if (ret.b)
                                {
                                    break;
                                }
                            }
                            if (sensor1Pos != 0)
                            {
                                double offset = Math.Round(sensor1Pos - startZPos) - mc.para.CAL.z.sensor1.value;
                                mc.log.debug.write(mc.log.CODE.CAL, "SF" + (sfTemp + 1).ToString() + " Offset: " + offset.ToString() + "[um]");
                                tempval[k] = offset;
                                teachDone  = true;
                                break;
                            }
                            else
                            {
                                mc.idle(100);
                            }
                        }
                        posZ = mc.hd.tool.tPos.z[(int)UnitCodeHead.HD1].XY_MOVING;
                        mc.hd.tool.jogMove((int)UnitCodeHead.HD1, posZ, out ret.message); if (ret.message != RetMessage.OK)
                        {
                            mc.message.alarmMotion(ret.message); goto EXIT;
                        }

                        double curSFZPos;
                        mc.sf.Z.actualPosition(out curSFZPos, out ret.message); if (ret.message != RetMessage.OK)
                        {
                            mc.message.alarmMotion(ret.message); goto EXIT;
                        }
                        mc.sf.jogMoveZ(curSFZPos - 300, out ret.message); if (ret.message != RetMessage.OK)
                        {
                            mc.message.alarmMotion(ret.message); goto EXIT;
                        }
                    }
                    mc.log.debug.write(mc.log.CODE.TRACE, "1st[" + tempval[0].ToString() + "], 2nd[" + tempval[1].ToString() + "], 3rd[" + tempval[2].ToString() + "], 4th[" + tempval[3].ToString() + "], 5th[" + tempval[4].ToString() + "]");
                    double sum = tempval[0] + tempval[1] + tempval[2] + tempval[3] + tempval[4];
                    mc.log.debug.write(mc.log.CODE.CAL, "SF" + (sfTemp + 1).ToString() + " Offset RESULT : " + Math.Round(sum / 5).ToString());

                    mc.para.setting(ref mc.para.HD.pick.offset[sfTemp].z, Math.Round(sum / 5));
                }
                mc.sf.req           = true; mc.sf.reqMode = REQMODE.DOWN;
                mc.sf.reqTubeNumber = UnitCodeSF.SF1;
                mc.main.Thread_Polling();
                mc.log.debug.write(mc.log.CODE.CAL, "Pick Z Offset Calibration END");
            }
            if (sender.Equals(TB_PickOffsetZ1))
            {
                mc.para.setting(mc.para.HD.pick.offset[0].z, out mc.para.HD.pick.offset[0].z);
            }
            if (sender.Equals(TB_PickOffsetZ2))
            {
                mc.para.setting(mc.para.HD.pick.offset[1].z, out mc.para.HD.pick.offset[1].z);
            }
            if (sender.Equals(TB_PickOffsetZ3))
            {
                mc.para.setting(mc.para.HD.pick.offset[2].z, out mc.para.HD.pick.offset[2].z);
            }
            if (sender.Equals(TB_PickOffsetZ4))
            {
                mc.para.setting(mc.para.HD.pick.offset[3].z, out mc.para.HD.pick.offset[3].z);
            }
            if (sender.Equals(TB_PickOffsetZ5))
            {
                mc.para.setting(mc.para.HD.pick.offset[4].z, out mc.para.HD.pick.offset[4].z);
            }
            if (sender.Equals(TB_PickOffsetZ6))
            {
                mc.para.setting(mc.para.HD.pick.offset[5].z, out mc.para.HD.pick.offset[5].z);
            }
            if (sender.Equals(TB_PickOffsetZ7))
            {
                mc.para.setting(mc.para.HD.pick.offset[6].z, out mc.para.HD.pick.offset[6].z);
            }
            if (sender.Equals(TB_PickOffsetZ8))
            {
                mc.para.setting(mc.para.HD.pick.offset[7].z, out mc.para.HD.pick.offset[7].z);
            }
            #endregion
            #region suction
            if (sender.Equals(BT_SuctionMode_Select_MovingLevelOn))
            {
                mc.para.setting(ref mc.para.HD.pick.suction.mode, (int)PICK_SUCTION_MODE.MOVING_LEVEL_ON);
            }
            if (sender.Equals(BT_SuctionMode_Select_SearchLevelOn))
            {
                mc.para.setting(ref mc.para.HD.pick.suction.mode, (int)PICK_SUCTION_MODE.SEARCH_LEVEL_ON);
            }
            if (sender.Equals(BT_SuctionMode_Select_PickLevelOn))
            {
                mc.para.setting(ref mc.para.HD.pick.suction.mode, (int)PICK_SUCTION_MODE.PICK_LEVEL_ON);
            }
            if (sender.Equals(TB_SuctionMode_Level))
            {
                mc.para.setting(mc.para.HD.pick.suction.level, out mc.para.HD.pick.suction.level);
            }
            if (sender.Equals(BT_SuctionCheck_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.suction.check, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_SuctionCheck_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.suction.check, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_SuctionCheckLimit_HD1))
            {
                mc.para.setting(mc.para.HD.pick.pickupVacLimit[(int)UnitCodeHead.HD1], out mc.para.HD.pick.pickupVacLimit[(int)UnitCodeHead.HD1]);
            }
            if (sender.Equals(TB_SuctionCheckLimit_HD2))
            {
                mc.para.setting(mc.para.HD.pick.pickupVacLimit[(int)UnitCodeHead.HD2], out mc.para.HD.pick.pickupVacLimit[(int)UnitCodeHead.HD2]);
            }
            if (sender.Equals(TB_SuctionCheck_Time))
            {
                mc.para.setting(mc.para.HD.pick.suction.checkLimitTime, out mc.para.HD.pick.suction.checkLimitTime);
            }
            #endregion
            #region missCheck
            if (sender.Equals(BT_MissCheck_SelectOnOff_On))
            {
                mc.para.setting(ref mc.para.HD.pick.missCheck.enable, (int)ON_OFF.ON);
            }
            if (sender.Equals(BT_MissCheck_SelectOnOff_Off))
            {
                mc.para.setting(ref mc.para.HD.pick.missCheck.enable, (int)ON_OFF.OFF);
            }
            if (sender.Equals(TB_MissCheck_Retry))
            {
                mc.para.setting(mc.para.HD.pick.missCheck.retry, out mc.para.HD.pick.missCheck.retry);
            }
            #endregion
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);
        }