Пример #1
0
        override public bool Autorun() //오토런닝시에 계속 타는 함수.
        {
            PreStep.eSeq = Step.eSeq;
            string sCycle = GetCrntCycleName();

            //Check Error & Decide Step.
            if (Step.eSeq == sc.Idle)
            {
                if (Stat.bReqStop)
                {
                    return(false);
                }

                if (OM.DevInfo.iMgzCntPerLot < 1)
                {
                    OM.DevInfo.iMgzCntPerLot = 1;                              //1이상이여야 함 다른데서 까먹을거 같아서 여기 넣어놈.
                }
                //자재 상태
                bool None     = DM.ARAY[ri.LODR].CheckAllStat(cs.None);
                bool Unkwn    = DM.ARAY[ri.LODR].GetCntStat(cs.Unknown) > 0;
                bool Empty    = DM.ARAY[ri.LODR].CheckAllStat(cs.Empty);
                bool bMgzSsr1 = IO_GetX(xi.LODR_MgzDetect1);
                bool bMgzSsr2 = IO_GetX(xi.LODR_MgzDetect2);

                //조건
                bool Supply   = (!IO_GetX(xi.LODR_MgzIn) && !Stat.bSupply);  //매거진에 구멍땜에 안들어와있을경우 반영 , 매거진 있을때라고 생각
                bool Pick     = !Supply;
                bool PreRdy   = DM.ARAY[ri.PREB].CheckAllStat(cs.None) && SEQ.VSNZ.GetSeqStep() != (int)VisnZone.sc.Move;
                bool bLot     = LOT.GetNextMgz() != "";
                bool bLotWait = LOT.GetLotNo() != DM.ARAY[ri.LODR].LotNo;  //랏변경시에 레일을 비우고 시작한다.
                bool bLotMove = DM.ARAY[ri.PREB].CheckAllStat(cs.None) &&
                                DM.ARAY[ri.VSN1].CheckAllStat(cs.None) &&
                                DM.ARAY[ri.VSN2].CheckAllStat(cs.None) &&
                                DM.ARAY[ri.VSN3].CheckAllStat(cs.None) &&
                                DM.ARAY[ri.PSTB].CheckAllStat(cs.None);

                //사이클
                bool isSupply = None && Supply && bLot && !OM.CmnOptn.bLoadStop;
                bool isPick   = None && Pick && bLot && !OM.CmnOptn.bLoadStop;
                bool isWork   = Unkwn && PreRdy && !OM.CmnOptn.bLoadStop && (!bLotWait || bLotMove);
                bool isDrop   = Empty;
                bool isEnd    = None && LOT.GetNextMgz() == "";

                //모르는 카세트 에러
                if (None && (bMgzSsr1 || bMgzSsr2))
                {
                    ER_SetErr(ei.PKG_Unknwn, "Loader have no data found, but mgz sensor detected");
                }

                //카세트 사라짐
                if (!None && (!bMgzSsr1 && !bMgzSsr2))
                {
                    ER_SetErr(ei.PKG_Dispr, "Loader have data, but mgz sensor not detected");
                }

                if (ER_IsErr())
                {
                    return(false);
                }

                //Normal Decide Step.
                if (isSupply)
                {
                    DM.ARAY[ri.LODR].Trace(m_iPartId); Step.eSeq = sc.Supply;
                }
                else if (isPick)
                {
                    DM.ARAY[ri.LODR].Trace(m_iPartId); Step.eSeq = sc.Pick;
                }
                else if (isWork)
                {
                    DM.ARAY[ri.LODR].Trace(m_iPartId); Step.eSeq = sc.Work;
                }
                else if (isDrop)
                {
                    DM.ARAY[ri.LODR].Trace(m_iPartId); Step.eSeq = sc.Drop;
                }
                else if (isEnd)
                {
                    Stat.bWorkEnd = true; return(true);
                }
                Stat.bWorkEnd = false;

                if (Step.eSeq != sc.Idle)
                {
                    Trace(Step.eSeq.ToString() + " Start");
                    InitCycleStep();
                    m_CycleTime[(int)Step.eSeq].Start();
                }
            }

            //Cycle.
            Step.eLastSeq = Step.eSeq;
            switch (Step.eSeq)
            {
            default: Trace("default End"); Step.eSeq = sc.Idle; return(false);

            case sc.Idle: return(false);

            case sc.Supply: if (!CycleSupply())
                {
                    return(false);
                }
                break;

            case sc.Pick: if (!CyclePick())
                {
                    return(false);
                }
                break;

            case sc.Work: if (!CycleWork())
                {
                    return(false);
                }
                break;

            case sc.Drop: if (!CycleDrop())
                {
                    return(false);
                }
                break;
            }
            Trace(sCycle + " End");
            m_CycleTime[(int)Step.eSeq].End();
            Step.eSeq = sc.Idle;
            return(false);
        }
Пример #2
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;
            }
        }
