Esempio n. 1
0
        /////SendMessage Receive
        //protected override void WndProc(ref Message m)
        //{
        //    const int WM_COPYDATA = 0x4A;
        //    try
        //    {
        //        switch (m.Msg)
        //        {
        //            default:
        //                base.WndProc(ref m);
        //                break;
        //
        //            case WM_COPYDATA:
        //                //VC.SetReceivedMsg((VC.COPYDATASTRUCT)m.GetLParam(typeof(VC.COPYDATASTRUCT)));
        //                return;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //}



        protected override void WndProc(ref Message m)
        {
            const int WM_DEVICECHANGE = 0x0219;
            const int WM_COPYDATA     = 0x4A;

            try
            {
                switch (m.Msg)
                {
                default:
                    base.WndProc(ref m);
                    break;

                case WM_COPYDATA:
                    VC.SetReceivedMsg((VC.COPYDATASTRUCT)m.GetLParam(typeof(VC.COPYDATASTRUCT)));
                    return;

                    //case WM_DEVICECHANGE:
                    //    if (m.WParam.ToInt32() == 7)
                    //    {
                    //        SEQ.XRAY.bDeviceChange = true;



                    //    }
                    //    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            string sText = ((Button)sender).Text;

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

            if (tbMsgData.Text != "")
            {
                VC.SendMsgTest(int.Parse(tbMsgData.Text));
            }
        }
Esempio n. 3
0
        //public static List<double> lstTime ;
        //static FileStream   fs;
        //static StreamWriter sw;
        //static bool bFst ;
        //static double dPreTime2;
        //static public void SaveCsv(ref List<double> _lst,string _sPath = "")
        //{
        //    string sPath1 = @"D:\" + _sPath + ".csv";
        //    string sPath2 = @"D:\TimeCheck.csv" ;

        //    if(!bFst)
        //    {
        //        fs = new FileStream(sPath1, FileMode.Append, FileAccess.Write);
        //        sw = new StreamWriter(fs, Encoding.UTF8);
        //        bFst = true;
        //    }
        //    string line = "";

        //    for(int i=0; i<_lst.Count; i++) {
        //        line += string.Format("{0:0.0000}",_lst[i]) + ",";
        //    }
        //    sw.WriteLine(line);
        //}
        //public static double GetTime()
        //{
        //    double dCrntTime = CTimer.GetTime_us();
        //    double dTime = (dCrntTime - dPreTime2) / 1000.0;
        //    dPreTime2 = dCrntTime;
        //    return dTime;
        //}
        //SaveCsv(ref lstTime,sPath);
        public static void Update()
        {
            //lstTime = new List<double>();
            //string sPath = DateTime.Now.ToString("HHmmss");
            double dPreTime = CTimer.GetTime_us();
            double dCrntTime;

            while (true)
            {
                dCrntTime = CTimer.GetTime_us();
                m_dMainThreadCycleTime = (dCrntTime - dPreTime) / 1000.0;
                dPreTime = dCrntTime;
                Thread.Sleep(0);

                //Motion Dll Update
                SM.Update(m_iSeqStat);

                //Part
                for (int i = 0; i < (int)pi.MAX_PART; i++)
                {
                    m_Part[i].Update();
                }

                //Inspection
                InspectMainAir();
                InspectEmergency();
                InspectActuator();
                InspectMotor();
                InspectCrash();
                InspectTemp();

                //Update ErrorProc.
                UpdateButton();

                //Check Button.
                UpdateSeqState();

                //Update Motor State (Input)
                MM.Update();

                //SPC
                SPC.Update(LOT.CrntLotData.sLotNo, OM.GetCrntDev(), m_iSeqStat, OM.EqpStat.bMaint);

                //Vision Communication
                VC.Update();

                //SEQ.BarcordPrnt.Update();
            }
        }
Esempio n. 4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            tmUpdate.Enabled = false;
            for (int i = 0; i < (int)pi.MAX_PART; i++)
            {
                lvSequence.Items[i].SubItems[2].Text = SEQ.m_Part[i].GetToStartStep().ToString(); lvSequence.Items[i].SubItems[2].BackColor = SEQ.m_Part[i].GetToStartStep() == 0 ? Color.White : Color.Yellow;
                lvSequence.Items[i].SubItems[3].Text = SEQ.m_Part[i].GetCrntCycleName(); lvSequence.Items[i].SubItems[3].BackColor = SEQ.m_Part[i].GetSeqStep() == 0 ? Color.White : Color.Yellow;
                lvSequence.Items[i].SubItems[4].Text = SEQ.m_Part[i].GetCycleStep().ToString(); lvSequence.Items[i].SubItems[4].BackColor = SEQ.m_Part[i].GetCycleStep() == 0 ? Color.White : Color.Yellow;
                lvSequence.Items[i].SubItems[5].Text = SEQ.m_Part[i].GetToStopStep().ToString(); lvSequence.Items[i].SubItems[5].BackColor = SEQ.m_Part[i].GetToStopStep() == 0 ? Color.White : Color.Yellow;
                lvSequence.Items[i].SubItems[6].Text = SEQ.m_Part[i].GetHomeStep().ToString(); lvSequence.Items[i].SubItems[6].BackColor = SEQ.m_Part[i].GetHomeStep() == 0 ? Color.White : Color.Yellow;
            }

            tbRcvDataId.Text = VC.GetVisnRecvViewMsgId().ToString();
            tbRcvData.Text   = VC.GetVisnRecvViewMsg();
            if (!this.Visible)
            {
                tmUpdate.Enabled = false;
                return;
            }
            tmUpdate.Enabled = true;
        }
Esempio n. 5
0
        static public MD_X1000 LaserMarking;         //= new MD_X1000       (0, "LaserMarking"   );
        //static public RS232_3310g         BarcordLODR = new RS232_3310g        (1, "BarcordLODR"   );
        //static public RS232_3310g         BarcordBARZ = new RS232_3310g        (2, "BarcordBARZ"   );


        //static public DispensePattern DispPtrn = new DispensePattern();
        //static public HeightPattern   HghtPtrn = new HeightPattern  ();

        //static public CSerialPort[] Com = new CSerialPort[(int)si.MAX_RS232];

        public static void Init()
        {
            //Common
            SM.TPara Para;
            Para.sParaFolderPath = Directory.GetCurrentDirectory() + "\\Util\\";
            Para.iWidth          = 1280;
            Para.iHeight         = 863;
            Para.bTabHides       = new bool[6];
            //Para.eLanSel   = EN_LAN_SEL.Chinese;
            //Para.eLanSel   = EN_LAN_SEL.Korean;

            switch (Eqp.sLanguage)
            {
            default: CLanguage.ChangeLanguage("en"); Para.eLanSel = EN_LAN_SEL.English; break;

            case "English": CLanguage.ChangeLanguage("en"); Para.eLanSel = EN_LAN_SEL.English; break;

            case "Korean": CLanguage.ChangeLanguage("ko"); Para.eLanSel = EN_LAN_SEL.Korean; break;

            case "Chinese": CLanguage.ChangeLanguage("zh-Hans"); Para.eLanSel = EN_LAN_SEL.Chinese; break;
            }

            //Error
            SM.TParaErr Err;
            Para.Err.bUseErrPic = true;
            Para.Err.eErr       = new ei();
            Para.bTabHides[0]   = false;
            //D IO
            SM.TParaDio Dio;
            Para.Dio.eDioSel  = EN_DIO_SEL.AXL;
            Para.Dio.eX       = new xi();
            Para.Dio.eY       = new yi();
            Para.bTabHides[1] = false;
            //A IO
            SM.TParaAio Aio;
            Para.Aio.eAioSel    = EN_AIO_SEL.AXL;
            Para.Aio.eX         = new ax();
            Para.Aio.eY         = new ay();
            Para.Aio.iRangeAMin = 0;
            Para.Aio.iRangeAMax = 0;
            Para.bTabHides[2]   = false;

            //TowerLamp
            Para.bTabHides[3] = false;

            //Cylinder
            SM.TParaCyl Cyl;
            Para.Cyl.eCyl     = new ci();
            Para.bTabHides[4] = false;

            //Motor
            SM.TParaMtr Mtr;
            Para.Mtr.eMtrSel = new EN_MTR_SEL[(int)mi.MAX_MOTR];
            for (int i = 0; i < (int)mi.MAX_MOTR; i++)
            {
                Para.Mtr.eMtrSel[i] = EN_MTR_SEL.AXL;
            }
            Para.Mtr.eMtr     = new mi();
            Para.bTabHides[5] = false;

            //
            //SM.InitErr(Para,Err);
            //SM.InitDio(Para,Dio);
            //SM.InitAio(Para,Aio);
            //SM.InitCyl(Para,Cyl);
            //SM.InitMtr(Para,Mtr);

            SM.Init(Para);
            OM.Init();
            DM.Init();
            LOT.Init();
            SPC.Init();
            PM.Init(PM.PstnCnt);

            LaserMarking = new MD_X1000(2,
                                        xi.LSR_Error,
                                        xi.LSR_Warning,
                                        xi.LSR_TrgReady,
                                        xi.LSR_InPrint,
                                        xi.LSR_PrintEnd,
                                        xi.LSR_CheckOk,
                                        xi.LSR_CheckNg,
                                        yi.LSR_Triger,
                                        yi.LSR_Check);

            EmbededExe.CameraInit();

            //public MD_X1000(int _iPortId ,
            //            xi  _xError  ,
            //            xi  _xWarning,
            //            xi  _xReady  ,
            //            xi  _xWorking,
            //            xi  _xWorkEnd,
            //            xi  _xCheckOk,
            //            xi  _xCheckNg,
            //            yi  _yTrigger,
            //            yi  _yCheck  )


            //VisnComm.TPara VisnPara = new VisnComm.TPara();
            //VisnPara.sVisnPcName     = "Visn"          ; //파일저장시에 파일명에 삽입.
            //VisnPara.sVisnFolder     = "c:\\Data"      ; //파일저장 하는 폴더.
            //VisnPara.xVisn_Ready     = xi.VISN_Ready   ;
            //VisnPara.xVisn_Busy      = xi.VISN_Busy    ;

            //VisnPara.yVisn_Command   = yi.VISN_Command ;
            //VisnPara.yVisn_JobChange = yi.VISN_Change  ;
            //VisnPara.yVisn_Reset     = yi.VISN_Reset   ;
            //VisnPara.yVisn_ManMode   = yi.VISN_ManMode ;
            //VisnPara.yVisn_ManInsp   = yi.VISN_ManInsp ;
            //Visn.Init(ref VisnPara);

            MainThread.Priority = ThreadPriority.Highest;
            //MainThread.Priority = ThreadPriority.Normal;
            MainThread.Start();

            m_tmToStop    = new CDelayTimer();
            m_tmToStrt    = new CDelayTimer();
            m_tmFlickOn   = new CDelayTimer();
            m_tmFlickOff  = new CDelayTimer();
            m_tmCloseDoor = new CDelayTimer();
            m_tmTemp      = new CDelayTimer();

            m_cyWorktime = new CCycleTimer();

            VC.Init();

            m_bBtnReset = false;
            m_bBtnStart = false;
            m_bBtnStop  = false;
            m_bBtnAir   = false;

            m_bRun     = false;
            m_bRunEdge = false;
            m_bFlick   = false;
            m_iStep    = EN_SEQ_STEP.Idle;
            m_iSeqStat = EN_SEQ_STAT.Stop;

            //Run End Buzzer.
            m_bRunEnd = false;

            m_Part[(int)pi.LODR] = LODR; //m_Part[(int)pi.LODR].SetPartId((int)pi.LODR + ti.Max);
            m_Part[(int)pi.PLDR] = PLDR; //m_Part[(int)pi.LODR].SetPartId((int)pi.LODR + ti.Max);
            m_Part[(int)pi.MARK] = MARK; //m_Part[(int)pi.IDXR].SetPartId((int)pi.IDXR + ti.Max);
            m_Part[(int)pi.VISN] = VISN; //m_Part[(int)pi.IDXF].SetPartId((int)pi.IDXF + ti.Max);
            m_Part[(int)pi.TBLE] = TTBL; //m_Part[(int)pi.TOOL].SetPartId((int)pi.TOOL + ti.Max);
            m_Part[(int)pi.PULD] = PULD; //m_Part[(int)pi.IDXF].SetPartId((int)pi.IDXF + ti.Max);
            m_Part[(int)pi.ULDR] = ULDR; //m_Part[(int)pi.STCK].SetPartId((int)pi.STCK + ti.Max);
            m_Part[(int)pi.REJM] = REJM; //m_Part[(int)pi.STCK].SetPartId((int)pi.STCK + ti.Max);
            m_Part[(int)pi.REJV] = REJV; //m_Part[(int)pi.STCK].SetPartId((int)pi.STCK + ti.Max);
            //m_Part[(int)pi.] = BARZ; //m_Part[(int)pi.BARZ].SetPartId((int)pi.BARZ + ti.Max);

            //LoadCell   .PortOpen();
            //Dispr      .PortOpen();
            //HeightSnsr .PortOpen();
            //BarcordLODR.PortOpen();
            //BarcordBARZ.PortOpen();
            //Temp       .PortOpen();

            //ML.IO_SetY(yi.SSTG_HeaterOn,true);


            //DateTime Time =  DateTime.Now ;
            //bool bConnect = SEQ.Oracle.OpenDB(OM.CmnOptn.sOracleIP , OM.CmnOptn.sOraclePort , OM.CmnOptn.sOracleID , OM.CmnOptn.sOraclePassword);//"192.168.1.77" , "1521" , "hr","hr"
            //TimeSpan Span =  DateTime.Now - Time ;
            //double dVal = Span.TotalMilliseconds ;


            //if(!OM.CmnOptn.bOracleNotUse && !bConnect) Log.ShowMessage("Oracle","DB Connection Error");
        }
Esempio n. 6
0
        public bool CycleWork()
        {
            String sTemp;

            if (m_tmCycle.OnDelay(Step.iCycle != 0 && Step.iCycle == PreStep.iCycle && CheckStop() && !OM.MstOptn.bDebugMode, 5000))
            {
                sTemp = string.Format("Cycle Step.iCycle={0:00}", Step.iCycle);
                sTemp = m_sPartName + sTemp;
                ER_SetErr(ei.PRT_CycleTO, sTemp);
                Trace(sTemp);
                return(true);
            }

            if (Step.iCycle != PreStep.iCycle)
            {
                sTemp = string.Format("Cycle Step.iCycle={0:00}", Step.iCycle);
                Trace(sTemp);
            }

            PreStep.iCycle = Step.iCycle;

            if (Stat.bReqStop)
            {
                //return true ;
            }

            int r = 0, c = 0;


            const int iMaxInspCnt = 4;

            string sVsnRecvMsg;

            switch (Step.iCycle)
            {
            default:
                sTemp = string.Format("Cycle Default Clear Step.iCycle={0:00}", Step.iCycle);
                //if(Step.iCycle != PreStep.iCycle)Trace(m_sPartName.c_str(), sTemp.c_str());
                return(true);

            case 10:
                //MoveCyl(ci.VISN_TurnGrpFwBw  , fb.Bwd);
                if (!IO_GetX(xi.TBLE_VISNPkgDtct))
                {
                    ER_SetErr(ei.PKG_Dispr, "Vision Disappear PKG Error.");
                    Step.iCycle = 0;
                    return(true);
                }
                if (!OM.CmnOptn.bVisnSkip)
                {
                    VC.SendVisnMsg(VC.sm.Ready);
                }
                Step.iCycle++;
                return(false);

            case 11:
                if (!OM.CmnOptn.bVisnSkip && !VC.IsEndSendMsg())
                {
                    return(false);
                }
                if (!OM.CmnOptn.bVisnSkip && VC.GetVisnRecvErrMsg() != "")
                {
                    ER_SetErr(ei.VSN_ComErr, VC.GetVisnSendErrMsg());
                    Step.iCycle = 0;
                    return(true);
                }
                if (!OM.CmnOptn.bVisnSkip && VC.GetVisnSendMsg() != "OK")
                {
                    ER_SetErr(ei.VSN_ComErr, "Vision Not Ready");
                    Step.iCycle = 0;
                    return(true);
                }
                if (!OM.CmnOptn.bVisnSkip)
                {
                    VC.ClearRecvData();
                }
                MoveCyl(ci.VISN_GrpRtrCwCCw, fb.Bwd);
                MoveCyl(ci.VISN_FixRtrCwCCw, fb.Bwd);
                //MoveCyl(ci.VISN_TurnRtrCwCCw , fb.Bwd);
                Step.iCycle++;
                return(false);

            case 12:
                //if(!CL_Complete(ci.VISN_TurnGrpFwBw , fb.Bwd))return false;
                if (!CL_Complete(ci.VISN_GrpRtrCwCCw, fb.Bwd))
                {
                    return(false);
                }
                if (!CL_Complete(ci.VISN_FixRtrCwCCw, fb.Bwd))
                {
                    return(false);
                }
                //if(!CL_Complete(ci.VISN_TurnRtrCwCCw))return false;
                MoveCyl(ci.VISN_TurnGrpFwBw, fb.Fwd);

                Step.iCycle++;
                return(false);

            case 13:
                if (!CL_Complete(ci.VISN_TurnGrpFwBw, fb.Fwd))
                {
                    return(false);
                }
                MoveCyl(ci.VISN_GrpRtrCwCCw, fb.Fwd);
                Step.iCycle++;
                return(false);

            case 14:
                if (!CL_Complete(ci.VISN_GrpRtrCwCCw, fb.Fwd))
                {
                    return(false);
                }
                MoveMotr(mi.VISN_ZGrpr, pv.VISN_ZGrprWork);
                Step.iCycle++;
                return(false);

            case 15:
                if (!MT_GetStopInpos(mi.VISN_ZGrpr))
                {
                    return(false);
                }
                MoveCyl(ci.VISN_FixRtrCwCCw, fb.Fwd);
                Step.iCycle++;
                return(false);

            case 16:
                if (!CL_Complete(ci.VISN_FixRtrCwCCw, fb.Fwd))
                {
                    return(false);
                }
                if (!OM.CmnOptn.bVisnSkip)
                {
                    VC.SendVisnMsg(VC.sm.Insp);
                }
                Step.iCycle++;
                return(false);

            case 17:
                if (!OM.CmnOptn.bVisnSkip && VC.GetVisnSendMsg() == "")
                {
                    return(false);
                }
                Step.iCycle++;
                return(false);

            case 18:
                CL_Move(ci.VISN_FixRtrCwCCw, fb.Bwd);

                Step.iCycle++;
                return(false);

            case 19:
                if (!CL_Complete(ci.VISN_FixRtrCwCCw, fb.Bwd))
                {
                    return(false);
                }
                //if (!OM.CmnOptn.bVisnSkip) VC.SendVisnMsg(VC.sm.Insp);
                Step.iCycle++;
                return(false);

            case 20:
                if (!OM.CmnOptn.bVisnSkip)
                {
                    sVsnRecvMsg = VC.GetVisnSendMsg();

                    if (sVsnRecvMsg == "1")
                    {
                        Step.iCycle = 24;
                        return(false);
                    }
                    //if (sVsnRecvMsg == "00002")
                    //{
                    //    Step.iCycle = 24;
                    //    return false;
                    //}
                }
                if (OM.CmnOptn.bVisnSkip)
                {
                    Step.iCycle = 24;
                    return(false);
                }
                Step.iCycle++;
                return(false);

            case 21:
                CL_Move(ci.VISN_GrpRtrCwCCw, fb.Bwd);
                Step.iCycle++;
                return(false);

            case 22:
                if (!CL_Complete(ci.VISN_GrpRtrCwCCw, fb.Bwd))
                {
                    return(false);
                }
                //CL_Move(ci.VISN_TurnGrpFwBw , fb.Bwd);
                Step.iCycle++;
                return(false);

            case 23:
                //if(!CL_Complete(ci.VISN_TurnGrpFwBw , fb.Bwd))return false;

                sVsnRecvMsg = VC.GetVisnSendMsg();
                //검사 Good일때
                if (sVsnRecvMsg == "0")
                {
                    DM.ARAY[ri.TVSN].SetStat(cs.Good);
                }
                //검사 실패시.
                else if (sVsnRecvMsg == "2")
                {
                    DM.ARAY[ri.TVSN].SetStat(cs.NGVisn);
                }
                if (OM.CmnOptn.bVisnSkip)
                {
                    DM.ARAY[ri.TVSN].SetStat(cs.Good);
                }
                Step.iCycle = 0;
                return(true);

            case 24:
                MoveMotr(mi.VISN_ZGrpr, pv.VISN_ZGrprWait);
                Step.iCycle++;
                return(false);

            case 25:
                if (!MT_GetStopInpos(mi.VISN_ZGrpr))
                {
                    return(false);
                }
                if (CL_GetCmd(ci.VISN_TurnRtrCwCCw) == fb.Bwd)
                {
                    CL_Move(ci.VISN_TurnRtrCwCCw, fb.Fwd);
                }
                else
                {
                    CL_Move(ci.VISN_TurnRtrCwCCw, fb.Bwd);
                }

                Step.iCycle++;
                return(false);

            case 26:
                //여기는 한번 확인.
                if (!CL_Complete(ci.VISN_TurnRtrCwCCw))
                {
                    return(false);
                }
                CL_Move(ci.VISN_GrpRtrCwCCw, fb.Bwd);
                Step.iCycle++;
                return(false);

            case 27:
                if (!CL_Complete(ci.VISN_GrpRtrCwCCw, fb.Bwd))
                {
                    return(false);
                }
                DM.ARAY[ri.TVSN].SetStat(cs.Good);
                Step.iCycle = 0;
                return(true);
            }
        }