コード例 #1
0
 private bool M_Rightstart; //中间变量
 private bool Double_Hands_Start(int timeinterval_ms = 500, bool RST_Start = false)
 {
     if (RST_Start)
     {
         M_leftstart = false;
         m_LeftTimer.Stop();
         m_LeftTimer.Reset();
         M_Rightstart = false;
         m_RightTimer.Stop();
         m_RightTimer.Reset();
         return(false);
     }
     else
     {
         //left
         //if (LeftStart.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.左手启动) == 1) && PVar.AutoRunFlag && PVar.IsSysEmcStop == false && Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 0)//这里需要加很多条件
         if (LeftStart.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.左手启动) == 1) && PVar.AutoRunFlag && PVar.IsSysEmcStop == false)//这里需要加很多条件
         {
             m_LeftTimer.Reset();
             m_LeftTimer.Start();
         }
         if (m_LeftTimer.ElapsedMilliseconds < timeinterval_ms && m_LeftTimer.ElapsedMilliseconds > 0 && AutoRunstep <= 20)
         {
             M_leftstart = true;
         }
         else if (m_LeftTimer.ElapsedMilliseconds > timeinterval_ms)
         {
             M_leftstart = false;
             m_LeftTimer.Stop();
             m_LeftTimer.Reset();
         }
         //right
         //if (RightStart.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.右手启动) == 1) && PVar.AutoRunFlag && PVar.IsSysEmcStop == false && Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 0)//这里需要加很多条件
         if (RightStart.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.右手启动) == 1) && PVar.AutoRunFlag && PVar.IsSysEmcStop == false && AutoRunstep <= 20)//这里需要加很多条件
         {
             m_RightTimer.Reset();
             m_RightTimer.Start();
         }
         if (m_RightTimer.ElapsedMilliseconds < timeinterval_ms && m_RightTimer.ElapsedMilliseconds > 0)
         {
             M_Rightstart = true;
         }
         else if (m_RightTimer.ElapsedMilliseconds > timeinterval_ms)
         {
             M_Rightstart = false;
             m_RightTimer.Stop();
             m_RightTimer.Reset();
         }
         return(M_leftstart && M_Rightstart);
     }
 }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: xhyangxianjun/wangliang
        private void Btn_Start_Click(object sender, EventArgs e)
        {
            this.Btn_Start.BackColor = Mycolor.UnselectedBtn;;
            this.Btn_Pause.BackColor = Mycolor.None;
            this.Btn_Stop.BackColor  = Mycolor.None;

            if (GoHome.Instance.Reset.Result)
            {
                if (MessageBox.Show("确定开始自动运行?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    FileLog.OperateLog("自动运行");
                    XTaskManager.Instance.FindTaskById((int)TasksId.Manchine).TaskStart(StationRunMode.自动准备);//first run the thread
                    this.Btn_Start.Enabled = false;
                    this.Btn_Stop.Enabled  = true;
                    this.Btn_Pause.Enabled = true;
                }
            }
            else
            {
                if (PVar.AutoRunFlag == false)
                {
                    if (MessageBox.Show("确定开始复位?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        if (Gg.GetDi(0, Gg.InPutMMS0.紧急停止) == 1)
                        {
                            Globals.PostAlarmMachine(XAlarmLevel.STOP, (int)AlarmCode.急停, AlarmCategory.SYSTEM.ToString(), "急停中,复位异常结束!!");
                            Globals.addList("急停中,复位异常结束!!", Mycolor.ErrorRed);
                            return;
                        }
                        XTaskManager.Instance.FindTaskById((int)TasksId.Manchine).TaskReset();
                        if (Globals.settingMachineInfo.什么机器 == WhichMachine.MMS)
                        {
                            XTaskManager.Instance.FindTaskById((int)TasksId.MMS测试).TaskReset();
                        }
                        else
                        {
                            XTaskManager.Instance.FindTaskById((int)TasksId.测试).TaskReset();
                        }
                        FileLog.OperateLog("初始化");
                        this.Btn_Start.Enabled = true;
                        this.Btn_Stop.Enabled  = false;
                        this.Btn_Pause.Enabled = false;
                    }
                }
            }
            PVar.IsSysEmcStop = false;
        }
コード例 #3
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        if (Once == false)
                        {
                            if (BVar.FileRorW.ReadINI("Material_index", "是否片料", "有", PVar.PublicParPath) == "有")
                            {
                                StaWork.IsHavePianliao = true;
                            }
                            else
                            {
                                StaWork.IsHavePianliao = false;
                            }
                        }
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        //StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (StaWork.State == false && StaWork.Enable)
                    {
                        StaWork.State = true;
                        TimeOut       = API.GetTickCount();
                        StaWork.Step  = 30;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 500)
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 10;
                        }
                    }
                    break;

                case 30:
                    Once = true;
                    if (StaWork.IsHavePianliao)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 10;
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 40;
                    }
                    break;

                case 40:
                    //判断料仓有无物料
                    if (Gg.GetDi(0, Gg.InPut0.片料到位检测) == 1)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 60;
                    }
                    else
                    {
                    }
                    break;

                case 60:
                    Gg.SetExDo(0, 0, Gg.OutPut2.夹上摸气缸, 1);
                    Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0);
                    Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸左, 1);
                    Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸右, 1);
                    Gg.SetExDo(0, 0, Gg.OutPut2.拉料无杆干气缸, 0);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 70;
                    break;

                case 70:
                    if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 1 && Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 0 &&
                        Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0 &&
                        Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸左伸出) == 1 && Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸右伸出) == 1 &&
                        Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸左) == 1 && Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸右) == 0)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 80;
                    }
                    if (API.GetTickCount() - TimeOut > 2000)
                    {
                        if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 0 || Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 1)
                        {
                            AddList("夹上摸气缸伸出信号异常,请检查!");
                            ShowList("夹上摸气缸伸出信号异常,请检查!");
                        }
                        if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1)
                        {
                            AddList("撕摸升降气缸缩回信号异常,请检查!");
                            ShowList("撕摸升降气缸缩回信号异常,请检查!");
                        }
                        if (Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸左伸出) == 0)
                        {
                            AddList("片料夹紧气缸左伸出信号异常,请检查!");
                            ShowList("片料夹紧气缸左伸出信号异常,请检查!");
                        }
                        if (Gg.GetExDi(0, Gg.InPut2.片料夹紧气缸右伸出) == 0)
                        {
                            AddList("片料夹紧气缸右伸出信号异常,请检查!");
                            ShowList("片料夹紧气缸右伸出信号异常,请检查!");
                        }
                        if (Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸左) == 0 || Gg.GetExDi(0, Gg.InPut2.拉料无杆干气缸右) == 1)
                        {
                            AddList("拉料无杆干气缸左信号异常,请检查!");
                            ShowList("拉料无杆干气缸左信号异常,请检查!");
                        }
                        TimeOut      = API.GetTickCount();
                        BufferStep   = 70;
                        StaWork.Step = 8000;
                    }
                    break;

                case 80:
                    //取片料马达和拉料马达回到初始位置
                    Gg.AbsMotion(0, BVar.S2G_Y, mFunction.Pos.TeachAxis1[3, 0], PVar.ParAxis.Speed[BVar.S2G_Y]);
                    Gg.AbsMotion(0, BVar.S2L_Z, mFunction.Pos.TeachAxis3[3, 3], PVar.ParAxis.Speed[BVar.S2L_Z]);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 90;
                    break;

                case 90:
                    if (Gg.ZSPD(0, BVar.S2G_Y) && Gg.ZSPD(0, BVar.S2L_Z))
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 100;
                    }
                    break;

                case 100:
                    Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 1);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 110;
                    break;

                case 110:
                    if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0);
                        Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 1);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 120;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("撕摸升降气缸伸出信号异常,请检查!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 110;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

                case 120:
                    if (Gg.GetDi(0, Gg.InPut0.取片料真空检测) == 1)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.夹上摸气缸, 0);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 130;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("取片料真空检测信号异常,请检查!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 120;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

                case 130:
                    if (Gg.GetExDi(0, Gg.InPut2.夹上摸气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.夹上摸气缸伸出) == 0)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 140;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("夹上摸气缸缩回测信号异常,请检查!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 130;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

                case 140:
                    if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0)
                    {
                        Gg.AbsMotion(0, BVar.S2G_Y, mFunction.Pos.TeachAxis1[3, 1], PVar.ParAxis.Speed[BVar.S2G_Y]);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 150;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("撕摸升降气缸缩回信号异常,请检查!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 140;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

                case 150:
                    if (Gg.ZSPD(0, BVar.S2G_Y))
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 1);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 160;
                    }
                    break;

                case 160:
                    if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0);
                        Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 1);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 120;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("撕摸升降气缸伸出信号异常,请检查!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 110;
                            StaWork.Step = 8000;
                        }
                    }
                    break;


                case 23320:
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 100;
                    break;

                case 800:
                    StaWork.State = false;
                    StaWork.Step  = 10;
                    break;

                case 1000:
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    PVar.IsSystemOnPauseMode                        = true;
                    PVar.MacHold                                    = true;
                    PVar.Stop_Flag                                  = false;
                    Frm_Main.fMain.Btn_Start.Enabled                = false;
                    Frm_Main.fMain.Btn_Pause.Enabled                = true;
                    Frm_Main.fMain.Btn_Stop.Enabled                 = false;
                    Frm_Main.fMain.Btn_Start.BZ_BackColor           = PVar.BZColor_UnselectedBtn;
                    Frm_Main.fMain.Btn_Pause.BZ_BackColor           = PVar.BZColor_SelectedEndBtn;
                    Frm_Main.fMain.Btn_Stop.BZ_BackColor            = PVar.BZColor_UnselectedBtn;
                    Frm_Engineering.fEngineering.Auto_Timer.Enabled = false;
                    PVar.LampStatus                                 = 20;
                    StaWork.Step                                    = BufferStep;
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(exc.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
コード例 #4
0
        /// <summary>
        /// safe door /axis alarm
        /// </summary>
        private void AlarmReport()
        {
            #region 急停
            Globals.Invoker.SetCtl_BckColor(this.Btn_EMG, Gg.GetDi(0, Gg.InPutMMS0.紧急停止) == 1 ? Mycolor.Red : Color.LimeGreen);
            if (EmgSt.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.紧急停止) == 1))
            {
                EMG();
                if (ShowList != null)
                {
                    ShowList("紧急停止按下!");
                }
            }
            EmgSt.Update(Gg.GetDi(0, Gg.InPutMMS0.紧急停止) == 1);
            if (EmgSt.PLF)
            {
                //PVar.LampStatus = 50;
                Globals.addList("紧急停止松开!", Mycolor.Red);
            }
            #endregion

            #region 实时扫描 安全门 等
            Globals.Invoker.SetCtl_BckColor(this.CurtionSts, Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 1 ? Mycolor.Red : Color.LimeGreen);
            Globals.Invoker.SetCtl_BckColor(this.AirSts, Gg.GetDi(0, Gg.InPutMMS0.正气源感应表) == 1 ? Color.LimeGreen : Mycolor.Red);
            if (Globals.settingFunc.打开安全门 && PVar.Stop_Flag == false && PVar.MacHold == false && PVar.AutoRunFlag)
            {
                string tempStr  = "";
                string tempStr1 = "";
                if (Gg.GetDi(0, Gg.InPutMMS0.后安全门感应器) == 0)
                {
                    tempStr = "后安全门";
                }
                if (Gg.GetDi(0, Gg.InPutMMS0.左安全门感应器) == 0)
                {
                    tempStr = "左安全门";
                }
                if (Gg.GetDi(0, Gg.InPutMMS0.右安全门感应器) == 0)
                {
                    tempStr = "右安全门";
                }
                if (!string.IsNullOrEmpty(tempStr))
                {
                    PVar.MacHold   = true;
                    PVar.Stop_Flag = false;
                    if (ShowList != null)
                    {
                        ShowList("请关闭" + tempStr);
                    }
                    if (PauseClick != null)
                    {
                        PauseClick(true);
                    }
                    PVar.LampStatus = 20;
                }
                if (CurtionLDPF.Bool_LDP(Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 1))
                {
                    tempStr1 = "光栅触发!";
                }
                if (!string.IsNullOrEmpty(tempStr1))
                {
                    PVar.MacHold   = true;
                    PVar.Stop_Flag = false;
                    Globals.addList(tempStr1, Mycolor.ErrorRed);
                    if (ShowList != null)
                    {
                        ShowList(tempStr1);
                    }
                    if (PauseClick != null)
                    {
                        PauseClick(true);
                    }
                    PVar.LampStatus = 20;
                }
                //this.SafeDoorSts.Checked = string.IsNullOrEmpty(tempStr);
                this.CurtionSts.BackColor = string.IsNullOrEmpty(tempStr1) ? Mycolor.LimeGreen : Color.Red;
                this.AirSts.BackColor     = (Gg.GetDi(0, Gg.InPutMMS0.正气源感应表) == 1) ? Mycolor.LimeGreen : Color.Red;
            }

            #endregion

            #region 轴报警

            if (Gg.Get_AlarmDi(0, Gg.InAlarmMMS0.测试Y轴) == 1)
            {
                Globals.PostAlarmMachine(XAlarmLevel.STOP, (int)AlarmCode.Y伺服电机驱动器报警, AlarmCategory.SYSTEM.ToString(), "Y伺服电机驱动器报警");
            }
            if (Gg.GetLimitDi_F(0, (short)Gg.InAlarmMMS0.测试Y轴) == 1 && GoHome.Instance.Reset.Result)
            {
                Globals.PostAlarmMachine(XAlarmLevel.STOP, (int)AlarmCode.Y伺服电机驱动器报警, AlarmCategory.SYSTEM.ToString(), "Y伺服电机负极限报警");
            }
            if (Gg.GetLimitDi_Z(0, (short)Gg.InAlarmMMS0.测试Y轴) == 1 && GoHome.Instance.Reset.Result)
            {
                Globals.PostAlarmMachine(XAlarmLevel.STOP, (int)AlarmCode.Y伺服电机驱动器报警, AlarmCategory.SYSTEM.ToString(), "Y伺服电机正极限报警");
            }
            #endregion
        }
コード例 #5
0
        public void HomeSub()
        {
            switch (StepHome)
            {
            case 10:
                Reset.State = true;
                AddList("设备初始化开始,请等待!");
                Gg.SetDo(0, Gg.OutPut0.载具真空吸1, 0);
                Gg.SetDo(0, Gg.OutPut0.载具真空吸2, 0);
                Gg.SetDo(0, Gg.OutPut0.载具真空吸3, 0);
                Gg.SetDo(0, Gg.OutPut0.载具真空吸4, 0);
                Gg.SetDo(0, Gg.OutPut0.载具破真空1, 0);
                Gg.SetDo(0, Gg.OutPut0.载具破真空2, 0);
                Gg.SetDo(0, Gg.OutPut0.载具破真空3, 0);
                Gg.SetDo(0, Gg.OutPut0.载具破真空4, 0);

                Gg.SetDo(0, Gg.OutPut0.保压站刹车继电器, 0);
                Gg.SetDo(0, Gg.OutPut0.警示蜂鸣器, 0);
                Gg.SetDo(0, Gg.OutPut0.装配站刹车继电器, 0);

                Gg.SetDo(0, Gg.OutPut1.取料吸嘴破真空, 0);
                Gg.SetDo(0, Gg.OutPut1.取料吸嘴真空吸, 0);

                Gg.SetExDo(0, 0, Gg.OutPut2.NG蜂鸣器, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.NG指示灯, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.OK指示灯, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.除底摸平移气缸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.除底膜吸嘴气缸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.拉料无杆干气缸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸右, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.片料夹紧气缸左, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.取底膜破真空, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.取底膜真空吸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.取片料破真空, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.取片料真空吸, 0);
                Gg.SetExDo(0, 0, Gg.OutPut2.撕摸升降气缸, 0);

                ////界面
                Frm_Main.fMain.Btn_Stop.Enabled       = false;
                Frm_Main.fMain.Btn_Pause.Enabled      = false;
                Frm_Main.fMain.Btn_Stop.BZ_BackColor  = PVar.BZColor_UnselectedBtn;
                Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn;
                Frm_ProgressBar.IsShowProgresBar(true);
                InitTimeOut = API.GetTickCount();
                StepHome    = 20;
                break;

            case 20:
                Frm_ProgressBar.SetValueProgressBar(10);         //初始化进度条的进度更新显示
                if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 0 &&
                    Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 0 && Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 0 &&
                    Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 0
                    //&& Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 0
                    && Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 0 &&
                    Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 0 &&
                    Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 0)
                {
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 30;
                }

                if (API.GetTickCount() - InitTimeOut > 2000)
                {
                    if (Gg.GetDi(0, Gg.InPut0.载具真空检测1) == 1)
                    {
                        AddList("1#载具真空检测1异常,请检查!");
                        ShowList("1#载具真空检测1异常,请检查!");
                    }
                    if (Gg.GetDi(0, Gg.InPut0.载具真空检测2) == 1)
                    {
                        AddList("2#载具真空检测2异常,请检查!");
                        ShowList("2#载具真空检测2异常,请检查!");
                    }
                    if (Gg.GetDi(0, Gg.InPut0.载具真空检测3) == 1)
                    {
                        AddList("3#载具真空检测3异常,请检查!");
                        ShowList("3#载具真空检测3异常,请检查!");
                    }
                    if (Gg.GetDi(0, Gg.InPut0.载具真空检测4) == 1)
                    {
                        AddList("4#载具真空检测3异常,请检查!");
                        ShowList("4#载具真空检测3异常,请检查!");
                    }
                    if (Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.撕摸升降气缸伸出) == 1)
                    {
                        AddList("撕摸升降气缸缩回信号异常,请检查!");
                        ShowList("撕摸升降气缸缩回信号异常,请检查!");
                    }

                    //if (Gg.GetExDi(0, Gg.InPut2.复检气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.复检气缸伸出) == 1)
                    //    {
                    //    AddList("复检气缸缩回信号异常,请检查!");
                    //    ShowList("复检气缸缩回信号异常,请检查!");
                    //    }

                    if (Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 1)
                    {
                        AddList("保压升降气缸缩回信号异常,请检查!");
                        ShowList("保压升降气缸缩回信号异常,请检查!");
                    }

                    if (Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底摸平移气缸伸出) == 1)
                    {
                        AddList("除底摸平移气缸缩回信号异常,请检查!");
                        ShowList("除底摸平移气缸缩回信号异常,请检查!");
                    }

                    if (Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸缩回) == 0 || Gg.GetExDi(0, Gg.InPut2.除底膜吸嘴气缸伸出) == 1)
                    {
                        AddList("除底膜吸嘴气缸缩回信号异常,请检查!");
                        ShowList("除底膜吸嘴气缸缩回信号异常,请检查!");
                    }

                    StepHome = 1000;
                }
                break;

            case 30:
                AddList("组装Z轴开始回原点…");
                AddList("保压Z轴开始回原点…");
                GoHome.Instance.AxisHome[0, 3].Result = false;
                GoHome.Instance.AxisHome[0, 8].Result = false;
                GoHome.Instance.AxisHome[0, 3].Enable = true;
                GoHome.Instance.AxisHome[0, 8].Enable = true;
                GoHome.Instance.AxisHome[0, 3].Step   = 10;
                GoHome.Instance.AxisHome[0, 8].Step   = 10;
                InitTimeOut = API.GetTickCount();
                Frm_ProgressBar.SetValueProgressBar(30);
                StepHome = 40;
                break;

            case 40:
                GotoHome(0, 3, 20, -1000, 10, 1, 10);
                GotoHome(0, 8, 20, -1000, 10, 1, 10);
                if (GoHome.Instance.AxisHome[0, 3].Step == 0 && GoHome.Instance.AxisHome[0, 3].Enable)
                {
                    GoHome.Instance.AxisHome[0, 3].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 3].Result)
                    {
                        AddList("组装Z轴回原点成功!");
                    }
                    else
                    {
                        AddList("组装Z轴回原点失败!");
                        ShowList("组装Z轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 8].Step == 0 && GoHome.Instance.AxisHome[0, 8].Enable)
                {
                    GoHome.Instance.AxisHome[0, 8].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 8].Result)
                    {
                        AddList("保压Z轴回原点成功!");
                    }
                    else
                    {
                        AddList("保压Z轴回原点失败!");
                        ShowList("保压Z轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 3].Result && GoHome.Instance.AxisHome[0, 8].Result)
                {
                    Frm_ProgressBar.SetValueProgressBar(50);
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 50;
                }
                break;

            case 50:
                AddList("组装X轴开始回原点…");
                AddList("组装Y轴开始回原点…");
                AddList("组装R轴开始回原点…");
                GoHome.Instance.AxisHome[0, 1].Result = false;
                GoHome.Instance.AxisHome[0, 2].Result = false;
                GoHome.Instance.AxisHome[0, 4].Result = false;
                GoHome.Instance.AxisHome[0, 1].Enable = true;
                GoHome.Instance.AxisHome[0, 2].Enable = true;
                GoHome.Instance.AxisHome[0, 4].Enable = true;
                GoHome.Instance.AxisHome[0, 1].Step   = 10;
                GoHome.Instance.AxisHome[0, 2].Step   = 10;
                GoHome.Instance.AxisHome[0, 4].Step   = 10;
                InitTimeOut = API.GetTickCount();
                StepHome    = 60;
                break;

            case 60:
                GotoHome(0, 1, 20, -1000, 10, 1, 10);
                GotoHome(0, 2, 20, -1000, 10, 1, 10);
                GotoHome(0, 4, 20, -1000, 10, 1, 10);

                if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable)
                {
                    GoHome.Instance.AxisHome[0, 1].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 1].Result)
                    {
                        AddList("组装X轴回原点成功!");
                    }
                    else
                    {
                        AddList("组装X轴回原点失败!");
                        ShowList("组装X轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 2].Step == 0 && GoHome.Instance.AxisHome[0, 2].Enable)
                {
                    GoHome.Instance.AxisHome[0, 2].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 2].Result)
                    {
                        AddList("组装Y轴回原点成功!");
                    }
                    else
                    {
                        AddList("组装Y轴回原点失败!");
                        ShowList("组装Y轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 4].Step == 0 && GoHome.Instance.AxisHome[0, 4].Enable)
                {
                    GoHome.Instance.AxisHome[0, 4].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 4].Result)
                    {
                        AddList("组装R轴回原点成功!");
                    }
                    else
                    {
                        AddList("组装R轴回原点失败!");
                        ShowList("组装R轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 1].Result && GoHome.Instance.AxisHome[0, 2].Result && GoHome.Instance.AxisHome[0, 4].Result)
                {
                    Frm_ProgressBar.SetValueProgressBar(70);
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 70;
                }
                break;

            case 70:
                AddList("上料Z轴开始回原点…");
                AddList("平移Y轴开始回原点…");
                AddList("拉料Z轴开始回原点…");
                GoHome.Instance.AxisHome[0, 5].Result = false;
                GoHome.Instance.AxisHome[0, 6].Result = false;
                GoHome.Instance.AxisHome[0, 7].Result = false;
                GoHome.Instance.AxisHome[0, 5].Enable = true;
                GoHome.Instance.AxisHome[0, 6].Enable = true;
                GoHome.Instance.AxisHome[0, 7].Enable = true;
                GoHome.Instance.AxisHome[0, 5].Step   = 10;
                GoHome.Instance.AxisHome[0, 6].Step   = 10;
                GoHome.Instance.AxisHome[0, 7].Step   = 10;
                InitTimeOut = API.GetTickCount();
                StepHome    = 80;
                break;

            case 80:
                GotoHome(0, 5, 20, -1000, 10, 1, 10);
                GotoHome(0, 6, 20, -1000, 10, 1, 30);
                GotoHome(0, 7, 20, -1000, 10, 1, 10);

                if (GoHome.Instance.AxisHome[0, 5].Step == 0 && GoHome.Instance.AxisHome[0, 5].Enable)
                {
                    GoHome.Instance.AxisHome[0, 5].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 5].Result)
                    {
                        AddList("上料Z轴回原点成功!");
                    }
                    else
                    {
                        AddList("上料Z轴回原点失败!");
                        ShowList("上料Z轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 6].Step == 0 && GoHome.Instance.AxisHome[0, 6].Enable)
                {
                    GoHome.Instance.AxisHome[0, 6].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 6].Result)
                    {
                        AddList("平移Y轴回原点成功!");
                    }
                    else
                    {
                        AddList("平移Y轴回原点失败!");
                        ShowList("平移Y轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 7].Step == 0 && GoHome.Instance.AxisHome[0, 7].Enable)
                {
                    GoHome.Instance.AxisHome[0, 7].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 7].Result)
                    {
                        AddList("拉料Z轴回原点成功!");
                    }
                    else
                    {
                        AddList("拉料Z轴回原点失败!");
                        ShowList("拉料Z轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[0, 5].Result && GoHome.Instance.AxisHome[0, 6].Result && GoHome.Instance.AxisHome[0, 7].Result)
                {
                    Frm_ProgressBar.SetValueProgressBar(80);
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 90;
                }
                break;

            case 90:
                AddList("转盘R轴开始回原点…");
                GoHome.Instance.AxisHome[1, 2].Result = false;
                GoHome.Instance.AxisHome[1, 1].Enable = true;
                GoHome.Instance.AxisHome[1, 1].Step   = 10;
                InitTimeOut = API.GetTickCount();
                StepHome    = 100;
                break;

            case 100:
                GotoHome(1, 1, 30, -360, 5, mFunction.Pos.TeachAxis1[2, 0], 30);

                if (GoHome.Instance.AxisHome[1, 1].Step == 0 && GoHome.Instance.AxisHome[1, 1].Enable)
                {
                    GoHome.Instance.AxisHome[1, 1].Enable = false;
                    if (GoHome.Instance.AxisHome[1, 1].Result)
                    {
                        AddList("转盘R轴回原点成功!");
                    }
                    else
                    {
                        AddList("转盘R轴回原点失败!");
                        ShowList("转盘R轴回原点失败!");
                        StepHome = 1000;
                    }
                }

                if (GoHome.Instance.AxisHome[1, 1].Result)
                {
                    Frm_ProgressBar.SetValueProgressBar(90);
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 150;
                }
                break;

            case 150:
                AddList("各轴开始回待机位置…");
                //组装站
                Gg.AbsMotion(0, 1, mFunction.Pos.TeachAxis1[0, 0], 20);
                Gg.AbsMotion(0, 2, mFunction.Pos.TeachAxis2[0, 0], 20);
                Gg.AbsMotion(0, 3, mFunction.Pos.TeachAxis3[0, 0], 20);
                Gg.AbsMotion(0, 4, mFunction.Pos.TeachAxis4[0, 0], 20);

                //保压站
                Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 0], 20);    //保压初始位置
                Tools.AxisTmplPos[1, 1] = 0;

                //供料
                Gg.AbsMotion(0, 5, mFunction.Pos.TeachAxis2[3, 4], 50);    //供料起始位置
                Gg.AbsMotion(0, 6, mFunction.Pos.TeachAxis1[3, 6], 100);   //避让位置
                Gg.AbsMotion(0, 7, mFunction.Pos.TeachAxis3[3, 7], 50);    //换料位置

                InitTimeOut = API.GetTickCount();
                StepHome    = 160;
                break;

            case 160:
                if (Gg.ZSPD(0, 1) && Gg.ZSPD(0, 2) && Gg.ZSPD(0, 3) && Gg.ZSPD(0, 4) && Gg.ZSPD(0, 5) && Gg.ZSPD(0, 6) && Gg.ZSPD(0, 7) && Gg.ZSPD(0, 8) && Gg.ZSPD(1, 1))
                {
                    AddList("各轴回待机位置完成!");
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 170;
                }
                else
                {
                    if ((API.GetTickCount() - InitTimeOut) > 10000)
                    {
                        if (Gg.ZSPD(0, 1) == false)
                        {
                            AddList("组装X轴回待机位置失败!");
                            ShowList("组装X轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 2) == false)
                        {
                            AddList("组装Y轴回待机位置失败!");
                            ShowList("组装Y轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 3) == false)
                        {
                            AddList("组装Z轴回待机位置失败!");
                            ShowList("组装Z轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 4) == false)
                        {
                            AddList("组装R轴回待机位置失败!");
                            ShowList("组装R轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 5) == false)
                        {
                            AddList("上料Z轴回待机位置失败!");
                            ShowList("上料Z轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 6) == false)
                        {
                            AddList("平移Y轴回待机位置失败!");
                            ShowList("平移Y轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 7) == false)
                        {
                            AddList("拉料Z轴回待机位置失败!");
                            ShowList("拉料Z轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(0, 8) == false)
                        {
                            AddList("保压Z轴回待机位置失败!");
                            ShowList("保压Z轴回待机位置失败!");
                        }
                        if (Gg.ZSPD(1, 1) == false)
                        {
                            AddList("转盘R轴回待机位置失败!");
                            ShowList("转盘R轴回待机位置失败!");
                        }

                        StepHome = 1000;
                    }
                }
                break;

            case 170:
                if (API.GetTickCount() - InitTimeOut > 500)
                {
                    //gts.GT_SetPrfPos(1, 1, 0); //规划器置零
                    //gts.GT_SetEncPos(1, 1, 0); //编码器置零
                    //gts.GT_SynchAxisPos(1, 1 << 0); //将当前轴进行位置同步
                    InitTimeOut = API.GetTickCount();
                    StepHome    = 800;
                }
                break;

            case 800:
                AddList("初始化完成");
                ShowList("初始化完成");
                PVar.LampStatus    = 20;
                PVar.Stop_Flag     = true;
                PVar.AutoRunFlag   = false;
                PVar.MacHold       = false;
                PVar.CPKDoneCounts = 0;
                PVar.WorkMode      = 0;

                Frm_Main.fMain.Panel_CPK.Visible = false;
                Frm_Engineering.fEngineering.Btn_SelectMaterial.Enabled = true;

                //按钮初始化
                Frm_Main.fMain.Btn_Start.Enabled      = true;
                Frm_Main.fMain.Btn_Pause.Enabled      = false;
                Frm_Main.fMain.Btn_Stop.Enabled       = true;
                Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_SelectedBtn;       //'主页面初始化和自动运行按钮
                Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn;
                Frm_Main.fMain.Btn_Stop.BZ_BackColor  = PVar.BZColor_UnselectedBtn;

                Frm_Engineering.fEngineering.TabPage3.Parent = Frm_Engineering.fEngineering.TabControl1;
                Frm_Engineering.fEngineering.TabPage4.Parent = Frm_Engineering.fEngineering.TabControl1;

                Frm_ProgressBar.IsShowProgresBar(false);         //'初始化进度条显示
                Frm_Engineering.fEngineering.Home_Timer.Enabled = false;
                for (int i = 0; i <= 4; i++)
                {
                    PVar.Sta_Work[i].State     = false;
                    PVar.Sta_Work[i].Result    = false;
                    PVar.Sta_Work[i].IsHaveHSG = false;
                    PVar.Sta_Work[i].Step      = 0;
                }
                Mod_ErrorCode.CheckSystemTimeStep = 0;
                GoHome.Instance.Reset.State       = false;
                GoHome.Instance.Reset.Result      = true;
                StepHome = 0;
                break;

            case 1000:
                PVar.LampStatus = 10;
                PVar.MacHold    = false;
                PVar.Stop_Flag  = true;
                Frm_Engineering.fEngineering.Btn_SelectMaterial.Enabled = false;
                //按钮初始化
                Frm_Main.fMain.Btn_Start.Enabled      = true;
                Frm_Main.fMain.Btn_Pause.Enabled      = false;
                Frm_Main.fMain.Btn_Stop.Enabled       = false;
                Frm_Main.fMain.Btn_Start.BZ_BackColor = PVar.BZColor_UnselectedBtn;       //主页面初始化和自动运行按钮
                Frm_Main.fMain.Btn_Pause.BZ_BackColor = PVar.BZColor_UnselectedBtn;
                Frm_Main.fMain.Btn_Stop.BZ_BackColor  = PVar.BZColor_SelectedEndBtn;

                Frm_Engineering.fEngineering.Home_Timer.Enabled = false;
                Frm_ProgressBar.IsShowProgresBar(false);         //初始化进度条显示
                GoHome.Instance.Reset.Result = false;
                GoHome.Instance.Reset.State  = false;
                StepHome = 0;
                break;
            }
        }
コード例 #6
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        PVar.Sta_Work[1].IsHaveHSG = false;
                        StaWork.Result             = false;
                        StaWork.State = false;
                        StaWork.Step  = 20;
                        //PVar.Sta_Work[1].Step = 20;
                    }
                    break;

                case 20:
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (StaWork.State == false && Gg.GetDi(0, Gg.InPut0.放料光纤感应) == 1 && Gg.GetDi(0, Gg.InPut0.安全光幕) == 0)
                        {
                            AddList("光幕启动开始!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            if (API.GetTickCount() - TimeOut > 1000)
                            {
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else
                    {
                        if (StaWork.State == false)
                        {
                            AddList("光幕启动开始!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            if (API.GetTickCount() - TimeOut > 1000)
                            {
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    break;


                case 30:
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (Gg.GetDi(0, Gg.InPut0.放料光纤感应) == 1 && Gg.GetDi(0, Gg.InPut0.安全光幕) == 1)
                        {
                            if (BVar.ProductTakeOut)
                            {
                                AddList("启动OK!");

                                //根据载具编号打开相对应的真空吸
                                BVar.OpenedVacumeNo = OpenFixtureVocume();
                                TimeOut             = API.GetTickCount();
                                StaWork.Step        = 40;
                            }
                            else
                            {
                                AddList("请先取出产品!");
                                ShowList("请先取出产品!");
                                //蜂鸣器
                                PVar.Ring_EN = true;
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 1000;
                            }
                        }
                        else
                        {
                            if (Gg.GetDi(0, Gg.InPut0.放料光纤感应) == 0 && Gg.GetDi(0, Gg.InPut0.安全光幕) == 1)
                            {
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else
                    {
                        AddList("启动OK!");
                        //根据载具编号打开相对应的真空吸
                        //BVar.OpenedVacumeNo = OpenFixtureVocume();
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 50;
                    }
                    break;

                case 40:
                    if (API.GetTickCount() - TimeOut > 1000)    //延时1秒,等待真空吸信号
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (Gg.GetDi(0, BVar.OpenedVacumeNo + 5) == 1)    //判断真空吸信号
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 60;
                        }
                        else
                        {
                            if (API.GetTickCount() - TimeOut > 2000)
                            {
                                AddList("HSG真空吸没达到检测值,请检查产品是否放好!");
                                ShowList("HSG真空吸没达到检测值,请检查产品是否放好!");
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 1000;
                            }
                        }
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 60;
                    }
                    break;

                case 60:    //等待所有工位结束工作
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (PVar.Stop_Flag == false)
                        {
                            if (Gg.GetDi(0, Gg.InPut0.安全光幕) == 1 && Gg.GetDi(0, BVar.OpenedVacumeNo + 5) == 1 && PVar.Sta_Work[2].State == false && PVar.Sta_Work[3].State == false && PVar.Sta_Work[4].State == false)
                            {
                                StaWork.State = true;
                                CT_Start      = true;
                                PVar.Sta_Work[1].IsHaveHSG = true;
                                Frm_Engineering.fEngineering.OvalShape_Sta0.BackColor = Color.DarkOrange;
                                Frm_Engineering.fEngineering.Chk_StaRound.BackColor   = Color.DarkOrange;
                                if (Gg.GetPrfPos(1, 1) > 300)       //int类型最大值为2^31-1=2147483647
                                {
                                    gts.GT_SetPrfPos(1, 1, 0);      //规划器置零
                                    gts.GT_SetEncPos(1, 1, 0);      //编码器置零
                                    gts.GT_SynchAxisPos(1, 1 << 0); //将当前轴进行位置同步
                                }

                                AddList("转盘开始转动!");
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 70;
                            }
                            else
                            {
                                if (Gg.GetDi(0, BVar.OpenedVacumeNo + 5) == 0)    //判断真空吸信号
                                {
                                    AddList("HSG真空吸力异常,启动失败,请重新启动!");
                                    ShowList("HSG真空吸力异常,启动失败,请重新启动!");
                                    TimeOut      = API.GetTickCount();
                                    StaWork.Step = 1000;
                                }
                            }
                        }
                        else
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    else
                    {
                        if (PVar.Stop_Flag == false)
                        {
                            if (Gg.GetDi(0, Gg.InPut0.安全光幕) == 1 && PVar.Sta_Work[2].State == false && PVar.Sta_Work[3].State == false && PVar.Sta_Work[4].State == false)
                            {
                                StaWork.State = true;
                                CT_Start      = true;
                                PVar.Sta_Work[1].IsHaveHSG = true;
                                Frm_Engineering.fEngineering.OvalShape_Sta0.BackColor = Color.DarkOrange;
                                Frm_Engineering.fEngineering.Chk_StaRound.BackColor   = Color.DarkOrange;
                                if (Gg.GetPrfPosmm(1, 1) > 300)     //int类型最大值为2^31-1=2147483647
                                {
                                    gts.GT_SetPrfPos(1, 1, 0);      //规划器置零
                                    gts.GT_SetEncPos(1, 1, 0);      //编码器置零
                                    gts.GT_SynchAxisPos(1, 1 << 0); //将当前轴进行位置同步
                                }

                                AddList("转盘开始转动!");
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 70;
                            }
                        }
                        else
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 70:
                    StationR_State();
                    Gg.StepMotion(1, 1, PVar.ParAxis.Speed[9], 90, "+");
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 80;
                    break;

                case 80:
                    if (Gg.ZSPD(1, 1))
                    {
                        Frm_Engineering.fEngineering.OvalShape_Sta0.BackColor = Color.FromArgb(192, 255, 192);
                        Frm_Engineering.fEngineering.Chk_StaRound.BackColor   = Color.FromArgb(192, 255, 192);
                        AddList("转盘转动到位!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 90;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 10000)
                        {
                            AddList("转盘转动超时!");
                            ShowList("转盘转动超时!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 10000;
                        }
                    }
                    break;

                case 90:
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 800;
                    break;

                case 800:
                    StaWork.Result = true;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;

                case 1000:
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;

                //严重错误,急停处理
                case 10000:
                    Frm_Engineering.fEngineering.MacStop();
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(exc.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
コード例 #7
0
        /// <summary>
        /// 自动运行
        /// </summary>

        private void AutoRun()
        {
            #region Switch
            switch (AutoRunstep)
            {
            case 10:
                SetStep("CLEAR", Mycolor.None);
                TaskIsWorking = true;
                EventShowResult(EnumShowResult.Empty);
                SetStep("测试工站开始...", Mycolor.None);
                AutoRunstep = 20;
                break;

                #region run to test postion
            case 20:    //运动到测试位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut = API.GetTickCount();
                SetStep("测试Y轴运动到测试点开始", Mycolor.None);
                AutoRunstep = 30;
                break;

            case 30:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试Y轴运动到达测试位置", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 70 : 40;
                }
                break;

            case 40:
                Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1);
                SetStep("定位气缸打开", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 50;
                break;

            case 50:
                if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1)
                {
                    SetStep("定位气缸到定位位置", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 60;
                }
                else if (API.GetTickCount() - TimeOut > 2000)
                {
                    SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed);
                    PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常");
                    AutoRunstep = 8000;
                }
                break;

            case 60:
                if (API.GetTickCount() - TimeOut > 300)
                {
                    SetStep("延时300ms", Mycolor.None);
                    AutoRunstep = 70;
                }
                break;

                #endregion
                #region start test & collect data
            case 70:
                //if (Globals.settingFunc.打开SSH通信 && Globals.SSHconnSt)//SSH打开,且SSH连接成功!
            {
                //SSH.Instance.ExecuteCommand("/Users/gdlocal/Desktop/MMS/" + Globals.settingPara.SSH脚本名字);//运行mini脚本
                SetStep("Send SSH command-start to move Motor!", Mycolor.None);
                DAQ.Instance.PCI9222StartCollect();        //开始收集高度数据
                SetStep("测试开始,开始收集数据", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 80;
            }
                //else
                //{
                //    SetStep("SSH功能没打开,或SSH连接失败!", Mycolor.ErrorRed);
                //    SetStep("请确定SSH,退出测试!", Mycolor.ErrorRed);
                //    TimeOut = API.GetTickCount();
                //    AutoRunstep = 290;
                //}
                break;

            case 80:
                //if (API.GetTickCount() - TimeOut > Globals.settingPara.测试超时)
                if (API.GetTickCount() - TimeOut > 2000)
                {
                    SetStep("测试超时,退出测试!", Mycolor.ErrorRed);
                    TimeOut = API.GetTickCount();
                    DAQ.Instance.PCI9222StopCollect();
                    AutoRunstep = 90;
                }
                //if (Globals.SSHstring.Contains("Motor Run Complete"))//SSH feedback string
                //{
                //    SetStep("收到SSH的Motor Run Complete,测试结束!", Mycolor.None);
                //    DAQ.Instance.PCI9222Clear();//stop collect the 9222 data
                //    TimeOut = API.GetTickCount();
                //    AutoRunstep = 90;
                //}
                break;

            case 90:    //save the raw data
                ls.Clear();
                string[] stringheader = new string[] { "Time", "laer_p0", "laer_p1", "laer_p2", "laer_p3", "laer_p4" };
                ls.Add(stringheader);
                for (int i = 0; i < DAQ.Instance.listArray[0].Count - 2; i++)            //最后两组数据不要
                {
                    string[] strarr = new string[6];
                    strarr[0] = DAQ.Instance.listArray[0][i].X.ToString();    //time
                    strarr[1] = DAQ.Instance.listArray[0][i].Y.ToString();    //laser_p0
                    strarr[2] = DAQ.Instance.listArray[1][i].Y.ToString();    //laser_p1
                    strarr[3] = DAQ.Instance.listArray[2][i].Y.ToString();    //laser_p2
                    strarr[4] = DAQ.Instance.listArray[3][i].Y.ToString();    //laser_p3
                    strarr[5] = DAQ.Instance.listArray[4][i].Y.ToString();    //laser_p4
                    ls.Add(strarr);
                }
                string path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\RAW Displacement Data\\"
                              + DateTime.Now.ToString("yyyyMMdd") + "\\";
                if (System.IO.Directory.Exists(path) == false)
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                Globals.csv.WriteCSV(path + DataManager.Instance.CurrentCheckData.SN + "_" + DateTime.Now.ToString("HH_mm_ss_fff") + "_raw.csv", ls);
                ls.Clear();
                AutoRunstep = 100;
                break;

            case 100:
                AutoRunstep = 110;
                break;

            case 110:
                AutoRunstep = 120;
                break;

            case 120:
                AutoRunstep = 200;
                break;

            case 200:
                AutoRunstep = 210;
                break;

            case 210:
                SetStep("显示测试数据", Mycolor.None);
                #region 产生数据 1tray
                //  "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis"
                DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd");
                DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss");
                Random rd   = new Random();
                double m_A  = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00;
                double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00;
                double m_x  = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;
                double m_y  = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;

                if (tempi % 2 == 1)
                {
                    DataManager.Instance.CurrentCheckData.PASS     = true;
                    DataManager.Instance.CurrentCheckData.PDCAPASS = true;
                    SetStep("the result is Passed", Color.LimeGreen);
                    EventShowResult(EnumShowResult.OK);
                    DataManager.Instance.currentyield.AddOneResult(true);    //update the current yield and month yield
                }
                else
                {
                    DataManager.Instance.CurrentCheckData.PASS     = false;
                    DataManager.Instance.CurrentCheckData.PDCAPASS = false;
                    SetStep("the result is Failed", Color.Red);
                    EventShowResult(EnumShowResult.NG);
                    DataManager.Instance.currentyield.AddOneResult(false);                                                                    //update the current yield and month yield
                }
                DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString()); //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西
                DataManager.Instance.uph.UPHupdate();                                                                                         //UPH update by hour

                if (OnCurrentInf != null)
                {
                    OnCurrentInf(DataManager.Instance.CurrentCheckData);                          //给工程界面的数据显示
                }
                if (OnFlashDataPage != null)
                {
                    OnFlashDataPage();
                }
                tempi++;

                #endregion
                AutoRunstep = 220;
                break;

            case 220:    //PDCA
                DataManager.Instance.CurrentCheckData.Operator_ID  = "0";
                DataManager.Instance.CurrentCheckData.Mode         = "0";
                DataManager.Instance.CurrentCheckData.TestSeriesID = "'201805070859";
                DataManager.Instance.CurrentCheckData.Prioriyt     = "0";
                PDCA_data[0] = DataManager.Instance.CurrentCheckData.Mod_Brc_X.ToString();
                PDCA_data[1] = DataManager.Instance.CurrentCheckData.Mod_Brc_Y.ToString();
                PDCA_data[2] = DataManager.Instance.CurrentCheckData.Mod_Brc_A.ToString();
                PDCA_data[3] = DataManager.Instance.CurrentCheckData.Mod_Brc_CC.ToString();
                PDCA_data[4] = DataManager.Instance.CurrentCheckData.Operator_ID.ToString();
                PDCA_data[5] = DataManager.Instance.CurrentCheckData.Mode.ToString();
                PDCA_data[6] = DataManager.Instance.CurrentCheckData.TestSeriesID.ToString();
                PDCA_data[7] = DataManager.Instance.CurrentCheckData.Prioriyt.ToString();
                PDCA_Step    = 10;
                AutoRunstep  = 240;
                break;

            case 230:    //PDCA
                if (PDCA_Bali(PDCA_data) == FunctionStatus.Finish)
                {
                    DataManager.Instance.CurrentCheckData.PDCAPASS = true;
                    AutoRunstep = 240;
                }
                else if (PDCA_Bali(PDCA_data) == FunctionStatus.Error)
                {
                    DataManager.Instance.CurrentCheckData.PDCAPASS = false;
                    AutoRunstep = 240;
                }
                break;

            case 240:
                #region 从测试数据中取值,保留生产数据
                path = PVar.BZ_DataPath + "MMS Data-" + Globals.settingMachineInfo.机器编号 + "\\PDCA Data\\"
                       + DateTime.Now.ToString("yyyyMM") + "\\";
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Clear();
                stringBuilder.Append("" + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartDate + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.StartTime + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.SN + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.PASS + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.PDCAPASS + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_X + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_Y + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_A + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mod_Brc_CC + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Operator_ID + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Mode + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.TestSeriesID + ",");
                stringBuilder.Append(DataManager.Instance.CurrentCheckData.Prioriyt + ",");
                string pathtemp = path + DateTime.Now.ToString("yyyyMMdd") + "_PDCA_Data.csv";
                #region save the csv header
                if (File.Exists(pathtemp) == false)
                {
                    StringBuilder stringBuilderHeader = new StringBuilder();
                    stringBuilderHeader.Clear();
                    stringBuilderHeader.Append(" ,StartDate,StartTime,SN,Result,PDCA_Result,X,Y,A,CC,Operator_ID,Mode,TestSeriesID,Prioriyt,\t\n");
                    stringBuilderHeader.Append("Upper Limit,NA,NA,NA,NA,NA,1,2,3,4,\t\n");
                    stringBuilderHeader.Append("Lower Limit,NA,NA,NA,NA,NA,-1,-2,-3,-4,\t\n");
                    stringBuilderHeader.Append("Units,NA,NA,NA,NA,NA,mm,mm,mm,mm,");
                    CsvServer.Instance.WriteLine(pathtemp, stringBuilderHeader.ToString());
                    stringBuilderHeader.Clear();
                }
                #endregion
                CsvServer.Instance.WriteLine(pathtemp, stringBuilder.ToString());
                stringBuilder.Clear();
                #endregion
                AutoRunstep = 290;
                break;

            case 290:
                DAQ.Instance.PCI9222StopCollect();
                AutoRunstep = 300;
                break;

                #endregion
                #region back to wait postion
            case 300:
                Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0);
                SetStep("定位气缸复位......", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM) ? 320 : 310;
                break;

            case 310:
                if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1)
                {
                    SetStep("定位气缸在缩回位置", Mycolor.None);
                    AutoRunstep = 320;
                }
                else if (API.GetTickCount() - TimeOut > 2000)
                {
                    SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed);
                    PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常");
                    AutoRunstep = 8000;
                }
                break;

            case 320:    //等待位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 330;
                break;

            case 330:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试y轴运动到初始位置成功…", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 2000;
                }
                break;

                #endregion
            case 2000:
                StaStop = false;
                StopWatch_Stop();    //stop the CT count
                AutoRunstep   = 0;
                TaskIsWorking = false;
                SetStep("SAVE", Mycolor.None);
                PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST");     //for errorcode
                break;

            case 8000:
                DAQ.Instance.PCI9222Clear();
                SetStep("此步为异常,退出循环", Mycolor.None);
                AutoRunstep = 0;
                StopWatch_Stop();               //stop the CT count
                TaskIsWorking = false;
                SetStep("SAVE", Mycolor.None);
                return;
            }
            SetStepNum(AutoRunstep);
            Task_StopWatchElapsedMilliseconds();//获取CT
            #endregion
        }
コード例 #8
0
        /// <summary>
        /// 空跑
        /// </summary>
        private void DryRun()
        {
            #region Switch
            switch (AutoRunstep)
            {
            case 10:
                SetStep("CLEAR", Mycolor.None);
                TaskIsWorking = true;
                EventShowResult(EnumShowResult.Empty);
                SetStep("AutoRun Setp10", Mycolor.None);
                AutoRunstep = 20;
                break;

            case 20:
                SetStep("AutoRun Setp20", Mycolor.None);
                AutoRunstep = 30;
                break;

            case 30:
                Thread.Sleep(1);
                SetStep("AutoRun Setp30", Mycolor.None);
                AutoRunstep = 40;
                break;

            case 40:
                Thread.Sleep(10);
                SetStep("AutoRun Setp40", Mycolor.None);
                AutoRunstep = 50;
                break;

            case 50:    //等待位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 60;
                break;

            case 60:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试y轴运动到初始位置成功…", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 70;
                }
                break;

            case 70:
                if (API.GetTickCount() - TimeOut > 300)
                {
                    AutoRunstep = 80;
                }
                break;

            case 80:    //测试位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 2], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 90;
                break;

            case 90:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试y轴运动到测试位置成功…", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 100;
                }
                break;

            case 100:
                if (API.GetTickCount() - TimeOut > 300)
                {
                    AutoRunstep = 110;
                }
                break;

            case 110:
                Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 1);
                SetStep("定位气缸打开......", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 120;
                break;

            case 120:
                if (Gg.GetDi(0, Gg.InPutMMS0.气缸到位感应器) == 1)
                {
                    SetStep("定位气缸到定位位置", Mycolor.None);
                    AutoRunstep = 150;
                }
                else if (API.GetTickCount() - TimeOut > 2000)
                {
                    SetStep("定位气缸缩到定位位置信号异常!", Mycolor.ErrorRed);
                    PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸伸出信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸伸出信号异常");
                    AutoRunstep = 8000;
                }
                break;

            case 150:
                SetStep("测试开始.....", Mycolor.None);
                Thread.Sleep(2000);
                AutoRunstep = 180;
                break;

            case 180:
                Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0);
                SetStep("定位气缸复位......", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 190;
                break;

            case 190:
                if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1)
                {
                    SetStep("定位气缸在缩回位置", Mycolor.None);
                    AutoRunstep = 200;
                }
                else if (API.GetTickCount() - TimeOut > 2000)
                {
                    SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed);
                    PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常");
                    AutoRunstep = 8000;
                }
                break;

            case 200:
                uint pck;
                uint pck2;
                gts.GT_GetClockHighPrecision(0, out pck);
                Thread.Sleep(5);
                gts.GT_GetClockHighPrecision(0, out pck2);
                uint ctt = pck2 - pck;
                SetStep("AutoRun Setp60", Mycolor.None);
                AutoRunstep = 210;
                break;

            case 210:
                Thread.Sleep(1000);
                SetStep("AutoRun Setp70", Mycolor.None);
                #region 产生数据 1tray
                //  "装配时间", "产品条码", "Result", "X", "Y", "A", "Dis"
                DataManager.Instance.CurrentCheckData.SN        = "SNXXXXXXX";
                DataManager.Instance.CurrentCheckData.StartDate = DateTime.Now.ToString("yyyy-MM-dd");
                DataManager.Instance.CurrentCheckData.StartTime = DateTime.Now.ToString("HH:mm:ss");
                Random rd = new Random();
                if (Globals.settingMachineInfo.什么机器 == WhichMachine.IPDM)
                {
                    double left1  = DataManager.Instance.CurrentCheckData.IPD_Left1 = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00;
                    double left2  = DataManager.Instance.CurrentCheckData.IPD_Right1 = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00;
                    double Right1 = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;
                    double Right2 = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;
                    DataManager.Instance.chartData.Adddata(left1.ToString() + "," + Right1.ToString() + "," + left2.ToString() + "," + Right2.ToString());     //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西
                }
                else
                {
                    double m_A  = DataManager.Instance.CurrentCheckData.Mod_Brc_A = rd.Next(-1, 1) / 10.0 + rd.Next(-1, 1) / 100.00;
                    double m_cc = DataManager.Instance.CurrentCheckData.Mod_Brc_CC = 22 + rd.Next(-1, 1) / 100.0 + rd.Next(0, 1) / 1000.00;
                    double m_x  = DataManager.Instance.CurrentCheckData.Mod_Brc_X = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;
                    double m_y  = DataManager.Instance.CurrentCheckData.Mod_Brc_Y = rd.Next(-1, 1) / 100.0 + rd.Next(-1, 1) / 1000.00;
                    DataManager.Instance.chartData.Adddata(m_A.ToString() + "," + m_x.ToString() + "," + m_y.ToString() + "," + m_cc.ToString());     //AddData为更新生产的CPK数据 AddNewData为UPH数据,包括很多东西
                }
                if (tempi % 2 == 1)
                {
                    DataManager.Instance.CurrentCheckData.PASS     = true;
                    DataManager.Instance.CurrentCheckData.PDCAPASS = true;
                    SetStep("the result is Passed", Color.LimeGreen);
                    EventShowResult(EnumShowResult.OK);
                    DataManager.Instance.currentyield.AddOneResult(true);    //update the current yield and month yield
                }
                else
                {
                    DataManager.Instance.CurrentCheckData.PASS     = false;
                    DataManager.Instance.CurrentCheckData.PDCAPASS = false;
                    SetStep("the result is Failed", Color.Red);
                    EventShowResult(EnumShowResult.NG);
                    DataManager.Instance.currentyield.AddOneResult(false);    //update the current yield and month yield
                }


                DataManager.Instance.uph.UPHupdate();                            //UPH update by hour

                if (OnCurrentInf != null)
                {
                    OnCurrentInf(DataManager.Instance.CurrentCheckData);                          //给工程界面的数据显示
                }
                if (OnFlashDataPage != null)
                {
                    OnFlashDataPage();
                }

                tempi++;

                #endregion
                AutoRunstep = 220;
                break;

            case 220:    //等待位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 230;
                break;

            case 230:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试y轴运动到初始位置成功…", Mycolor.None);
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 2000;
                }
                break;

            case 2000:
                Thread.Sleep(100);
                SetStep("AutoRun Setp80", Mycolor.None);
                StaStop = false;
                StopWatch_Stop();    //stop the CT count
                AutoRunstep   = 0;
                TaskIsWorking = false;
                SetStep("SAVE", Mycolor.None);
                PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST");     //for errorcode
                break;

            case 8000:
                Thread.Sleep(1);
                SetStep("AutoRun Setp8000", Mycolor.None);
                AutoRunstep = 0;
                StopWatch_Stop();    //stop the CT count
                TaskIsWorking = false;
                return;
            }
            SetStepNum(AutoRunstep);
            Task_StopWatchElapsedMilliseconds();//获取CT
            #endregion
        }
コード例 #9
0
        private FunctionStatus InitHoming()
        {
            switch (InitHomingStep)
            {
            case 10:
                AutoRunstep = 0;
                Gg.Set_Servo(0, BVar.MMSY, true);        //open servo on
                Thread.Sleep(200);
                SetStep("开始回零.......", Mycolor.None);
                InitHomingStep = 15;
                break;

            case 15:
                Gg.SetDo(0, Gg.OutPutMMS0.产品定位气缸电磁阀, 0);
                SetStep("定位气缸复位......", Mycolor.None);
                InitHomingDelay.InitialTime();
                InitHomingStep = 20;
                break;

            case 20:
                if (Gg.GetDi(0, Gg.InPutMMS0.气缸缩回位置感应器) == 1)
                {
                    SetStep("定位气缸在缩回位置", Mycolor.None);
                    InitHomingStep = 30;
                }
                else if (InitHomingDelay.TimeIsUp(2000))
                {
                    SetStep("定位气缸缩回位置信号异常!", Mycolor.ErrorRed);
                    PostTaskAlarm(XAlarmLevel.STOP, (int)AlarmCode.载具进出气缸缩回信号异常, AlarmCategory.MOTION.ToString(), "载具进出气缸缩回信号异常");
                    InitHomingStep = 8000;
                }
                break;

            case 30:
                SetStep("测试y轴开始回原点…", Mycolor.None);
                GoHome.Instance.AxisHome[0, 1].Result = false;
                GoHome.Instance.AxisHome[0, 1].Enable = true;
                GoHome.Instance.AxisHome[0, 1].Step   = 10;
                TimeOut        = API.GetTickCount();
                InitHomingStep = 40;
                break;

            case 40:
                GoHome.GotoHome(0, 1, 30, -1000, 5, 1, 10);
                if (GoHome.Instance.AxisHome[0, 1].Step == 0 && GoHome.Instance.AxisHome[0, 1].Enable)
                {
                    GoHome.Instance.AxisHome[0, 1].Enable = false;
                    if (GoHome.Instance.AxisHome[0, 1].Result)
                    {
                        SetStep("测试y轴回原点成功…", Mycolor.None);
                        InitHomingStep = 50;
                    }
                    else
                    {
                        SetStep("测试y轴回原点失败…", Mycolor.ErrorRed);
                        InitHomingStep = 8000;
                    }
                }
                break;

            case 50:    //等待位置
                Gg.AbsMotion(0, BVar.MMSY, mFunction.Pos.TeachAxis1[0, 0], PVar.ParAxis.Speed[BVar.MMSY]);
                TimeOut        = API.GetTickCount();
                InitHomingStep = 60;
                break;

            case 60:
                if (Gg.ZSPD(0, BVar.MMSY))
                {
                    SetStep("测试y轴运动到初始位置成功…", Mycolor.None);
                    InitHomingStep = 2000;
                }
                break;

            case 2000:
                InitHomingStep = 0;
                SetStep("MMS测试工站复位OK!", Mycolor.None);
                SetState(XTaskState.WAITRUN);
                SetStepNum(InitHomingStep);
                HomeOK          = true;
                PVar.LampStatus = 20;
                PostTaskAlarm(XAlarmLevel.RST, (int)AlarmCode.位, AlarmCategory.RESET.ToString(), "RST");         //for errorcode
                return(FunctionStatus.Finish);

            case 8000:
                InitHomingStep  = 0;
                PVar.LampStatus = 10;
                return(FunctionStatus.Error);
            }
            SetStepNum(InitHomingStep);
            return(FunctionStatus.Working);
        }
コード例 #10
0
        public static short mGetDi(short CardTag, short index)
        {
            //      CardIndex              CardInfo
            //控件  TabIndex  代表卡类型, Tag(A,B) A代表卡号,B代表模块序号(0-15);
            //CardType=0 固高卡自带IO,CardType=1 固高卡扩展IO。
            int    CardType    = 0;
            string CardInfo    = "0,0";
            short  CardIndex   = 0;
            short  CardNum     = 0;
            ushort ReturnStr   = 0;
            short  mGetDiValue = -1;

            switch (CardTag)
            {
            case 0:     //0号输入单元
                CardType = 0;
                CardInfo = "0,0";
                break;

            case 1:     //0号输入单元
                CardType = 0;
                CardInfo = "1,0";
                break;

            case 2:
                CardType = 1;
                CardInfo = "0,0";     //卡号,index
                break;

            case 3:
                CardType = 1;
                CardInfo = "0,1";     //卡号,index
                break;

            case 4:
                CardType = 1;
                CardInfo = "0,2";     //卡号,index
                break;
            }
            CardNum   = System.Convert.ToInt16(CardInfo.Substring(0, 1));
            CardIndex = System.Convert.ToInt16(CardInfo.Substring(CardInfo.Length - 1, 1));
            try
            {
                switch (CardType)
                {
                case 0:     //固高卡自带通用输入
                    mGetDiValue = Gg.GetDi(CardNum, index);
                    break;

                case 1:     //固高卡扩展输入
                    PVar.Rtn    = gts.GT_GetExtIoBitGts(CardNum, CardIndex, index, ref ReturnStr);
                    mGetDiValue = (short)Math.Abs(ReturnStr - 1);
                    break;
                }
            }
            catch (Exception)
            {
                mGetDiValue = -1;
            }
            return(mGetDiValue);
        }
コード例 #11
0
        private void AutoRun()
        {
            #region Swithch
            switch (AutoRunstep)
            {
            case 10:
                if (PVar.AutoRunFlag)
                {
                    StopWatch_Stop();
                    StopWatch_Reset();
                    AutoRunstep = 20;
                }
                break;

            case 20:    //double start
                if (Globals.Flag_ManualStart || Double_Hands_Start(1000, false))
                {
                    Globals.Flag_ManualStart = false;
                    Double_Hands_Start(1000, true);
                    SetStep("CLEAR", Mycolor.None);
                    SetStep("手动启动或双手启动开始", Mycolor.None);
                    TaskIsWorking = true;
                    StopWatch_Start();
                    AutoRunstep = 25;
                }
                break;

            case 25:
                if (Globals.settingFunc.启用空跑模式)      //空跑不需要条码
                {
                    AutoRunstep = 40;
                }
                else
                {
                    AutoRunstep = 30;
                }
                break;

            case 30:    //check the product sensor and check the fixtrue closed sensor
                if (Gg.GetDi(0, Gg.InPutMMS0.夹具到位金属感应器) == 0)
                {
                    SetStep("夹具到位金属感应器感应异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                if (Gg.GetDi(0, Gg.InPutMMS0.产品到位光纤感应器) == 0)
                {
                    SetStep("产品到位光纤感应器感应异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 40;
                break;

            case 40:    //check postion
                if ((Gg.GetEncPosmm(0, BVar.MMSY) - mFunction.Pos.TeachAxis1[0, 0]) > 0.05)
                {
                    SetStep("载具不在初始位置!请回零!", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 50;
                break;

            case 45:
                if (Gg.GetDi(0, Gg.InPutMMS0.安全光幕) == 1)
                {
                    SetStep("安全光幕异常", Mycolor.ErrorRed);
                    PVar.Ring_EN = true;    //buzzer
                    AutoRunstep  = 8000;
                    break;
                }
                AutoRunstep = 50;
                break;

            case 50:                            //check barcode
                if (Globals.settingFunc.启用空跑模式) //空跑不需要条码
                {
                    AutoRunstep = 80; break;
                }
                if (PageLogin.loginTp != loginType.Op)
                {
                    if ((Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length - 2 || Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length + 2))
                    {
                        SetStep("条码长度OK!", Mycolor.None);
                        DataManager.Instance.CurrentCheckData.SN = Globals.BarcodeSN;
                    }
                    else
                    {
                        SetStep("生成时间条码!", Mycolor.None);
                        DataManager.Instance.CurrentCheckData.SN = DateTime.Now.ToString("yyyMMdd_HHmmss");
                    }
                    TimeOut     = API.GetTickCount();
                    AutoRunstep = 80;
                }
                else    //op
                {
                    if ((Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length - 5 ||
                         Globals.BarcodeSN.Length >= Globals.settingPara.学习条码长度.Length + 5))  //OP mode ,need check the length of barcode
                    {
                        SetStep("条码长度OK!", Mycolor.None);
                        PVar.Ring_EN = true;    //buzzer
                        DataManager.Instance.CurrentCheckData.SN = Globals.BarcodeSN;
                        TimeOut     = API.GetTickCount();
                        AutoRunstep = 80;
                    }
                    else
                    {
                        SetStep("条码长度异常!", Mycolor.ErrorRed);
                        DataManager.Instance.CurrentCheckData.SN = "";
                        if (OnEngineerSN != null)
                        {
                            OnEngineerSN("");                          //让工程界面的clear SN, foucs on
                        }
                        AutoRunstep = 8000;
                    }
                }
                break;

            case 80:
                if (OnShowSth_OnSSH_Output != null)
                {
                    OnShowSth_OnSSH_Output("");                                    //clear SSHinfo
                }
                if (OnEngineerSN != null)
                {
                    OnEngineerSN("");                          //让工程界面的clear SN, foucs on
                }
                Globals.BarcodeSN = "";

                if (Globals.settingFunc.启用空跑模式)
                {
                    StopWatch_Reset();
                    StopWatch_Start();
                    SetStep("CLEAR", Mycolor.None);
                }
                StationRunMode _runmode = Globals.settingFunc.启用空跑模式 ? StationRunMode.空跑 : StationRunMode.自动运行;
                if (Globals.settingMachineInfo.什么机器 == WhichMachine.MMS)
                {
                    XTaskManager.Instance.FindTaskById((int)TasksId.MMS测试).TaskGo();
                }
                else
                {
                    XTaskManager.Instance.FindTaskById((int)TasksId.测试).TaskGo();
                }
                SetStep("每站自动开始", Mycolor.None);
                TimeOut     = API.GetTickCount();
                AutoRunstep = 90;
                break;

            case 90:
                if (Globals.settingMachineInfo.什么机器 == WhichMachine.MMS)
                {
                    if (XTaskManager.Instance.FindTaskById((int)TasksId.MMS测试).TaskIsWorking == false)
                    {
                        SetStep("自动单循环完成", Mycolor.None);
                        AutoRunstep = 100;
                    }
                }
                else
                {
                    if (XTaskManager.Instance.FindTaskById((int)TasksId.测试).TaskIsWorking == false)
                    {
                        SetStep("自动单循环完成", Mycolor.None);
                        AutoRunstep = 100;
                    }
                }

                if (API.GetTickCount() - TimeOut > 60000)
                {
                    SetStep("自动超时60S,退出主循环!!", Mycolor.ErrorRed);
                    AutoRunstep = 8000;
                }
                break;

            case 100:
                StopWatch_Stop();
                TaskIsWorking = false;
                AutoRunstep   = 10;  //正常结束
                if (Globals.settingFunc.启用空跑模式)
                {
                    SetStep("空跑模式,继续", Mycolor.ErrorRed);
                    Thread.Sleep(1000);
                    AutoRunstep = 80;
                    if (StaStop)    //如果点了停止按钮,把当前的Cycle完成
                    {
                        SetStep("停止中......", Mycolor.ErrorRed);
                        Globals.Flag_ManualStart = false;
                        StaStop     = false;
                        AutoRunstep = 10;
                    }
                }
                break;

            case 8000:
                StopWatch_Stop();
                TaskIsWorking = false;
                AutoRunstep   = 10;
                break;
            }
            SetStepNum(AutoRunstep);
            Task_StopWatchElapsedMilliseconds();//获取CT
            #endregion
        }