Exemplo n.º 1
0
        private void btAllHome_Click_1(object sender, EventArgs e)
        {
            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ti.Frm);

            if (!OM.MstOptn.bDebugMode)
            {
                if (Log.ShowMessageModal("Confirm", "Do you want to All Homming?") != DialogResult.Yes)
                {
                    return;
                }
                MM.SetManCycle(mc.AllHome);
            }
            else
            {
                DialogResult Rslt;
                Rslt = MessageBox.Show("홈동작을 생략 하겠습니까?", "Confirm", MessageBoxButtons.YesNoCancel);
                if (Rslt == DialogResult.Yes)
                {
                    ML.MT_SetServoAll(true);
                    Thread.Sleep(100);
                    for (int i = 0; i < (int)mi.MAX_MOTR; i++)
                    {
                        ML.MT_SetHomeDone(i, true);
                    }
                }
                else if (Rslt == DialogResult.No)
                {
                    MM.SetManCycle(mc.AllHome);
                }
            }
        }
Exemplo n.º 2
0
 private void btAllHome_Click(object sender, EventArgs e)
 {
     if (!OM.MstOptn.bDebugMode)
     {
         if (Log.ShowMessageModal("Confirm", "Do you want to All Homming?") != DialogResult.Yes)
         {
             return;
         }
         MM.SetManCycle(mc.AllHome);
     }
     else
     {
         DialogResult Rslt;
         Rslt = MessageBox.Show(new Form()
         {
             TopMost = true
         }, "홈동작을 생략 하겠습니까?", "Confirm", MessageBoxButtons.YesNoCancel);
         if (Rslt == DialogResult.Yes)
         {
             SM.MT_SetServoAll(true);
             Thread.Sleep(100);
             for (mi i = 0; i < mi.MAX_MOTR; i++)
             {
                 SM.MT_SetHomeDone(i, true);
             }
         }
         else if (Rslt == DialogResult.No)
         {
             MM.SetManCycle(mc.AllHome);
         }
     }
 }
Exemplo n.º 3
0
        private void btManual1_Click(object sender, EventArgs e)
        {
            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ForContext.Frm);

            int iBtnTag = Convert.ToInt32(((Button)sender).Tag);

            MM.SetManCycle((mc)iBtnTag);
        }
Exemplo n.º 4
0
        private void btMan1_Click(object sender, EventArgs e)
        {
            Program.SendListMsg("Mansul");
            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ti.Frm);

            int iBtnTag = Convert.ToInt32(((Button)sender).Tag);

            MM.SetManCycle((mc)iBtnTag);
        }
Exemplo n.º 5
0
        private void btManual1_Click(object sender, EventArgs e)
        {
            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ForContext.Frm);

            if (Log.ShowMessageModal("Confirm", "Do you want to perform manual actions?") != DialogResult.Yes)
            {
                return;
            }

            int iBtnTag = Convert.ToInt32(((Button)sender).Tag);

            MM.SetManCycle((mc)iBtnTag);
        }
Exemplo n.º 6
0
        public static void LotEnd()
        {
            //Check already opened Lot.
            Log.Trace("SEQ", "Lot Finished");

            //Reset Lot Flag.
            CrntLotData.sLotNo = "";
            LotOpened          = false;
            LotEnded           = true;

            MM.SetManCycle(mc.LODR_ManLotSupply);


            //SEQ.LODR.iLDRSplyCnt = 0;
        }
Exemplo n.º 7
0
        private void btAllHome_Click(object sender, EventArgs e)
        {
            //    if(IO_GetX(xSTG_Vccm)){
            //        FM_MsgOk("Error" , "작업 Stage에 자제를 제거하여 주십시오");
            //        return ;
            //    }
            //if (MessageBox.Show(new Form{TopMost = true}, "전체 홈을 잡으시겠습니까?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)!=DialogResult.Yes) return;

            if (Log.ShowMessageModal("Confirm", "Do you want to All Homming?") != DialogResult.Yes)
            {
                return;
            }

            MM.SetManCycle(mc.AllHome);
            bHomeClick = true;
        }
Exemplo n.º 8
0
        private void btAllHome_Click(object sender, EventArgs e)
        {
            if (!ML.IO_GetY(yi.ETC_MainAirOnOff))
            {
                ML.ER_SetErr(ei.ETC_MainAir, "메인 에어를 ON 해주세요.");
                return;
            }

            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ForContext.Frm);

            if (!OM.MstOptn.bDebugMode)
            {
                if (Log.ShowMessageModal("Confirm", "Do you want to perform manual actions?") != DialogResult.Yes)
                {
                    return;
                }
                MM.SetManCycle(mc.AllHome);
            }
            else
            {
                DialogResult Rslt;
                Rslt = MessageBox.Show("홈동작을 생략 하겠습니까?", "Confirm", MessageBoxButtons.YesNoCancel);
                if (Rslt == DialogResult.Yes)
                {
                    ML.MT_SetServoAll(true);
                    Thread.Sleep(100);
                    for (mi i = 0; i < mi.MAX_MOTR; i++)
                    {
                        ML.MT_SetHomeDone(i, true);
                    }
                }
                else if (Rslt == DialogResult.No)
                {
                    MM.SetManCycle(mc.AllHome);
                }
            }
        }
Exemplo n.º 9
0
        private void btSaveDevice_Click(object sender, EventArgs e)
        {
            string sText = ((Button)sender).Text;

            Log.Trace(sFormText + sText + " Button Clicked", ti.Frm);

            if (Log.ShowMessageModal("Confirm", "Are you Sure?") != DialogResult.Yes)
            {
                return;
            }

            UpdateDevInfo(false);

            OM.SaveDevInfo(OM.GetCrntDev().ToString());
            OM.SaveEqpOptn();

            //SaveMask(OM.GetCrntDev());

            DM.ARAY[ri.LODR].SetMaxColRow(1, OM.DevInfo.iLODR_BarCnt);
            DM.ARAY[ri.PLDR].SetMaxColRow(1, 1);
            DM.ARAY[ri.TLDR].SetMaxColRow(1, 1);
            DM.ARAY[ri.TVSN].SetMaxColRow(1, 1);
            DM.ARAY[ri.TMRK].SetMaxColRow(1, 1);
            DM.ARAY[ri.TULD].SetMaxColRow(1, 1);
            DM.ARAY[ri.TRJM].SetMaxColRow(1, 1);
            DM.ARAY[ri.TRJV].SetMaxColRow(1, 1);
            DM.ARAY[ri.PULD].SetMaxColRow(1, 1);
            DM.ARAY[ri.ULDR].SetMaxColRow(1, OM.DevInfo.iULDR_BarCnt);
            DM.ARAY[ri.PICK].SetMaxColRow(1, 1);
            DM.ARAY[ri.PSHR].SetMaxColRow(1, 1);
            //           DM.ARAY[ri.BPCK].SetMaxColRow(1                        , 1                           );

            MM.SetManCycle(mc.MARK_CycleManChage);
            //Refresh();
            Invalidate(true);
        }