Пример #3
0
        override public bool Autorun() //오토런닝시에 계속 타는 함수.
        {
            PreStep.eSeq = Step.eSeq;
            string sCycle = GetCrntCycleName();

            //Check Error & Decide Step.
            if (Step.eSeq == sc.Idle)
            {
                if (Stat.bReqStop)
                {
                    return(false);
                }

                //자재 상태
                bool None  = DM.ARAY[ri.ULDR].CheckAllStat(cs.None);
                bool Work  = DM.ARAY[ri.ULDR].CheckAllStat(cs.Work);
                bool Empty = DM.ARAY[ri.ULDR].GetCntStat(cs.Empty) > 0;
                bool Strip = !DM.ARAY[ri.PREB].CheckAllStat(cs.None) || !DM.ARAY[ri.VSN1].CheckAllStat(cs.None) || !DM.ARAY[ri.VSN2].CheckAllStat(cs.None) ||
                             !DM.ARAY[ri.VSN3].CheckAllStat(cs.None) || !DM.ARAY[ri.PSTB].CheckAllStat(cs.None);         //|| !DM.ARAY[ri.ULDR].CheckAllStat(cs.None   ) ;
                bool NonePsb  = DM.ARAY[ri.PSTB].CheckAllStat(cs.None);
                bool bMgzSsr1 = IO_GetX(xi.ULDR_MgzDetect1);
                bool bMgzSsr2 = IO_GetX(xi.ULDR_MgzDetect2);

                string sLastLotNo = "";//DM.ARAY[ri.PSTB].LotNo;
                if (!DM.ARAY[ri.PSTB].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.PSTB].LotNo;
                }
                else if (!DM.ARAY[ri.VSN3].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.VSN3].LotNo;
                }
                else if (!DM.ARAY[ri.VSN2].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.VSN2].LotNo;
                }
                else if (!DM.ARAY[ri.VSN1].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.VSN1].LotNo;
                }
                else if (!DM.ARAY[ri.PREB].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.PREB].LotNo;
                }
                else if (!DM.ARAY[ri.LODR].CheckAllStat(cs.None))
                {
                    sLastLotNo = DM.ARAY[ri.LODR].LotNo;
                }
                else
                {
                    sLastLotNo = LOT.GetNextMgz();
                }


                //조건
                double dPos    = DM.ARAY[ri.ULDR].FindFrstRow(cs.Empty) * OM.DevInfo.dMgzPitch;
                bool   WorkPos = MT_CmprPos(mi.ULDR_ZClmp, PM.GetValue(mi.ULDR_ZClmp, pv.ULDR_ZClmpWorkStart) - dPos);
                bool   LotCng  = DM.ARAY[ri.ULDR].LotNo != "" && DM.ARAY[ri.ULDR].LotNo != sLastLotNo; //&& !NonePsb ;
                bool   Supply  = (!IO_GetX(xi.ULDR_MgzIn) && !Stat.bSupply);                           //매거진에 구멍땜에 안들어와있을경우 반영 , 매거진 있을때라고 생각

                //사이클
                bool isSupply = None && Strip && Supply;
                bool isPick   = None && Strip && !Supply;
                bool isWork   = Empty && !WorkPos;
                bool isDrop   = !None && (Work || LotCng || (!Strip && SEQ.LODR.GetSeqStep() == 0));
                bool isEnd    = None && !Strip && SEQ.LODR.GetSeqStep() == 0;

                //모르는 카세트 에러
                if (!isPick)
                {
                    if (None && (bMgzSsr1 || bMgzSsr2))
                    {
                        ER_SetErr(ei.PKG_Unknwn, "Unloader have no data found, but mgz sensor detected");
                    }
                }
                //카세트 사라짐
                if (!isDrop)
                {
                    if (!None && (!bMgzSsr1 && !bMgzSsr2))
                    {
                        ER_SetErr(ei.PKG_Dispr, "Unloader have data, but mgz sensor not detected");
                    }
                }
                //카세트 필요
                if (None && !IO_GetX(xi.ULDR_MgzIn) && Stat.bSupply && !NonePsb)
                {
                    ER_SetErr(ei.PRT_NeedMgz, "Unloader need to magazine");
                }
                //카세트 꽉참
                //if(  None && !IO_GetX(xi.ULDR_MgzIn) && Stat.bSupply && !NonePsb) ER_SetErr(ei.PRT_NeedMgz,"Unloader need to magazine") ;


                if (ER_IsErr())
                {
                    return(false);
                }

                //Normal Decide Step.
                if (isSupply)
                {
                    DM.ARAY[ri.ULDR].Trace(m_sPartName); Step.eSeq = sc.Supply;
                }
                else if (isPick)
                {
                    DM.ARAY[ri.ULDR].Trace(m_sPartName); Step.eSeq = sc.Pick;
                }
                else if (isWork)
                {
                    DM.ARAY[ri.ULDR].Trace(m_sPartName); Step.eSeq = sc.Work;
                }
                else if (isDrop)
                {
                    DM.ARAY[ri.ULDR].Trace(m_sPartName); Step.eSeq = sc.Drop;
                }
                else if (isEnd)
                {
                    Stat.bWorkEnd = true; return(true);
                }

                Stat.bWorkEnd = false;

                if (Step.eSeq != sc.Idle)
                {
                    Trace(Step.eSeq.ToString() + " Start");
                    InitCycleStep();
                    m_CycleTime[(int)Step.eSeq].Start();
                }
            }

            //Cycle.
            Step.eLastSeq = Step.eSeq;
            switch (Step.eSeq)
            {
            default: Trace("default End"); Step.eSeq = sc.Idle; return(false);

            case sc.Idle: return(false);

            case sc.Supply: if (!CycleSupply())
                {
                    return(false);
                }
                break;

            case sc.Pick: if (!CyclePick())
                {
                    return(false);
                }
                break;

            case sc.Work: if (!CycleWork())
                {
                    return(false);
                }
                break;

            case sc.Drop: if (!CycleDrop())
                {
                    return(false);
                }
                break;
            }
            Trace(sCycle + " End");
            m_CycleTime[(int)Step.eSeq].End();
            Step.eSeq = sc.Idle;
            return(false);
        }