예제 #1
0
        /// <summary>
        /// 设备正常运行Log写入
        /// </summary>
        /// <param name="Msg"></param>
        /// <remarks></remarks>
        public static void WriteLog(string Msg)
        {
            string TempStr  = "";
            string TempStr1 = "";

            TempStr = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd");
            if (System.IO.Directory.Exists(TempStr))
            {
            }
            else
            {
                System.IO.Directory.CreateDirectory(TempStr);
            }
            TempStr  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_运行日志" + ".txt";
            TempStr1 = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + " " + Msg;
            FileRw.WriteDattxt(TempStr, TempStr1);
        }
예제 #2
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);
            }
        }
예제 #3
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        StaWork.Step  = 20;
                    }
                    break;

                case 20:
                    //本站工作状态,工站使能,本站是否有产品,转盘工作状态
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (StaWork.State == false && StaWork.Enable && StaWork.Result && StaWork.IsHaveHSG && PVar.Sta_Work[1].State == false)
                        {
                            StaWork.State  = true;
                            StaWork.Result = false;
                            //清空缓存的压力值
                            for (int i = PVar.Press.Count() - 1; i > 0; i--)
                            {
                                PVar.Press[i] = 0;
                            }
                            Command.Com2_Send(Command.压力控制打开);
                            Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 1);
                            AddList("复检开始开始!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            StaWork.Step = 10;
                        }
                    }
                    else
                    {
                        if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveHSG && PVar.Sta_Work[1].State == false)
                        {
                            StaWork.State  = true;
                            StaWork.Result = false;
                            //清空缓存的压力值
                            for (int i = PVar.Press.Count() - 1; i > 0; i--)
                            {
                                PVar.Press[i] = 0;
                            }
                            Command.Com2_Send(Command.压力控制打开);
                            Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 1);
                            AddList("复检开始开始!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                    }
                    break;

                case 30:
                    if (Gg.GetExDi(0, Gg.InPut2.保压升降气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.保压升降气缸伸出) == 1)
                    {
                        //AddList("保压升降气缸复位OK!");
                        Frm_Production.fProduction.Chart_Time.Enabled = true;
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 40;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("保压升降气缸伸出信号异常!");
                            ShowList("保压升降气缸伸出信号异常!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 40:
                    if (API.GetTickCount() - TimeOut > 100)
                    {
                        Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 1], PVar.ParAxis.Speed[BVar.S3_Z]);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    if (Gg.ZSPD(0, BVar.S3_Z))
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut2.保压升降气缸, 0);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 60;
                    }
                    break;

                case 60:
                    if (PVar.IsCOM2_Working)
                    {
                        //**保压位置+偏移值=终点最大行程
                        Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 1] + PVar.ParList.Data[22], PVar.ParList.Data[23]);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 70;
                    }
                    else
                    {
                        AddList("保压站压力传感器异常!");
                        ShowList("保压站压力传感器异常!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    break;

                case 70:
                    if (Gg.ZSPD(0, BVar.S3_Z))
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 80;
                    }
                    break;

                case 80:
                    if (API.GetTickCount() - TimeOut > PVar.ParList.Data[41] * 1000)
                    {
                        Gg.AbsMotion(0, 8, mFunction.Pos.TeachAxis1[1, 0], PVar.ParAxis.Speed[BVar.S3_Z]);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 90;
                    }
                    break;

                case 90:
                    if (Gg.ZSPD(0, BVar.S3_Z))
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 800;
                    }
                    break;

                case 800:
                    Frm_Production.fProduction.Chart_Time.Enabled = false;
                    StaWork.Enable = false;
                    StaWork.Result = true;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;

                case 1000:
                    StaWork.Enable = false;
                    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);
            }
        }