Exemplo n.º 10
0
        private static void UpdateButton()
        {
            if (m_iStep != EN_SEQ_STEP.Idle)
            {
                InspectHomeDone();
                if (!OM.CmnOptn.bIgnrDoor)
                {
                    InspectDoor();
                }
            }

            //Local Var.
            bool isErr     = ML.ER_IsErr();
            bool isHomeEnd = ML.MT_GetHomeDoneAll();

            //vision manual button.
            //CDelayTimer tmVisnCycle ;
            //if(IO_GetX(xETC_LStopSw)&& m_iSeqStat == ssStop ){
            //if(tmVisnCycle.OnDelay(true , 1000)) {
            //    tmVisnCycle.Clear();
            //    if(MM.GetManNo() == mcNoneCycle) {
            //        MM.SetManCycle(mcVSN_CycleWork);
            //    }
            //}
            //}
            //else {
            //tmVisnCycle.Clear();
            //}

            bool bStartSw = ML.IO_GetXUp(xi.ETC_LStartSw) || ML.IO_GetXUp(xi.ETC_RStartSw) || m_bBtnStart; // || ML.IO_GetXUp(xi.ETC_StartSwR) || m_bBtnStart ;
            bool bStopSw  = ML.IO_GetXUp(xi.ETC_LStopSw) || ML.IO_GetXUp(xi.ETC_RStopSw) || m_bBtnStop;    // || ML.IO_GetXUp(xi.ETC_StopSwR ) || m_bBtnStop  ;
            bool bResetSw = ML.IO_GetXUp(xi.ETC_LResetSw) || ML.IO_GetXUp(xi.ETC_RResetSw) || m_bBtnReset; // || ML.IO_GetXUp(xi.ETC_ResetSwR) || m_bBtnReset ;
            bool bAirSw   = ML.IO_GetXUp(xi.ETC_LAirSw) || ML.IO_GetXUp(xi.ETC_RAirSw) || m_bBtnAir;
            bool bInitSw  = ML.IO_GetXUp(xi.ETC_LInitSw) || ML.IO_GetXUp(xi.ETC_RInitSw);
            bool bVisnSw  = ML.IO_GetXUp(xi.ETC_LVisnSw) || ML.IO_GetXUp(xi.ETC_RVisnSw);


            if (m_bBtnStart)
            {
                Log.Trace("m_bBtnStart", "true");
            }
            if (bStartSw)
            {
                Log.Trace("bStartSw", "Started");

                if (MM.GetManNo() != (int)mc.NoneCycle)
                {
                    Log.Trace("ManCycle", string.Format(MM.GetManNo().ToString()));
                    bStartSw = false;
                }
            }

            //Update Switch's Lamp
            bool bStopBtnFlick = (m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop) && m_bFlick;

            //버튼 클릭시나
            ML.IO_SetY(yi.ETC_LStartLp, ML.IO_GetX(xi.ETC_LStartSw) || m_bRun);
            ML.IO_SetY(yi.ETC_RStartLp, ML.IO_GetX(xi.ETC_RStartSw) || m_bRun);
            ML.IO_SetY(yi.ETC_LStopLp, ML.IO_GetX(xi.ETC_LStopSw) || !m_bRun || bStopBtnFlick);
            ML.IO_SetY(yi.ETC_RStopLp, ML.IO_GetX(xi.ETC_RStopSw) || !m_bRun || bStopBtnFlick);
            ML.IO_SetY(yi.ETC_LResetLp, ML.IO_GetX(xi.ETC_LResetSw) || (m_bFlick && isErr));
            ML.IO_SetY(yi.ETC_RResetLp, ML.IO_GetX(xi.ETC_RResetSw) || (m_bFlick && isErr));
            ML.IO_SetY(yi.ETC_LAirLp, ML.IO_GetX(xi.ETC_LAirSw) || ML.IO_GetY(yi.ETC_MainAirOnOff));
            ML.IO_SetY(yi.ETC_RAirLp, ML.IO_GetX(xi.ETC_RAirSw) || ML.IO_GetY(yi.ETC_MainAirOnOff));
            ML.IO_SetY(yi.ETC_LInitLp, ML.IO_GetX(xi.ETC_LInitSw));
            ML.IO_SetY(yi.ETC_RInitLp, ML.IO_GetX(xi.ETC_RInitSw));
            ML.IO_SetY(yi.ETC_LVisnLp, ML.IO_GetX(xi.ETC_LVisnSw));
            ML.IO_SetY(yi.ETC_RVisnLp, ML.IO_GetX(xi.ETC_RVisnSw));

            //Center Man Button
            m_bBtnStart = false;
            m_bBtnStop  = false;
            m_bBtnReset = false;
            m_bBtnAir   = false;


            //Init. Button Flags.
            if (bStartSw)
            {
                if (!isHomeEnd)
                {
                    Log.ShowMessage("Error", "Machine Needed Initial"); bStartSw = false;
                }
                if (!LOT.GetLotOpen() && LOT.GetNextMgz() == "")
                {
                    Log.ShowMessage("Error", "Machine Need to Lot "); bStartSw = false;
                }                                                                                                                         //기존 랏오픈 패턴
                //if(LOT.GetNextMgz()=="") { Log.ShowMessage("Error" , "Machine Needed Lot List Registration"  ); bStartSw = false ; } //기존 랏오픈 패턴

                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd || m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Reset();
                }
            }

            if (bInitSw)
            {
                if (!ML.IO_GetY(yi.ETC_MainAirOnOff))
                {
                    ML.ER_SetErr(ei.ETC_MainAir, "Check Main Air");
                    return;
                }

                MM.SetManCycle(mc.AllHome);
            }

            //Vision버튼 추가. 진섭
            if (bVisnSw)
            {
                if (!isHomeEnd)
                {
                    Log.ShowMessage("Error", "Machine Needed Initial");
                    //ML.ER_SetErr(ei.MTR_HomeEnd, "Machine Needed Initial");
                    return;
                }
                if (m_iSeqStat == EN_SEQ_STAT.Running || m_iSeqStat == EN_SEQ_STAT.Manual)
                {
                    Log.ShowMessage("Error", "Machine is not stopped.");
                    //ML.ER_SetErr(ei.)
                    return;
                }
                MM.SetManCycle(mc.VSNZ_Insp);
            }

            //Air Switch.
            if (bAirSw && !m_bRun && m_iSeqStat != EN_SEQ_STAT.Init)
            {
                ML.IO_SetY(yi.ETC_MainAirOnOff, !ML.IO_GetY(yi.ETC_MainAirOnOff));
            }

            //Buzzer Off.
            if (isErr && bStopSw)
            {
                ML.TL_SetBuzzOff(true);
            }

            //Set Condition Flags.
            if (bStartSw)   //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isErr", isErr ? "true":"false");
                Log.Trace("ManualMan.GetManNo()", string.Format(MM.GetManNo().ToString()));
            }
            if (bStopSw)
            {
                if (!_bRun && !MM.Working())
                {
                    ML.IO_SetY(yi.RAIL_FeedingAC1, false);
                    ML.IO_SetY(yi.RAIL_FeedingAC2, false);
                    ML.IO_SetY(yi.RAIL_FeedingAC3, false);
                }
                MM.Stop = true;
                Log.Trace("Stop", "Stop");
            }

            bool isStopCon  = bStopSw || (isErr && !m_bReqStop && m_bRun);
            bool isRunCon   = bStartSw && !isErr /*&& ManualMan.GetManNo() == mcNone*/;
            bool isResetCon = bResetSw && !m_bRun;

            //Run.
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                m_iStep = EN_SEQ_STEP.ToStartCon;
                ML.TL_SetBuzzOff(false);
                ML.ER_SetDisp(true);
            }
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle)) //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isRunCon && m_iStep", string.Format(m_iStep.ToString()));
            }
            if (isStopCon && (m_iStep != EN_SEQ_STEP.Idle))   //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isStopCon  &&  m_iStep", string.Format(m_iStep.ToString()));
                Log.Trace("bStopSw", bStopSw    ? "True" : "False");
                Log.Trace("isErr", isErr      ? "True" : "False");
                Log.Trace("m_bReqStop", m_bReqStop ? "True" : "False");
                Log.Trace("m_bRun", m_bRun     ? "True" : "False");

                m_bReqStop = true;
            }

            if (isResetCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                Reset();
            }

            if (m_tmToStrt.OnDelay(m_iStep == EN_SEQ_STEP.ToStartCon || m_iStep == EN_SEQ_STEP.ToStart, 10000))
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStrtTimeOut : m_iStep=", m_iStep.ToString());
                Log.Trace("SEQ", Msg);
                ML.ER_SetErr(ei.ETC_ToStartTO);
                m_iStep = EN_SEQ_STEP.Idle;
                m_bRun  = false;
            }
            //CDelayTimer StopBtn = null;
            //StopBtn = new CDelayTimer();
            //if(m_iStep == EN_SEQ_STEP.scToStopCon)
            //{
            //    if(StopBtn.OnDelay(ML.IO_GetX((int)IP.xETC_StopSw)||ML.IO_GetX((int)IP.xETC_StopSw) , 5000))
            //    {
            //        Log.Trace("SEQ","Forced Stop");
            //        m_bRun = false ;
            //        m_iStep    = EN_SEQ_STEP.scIdle;
            //        m_bReqStop = false;
            //    }
            //}
            //else
            //{
            //    StopBtn.Clear();
            //}

            bool bVisnInsp = VSNZ.GetSeqStep() == (int)VisnZone.sc.Insp;

            if (m_tmToStop.OnDelay((m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop) && !bVisnInsp, 10000))
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStopTimeOut : m_iStep=", m_iStep.ToString());
                Log.Trace("SEQ", Msg);
                m_bRun = false;

                ML.ER_SetErr(ei.ETC_ToStopTO);
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;
            }

            EN_SEQ_STEP iPreStep = m_iStep;

            if (iPreStep != m_iStep)
            {
                string sMsg = "";
                sMsg = "Step Changed" + string.Format(iPreStep.ToString()) + " -> " + string.Format(m_iStep.ToString());
                Log.Trace("SEQ", sMsg);
            }
            iPreStep = m_iStep;


            //이상하게 중간에 랏엔드가 되는 현상 발견해서 넣어둠.
            bool bPreLotEnd = LOT.GetLotEnd();

            if (LOT.GetLotEnd() != bPreLotEnd)
            {
                Log.Trace("SEQ", LOT.GetLotEnd() ? "LotEnd True" : "LotEnd False");
            }
            bPreLotEnd = LOT.GetLotEnd();

            //Running Step.
            switch (m_iStep)
            {
            case EN_SEQ_STEP.Idle:
                return;

            case EN_SEQ_STEP.ToStartCon:
                if (!ToStartCon())
                {
                    return;
                }
                m_iStep = EN_SEQ_STEP.ToStart;
                Log.Trace("SEQ", "scToStartCon END");
                return;

            case EN_SEQ_STEP.ToStart:
                if (!ToStart())
                {
                    return;
                }
                m_bRun     = true;
                m_bRunEdge = true;
                m_iStep    = EN_SEQ_STEP.Run;
                Log.Trace("SEQ", "scToStart END");
                return;

            case EN_SEQ_STEP.Run:
                if (!m_bReqStop)
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.ShowMessage("Checked", "Lot Ended.");
                        Log.Trace("SEQ", LOT.GetLotNo() + "LotEnd");
                        m_bRunEnd = true;
                        m_iStep   = EN_SEQ_STEP.ToStopCon;
                    }
                    return;
                }
                m_bReqStop = false;
                m_iStep    = EN_SEQ_STEP.ToStopCon;
                Log.Trace("SEQ", "scRun END");
                return;

            case EN_SEQ_STEP.ToStopCon:
                if (!ToStopCon())
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.Trace("SEQ", "scToStopCon LotEnd");
                    }
                    return;
                }
                m_bRun  = false;
                m_iStep = EN_SEQ_STEP.ToStop;
                Log.Trace("SEQ", "scToStopCon END");
                return;

            case EN_SEQ_STEP.ToStop:
                if (!ToStop())
                {
                    return;
                }
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;

                DM.SaveMap();
                Log.Trace("SEQ", "scToStop END");

                return;
            }
        }
Exemplo n.º 11
0
        private void btManual1_Click(object sender, EventArgs e)
        {
            int iBtnTag = Convert.ToInt32(((Button)sender).Tag);

            MM.SetManCycle((mc)iBtnTag);
        }
Exemplo n.º 12
0
        private void btLotOpen_Click(object sender, EventArgs e)
        {
            if (tbLotNo.Text == "")
            {
                Log.ShowMessage("Error", "Lot No is Empty");
                return;// tbLotId.Text = DateTime.Now.ToString("HHmmss");
            }
            if (tbMaterialNo.Text == "")
            {
                Log.ShowMessage("Error", "Material No is Empty");
                return;// tbLotId.Text = DateTime.Now.ToString("HHmmss");
            }
            if (tbLotAlias.Text == "")
            {
                Log.ShowMessage("Error", "Lot Alias is Empty");
                return;// tbLotId.Text = DateTime.Now.ToString("HHmmss");
            }
            if (tbEmployeeID.Text == "")
            {
                Log.ShowMessage("Error", "EmployeeID is Empty");
                return;// tbLotId.Text = DateTime.Now.ToString("HHmmss");
            }



            if (!SM.IO_GetX(xi.VISN_Ready))
            {
                Log.ShowMessage("Vision", SM.IO_GetXName(xi.VISN_Ready) + "Vision Ready IO is not On");
                return;
            }
            OM.EqpStat.bWrapingEnd = false;

            Log.Trace("LotOpen", "Try");

            string LotNo  = tbLotNo.Text.Trim();
            string Device = tbSelDevice.Text.Trim();

            CDelayTimer TimeOut = new CDelayTimer();

            TimeOut.Clear();
            SEQ.Visn.SendLotStart(LotNo);
            while (!SEQ.Visn.GetSendCycleEnd(VisnCom.vs.LotStart))
            {
                Thread.Sleep(1);
                if (TimeOut.OnDelay(5000))
                {
                    Log.ShowMessage("Vision", "Lot Start TimeOut");
                    return;
                }
            }

            OM.EqpStat.iWorkBundle = 0;

            LOT.TLot Lot;
            Lot.sEmployeeID = tbEmployeeID.Text.Trim();
            Lot.sLotNo      = tbLotNo.Text.Trim();
            Lot.sMaterialNo = tbMaterialNo.Text.Trim();
            Lot.sLotAlias   = tbLotAlias.Text.Trim();
            LOT.LotOpen(Lot);

            OM.EqpStat.sLotSttTime = DateTime.Now.ToString("HH:mm:ss");
            if (!OM.CmnOptn.bOracleNotUse && !OM.CmnOptn.bIdleRun)
            {
                if (SEQ.Oracle.ProcessLotOpen(Lot.sLotNo, Lot.sMaterialNo, Lot.sLotAlias))
                {
                    if (!DeviceChange(SEQ.Oracle.Stat.sVisionRecipe_RecipeName))
                    {
                        Log.ShowMessage("Device", "'" + SEQ.Oracle.Stat.sVisionRecipe_RecipeName + "'" + "dosn't exist!");
                    }
                }
                else
                {
                    Log.ShowMessage("Oracle", SEQ.Oracle.GetLastMsg());
                    return;
                }
                //유닛아이디 리스트 만들기 시간 오래 걸려서
                //별도 스레드 만듬.
                SEQ.Oracle.ThreadMakeUnitIDDMC1List();
            }
            else
            {
                //Device Change에서 함.
                DM.ARAY[ri.SPLR].SetStat(cs.None);
                DM.ARAY[ri.IDXR].SetStat(cs.None);
                DM.ARAY[ri.IDXF].SetStat(cs.None);
                DM.ARAY[ri.PCKR].SetStat(cs.None);
                DM.ARAY[ri.TRYF].SetStat(cs.None);
                DM.ARAY[ri.TRYG].SetStat(cs.Good);
                DM.ARAY[ri.OUTZ].SetStat(cs.None);
                DM.ARAY[ri.STCK].SetStat(cs.Empty);
                DM.ARAY[ri.BARZ].SetStat(cs.None);
                DM.ARAY[ri.INSP].SetStat(cs.Good);
                DM.ARAY[ri.PSTC].SetStat(cs.None);
                Close();
            }

            //if (Log.ShowMessageModal("Confirm", "Do you want to All Homming?") != DialogResult.Yes) ;

            //20180305 오스람 요청... 랏오픈시에 올홈.
            MM.SetManCycle(mc.AllHome);
        }
Exemplo n.º 13
0
        private static void UpdateButton()
        {
            //Check Inspect.
            //if (!OM.CmnOptn.bIgnrDoor)
            InspectDoor();

            if (m_iStep != EN_SEQ_STEP.Idle)
            {
                InspectHomeDone();
            }

            if (m_iStep == EN_SEQ_STEP.Idle)
            {
                InspectLightGrid();
            }
            //Local Var.
            bool isErr    = ML.ER_IsErr();
            bool bStartSw = ML.IO_GetXUp(xi.ETC_StartSw) || m_bBtnStart; // || ML.IO_GetXUp(xi.ETC_StartSwR) || m_bBtnStart ;
            bool bStopSw  = ML.IO_GetXUp(xi.ETC_StopSw) || m_bBtnStop;   // || ML.IO_GetXUp(xi.ETC_StopSwR ) || m_bBtnStop  ;
            bool bResetSw = ML.IO_GetXUp(xi.ETC_ResetSw) || m_bBtnReset; // || ML.IO_GetXUp(xi.ETC_ResetSwR) || m_bBtnReset ;
            bool bAirSw   = false;                                       //ML.IO_GetXUp(xi.ETC_AirSw  ) || m_bBtnAir ;
            bool bInitSw  = false;                                       //ML.IO_GetXUp(xi.ETC_InitSw ) ;
            bool bMotorSw = ML.IO_GetXUp(xi.ETC_MotorSw);

            if (m_bBtnStart)
            {
                Log.Trace("m_bBtnStart", "true");
            }
            if (bStartSw)
            {
                Log.Trace("bStartSw", "Started");

                if (m_iSeqStat == EN_SEQ_STAT.Init)
                {
                    Log.Trace("SeqStat", "ssInit   ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd)
                {
                    Log.Trace("SeqStat", "ssWorkEnd");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Error)
                {
                    Log.Trace("SeqStat", "ssError  ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Running)
                {
                    Log.Trace("SeqStat", "ssRunning");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Stop)
                {
                    Log.Trace("SeqStat", "ssStop   ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Log.Trace("SeqStat", "ssRunWarn");
                }

                if (MM.GetManNo() != (int)mc.NoneCycle)
                {
                    Log.Trace("ManCycle", string.Format(MM.GetManNo().ToString()));
                    bStartSw = false;
                }
            }


            //Update Switch's Lamp
            bool bStopBtnFlick = (m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop) && m_bFlick;


            //버튼 클릭시나
            ML.IO_SetY(yi.ETC_StartLp, ML.IO_GetX(xi.ETC_StartSw) || m_bRun);
            ML.IO_SetY(yi.ETC_StopLp, ML.IO_GetX(xi.ETC_StopSw) || !m_bRun || bStopBtnFlick);
            ML.IO_SetY(yi.ETC_ResetLp, ML.IO_GetX(xi.ETC_ResetSw) || (m_bFlick && isErr));
            //ML.IO_SetY(yi.ETC_AirLp    , ML.IO_GetX(xi.ETC_AirSw   ) || ML.IO_GetY(yi.ETC_MainAirSol       ));
            //ML.IO_SetY(yi.ETC_InitLp   , ML.IO_GetX(xi.ETC_InitSw  )                                        );

            ML.IO_SetY(yi.ETC_MotorLp, ML.MT_GetServo(mi.OUT_TRelT));

            //Center Man Button
            m_bBtnStart = false;
            m_bBtnStop  = false;
            m_bBtnReset = false;
            m_bBtnAir   = false;


            //Init. Button Flags.
            bool isHomeEnd = ML.MT_GetHomeDoneAll();

            if (bStartSw)
            {
                if (!isHomeEnd)
                {
                    Log.ShowMessage("Error", "장비 홈을 잡아주세요."); bStartSw = false;
                }
                //if(!LOT.GetLotOpen     ()) { Log.ShowMessage("Error" , "장비 랏오픈을 해주세요."); bStartSw = false ; }
                //if(!InspectStripDispr  ()) { m_bInspDispr = true ; bStartSw = false ; }
                //if(!InspectStripUnknown()) { m_bInspUnkwn = true ; bStartSw = false ; }

                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd || m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Reset();
                }
            }

            if (bInitSw)
            {
                MM.SetManCycle(mc.AllHome);
            }

            if (bMotorSw)
            {
                if (ML.MT_GetServo(mi.OUT_TRelT))
                {
                    ML.MT_SetServo(mi.OUT_TRelT, false);
                    ML.MT_SetServo(mi.OUT_TRelB, false);
                }
                else
                {
                    ML.MT_SetServo(mi.OUT_TRelT, true);
                    ML.MT_SetServo(mi.OUT_TRelB, true);

                    ML.MT_SetHomeDone(mi.OUT_TRelT, true);
                    ML.MT_SetHomeDone(mi.OUT_TRelB, true);
                }
            }

            //Air Switch.
            //if(bAirSw && !m_bRun && m_iSeqStat != EN_SEQ_STAT.Init)
            //{
            //    ML.IO_SetY(yi.ETC_MainAirSol , !ML.IO_GetY(yi.ETC_MainAirSol )) ;
            //}

            //Buzzer Off.
            if (isErr && bStopSw)
            {
                ML.TL_SetBuzzOff(true);
            }

            bool isStopCon  = bStopSw || (isErr && !m_bReqStop && m_bRun);
            bool isRunCon   = bStartSw && !isErr;
            bool isResetCon = bResetSw && !m_bRun;

            //Run.
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                m_iStep = EN_SEQ_STEP.ToStartCon;
                ML.TL_SetBuzzOff(false);
                ML.ER_SetDisp(true);
            }

            if (isStopCon && (m_iStep != EN_SEQ_STEP.Idle))    //스타트버튼 안눌리는것 때문에 테스트.
            {
                m_bReqStop = true;
            }

            if (isResetCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                Reset();
            }

            if (m_tmToStrt.OnDelay(m_iStep == EN_SEQ_STEP.ToStartCon || m_iStep == EN_SEQ_STEP.ToStart, 10000))
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStrtTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                ML.ER_SetErr(ei.ETC_ToStartTO);
                m_iStep = EN_SEQ_STEP.Idle;
                m_bRun  = false;
            }

            //CDelayTimer StopBtn = null;
            //StopBtn = new CDelayTimer();
            //if(m_iStep == EN_SEQ_STEP.scToStopCon)
            //{
            //    if(StopBtn.OnDelay(ML.IO_GetX((int)IP.xETC_StopSw)||ML.IO_GetX((int)IP.xETC_StopSw) , 5000))
            //    {
            //        Log.Trace("SEQ","Forced Stop");
            //        m_bRun = false ;
            //        m_iStep    = EN_SEQ_STEP.scIdle;
            //        m_bReqStop = false;
            //    }
            //}
            //else
            //{
            //    StopBtn.Clear();
            //}


            if (m_tmToStop.OnDelay(m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop, 10000))        //  20000)) {
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStopTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                m_bRun = false;

                ML.ER_SetErr(ei.ETC_ToStopTO);
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;
            }

            EN_SEQ_STEP iPreStep = m_iStep;

            if (iPreStep != m_iStep)
            {
                string sMsg = "";
                sMsg = "Step Changed" + string.Format(iPreStep.ToString()) + " -> " + string.Format(m_iStep.ToString());
                Log.Trace("SEQ", sMsg);
            }
            iPreStep = m_iStep;


            //이상하게 중간에 랏엔드가 되는 현상 발견해서 넣어둠.
            bool bPreLotEnd = LOT.GetLotEnd();

            if (LOT.GetLotEnd() != bPreLotEnd)
            {
                Log.Trace("SEQ", LOT.GetLotEnd() ? "LotEnd True" : "LotEnd False");
            }
            bPreLotEnd = LOT.GetLotEnd();



            //Running Step.
            switch (m_iStep)
            {
            case EN_SEQ_STEP.Idle: return;

            case EN_SEQ_STEP.ToStartCon: if (!ToStartCon())
                {
                    return;
                }
                m_iStep = EN_SEQ_STEP.ToStart;
                Log.Trace("SEQ", "scToStartCon END");
                return;

            case EN_SEQ_STEP.ToStart: if (!ToStart())
                {
                    return;
                }
                m_bRun     = true;
                m_bRunEdge = true;
                m_iStep    = EN_SEQ_STEP.Run;
                Log.Trace("SEQ", "scToStart END");
                return;

            case EN_SEQ_STEP.Run: if (!m_bReqStop)
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.ShowMessage("Checked", "Lot Ended.");
                        Log.Trace("SEQ", LOT.GetLotNo() + "LotEnd");
                        m_bRunEnd = true;
                        m_iStep   = EN_SEQ_STEP.ToStopCon;
                    }
                    return;
                }
                m_bReqStop = false;
                m_iStep    = EN_SEQ_STEP.ToStopCon;
                Log.Trace("SEQ", "scRun END");
                return;

            case EN_SEQ_STEP.ToStopCon:  if (!ToStopCon())
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.Trace("SEQ", "scToStopCon LotEnd");
                    }
                    return;
                }
                m_bRun  = false;
                m_iStep = EN_SEQ_STEP.ToStop;
                Log.Trace("SEQ", "scToStopCon END");
                return;

            case EN_SEQ_STEP.ToStop:  if (!ToStop())
                {
                    return;
                }
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;

                DM.SaveMap();
                Log.Trace("SEQ", "scToStop END");

                return;
            }
        }
Exemplo n.º 14
0
        private static void UpdateButton()
        {
            //Check Inspect.
            //if (!OM.CmnOptn.bIgnrDoor)
            InspectDoor();

            if (m_iStep != EN_SEQ_STEP.Idle)
            {
                InspectHomeDone();
            }

            if (m_iStep == EN_SEQ_STEP.Idle)
            {
                InspectLightGrid();
            }
            //Local Var.
            bool isErr     = ML.ER_IsErr();
            bool isHomeEnd = ML.MT_GetHomeDoneAll();

            //vision manual button.
            //CDelayTimer tmVisnCycle ;
            //if(IO_GetX(xETC_LStopSw)&& m_iSeqStat == ssStop ){
            //if(tmVisnCycle.OnDelay(true , 1000)) {
            //    tmVisnCycle.Clear();
            //    if(MM.GetManNo() == mcNoneCycle) {
            //        MM.SetManCycle(mcVSN_CycleWork);
            //    }
            //}
            //}
            //else {
            //tmVisnCycle.Clear();
            //}

            bool bStartSw = ML.IO_GetXUp(xi.ETC_LStartSw) || ML.IO_GetXUp(xi.ETC_RStartSw) || m_bBtnStart;   // || ML.IO_GetXUp(xi.ETC_StartSwR) || m_bBtnStart ;
            bool bStopSw  = ML.IO_GetXUp(xi.ETC_LStopSw) || ML.IO_GetXUp(xi.ETC_RStopSw) || m_bBtnStop;      // || ML.IO_GetXUp(xi.ETC_StopSwR ) || m_bBtnStop  ;
            bool bResetSw = ML.IO_GetXUp(xi.ETC_LResetSw) || ML.IO_GetXUp(xi.ETC_RResetSw) || m_bBtnReset;   // || ML.IO_GetXUp(xi.ETC_ResetSwR) || m_bBtnReset ;
            bool bAirSw   = ML.IO_GetXUp(xi.ETC_LAirSw) || ML.IO_GetXUp(xi.ETC_RAirSw) || m_bBtnAir;
            bool bInitSw  = ML.IO_GetXUp(xi.ETC_LInitSw) || ML.IO_GetXUp(xi.ETC_RInitSw);



            if (m_bBtnStart)
            {
                Log.Trace("m_bBtnStart", "true");
            }
            if (bStartSw)
            {
                Log.Trace("bStartSw", "Started");

                if (MM.GetManNo() != (int)mc.NoneCycle)
                {
                    Log.Trace("ManCycle", string.Format(MM.GetManNo().ToString()));
                    bStartSw = false;
                }
            }


            //Update Switch's Lamp
            bool bStopBtnFlick = (m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop) && m_bFlick;


            //버튼 클릭시나
            ML.IO_SetY(yi.ETC_LStartLp, ML.IO_GetX(xi.ETC_LStartSw) || m_bRun);
            ML.IO_SetY(yi.ETC_LStopLp, ML.IO_GetX(xi.ETC_LStopSw) || !m_bRun || bStopBtnFlick);
            ML.IO_SetY(yi.ETC_LResetLp, ML.IO_GetX(xi.ETC_LResetSw) || (m_bFlick && isErr));
            ML.IO_SetY(yi.ETC_LAirLp, ML.IO_GetX(xi.ETC_LAirSw) || ML.IO_GetY(yi.ETC_MainAir));
            ML.IO_SetY(yi.ETC_LInitLp, ML.IO_GetX(xi.ETC_LInitSw));

            ML.IO_SetY(yi.ETC_RStartLp, ML.IO_GetX(xi.ETC_RStartSw) || m_bRun);
            ML.IO_SetY(yi.ETC_RStopLp, ML.IO_GetX(xi.ETC_RStopSw) || !m_bRun || bStopBtnFlick);
            ML.IO_SetY(yi.ETC_RResetLp, ML.IO_GetX(xi.ETC_RResetSw) || (m_bFlick && isErr));
            ML.IO_SetY(yi.ETC_RAirLp, ML.IO_GetX(xi.ETC_RAirSw) || ML.IO_GetY(yi.ETC_MainAir));
            ML.IO_SetY(yi.ETC_RInitLp, ML.IO_GetX(xi.ETC_RInitSw));

            ML.IO_SetY(yi.ETC_Manual1, ML.IO_GetX(xi.ETC_Manual1));
            ML.IO_SetY(yi.ETC_Manual2, ML.IO_GetX(xi.ETC_Manual2));
            ML.IO_SetY(yi.ETC_Manual3, ML.IO_GetX(xi.ETC_Manual3));
            ML.IO_SetY(yi.ETC_Manual4, ML.IO_GetX(xi.ETC_Manual4));
            ML.IO_SetY(yi.ETC_Manual5, ML.IO_GetX(xi.ETC_Manual5));

            //  ML.IO_SetY(yi.ETC_StartLpR  , ML.IO_GetX(xi.ETC_StartSwR ) ||  m_bRun                             );
            //  ML.IO_SetY(yi.ETC_StopLpR   , ML.IO_GetX(xi.ETC_StopSwR  ) || !m_bRun || bStopBtnFlick            );
            //  ML.IO_SetY(yi.ETC_ResetLpR  , ML.IO_GetX(xi.ETC_ResetSwR ) || (m_bFlick && isErr)                 );
            ////ML.IO_SetY(yi.ETC_AirLp     , ML.IO_GetX(xi.ETC_AirSw    ) || ML.IO_GetY(yi.ETC_MainAirSol     ));
            //  ML.IO_SetY(yi.ETC_InitLpR   , ML.IO_GetX(xi.ETC_InitSwR  )                                        );

            //Center Man Button
            m_bBtnStart = false;
            m_bBtnStop  = false;
            m_bBtnReset = false;
            m_bBtnAir   = false;


            //Init. Button Flags.
            if (bStartSw)
            {
                //bool bAllArayNone = DM.ARAY[riLSP].CheckAllStat(csNone) && DM.ARAY[riLDR].CheckAllStat(csNone) && DM.ARAY[riLST].CheckAllStat(csNone) &&
                //                    DM.ARAY[riPSB].CheckAllStat(csNone) && DM.ARAY[riULD].CheckAllStat(csNone) && DM.ARAY[riVSN].CheckAllStat(csNone)  ;
                if (!isHomeEnd)
                {
                    Log.ShowMessage("Error", "장비 홈을 잡아주세요."); bStartSw = false;
                }
                //if(!LOT.GetLotOpen     ()) { Log.ShowMessage("Error" , "장비 랏오픈을 해주세요."); bStartSw = false ; }
                if (!InspectStripDispr())
                {
                    m_bInspDispr = true; bStartSw = false;
                }
                if (!InspectStripUnknown())
                {
                    m_bInspUnkwn = true; bStartSw = false;
                }

                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd || m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Reset();
                }
            }

            if (bInitSw)
            {
                MM.SetManCycle(mc.AllHome);
            }

            //Air Switch.
            if (bAirSw && !m_bRun && m_iSeqStat != EN_SEQ_STAT.Init)
            {
                ML.IO_SetY(yi.ETC_MainAir, !ML.IO_GetY(yi.ETC_MainAir));
            }

            //Buzzer Off.
            if (isErr && bStopSw)
            {
                ML.TL_SetBuzzOff(true);
            }

            //Set Condition Flags.
            if (bStartSw)    //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isErr", isErr ? "true":"false");
                Log.Trace("ManualMan.GetManNo()", string.Format(MM.GetManNo().ToString()));
            }
            if (bStopSw)
            {
                Log.Trace("Stop", "Stop");
            }

            bool isStopCon  = bStopSw || (isErr && !m_bReqStop && m_bRun);
            bool isRunCon   = bStartSw && !isErr /*&& ManualMan.GetManNo() == mcNone*/;
            bool isResetCon = bResetSw && !m_bRun;

            //Run.
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                m_iStep = EN_SEQ_STEP.ToStartCon;
                ML.TL_SetBuzzOff(false);
                ML.ER_SetDisp(true);
            }
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle))  //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isRunCon && m_iStep", string.Format(m_iStep.ToString()));
            }
            if (isStopCon && (m_iStep != EN_SEQ_STEP.Idle))    //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isStopCon  &&  m_iStep", string.Format(m_iStep.ToString()));
                Log.Trace("bStopSw", bStopSw    ? "True" : "False");
                Log.Trace("isErr", isErr      ? "True" : "False");
                Log.Trace("m_bReqStop", m_bReqStop ? "True" : "False");
                Log.Trace("m_bRun", m_bRun     ? "True" : "False");

                m_bReqStop = true;
            }

            if (isResetCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                Reset();
            }

            if (m_tmToStrt.OnDelay(m_iStep == EN_SEQ_STEP.ToStartCon || m_iStep == EN_SEQ_STEP.ToStart, 30000))
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStrtTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                ML.ER_SetErr(ei.ETC_ToStartTO);
                m_iStep = EN_SEQ_STEP.Idle;
                m_bRun  = false;
            }

            //CDelayTimer StopBtn = null;
            //StopBtn = new CDelayTimer();
            //if(m_iStep == EN_SEQ_STEP.scToStopCon)
            //{
            //    if(StopBtn.OnDelay(ML.IO_GetX((int)IP.xETC_StopSw)||ML.IO_GetX((int)IP.xETC_StopSw) , 5000))
            //    {
            //        Log.Trace("SEQ","Forced Stop");
            //        m_bRun = false ;
            //        m_iStep    = EN_SEQ_STEP.scIdle;
            //        m_bReqStop = false;
            //    }
            //}
            //else
            //{
            //    StopBtn.Clear();
            //}


            if (m_tmToStop.OnDelay(m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop, 30000))        //  20000)) {
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStopTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                m_bRun = false;

                ML.ER_SetErr(ei.ETC_ToStopTO);
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;
            }

            EN_SEQ_STEP iPreStep = m_iStep;

            if (iPreStep != m_iStep)
            {
                string sMsg = "";
                sMsg = "Step Changed" + string.Format(iPreStep.ToString()) + " -> " + string.Format(m_iStep.ToString());
                Log.Trace("SEQ", sMsg);
            }
            iPreStep = m_iStep;


            //이상하게 중간에 랏엔드가 되는 현상 발견해서 넣어둠.
            bool bPreLotEnd = LOT.GetLotEnd();

            if (LOT.GetLotEnd() != bPreLotEnd)
            {
                Log.Trace("SEQ", LOT.GetLotEnd() ? "LotEnd True" : "LotEnd False");
            }
            bPreLotEnd = LOT.GetLotEnd();



            //Running Step.
            switch (m_iStep)
            {
            case EN_SEQ_STEP.Idle: return;

            case EN_SEQ_STEP.ToStartCon: if (!ToStartCon())
                {
                    return;
                }
                m_iStep = EN_SEQ_STEP.ToStart;
                Log.Trace("SEQ", "scToStartCon END");
                return;

            case EN_SEQ_STEP.ToStart: if (!ToStart())
                {
                    return;
                }
                m_bRun     = true;
                m_bRunEdge = true;
                m_iStep    = EN_SEQ_STEP.Run;
                Log.Trace("SEQ", "scToStart END");
                return;

            case EN_SEQ_STEP.Run: if (!m_bReqStop)
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.ShowMessage("Checked", "Lot Ended.");
                        Log.Trace("SEQ", LOT.GetLotNo() + "LotEnd");
                        m_bRunEnd = true;
                        m_iStep   = EN_SEQ_STEP.ToStopCon;
                    }
                    return;
                }
                m_bReqStop = false;
                m_iStep    = EN_SEQ_STEP.ToStopCon;
                Log.Trace("SEQ", "scRun END");
                return;

            case EN_SEQ_STEP.ToStopCon:  if (!ToStopCon())
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.
                        LOT.LotEnd();
                        Log.Trace("SEQ", "scToStopCon LotEnd");
                    }
                    return;
                }
                m_bRun  = false;
                m_iStep = EN_SEQ_STEP.ToStop;
                Log.Trace("SEQ", "scToStopCon END");
                return;

            case EN_SEQ_STEP.ToStop:  if (!ToStop())
                {
                    return;
                }
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;

                DM.SaveMap();
                Log.Trace("SEQ", "scToStop END");

                return;
            }
        }
Exemplo n.º 15
0
        private static void UpdateButton()
        {
            //Check Inspect.
            //if (!OM.CmnOptn.bIgnrDoor)
            InspectDoor();

            if (m_iStep != EN_SEQ_STEP.Idle)
            {
                InspectHomeDone();
            }

            if (m_iStep == EN_SEQ_STEP.Idle)
            {
                InspectLightGrid();
            }
            //Local Var.
            bool isErr     = SM.ER_IsErr();
            bool isHomeEnd = SM.MT_GetHomeDoneAll();

            //vision manual button.
            //CDelayTimer tmVisnCycle ;
            //if(IO_GetX(xETC_LStopSw)&& m_iSeqStat == ssStop ){
            //if(tmVisnCycle.OnDelay(true , 1000)) {
            //    tmVisnCycle.Clear();
            //    if(MM.GetManNo() == mcNoneCycle) {
            //        MM.SetManCycle(mcVSN_CycleWork);
            //    }
            //}
            //}
            //else {
            //tmVisnCycle.Clear();
            //}

            bool bStartSw = SM.IO_GetXUp(xi.ETC_StartSw) || m_bBtnStart;   // || SM.IO_GetXUp(xi.ETC_StartSwR) || m_bBtnStart ;
            bool bStopSw  = SM.IO_GetXUp(xi.ETC_StopSw) || m_bBtnStop;     // || SM.IO_GetXUp(xi.ETC_StopSwR ) || m_bBtnStop  ;
            bool bResetSw = SM.IO_GetXUp(xi.ETC_ResetSw) || m_bBtnReset;   // || SM.IO_GetXUp(xi.ETC_ResetSwR) || m_bBtnReset ;
            bool bAirSw   = m_bBtnAir;
            bool bInitSw  = SM.IO_GetXUp(xi.ETC_InitSw);

            if (m_bBtnStart)
            {
                Log.Trace("m_bBtnStart", "true");
            }
            if (bStartSw)
            {
                Log.Trace("bStartSw", "Started");

                if (m_iSeqStat == EN_SEQ_STAT.Init)
                {
                    Log.Trace("SeqStat", "ssInit   ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd)
                {
                    Log.Trace("SeqStat", "ssWorkEnd");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Error)
                {
                    Log.Trace("SeqStat", "ssError  ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Running)
                {
                    Log.Trace("SeqStat", "ssRunning");
                }
                if (m_iSeqStat == EN_SEQ_STAT.Stop)
                {
                    Log.Trace("SeqStat", "ssStop   ");
                }
                if (m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Log.Trace("SeqStat", "ssRunWarn");
                }

                if (MM.GetManNo() != (int)mc.NoneCycle)
                {
                    Log.Trace("ManCycle", string.Format(MM.GetManNo().ToString()));
                    bStartSw = false;
                }
            }


            //Update Switch's Lamp
            bool bStopBtnFlick = (m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop) && m_bFlick;


            //버튼 클릭시나
            SM.IO_SetY(yi.ETC_StartLp, SM.IO_GetX(xi.ETC_StartSw) || m_bRun);
            SM.IO_SetY(yi.ETC_StopLp, SM.IO_GetX(xi.ETC_StopSw) || !m_bRun || bStopBtnFlick);
            SM.IO_SetY(yi.ETC_ResetLp, SM.IO_GetX(xi.ETC_ResetSw) || (m_bFlick && isErr));
            //SM.IO_SetY(yi.ETC_AirLp     , SM.IO_GetX(xi.ETC_AirSw    ) || SM.IO_GetY(yi.ETC_MainAirSol     ));
            SM.IO_SetY(yi.ETC_InitLp, SM.IO_GetX(xi.ETC_InitSw));

            //  SM.IO_SetY(yi.ETC_StartLpR  , SM.IO_GetX(xi.ETC_StartSwR ) ||  m_bRun                             );
            //  SM.IO_SetY(yi.ETC_StopLpR   , SM.IO_GetX(xi.ETC_StopSwR  ) || !m_bRun || bStopBtnFlick            );
            //  SM.IO_SetY(yi.ETC_ResetLpR  , SM.IO_GetX(xi.ETC_ResetSwR ) || (m_bFlick && isErr)                 );
            ////SM.IO_SetY(yi.ETC_AirLp     , SM.IO_GetX(xi.ETC_AirSw    ) || SM.IO_GetY(yi.ETC_MainAirSol     ));
            //  SM.IO_SetY(yi.ETC_InitLpR   , SM.IO_GetX(xi.ETC_InitSwR  )                                        );

            //Center Man Button
            m_bBtnStart = false;
            m_bBtnStop  = false;
            m_bBtnReset = false;
            m_bBtnAir   = false;


            //Init. Button Flags.
            if (bStartSw)
            {
                if (!SM.IO_GetX(xi.VISN_Ready))
                {
                    Log.ShowMessage("Vision", SM.IO_GetXName(xi.VISN_Ready) + "Vision Ready IO is not On");
                    bStartSw = false;
                }
                if (COracle.bMakingDMC1List)
                {
                    Log.ShowMessage("OracleDB", "Please Wait for Finish Making DMC1 List!");
                    bStartSw = false;
                }
                if (COracle.bMakingPanelList)
                {
                    Log.ShowMessage("OracleDB", "Please Wait for Finish Making Panel List!");
                    bStartSw = false;
                }
                //if(!RockKey.Check()) { Log.ShowMessage("Error" , "Rock Key Error"        ); bStartSw = false ; }
                if (!isHomeEnd)
                {
                    Log.ShowMessage("Error", "Please Initial First"); bStartSw = false;
                }
                //

                if (!LOT.GetLotOpen())
                {
                    Log.ShowMessage("Error", "Open Lot!"); bStartSw = false;
                }
                if (!InspectStripDispr())
                {
                    m_bInspDispr = true; bStartSw = false;
                }
                if (!InspectStripUnknown())
                {
                    m_bInspUnkwn = true; bStartSw = false;
                }

                if (m_iSeqStat == EN_SEQ_STAT.WorkEnd || m_iSeqStat == EN_SEQ_STAT.RunWarn)
                {
                    Reset();
                }
            }

            if (bInitSw)
            {
                MM.SetManCycle(mc.AllHome);
            }

            //Air Switch.
            if (bAirSw && !m_bRun && m_iSeqStat != EN_SEQ_STAT.Init)
            {
                //SM.IO_SetY((int)yi.ETC_MainAirSol , !SM.IO_GetY((int)yi.ETC_MainAirSol )) ;
            }

            //Buzzer Off.
            if (isErr && bStopSw)
            {
                SML.TL.SetBuzzOff(true);
            }

            //Set Condition Flags.
            if (bStartSw)    //스타트버튼 안눌리는것 때문에 테스트.
            {
                Log.Trace("isErr", isErr ? "true":"false");
                Log.Trace("ManualMan.GetManNo()", string.Format(MM.GetManNo().ToString()));
            }
            if (bStopSw)
            {
                Log.Trace("Stop", "Stop");
            }

            bool isStopCon  = bStopSw || (isErr && !m_bReqStop && m_bRun);
            bool isRunCon   = bStartSw && !isErr /*&& ManualMan.GetManNo() == mcNone*/;
            bool isResetCon = bResetSw && !m_bRun;

            //Run.
            if (isRunCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                m_iStep = EN_SEQ_STEP.ToStartCon;
                SML.TL.SetBuzzOff(false);
                SM.ER_SetNeedShowErr(true);
            }
            //if( isRunCon && (m_iStep == EN_SEQ_STEP.Idle)) //스타트버튼 안눌리는것 때문에 테스트.
            //{
            //    Log.Trace("isRunCon && m_iStep" , string.Format(m_iStep.ToString()));
            //}
            if (isStopCon && (m_iStep != EN_SEQ_STEP.Idle))    //스타트버튼 안눌리는것 때문에 테스트.
            {
                //Log.Trace("isStopCon  &&  m_iStep" , string.Format(m_iStep.ToString()));
                //Log.Trace("bStopSw"                , bStopSw    ? "True" : "False");
                //Log.Trace("isErr"                  , isErr      ? "True" : "False");
                //Log.Trace("m_bReqStop"             , m_bReqStop ? "True" : "False");
                //Log.Trace("m_bRun"                 , m_bRun     ? "True" : "False");

                m_bReqStop = true;
            }

            if (isResetCon && (m_iStep == EN_SEQ_STEP.Idle))
            {
                Reset();
            }

            if (m_tmToStrt.OnDelay(m_iStep == EN_SEQ_STEP.ToStartCon || m_iStep == EN_SEQ_STEP.ToStart, 30000))
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStrtTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                SM.ER_SetErr(ei.ETC_ToStartTO);
                m_iStep = EN_SEQ_STEP.Idle;
                m_bRun  = false;
            }

            //CDelayTimer StopBtn = null;
            //StopBtn = new CDelayTimer();
            //if(m_iStep == EN_SEQ_STEP.scToStopCon)
            //{
            //    if(StopBtn.OnDelay(SM.IO_GetX((int)IP.xETC_StopSw)||SM.IO_GetX((int)IP.xETC_StopSw) , 5000))
            //    {
            //        Log.Trace("SEQ","Forced Stop");
            //        m_bRun = false ;
            //        m_iStep    = EN_SEQ_STEP.scIdle;
            //        m_bReqStop = false;
            //    }
            //}
            //else
            //{
            //    StopBtn.Clear();
            //}


            if (m_tmToStop.OnDelay(m_iStep == EN_SEQ_STEP.ToStopCon || m_iStep == EN_SEQ_STEP.ToStop, 30000))        //  20000)) {
            {
                //Trace Log.
                string Msg;
                Msg = string.Format("ToStopTimeOut : m_iStep=%d", m_iStep);
                Log.Trace("SEQ", Msg);
                m_bRun = false;

                SM.ER_SetErr(ei.ETC_ToStopTO);
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;
            }

            EN_SEQ_STEP iPreStep = m_iStep;

            if (iPreStep != m_iStep)
            {
                string sMsg = "";
                sMsg = "Step Changed" + string.Format(iPreStep.ToString()) + " -> " + string.Format(m_iStep.ToString());
                Log.Trace("SEQ", sMsg);
            }
            iPreStep = m_iStep;


            //이상하게 중간에 랏엔드가 되는 현상 발견해서 넣어둠.
            bool bPreLotEnd = LOT.GetLotEnd();

            if (LOT.GetLotEnd() != bPreLotEnd)
            {
                Log.Trace("SEQ", LOT.GetLotEnd() ? "LotEnd True" : "LotEnd False");
            }
            bPreLotEnd = LOT.GetLotEnd();



            //Running Step.
            switch (m_iStep)
            {
            case EN_SEQ_STEP.Idle: return;

            case EN_SEQ_STEP.ToStartCon: if (!ToStartCon())
                {
                    return;
                }
                m_iStep = EN_SEQ_STEP.ToStart;
                Log.Trace("SEQ", "scToStartCon END");
                return;

            case EN_SEQ_STEP.ToStart: if (!ToStart())
                {
                    return;
                }
                m_bRun     = true;
                m_bRunEdge = true;
                m_iStep    = EN_SEQ_STEP.Run;
                Log.Trace("SEQ", "scToStart END");
                return;

            case EN_SEQ_STEP.Run: if (!m_bReqStop)
                {
                    if (Autorun())
                    {
                        //랏엔드 상황.

                        if (OM.CmnOptn.bGoldenTray)
                        {
                            LOT.LotEnd();
                            int iIdx = 0;
                            if (DM.ARAY[ri.IDXR].CheckAllStat(cs.None))
                            {
                                iIdx = ri.IDXF;
                            }
                            else
                            {
                                iIdx = ri.IDXR;
                            }
                            int iCntGood = DM.ARAY[iIdx].GetCntStat(cs.Good);
                            int iCntNG   = DM.ARAY[iIdx].GetCntStat(cs.NG1) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG2) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG3) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG4) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG5) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG6) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG7) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG8) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG9) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG10);
                            int iCntEmpty = DM.ARAY[iIdx].GetCntStat(cs.NG0);
                            Log.ShowMessage("Golden Tray Ended", "Good=" + iCntGood + " NG=" + iCntNG + " Empty=" + iCntEmpty);
                            SEQ.IDXF.MoveCyl(ci.IDXF_ClampClOp, fb.Bwd);
                            SEQ.IDXR.MoveCyl(ci.IDXR_ClampClOp, fb.Bwd);
                        }
                        else
                        {
                            if (OM.EqpStat.iWorkBundle >= OM.DevInfo.iTRAY_BundleCnt)
                            {
                                LOT.LotEnd();
                                Log.ShowMessage("Checked", "Lot Ended.");
                                Log.Trace("SEQ", LOT.GetLotNo() + "LotEnd");
                            }
                            else
                            {
                                m_bRunEnd = true;
                                Log.ShowMessage("Checked", OM.EqpStat.iWorkBundle.ToString() + " Bundle Ended.");
                                Log.Trace("SEQ", LOT.GetLotNo() + OM.EqpStat.iWorkBundle.ToString() + "BundleEnd");
                                OM.EqpStat.bWrapingEnd = false;                                   //요걸 초기화 해야 로딩을 한다.
                            }
                        }

                        //m_bRunEnd = true;
                        m_iStep = EN_SEQ_STEP.ToStopCon;
                    }
                    return;
                }
                m_bReqStop = false;
                m_iStep    = EN_SEQ_STEP.ToStopCon;
                Log.Trace("SEQ", "scRun END");
                return;

            case EN_SEQ_STEP.ToStopCon:  if (!ToStopCon())
                {
                    if (Autorun())
                    {
                        if (OM.CmnOptn.bGoldenTray)
                        {
                            LOT.LotEnd();
                            int iIdx = 0;
                            if (DM.ARAY[ri.IDXR].CheckAllStat(cs.None))
                            {
                                iIdx = ri.IDXF;
                            }
                            else
                            {
                                iIdx = ri.IDXR;
                            }
                            int iCntGood = DM.ARAY[iIdx].GetCntStat(cs.Good);
                            int iCntNG   = DM.ARAY[iIdx].GetCntStat(cs.NG1) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG2) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG3) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG4) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG5) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG6) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG7) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG8) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG9) +
                                           DM.ARAY[iIdx].GetCntStat(cs.NG10);
                            int iCntEmpty = DM.ARAY[iIdx].GetCntStat(cs.NG0);
                            Log.ShowMessage("Golden Tray Ended", "Good=" + iCntGood + " NG=" + iCntNG + " Empty=" + iCntEmpty);
                            SEQ.IDXF.MoveCyl(ci.IDXF_ClampClOp, fb.Bwd);
                            SEQ.IDXR.MoveCyl(ci.IDXR_ClampClOp, fb.Bwd);
                        }
                        else
                        {
                            if (OM.EqpStat.iWorkBundle >= OM.DevInfo.iTRAY_BundleCnt)
                            {
                                LOT.LotEnd();
                                Log.ShowMessage("Checked", "Lot Ended.");
                                Log.Trace("SEQ", LOT.GetLotNo() + "LotEnd");
                            }
                            else
                            {
                                m_bRunEnd = true;
                                Log.ShowMessage("Checked", OM.EqpStat.iWorkBundle.ToString() + " Bundle Ended.");
                                Log.Trace("SEQ", LOT.GetLotNo() + OM.EqpStat.iWorkBundle.ToString() + "BundleEnd");
                                OM.EqpStat.bWrapingEnd = false;                                   //요걸 초기화 해야 로딩을 한다.
                            }
                        }
                    }
                    return;
                }
                m_bRun  = false;
                m_iStep = EN_SEQ_STEP.ToStop;
                Log.Trace("SEQ", "scToStopCon END");
                return;

            case EN_SEQ_STEP.ToStop:  if (!ToStop())
                {
                    return;
                }
                m_iStep    = EN_SEQ_STEP.Idle;
                m_bReqStop = false;

                DM.SaveMap();
                Log.Trace("SEQ", "scToStop END");

                return;
            }
        }