예제 #4
0
        public void Frm_L1Adddata()
        {
            int    tempRow    = 0;
            string Error_Str  = "";
            string Error_Str1 = "";

            try
            {
                //查找条码
                if (BarCodeData != "")
                {
                    Frm_L1Adddata_tempBarcode = BarCodeData.Trim();
                    BarCodeData = "";
                }
                else
                {
                    Frm_L1Adddata_tempBarcode = DateTime.Now.ToString("HH:mm:ss");
                }
                tempRow = FunctionSub.FindRowfromSN(Frm_L1Adddata_tempBarcode);

                if (tempRow == 100)                        //新的条码
                {
                    PVar.DataCount = PVar.DataCount % 100; //加到100则为0
                    while (true)
                    {
                        if (PVar.BarcodeArrayList[PVar.DataCount] != "")
                        {
                            if (PVar.BarcodeArrayList[PVar.DataCount] == BVar.ProData[2, 1] || PVar.BarcodeArrayList[PVar.DataCount] == BVar.ProData[3, 1])
                            {
                                PVar.DataCount++; //数据计数,便于datagrid数据显示
                                PVar.DataCount = PVar.DataCount % 100;
                            }
                            else
                            {
                                break;
                            }
                            Application.DoEvents();
                        }
                        else
                        {
                            break;
                        }
                    }
                    BVar.FileRorW.WriteINI("Data100Count", "Count", System.Convert.ToString(PVar.DataCount), PVar.ListDataIniPath);
                    tempRow         = PVar.DataCount;
                    tempTestData[0] = DateTime.Now.ToString("yyyy-MM-dd");
                    tempTestData[1] = DateTime.Now.ToString("HH:mm:ss");
                    tempTestData[2] = DateTime.Now.ToString(Frm_L1Adddata_tempBarcode);
                    PVar.BarcodeArrayList[tempRow] = Frm_L1Adddata_tempBarcode; //将条码存到数组缓存区
                    //---------------------
                    //记录:日期,时间,条码
                    //---------------------
                    for (int i = 0; i <= 2; i++)
                    {
                        BVar.FileRorW.WriteINI(tempRow.ToString(), PVar.DataGrid_CheckDataHeadName[i], tempTestData[i], PVar.ListDataIniPath); //写入本地
                        FunctionSub.Grid_TestData_Show(Frm_Engineering.fEngineering.DataGrid_CheckData, tempRow, i, tempTestData[i]);          //显示在工程界面上
                    }

                    try
                    {
                        Frm_Engineering.fEngineering.DataGrid_CheckData.CurrentCell            = Frm_Engineering.fEngineering.DataGrid_CheckData.Rows[tempRow].Cells[0];
                        Frm_Engineering.fEngineering.DataGrid_CheckData.Rows[tempRow].Selected = true;
                    }
                    catch (Exception)
                    {
                    }
                    PVar.DataCount++; //数据计数,便于datagrid数据显示
                }
                else
                {
                    tempTestData[0] = DateTime.Now.ToString("yyyy-MM-dd");
                    tempTestData[1] = DateTime.Now.ToString("HH:mm:ss");
                    tempTestData[2] = DateTime.Now.ToString(Frm_L1Adddata_tempBarcode);
                    PVar.BarcodeArrayList[tempRow] = Frm_L1Adddata_tempBarcode; //将条码存到数组缓存区
                    //---------------------
                    //记录:日期,时间,条码
                    //---------------------
                    for (int i = 0; i <= 2; i++)
                    {
                        BVar.FileRorW.WriteINI(tempRow.ToString(), PVar.DataGrid_CheckDataHeadName[i], tempTestData[i], PVar.ListDataIniPath); //写入本地
                        FunctionSub.Grid_TestData_Show(Frm_Engineering.fEngineering.DataGrid_CheckData, tempRow, i, tempTestData[i]);          //显示在工程界面上
                    }

                    try
                    {
                        Frm_Engineering.fEngineering.DataGrid_CheckData.CurrentCell            = Frm_Engineering.fEngineering.DataGrid_CheckData.Rows[tempRow].Cells[0];
                        Frm_Engineering.fEngineering.DataGrid_CheckData.Rows[tempRow].Selected = true;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception exc)
            {
                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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        //StaWork.Step = 20;
                    }
                    break;

                case 20:
                    //本站工作状态,工站使能,转盘工作状态,本站是否有产品
                    if (StaWork.State == false && StaWork.Enable && StaWork.Result && PVar.Sta_Work[1].State == false && PVar.Sta_Work[4].IsHaveHSG)
                    {
                        StaWork.State  = true;
                        StaWork.Result = false;
                        Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 0);
                        AddList("复检开始开始!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 30;
                    }
                    else
                    {
                        StaWork.Step = 10;
                    }
                    break;

                case 30:
                    if (Gg.GetExDi(0, Gg.InPut2.检气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut2.检气缸伸出) == 0)
                    {
                        //AddList("复检气缸复位OK!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 40;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("复检气缸缩回信号异常!");
                            ShowList("复检气缸缩回信号异常!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 40:
                    if (API.GetTickCount() - TimeOut > 1000)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    sRtn = Command.TCP_CCD2_Send(Command.检角度);
                    if (sRtn == 1)     //命令发送成功
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 60;
                    }
                    else if (sRtn == 2)     //网络链接异常
                    {
                        AddList("网络链接异常!");
                        ShowList("网络链接异常!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    break;


                case 60:
                    if (Command.CCD2_Resule && PVar.CCD2_Data[0] == Command.检角度)
                    {
                        AddList("复检角度数据收到!");
                        CCD_Vale[1].X     = Convert.ToDouble(PVar.CCD2_Data[1]);
                        CCD_Vale[1].Y     = Convert.ToDouble(PVar.CCD2_Data[2]);
                        CCD_Vale[1].T     = Convert.ToDouble(PVar.CCD2_Data[3]);
                        CCD_Vale[1].CC    = Convert.ToDouble(PVar.CCD2_Data[4]);
                        CCD_Vale[1].Judge = Convert.ToDouble(PVar.CCD2_Data[5]);

                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 70;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("等待复检角度数据超时!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 70:
                    if (CCD_Vale[1].Judge == 0)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 80;
                    }
                    else if (CCD_Vale[1].Judge == 1)
                    {
                        AddList("复检角度模型搜索错误!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    else
                    {
                        AddList("CCD复检角度其他异常!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    break;

                case 80:
                    Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 1);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 90;
                    break;

                case 90:
                    if (Gg.GetExDi(0, Gg.InPut2.检气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut2.检气缸伸出) == 1)
                    {
                        AddList("复检气缸伸出OK!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 100;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 4000)
                        {
                            AddList("复检气缸伸出信号异常!");
                            ShowList("复检气缸伸出信号异常!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 100:
                    if (API.GetTickCount() - TimeOut > 1000)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 110;
                    }
                    break;

                case 110:
                    sRtn = Command.TCP_CCD2_Send(Command.检同心度);
                    if (sRtn == 1)     //命令发送成功
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 120;
                    }
                    else if (sRtn == 2)     //网络链接异常
                    {
                        AddList("网络链接异常!");
                        ShowList("网络链接异常!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    break;


                case 120:
                    if (Command.CCD2_Resule && PVar.CCD2_Data[0] == Command.检同心度)
                    {
                        AddList("复检同心度数据收到!");
                        CCD_Vale[2].X     = Convert.ToDouble(PVar.CCD2_Data[1]);
                        CCD_Vale[2].Y     = Convert.ToDouble(PVar.CCD2_Data[2]);
                        CCD_Vale[2].T     = Convert.ToDouble(PVar.CCD2_Data[3]);
                        CCD_Vale[2].CC    = Convert.ToDouble(PVar.CCD2_Data[4]);
                        CCD_Vale[2].Judge = Convert.ToDouble(PVar.CCD2_Data[5]);

                        if (CCD_Vale[2].CC <= 0.05 && CCD_Vale[2].T <= 1)
                        {
                            BVar.ProData[4, 30] = "OK";
                        }
                        else
                        {
                            BVar.ProData[4, 30] = "NG";
                        }
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 130;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 2000)
                        {
                            AddList("等待复检同心度数据超时!");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 140:
                    if (CCD_Vale[2].Judge == 0)
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 150;
                    }
                    else if (CCD_Vale[2].Judge == 1)
                    {
                        AddList("复检角度模型搜索错误!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    else
                    {
                        AddList("CCD复检角度其他异常!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 1000;
                    }
                    break;

                case 150:
                    Gg.SetExDo(0, 0, Gg.OutPut2.检气缸, 0);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 300;
                    break;

                ////复检数据处理
                case 300:
                    if (BVar.ProData[4, 30] == "OK")
                    {
                        StaWork.Result = true;
                        Frm_Engineering.fEngineering.Label_NG_OK.Text                 = "OK";
                        Frm_Production.fProduction.DRB_YieldRetest.BZ_ResultText      = "OK";
                        Frm_Production.fProduction.DRB_YieldRetest.BZ_ResultBackColor = Color.FromArgb(111, 192, 64);
                        Gg.SetExDo(0, 0, Gg.OutPut2.OK指示灯, 1);
                        Gg.SetExDo(0, 0, Gg.OutPut2.NG指示灯, 0);
                        //Gg.SetExDo(0, 0, Gg.OutPut2.NG蜂鸣器, 0);
                    }
                    else
                    {
                        Frm_Engineering.fEngineering.Label_NG_OK.Text                 = "NG";
                        Frm_Production.fProduction.DRB_YieldRetest.BZ_ResultText      = "NG";
                        Frm_Production.fProduction.DRB_YieldRetest.BZ_ResultBackColor = Color.FromArgb(200, 37, 6);
                        Gg.SetExDo(0, 0, Gg.OutPut2.OK指示灯, 0);
                        Gg.SetExDo(0, 0, Gg.OutPut2.NG指示灯, 1);
                        //Gg.SetExDo(0, 0, Gg.OutPut2.NG蜂鸣器, 0);
                        PVar.Ring_EN = true;
                    }
                    Write_FinalData();
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 800;
                    break;

                case 800:
                    StaWork.Enable = false;
                    ////StaWork.Result = true; 做为最总结过判断
                    StaWork.State = false;
                    StaWork.Step  = 10;
                    break;

                case 1000:
                    StaWork.Enable = false;
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;
                }
            }
            catch (Exception ex)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(ex.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" + ex.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }