Ejemplo n.º 1
0
        private void MainUserNameDisplay()
        {
            FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "PassWord.dat", PVar.Login);
            MainUserName.Items.Add("OP");
            MainUserName.Items.Add("Administrator");
            for (var i = 0; i <= 20; i++)
            {
                if (PVar.Login.NewUser[i] != "OP" && PVar.Login.NewUser[i] != "Administrator")
                {
                    if (PVar.Login.NewUser[i] != "" && PVar.Login.NewUser[i] != null)
                    {
                        MainUserName.Items.Add(PVar.Login.NewUser[(int)i]);

                        if (Frm_Login.fLogin == null || Frm_Login.fLogin.IsDisposed)
                        {
                            Frm_Login.fLogin = new Frm_Login();
                        }
                        Frm_Login.fLogin.MainUserName.Items.Add(PVar.Login.NewUser[(int)i]);
                    }
                }
            }



            if (MainUserName.Items.Count > 0)
            {
                MainUserName.SelectedIndex = 0;
            }
        }
Ejemplo n.º 2
0
 private void UserListRefresh()
 {
     FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
     for (var i = 0; i <= 20; i++)
     {
         if (PVar.Login.NewUser[i] != "")
         {
             if (UserListBox.Items.Count > 0)
             {
                 for (var j = 0; j <= (UserListBox.Items.Count - 1); j++)
                 {
                     if (j <= (UserListBox.Items.Count - 1))
                     {
                         string ss;
                         string FF;
                         ss = System.Convert.ToString(UserListBox.Items[j]);
                         FF = System.Convert.ToString(Frm_Main.fMain.MainUserName.Items[j]);
                         if (ss == NewUserName.Text)
                         {
                             UserListBox.Items.Remove(PVar.Login.NewUser[(int)j]);
                             Frm_Main.fMain.MainUserName.Items.Remove(PVar.Login.NewUser[(int)j]);
                             Frm_Login.fLogin.MainUserName.Items.Remove(PVar.Login.NewUser[(int)j]);
                         }
                     }
                 }
             }
         }
     }
     NewUserName.Text = "";
     FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
 }
Ejemplo n.º 3
0
 private void UserDelete_Click(object sender, EventArgs e)
 {
     if (NewUserName.Text == "Engineering")
     {
         Interaction.MsgBox("无法删除工程师账号!", (int)Constants.vbOKCancel + Constants.vbInformation, "提示");
         return;
     }
     FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
     if (UserListBox.Items.Count > 0)
     {
         for (var i = 0; i <= 20; i++)
         {
             if ((string)UserListBox.SelectedItem == PVar.Login.NewUser[(int)i] && PVar.Login.NewUser[i] != "")
             {
                 UserListBox.Items.Remove(PVar.Login.NewUser[(int)i]);
                 Frm_Main.fMain.MainUserName.Items.Remove(PVar.Login.NewUser[(int)i]);
                 Frm_Login.fLogin.MainUserName.Items.Remove(PVar.Login.NewUser[(int)i]);
                 PVar.Login.NewUser[(int)i]            = "";
                 NewUserName.Text                      = PVar.Login.NewUser[(int)i];
                 PVar.Login.NewPassword[(int)i]        = "";
                 PVar.Login.NewPasswordChecked[(int)i] = "";
                 PVar.Login.NewUserAuthority[(int)i]   = (short)-1;
                 FileRw.WriteDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public void Dialog_OnAdd(string ListStr, short listType = 1)
        {
            try
            {
                if (FileRw.IsNotShow("Frm_Dialog"))
                {
                    this.Show();
                }
                this.Show();
                if (this.List_Message.Items.Count == 30)
                {
                    this.List_Message.Items.Clear();
                }

                this.BeginInvoke(new Action(() =>
                {
                    this.List_Message.Items.Add("◇" + ListStr);
                    this.List_Message.SelectedIndex = this.List_Message.Items.Count - 1;
                    switch (listType)
                    {
                    case (short)1:
                        FileLog.WriteErrLog(ListStr);
                        break;

                    default:
                        break;
                    }
                }));
                API.BringWindowToTop((int)this.Handle); //将此窗口显示在顶层
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
 private void Btn_UserManagement_Click(object sender, EventArgs e)
 {
     if (FileRw.IsNotShow("UserManagement"))
     {
         if (Frm_UserManagement.fUserManagement == null || Frm_UserManagement.fUserManagement.IsDisposed)
         {
             Frm_UserManagement.fUserManagement = new Frm_UserManagement();
         }
         Frm_UserManagement.fUserManagement.Show(this);
     }
 }
Ejemplo n.º 6
0
        private void Frm_Production_Load(object sender, EventArgs e)
        {
            this.Location  = PVar.ChildFrmOffsetPoint;
            this.Size      = new Size(1020, 660);
            this.BackColor = Frm_Main.fMain.Main_Color;
            this.AlarmStatus.BZ_ShowMode    = true;
            this.AlarmStatus.ForeColor      = Color.Black;
            this.AlarmStatus.BZ_Color       = PVar.BZColor_SelectedBtn;
            this.AlarmStatus.Text           = "No Alarm";
            this.AlarmTime.ForeColor        = Color.Black;
            this.AlarmTime.BZ_Color         = PVar.BZColor_SelectedBtn;
            this.AlarmTime.BZ_SmallText     = "Alarm Time";
            this.AlarmTime.BZ_BigText       = "00:16:58";
            this.UPH.ForeColor              = Color.Black;
            this.UPH.BZ_Color               = Color.FromArgb(253, 253, 191);
            this.UPH.BZ_SmallText           = "UPH";
            this.UPH.BZ_BigText             = "230";
            this.MaterialLevel.ForeColor    = Color.Black;
            this.MaterialLevel.BZ_Color     = PVar.BZColor_SelectedBtn;
            this.MaterialLevel.BZ_SmallText = "Material";
            this.MaterialLevel.BZ_BigText   = "High";

            Lbl_StartTime.Text = System.Convert.ToString(DateAndTime.DateAdd("d", 0, DateTime.Now).ToString("MM/dd/yy"));
            Lbl_EndTime.Text   = System.Convert.ToString(DateAndTime.DateAdd("d", -29, DateTime.Now).ToString("MM/dd/yy"));
            int SelectNum;

            if (FileRw.IniGetNValue(PVar.UIChartCurveName, "CurveData", "TotalNum", 0) == 49)
            {
                SelectNum = 49;
            }
            else
            {
                SelectNum = (int)(FileRw.IniGetNValue(PVar.UIChartCurveName, "CurveData", "CurrentNum", 0));
            }

            BTN_X.BZ_BackColor  = PVar.BZColor_SelectedBtn;
            BTN_Y.BZ_BackColor  = Color.LightGray;
            BTN_CC.BZ_BackColor = Color.LightGray;
            BTN_A.BZ_BackColor  = Color.LightGray;
            Cpk_X.BZ_BackColor  = PVar.BZColor_SelectedBtn;
            Cpk_Y.BZ_BackColor  = Color.LightGray;
            Cpk_CC.BZ_BackColor = Color.LightGray;
            Cpk_A.BZ_BackColor  = Color.LightGray;
            Btn_Yield_Click(sender, e); //显示Retest和NG率

            UPH.BZ_BigText = System.Convert.ToString(CalculateUPH());

            BTN_X_Click(BTN_X, e);
            Cpk_X_Click(Cpk_X, e);
            LoadYield();
            Frm_Engineering.fEngineering.SetChart(chartForce);
            this.Chart_Time.Elapsed += new System.Timers.ElapsedEventHandler(this.Chart_Time_Elapsed);
            Chart_Time.Enabled       = true;
        }
Ejemplo n.º 7
0
 private void UserListDisplay()
 {
     UserListBox.Items.Clear();
     FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
     for (var i = 0; i <= 20; i++)
     {
         if (PVar.Login.NewUser[i] != "" && PVar.Login.NewUser[i] != null)
         {
             UserListBox.Items.Add(PVar.Login.NewUser[(int)i]);
         }
     }
 }
Ejemplo n.º 8
0
        private void TrackBar_tossing_Scroll(object sender, EventArgs e)
        {
            string XDate      = "";
            int    SelectData = 0;

            SelectData = TrackBar_tossing.Value;
            for (var i = 0; i <= SelectData - 1; i++)
            {
                XDate = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("yyyyMMdd"));
                PVar.StorXData[(int)i]   = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("MM/dd"));
                PVar.StorTossing[(int)i] = double.Parse(FileRw.IniGetStringValue(PVar.UIChartYieldOverViewName, XDate, "Tossing", "0"));                  //当天抛料率
            }
            FileRw.Chart_Curve(Chart_Tossing, "Tossing(Unit:%)", "", "", "Tossing", PVar.StorXData, PVar.StorTossing, 0, 0, 0, false);
        }
Ejemplo n.º 9
0
        private void TrackBar_yeild_Scroll(object sender, EventArgs e)
        {
            string XDate;
            int    SelectData = 0;

            //Call CalculateYieldRetestRate()
            FileRw.ReadYieldFile(PVar.BZ_YieldMonthDataFileName, PVar.YieldOfMonth);
            SelectData = TrackBar_yeild.Value;
            for (var i = 0; i <= SelectData - 1; i++)
            {
                XDate = System.Convert.ToString(PVar.YieldOfMonth.RecordTime[i].ToString("yyyyMMdd"));
                PVar.StorXData[(int)i]         = System.Convert.ToString(PVar.YieldOfMonth.RecordTime[i].ToString("MM/dd"));
                PVar.StorYieldOverView[(int)i] = System.Convert.ToDouble((PVar.YieldOfMonth.ProductCount[(int)i] == 0) ? 0 : (Math.Round((1 - (double)PVar.YieldOfMonth.NgCount[(int)i] / PVar.YieldOfMonth.ProductCount[(int)i]) * 100, 1)));                      //当天良率
            }
            FileRw.Chart_Curve(Chart_YieldOverview, "Yield Rate(Unit:%)", "", "", "Yield", PVar.StorXData, PVar.StorYieldOverView, 0, 0, 0, false);
        }
Ejemplo n.º 10
0
        private void TrackBar_uph_Scroll(object sender, EventArgs e)
        {
            string XDate = "";

            string[] YData      = new string[31];
            string[] Temp       = new string[25];
            int      SelectData = 0;

            SelectData = TrackBar_uph.Value;
            for (var i = 0; i <= SelectData - 1; i++)
            {
                XDate = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("yyyyMMdd"));
                PVar.StorXData[(int)i] = System.Convert.ToString(DateAndTime.DateAdd("d", System.Convert.ToDouble(-i), DateTime.Now.Date).ToString("MM/dd"));
                PVar.StorUPH[(int)i]   = double.Parse(FileRw.IniGetStringValue(PVar.UIChartYieldOverViewName, XDate, "OneTodayUPH", "0"));
            }
            FileRw.Chart_Curve(Chart_UPH, "UPH(Unit:PCS)", "", "", "UPH", PVar.StorXData, PVar.StorUPH, 0, 0, 0, false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 设备异常Log写入
        /// </summary>
        /// <param name="Msg"></param>
        /// <remarks></remarks>
        public static void WriteErrLog(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);
        }
Ejemplo n.º 12
0
        private void MainUserNameDisplay()
        {
            FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "PassWord.dat", PVar.Login);

            for (var i = 0; i <= 20; i++)
            {
                if (PVar.Login.NewUser[(int)i] != "OP" && PVar.Login.NewUser[(int)i] != "Administrator")
                {
                    if (PVar.Login.NewUser[(int)i] != "" && PVar.Login.NewUser[(int)i] != null)
                    {
                        MainUserName.Items.Add(PVar.Login.NewUser[(int)i]);
                    }
                }
            }
            Frm_Login.fLogin.MainUserName.Items.Add("Administrator");
            MainUserName.SelectedIndex = 0;
            MainPassword.Focus();
            //Call Start_NumberKey_Process()
            //MainPassword.SelectionStart = 0     '选取的起始位置设为0,即从头开始进行文本框内容的选取
            //MainPassword.SelectionLength = Len(MainPassword.Text)       '选取内容的长度为文本框已经接受的文本长度
        }
Ejemplo n.º 13
0
        public void Par_Normal(string Sts)
        {
            lock (LockPar)

                switch (Sts)
                {
                case "Read":
                    PVar.IsReadParData = false;
                    FileRw.ReadParData(PVar.BZ_ParameterPath + "\\ParData.dat", PVar.ParList); //指定目录下面
                    try
                    {
                        for (var i = 1; i <= 10; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel3.Controls)
                            {
                                if (f.Name == "TextMachine" + (i).ToString())
                                {
                                    f.Text = PVar.ParList.MacInfo[i];
                                }
                            }
                        }

                        for (var i = 1; i <= 63; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel1.Controls)
                            {
                                if (f.Name == "TextBox_" + (i).ToString())
                                {
                                    f.Text = Convert.ToString(PVar.ParList.Data[i]);
                                }
                            }
                        }

                        for (var i = 1; i <= 48; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel4.Controls)
                            {
                                if (f.Name == "CheckBox" + (i).ToString())
                                {
                                    if (PVar.ParList.CheckSts[i])
                                    {
                                        f.Checked = true;
                                    }
                                    else
                                    {
                                        f.Checked = false;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("参数读取出错,请注意!");
                    }
                    break;

                case "Write":
                    try
                    {
                        for (var i = 1; i <= 10; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel3.Controls)
                            {
                                if (f.Name == "TextMachine" + (i).ToString())
                                {
                                    PVar.ParList.MacInfo[i] = System.Convert.ToString(f.Text);
                                }
                            }
                        }

                        for (var i = 1; i <= 63; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel1.Controls)
                            {
                                if (f.Name == "TextBox_" + (i).ToString())
                                {
                                    PVar.ParList.Data[(int)i] = System.Convert.ToDouble(AxScriptControl1.Eval(f.Text));
                                }
                            }
                        }

                        for (var i = 1; i <= 48; i++)
                        {
                            foreach (dynamic f in this.TableLayoutPanel4.Controls)
                            {
                                if (f.Name == "CheckBox" + (i).ToString())
                                {
                                    if (f.Checked)
                                    {
                                        PVar.ParList.CheckSts[i] = true;
                                    }
                                    else
                                    {
                                        PVar.ParList.CheckSts[i] = false;
                                    }
                                }
                            }
                        }
                        FileRw.WriteParData(PVar.BZ_ParameterPath + "\\ParData.dat", PVar.ParList);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("参数保存出错,请注意!");
                        return;
                    }
                    break;
                }

            if (PVar.ParList.CheckSts[17])
            {
                PVar.空跑 = true;
            }
            else
            {
                PVar.空跑 = false;
            }

            if (PVar.ParList.CheckSts[17])
            {
                Frm_Engineering.fEngineering.Label_WorkMode.Visible = true;
                Frm_Engineering.fEngineering.Label_NG_OK.Visible    = false;
            }
            else
            {
                Frm_Engineering.fEngineering.Label_WorkMode.Visible = false;
                Frm_Engineering.fEngineering.Label_NG_OK.Visible    = true;
            }
            if (PVar.WorkMode == 1)
            {
                Frm_Engineering.fEngineering.Label_CPK.Visible = true;
            }
            else
            {
                Frm_Engineering.fEngineering.Label_CPK.Visible = false;
            }
        }
Ejemplo n.º 14
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.IsHaveBezel = false;
                        StaWork.IsHaveSN    = false;
                        StaWork.Result      = false;
                        StaWork.State       = false;
                        TriggerCount        = 0;
                        Line1Time.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;
                //if (PVar.空跑)
                //{

                //}
                //else
                //{

                //}
                case 20:
                    if (PVar.空跑)
                    {
                        if (StaWork.State == false && StaWork.IsHaveFix)
                        {
                            AddList("流水线1开始工作!");
                            StaWork.State      = true;
                            BVar.ProData[1, 1] = "";    //Bezel条码
                            BVar.ProData[1, 2] = "";    //PDCA返回条码
                            BVar.ProData[1, 3] = "";    //载具条码
                            Line1Time.InitialTime();
                            StaWork.Step = 200;
                        }
                        else
                        {
                            if (Line1Time.TimeIsUp(20))
                            {
                                Line1Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else
                    {
                        if (StaWork.State == false && StaWork.IsHaveFix && Gg.GetExDi(1, Gg.InPut2.流水线对射感应2) == 1 && Gg.GetExDi(1, Gg.InPut2.流水线对射感应3) == 1)
                        {
                            AddList("流水线1开始工作!");
                            StaWork.State      = true;
                            BVar.ProData[1, 1] = "";    //Bezel条码
                            BVar.ProData[1, 2] = "";    //PDCA返回条码
                            BVar.ProData[1, 3] = "";    //载具条码
                            Line1Time.InitialTime();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            if (Line1Time.TimeIsUp(20))
                            {
                                Line1Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    break;

                case 30:

                    if (PVar.ParList.CheckSts[3])     //左右机切换
                    {
                        Frm_Engineering.fEngineering.Lab_Station1.Text = "";
                    }
                    else
                    {
                        Frm_Engineering.fEngineering.Lab_Station3.Text = "";
                    }
                    if (PVar.ParList.CheckSts[8])
                    {
                        StaWork.IsHaveSN    = true;
                        StaWork.IsHaveBezel = true;
                        BVar.ProData[1, 1]  = Frm_Engineering.fEngineering.Txt_BarCode.Text;
                        if (PVar.ParList.CheckSts[3])     //左右机切换
                        {
                            Frm_Engineering.fEngineering.Lab_Station1.Text = BVar.ProData[1, 1];
                        }
                        else
                        {
                            Frm_Engineering.fEngineering.Lab_Station3.Text = BVar.ProData[1, 1];
                        }
                        Line1Time.InitialTime();
                        StaWork.Step = 200;
                    }
                    else
                    {
                        AddList("触发条码枪,获取Bezel条码");
                        TriggerCount += 1;
                        if (Command.TCP_Barcode_Send("||>trigger on") == 1)
                        {
                            Line1Time.InitialTime();
                            StaWork.Step = 50;
                        }
                        else
                        {
                            AddList("条码枪网络异常!");
                            ShowList("条码枪网络异常!");
                            Line1Time.InitialTime();
                            StaWork.Step = 900;    //跳到异常处理
                        }
                    }

                    break;

                case 50:
                    if (BVar.BarCodeData.GetCodeOK)
                    {
                        BVar.BarCodeData.GetCodeOK = false;
                        StaWork.IsHaveSN           = true;
                        StaWork.IsHaveBezel        = true;
                        BVar.ProData[1, 1]         = BVar.BarCodeData.sData.Trim();
                        if (PVar.ParList.CheckSts[3])     //左右机切换
                        {
                            Frm_Engineering.fEngineering.Lab_Station1.Text = BVar.ProData[1, 1];
                        }
                        else
                        {
                            Frm_Engineering.fEngineering.Lab_Station3.Text = BVar.ProData[1, 1];
                        }
                        AddList("Bezel条码:" + BVar.ProData[1, 1]);
                        if (PVar.ParList.CheckSts[20])    //PDCA开启
                        {
                            AddList("等待上传PDCA,检测是否过SFC!");
                        }
                        Line1Time.InitialTime();
                        StaWork.Step = 100;
                    }
                    else if (Line1Time.TimeIsUp(200))
                    {
                        if (TriggerCount < 3)
                        {
                            AddList("重新触发条码枪!");
                            Line1Time.InitialTime();
                            StaWork.Step = 30;    //返回重新触发条码
                        }
                        else
                        {
                            AddList("条码枪获取SN失败!");
                            BVar.RecordErrInfo("HsgSnErr");
                            StaWork.IsHaveSN = false;
                            StaWork.Result   = false;
                            Line1Time.InitialTime();
                            StaWork.Step = 900;    //跳到异常处理
                        }
                    }
                    break;


                //*********************************传PDCA数据,检测是否过路径***********************************
                case 100:
                    if (PVar.ParList.CheckSts[20])    //PDCA开启
                    {
                        if (PDCA.PDCAIsWorking == false)
                        {
                            AddList("开始上传PDCA");
                            PDCA.PDCAIsWorking = true;
                            PDCA.UpLoadStep    = 10;
                            Line1Time.InitialTime();
                            StaWork.Step = 110;
                        }
                    }
                    else
                    {
                        AddList("PDCA关闭,直接跳过SFC!");
                        Line1Time.InitialTime();
                        StaWork.Step = 110;
                    }
                    break;

                case 110:
                    Line1Time.InitialTime();
                    StaWork.Step = 200;
                    break;

                case 200:
                    if (PVar.空跑)
                    {
                        if (PVar.Stop_Flag == false && Gg.GetExDi(1, Gg.InPut2.流水线对射感应4) == 0 &&
                            Gg.GetExDi(1, Gg.InPut2.流水线对射感应5) == 0 && PVar.Sta_Work[(int)BVar.工位.流水线2].State == false)
                        {
                            PVar.Sta_Work[(int)BVar.工位.流水线2].Enable = true;
                            AddList("载具开始放行,等待流水线2接收!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸2, 0);
                            Frm_Engineering.fEngineering.Txt_BarCode.Text = "";
                            Linechange.SetMotor1(true, PVar.ParList.Data[43]);
                            Linechange.SetMotor2(true, PVar.ParList.Data[43]);
                            Line1Time.InitialTime();
                            StaWork.Step = 210;
                        }
                        else
                        {
                            if (PVar.Stop_Flag)
                            {
                                StaWork.State = false;
                                Line1Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else
                    {
                        //等待放行*****************************
                        if (PVar.Stop_Flag == false && Gg.GetExDi(1, Gg.InPut2.流水线对射感应4) == 0 &&
                            Gg.GetExDi(1, Gg.InPut2.流水线对射感应5) == 0 && PVar.Sta_Work[(int)BVar.工位.流水线2].State == false)
                        {
                            PVar.Sta_Work[(int)BVar.工位.流水线2].Enable = StaWork.IsHaveSN ? true : false;
                            AddList("载具开始放行,等待流水线2接收!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸2, 0);
                            Frm_Engineering.fEngineering.Txt_BarCode.Text = "";
                            Linechange.SetMotor1(true, PVar.ParList.Data[43]);
                            Linechange.SetMotor2(true, PVar.ParList.Data[43]);
                            Line1Time.InitialTime();
                            StaWork.Step = 210;
                        }
                    }
                    break;

                case 210:
                    if (PVar.空跑)
                    {
                        if (Line1Time.TimeIsUp(1000))
                        {
                            AddList("载具放行完成!");
                            PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix = false;
                            Linechange.SetMotor1(false, PVar.ParList.Data[43]);
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸2, 1);
                            Line1Time.InitialTime();
                            StaWork.Step = 220;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应3) == 0)
                        {
                            AddList("载具放行完成!");
                            PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix = false;
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸2, 1);
                            Line1Time.InitialTime();
                            StaWork.Step = 220;
                        }
                        else if (Line1Time.TimeIsUp(5000))
                        {
                            AddList("流水线1放行载具超时!");
                            ShowList("流水线1放行载具超时!");
                            Line1Time.InitialTime();
                            StaWork.Step = 220;
                        }
                    }
                    break;

                case 220:
                    if (PVar.空跑)
                    {
                        if (Line1Time.TimeIsUp(1500))
                        {
                            AddList("载具到达流水线2!");
                            AddList("流水线2开始减速!");
                            Linechange.SetMotor2(true, 10);
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1);
                            Line1Time.InitialTime();
                            StaWork.Step = 240;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应4) == 1)
                        {
                            AddList("载具到达流水线2!");
                            Line1Time.InitialTime();
                            StaWork.Step = 230;
                        }
                        else if (Line1Time.TimeIsUp(5000))
                        {
                            AddList("流水线2接收载具超时!");
                            ShowList("流水线2接收载具超时!");
                            Line1Time.InitialTime();
                            StaWork.Step = 230;
                        }
                    }
                    break;

                case 230:
                    if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应5) == 1)
                    {
                        AddList("流水线2收到产品完成!");
                        Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1);
                        StaWork.IsHaveFix = false;    //本站载具标志复位

                        Linechange.SetMotor1(false, PVar.ParList.Data[43]);
                        if (PVar.ParList.CheckSts[3])     //左右机切换
                        {
                            Frm_Engineering.fEngineering.Lab_Station1.Text = "";
                        }
                        else
                        {
                            Frm_Engineering.fEngineering.Lab_Station3.Text = "";
                        }
                        Line1Time.InitialTime();
                        StaWork.Step = 240;
                    }
                    else if (Line1Time.TimeIsUp(5000))
                    {
                        AddList("流水线2载具到位超时!");
                        ShowList("流水线2载具到位超时!");
                        Line1Time.InitialTime();
                        StaWork.Step = 240;
                    }
                    break;

                case 240:
                    if (Line1Time.TimeIsUp(500))
                    {
                        PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix = true;
                        Linechange.SetMotor2(false, PVar.ParList.Data[43]);
                        Line1Time.InitialTime();
                        StaWork.Step = 250;
                    }
                    break;

                case 250:
                    if (Gg.GetDi(0, Gg.InPut0.阻挡气缸1伸出) == 1)
                    {
                        AddList("阻挡气缸1伸出到位!");
                        Line1Time.InitialTime();
                        StaWork.Step = 800;
                    }
                    else if (Line1Time.TimeIsUp(500))
                    {
                        AddList("阻挡气缸1伸出异常!");
                        ShowList("阻挡气缸1伸出异常!");
                        Line1Time.InitialTime();
                        StaWork.Step = 800;
                    }
                    break;

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

                case 900:
                    //跳转到等待放行
                    StaWork.Result    = false;
                    StaWork.IsHaveFix = true;
                    StaWork.IsHaveSN  = false;
                    Linechange.SetMotor1(false, PVar.ParList.Data[43]);
                    StaWork.Step = 200;
                    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);
            }
        }
Ejemplo n.º 15
0
        public void UserMessageConfirm()
        {
            int i = 0;

            if (NewUserName.Text != "")
            {
                if (NewUserPassword.Text != "" && NewUserPasswordChecked.Text != "")
                {
                    if (NewUserPassword.Text == NewUserPasswordChecked.Text)
                    {
                        if (AfterSaleSelected.Checked || EngineeringSelected.Checked || FE2Selected.Checked)
                        {
                            for (i = 0; i <= 20; i++)
                            {
                                if (PVar.Login.NewUser[i] == null)
                                {
                                    PVar.Login.NewUser[i]            = NewUserName.Text;
                                    PVar.Login.NewPassword[i]        = NewUserPassword.Text;
                                    PVar.Login.NewPasswordChecked[i] = NewUserPasswordChecked.Text;
                                    PVar.Login.NewUserAuthority[i]   = UserAuthorityTemp;
                                    NewUserPassword.Text             = "";
                                    NewUserPasswordChecked.Text      = "";
                                    FileRw.WriteDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
                                    UserListRefresh();
                                    UserListBox.Items.Add(PVar.Login.NewUser[i]);
                                    Frm_Main.fMain.MainUserName.Items.Add(PVar.Login.NewUser[i]);
                                    Frm_Login.fLogin.MainUserName.Items.Add(PVar.Login.NewUser[i]);
                                    break;
                                }
                                else if (PVar.Login.NewUser[i] == NewUserName.Text)
                                {
                                    PVar.Login.NewUser[i]            = NewUserName.Text;
                                    PVar.Login.NewPassword[i]        = NewUserPassword.Text;
                                    PVar.Login.NewPasswordChecked[i] = NewUserPasswordChecked.Text;
                                    PVar.Login.NewUserAuthority[i]   = UserAuthorityTemp;
                                    NewUserPassword.Text             = "";
                                    NewUserPasswordChecked.Text      = "";
                                    FileRw.WriteDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
                                    UserListRefresh();
                                    UserListBox.Items.Add(PVar.Login.NewUser[i]);
                                    Frm_Login.fLogin.MainUserName.Items.Add(PVar.Login.NewUser[i]);
                                    Frm_Main.fMain.MainUserName.Items.Add(PVar.Login.NewUser[i]);
                                    break;
                                }
                            }
                            FileRw.WriteDatFilePassWord(PVar.BZ_ParameterPath + "\\PassWord.dat", PVar.Login);
                            UserListRefresh();
                        }
                        else
                        {
                            if (Interaction.MsgBox("用户权限不能为空,请选择!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                            {
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (Interaction.MsgBox("两次密码输入不同,请重新输入!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (NewUserName.Text != "OP")
                    {
                        if (Interaction.MsgBox("密码不能为空,请重新输入!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                if (Interaction.MsgBox("账户不能为空,请重新输入!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                {
                    return;
                }
            }
        }
Ejemplo n.º 16
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        LoadPSATime.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (PVar.空跑)
                    {
                        if (StaWork.State == false && StaWork.IsLoadPSA == false && Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 0 &&
                            (PVar.Sta_Work[(int)BVar.工位.流水线0].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix))
                        {
                            AddList("PSA上料开始!");
                            StaWork.State = true;
                            PickUpNumber  = 0;
                            Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                            Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0);
                            Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                            LoadPSATime.InitialTime();
                            StaWork.Step = 30;
                        }
                        else if (LoadPSATime.TimeIsUp(50))
                        {
                            StaWork.Step = 10;
                        }
                    }
                    else    //*****************************************************
                    {
                        if (StaWork.State == false && StaWork.IsLoadPSA == false && Gg.GetExDi(0, Gg.InPut1.PSA料仓夹紧气缸伸出) == 1 && Gg.GetExDi(1, Gg.InPut2.PSA料仓到位感应信号) == 1 && Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 0 &&
                            (PVar.Sta_Work[(int)BVar.工位.流水线0].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix || PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix))
                        {
                            AddList("PSA上料开始!");
                            StaWork.State = true;
                            PickUpNumber  = 0;
                            Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                            Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0);
                            Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                            LoadPSATime.InitialTime();
                            StaWork.Step = 30;
                        }
                        else if (LoadPSATime.TimeIsUp(50))
                        {
                            StaWork.Step = 10;
                        }
                    }
                    break;

                case 30:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        AddList("PSA搬运Y轴运动到取料位置!");
                        Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 40;
                    }
                    else if (LoadPSATime.TimeIsUp(5000))
                    {
                        AddList("PSA吸嘴升降气缸上感应信号异常!");
                        ShowList("PSA吸嘴升降气缸上感应信号异常!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 8000;
                    }
                    break;

                case 40:
                    if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0)
                    {
                        AddList("PSA吸嘴升降气缸上信号异常!");
                        ShowList("PSA吸嘴升降气缸上信号异常!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10000;
                    }

                    if (Gg.ZSPD(0, Axis.PSA搬运Y轴))
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 50;
                    }
                    else if (LoadPSATime.TimeIsUp(5000))
                    {
                        AddList("PSA搬运Y轴运动超时!");
                        ShowList("PSA搬运Y轴运动超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10000;
                    }
                    break;

                case 50:
                    if (PVar.空跑)
                    {
                        AddList("PSA料仓上层感应到物料!");
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1);
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                        AddList("PSA吸嘴升降气缸下降取料!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 90;
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1)
                        {
                            AddList("PSA料仓上层感应到物料!");
                            LoadPSATime.InitialTime();
                            StaWork.Step = 60;
                        }
                        else
                        {
                            //当前位置已经到达最高处
                            if (Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) >= mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置])
                            {
                                //回到供料初始位置
                                Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]);
                                AddList("PSA物料用完,运动到初始位置!");
                                ShowList("PSA物料用完,运动到初始位置!");
                                Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                                Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0);
                                Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                                LoadPSATime.InitialTime();
                                StaWork.Step = 1000;
                            }
                            else
                            {
                                //继续顶PSA物料
                                Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]);
                                AddList("PSA料仓向上顶料!");
                                LoadPSATime.InitialTime();
                                StaWork.Step = 60;
                            }
                        }
                    }
                    break;

                case 60:
                    if (Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1)
                    {
                        gts.GT_Stop(0, 1 << (Axis.PSA供料Z轴 - 1), 0);
                        AddList("感应到PSA物料,顶料轴停止!");
                    }
                    if (Gg.ZSPD(0, Axis.PSA供料Z轴) && Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 0)
                    {
                        Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]);
                        AddList("PSA物料用完,运动到初始位置!");
                        ShowList("PSA物料用完,运动到初始位置!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    else if (Gg.ZSPD(0, Axis.PSA供料Z轴) && Gg.GetExDi(1, Gg.InPut2.PSA料仓上层感应) == 1)
                    {
                        Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]);
                        AddList("PSA料仓上层感应到物料!");

                        LoadPSATime.InitialTime();
                        StaWork.Step = 70;
                    }
                    else if (Gg.ZSPD(0, Axis.PSA供料Z轴) == false && LoadPSATime.TimeIsUp(5000))
                    {
                        AddList("PSA供料Z轴运动超时!");
                        ShowList("PSA供料Z轴运动超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10000;
                    }
                    break;

                case 70:
                    if (mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置] - Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) > 2)
                    {
                        //2mm/s的速度,按比例向上顶,防止料是倾斜的
                        Gg.AbsMotion(0, Axis.PSA供料Z轴, Gg.GetPrfPosmm(0, Axis.PSA供料Z轴) + (mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴单片位置] - Gg.GetPrfPosmm(0, Axis.PSA供料Z轴)) * 0.08, 2);
                    }
                    PickUpNumber += 1;
                    Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                    Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1);
                    Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                    AddList("PSA吸嘴升降气缸下降取料!");
                    LoadPSATime.InitialTime();
                    StaWork.Step = 80;
                    break;

                case 80:
                    if (Gg.GetExDi(1, Gg.InPut2.搬运PSA真空吸检测信号) == 1)
                    {
                        gts.GT_Stop(0, 1 << (Axis.PSA供料Z轴 - 1), 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 90;
                    }
                    else
                    {
                        if (Gg.ZSPD(0, Axis.PSA供料Z轴))
                        {
                            LoadPSATime.InitialTime();
                            StaWork.Step = 90;
                        }
                    }
                    break;

                case 90:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 1)
                    {
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 100;
                    }
                    else if (LoadPSATime.TimeIsUp(3000))
                    {
                        AddList("PSA吸嘴升降气缸下降超时!");
                        ShowList("PSA吸嘴升降气缸下降超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 8000;
                    }
                    break;

                case 100:
                    if (LoadPSATime.TimeIsUp(500))
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 120;
                    }
                    break;

                case 120:
                    if (Gg.ZSPD(0, Axis.PSA供料Z轴))
                    {
                        AddList("PSA吸嘴升降气缸上升!");
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 130;
                    }
                    break;

                case 130:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 140;
                    }
                    else if (LoadPSATime.TimeIsUp(3000))
                    {
                        AddList("PSA吸嘴升降气缸上升超时!");
                        ShowList("PSA吸嘴升降气缸上升超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 8000;
                    }
                    break;

                case 140:
                    if (LoadPSATime.TimeIsUp(500))
                    {
                        if (PVar.空跑)
                        {
                            AddList("PSA吸嘴升降气缸上升到位,真空吸OK!");
                            PickUpNumber = 0;
                            Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴放料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]);
                            LoadPSATime.InitialTime();
                            StaWork.Step = 150;
                        }
                        else
                        {
                            if (Gg.GetExDi(1, Gg.InPut2.搬运PSA真空吸检测信号) == 1)
                            {
                                AddList("PSA吸嘴升降气缸上升到位,真空吸OK!");
                                PickUpNumber = 0;
                                Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴放料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]);
                                LoadPSATime.InitialTime();
                                StaWork.Step = 150;
                            }
                            else
                            {
                                if (PickUpNumber > 1)
                                {
                                    PickUpNumber = 0;
                                    AddList("PSA吸料真空异常,请检查!");
                                    ShowList("PSA吸料真空异常,请检查!");
                                    ErrName = "Foam吸料真空异常,请确认后继续";
                                    LoadPSATime.InitialTime();
                                    StaWork.Step = 6000;
                                }
                                else
                                {
                                    Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                                    LoadPSATime.InitialTime();
                                    StaWork.Step = 70;
                                }
                            }
                        }
                    }
                    break;

                case 150:
                    if (Gg.ZSPD(0, Axis.PSA搬运Y轴))
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 160;
                    }
                    break;

                case 160:
                    if (LoadPSATime.TimeIsUp(100))
                    {
                        AddList("吸嘴移动到中转台上方!");
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 170;
                    }
                    break;

                case 170:    //取料和载具平台很难保证统一平面,这里不判断气缸下信号
                    if (LoadPSATime.TimeIsUp(1500) && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0)
                    {
                        AddList("PSA吸嘴升降气缸下降到位!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 180;
                    }
                    break;

                case 180:
                    if (LoadPSATime.TimeIsUp(200))
                    {
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 1);
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0);

                        Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台破真空, 0);
                        Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台真空吸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 190;
                    }
                    break;

                case 190:
                    if (LoadPSATime.TimeIsUp(1000))
                    {
                        if (PVar.空跑)
                        {
                            AddList("PSA载台真空吸检测信号OK!");
                            Gg.SetExDo(0, 1, Gg.OutPut2.PSA载台真空吸, 0);
                            Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                            LoadPSATime.InitialTime();
                            StaWork.Step = 200;
                        }
                        else
                        {
                            if (Gg.GetExDi(1, Gg.InPut2.PSA载台真空吸检测信号) == 1)
                            {
                                AddList("PSA载台真空吸检测信号OK!");
                                Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                                LoadPSATime.InitialTime();
                                StaWork.Step = 200;
                            }
                            else
                            {
                                AddList("PSA载台真空吸检测信号异常,请检查!");
                                Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                                ErrName = "Foam承接平台真空异常,请确认后继续";
                                LoadPSATime.InitialTime();
                                StaWork.Step = 7000;
                            }
                        }
                    }
                    break;

                case 200:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 210;
                    }
                    else if (LoadPSATime.TimeIsUp(3000))
                    {
                        AddList("PSA吸嘴升降气缸上升超时!");
                        ShowList("PSA吸嘴升降气缸上升超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 8000;
                    }
                    break;

                case 210:
                    if (LoadPSATime.TimeIsUp(300))
                    {
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA破真空, 0);
                        Gg.SetExDo(0, 1, Gg.OutPut2.搬运PSA真空吸, 0);
                        Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], PVar.ParAxis.Speed[Axis.PSA搬运Y轴]);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 220;
                    }
                    break;

                case 220:
                    if (Gg.ZSPD(0, Axis.PSA搬运Y轴) == false && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 0)
                    {
                        AddList("PSA吸嘴升降气缸上信号异常!");
                        ShowList("PSA吸嘴升降气缸上信号异常!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10000;
                    }

                    if (Gg.ZSPD(0, Axis.PSA搬运Y轴))
                    {
                        StaWork.IsHavePSA = true;    //给取PSA信号
                        LoadPSATime.InitialTime();
                        StaWork.Step = 300;
                    }
                    else if (LoadPSATime.TimeIsUp(5000))
                    {
                        AddList("PSA搬运Y轴运动超时!");
                        ShowList("PSA搬运Y轴运动超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10000;
                    }
                    break;

                case 300:
                    LoadPSATime.InitialTime();
                    StaWork.Step = 310;
                    break;

                case 310:
                    if (StaWork.IsHavePSA == false)
                    {
                        LoadPSATime.InitialTime();
                        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;

                case 6000:
                    if (MessageBox.Show(ErrName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 6010;
                    }
                    else
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                        Gg.AbsMotion(0, Axis.PSA供料Z轴, mFunction.Pos.TeachAxis2[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Z轴初始位置], PVar.ParAxis.Speed[Axis.PSA供料Z轴]);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 6010:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 70;
                    }
                    else
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 6020;
                    }
                    break;

                case 6020:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 1);
                        LoadPSATime.InitialTime();
                        StaWork.Step = 70;
                    }
                    else if (LoadPSATime.TimeIsUp(3000))
                    {
                        AddList("PSA吸嘴升降气缸上升超时!");
                        ShowList("PSA吸嘴升降气缸上升超时!");
                        LoadPSATime.InitialTime();
                        StaWork.Step = 8000;
                    }
                    break;

                case 7000:
                    if (MessageBox.Show(ErrName, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 160;
                    }
                    else
                    {
                        LoadPSATime.InitialTime();
                        StaWork.Step = 10;
                    }
                    break;


                case 8000:
                    Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                    StaWork.Enable = false;
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    Frm_Engineering.fEngineering.MacStop();
                    break;


                //遇到异常,设备先暂停,确定后处理************************
                case 8800:
                    if (Manual.AutoMotionFlag[3])
                    {
                        if (Manual.HoldFlag[3])
                        {
                            Manual.HoldFlag[3] = false;
                            Frm_Engineering.fEngineering.CmdHoldPress.Text      = "暂停";
                            Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.BurlyWood;
                            ShowList("运动已继续");
                        }
                        else
                        {
                            Manual.HoldFlag[3] = true;
                            Frm_Engineering.fEngineering.CmdHoldPress.Text      = "继续";
                            Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.Red;
                            ShowList("运动已暂停");
                        }
                    }
                    else
                    {
                        PVar.IsSystemOnPauseMode                        = true;
                        PVar.MacHold                                    = true;
                        StaWork.StaHold                                 = 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;

                //严重错误,急停处理
                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);
            }
        }
Ejemplo n.º 17
0
        public static void AutoRunTB(ref PVar.WorkType StaWork, String Name, String testpos)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    StaWork.Result = false;
                    StaWork.State  = true;
                    ClearList2("");    //清空list
                    TestCount = 1;
                    string fileFinalData = "E:\\BZ-Data\\DAB\\TestData\\" + DateTime.Now.ToString("yyyyMM") + "\\" + Name + DateTime.Now.ToString("yyyyMMdd") + ".csv";
                    Path = fileFinalData;
                    Gg.SetExDo(0, 0, Gg.OutPut1.PSA吸嘴升降气缸, 0);
                    InitTime.InitialTime();
                    StaWork.Step = 20;
                    break;

                case 20:
                    if (Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸上) == 1 && Gg.GetExDi(0, Gg.InPut1.PSA吸嘴升降气缸下) == 0)
                    {
                        Gg.AbsMotion(0, Axis.PSA搬运Y轴, mFunction.Pos.TeachAxis1[Axis.tTag.PSA供料, Axis.Point供料PSA.PSA_Y轴吸料位置], 20);
                        InitTime.InitialTime();
                        StaWork.Step = 30;
                    }
                    break;

                case 30:
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.待机位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 30;
                    break;

                case 40:
                    if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.待机位置)
                    {
                        AddList2("机械手回待机位置OK!");
                        InitTime.InitialTime();
                        StaWork.Step = 50;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手回待机位置超时!");
                        ShowList("机械手回待机位置超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 50:
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", testpos, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 60;
                    break;

                case 60:
                    if (EpsonRobot.sRobot_Status == "Step" + testpos)
                    {
                        AddList2("机械手位置OK!");
                        InitTime.InitialTime();
                        StaWork.Step = 70;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手运动超时!");
                        ShowList("机械手运动超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 70:
                    if (InitTime.TimeIsUp(500))    //等待机械手停稳
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 80;
                    }
                    break;

                case 80:
                    if (Name == "相机1动态")
                    {
                        CCD_CMD = "Send: T11," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    if (Name == "相机2动态")
                    {
                        CCD_CMD = "Send: T21," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    sRtn = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("CCD命令  ->> " + CCD_CMD);
                    AddList2("动态测试拍照第" + TestCount + "次");
                    TestCount += 1;
                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 90;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 90:
                    if (Command.CCD_Resule)
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        //时间,CCD判断值,X,Y,R
                        string TestData = Convert.ToString(DateAndTime.TimeOfDay.TimeOfDay) + "," + PVar.CCD_Data[1] + "," + PVar.CCD_Data[2] + "," + PVar.CCD_Data[3] + "," + PVar.CCD_Data[4];
                        BVar.FileRorW.WriteTestDataCsv(TestData, Path);
                        InitTime.InitialTime();
                        StaWork.Step = 100;
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 100:
                    if (TestCount <= Convert.ToInt16(Frm_Engineering.fEngineering.TextBox_Num.Text))
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 30;
                    }
                    else
                    {
                        AddList2("测试完成!");
                        ShowList("测试完成!");
                        InitTime.InitialTime();
                        StaWork.Step = 800;
                    }
                    break;

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

                case 1000:
                    AddList2("测试失败!");
                    ShowList("测试失败!");
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 0;
                    break;

                //严重错误,急停处理
                case 10000:
                    Frm_Engineering.fEngineering.MacStop();
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                AddList2("标定失败!");
                ShowList("标定失败!");
                StaWork.Result = false;
                StaWork.State  = false;
                StaWork.Step   = 0;
                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);
            }
        }
Ejemplo n.º 18
0
        public static void aAutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    StaWork.Result = false;
                    StaWork.State  = true;
                    ClearList2("");    //清空list
                    CalibCount = 0;

                    CCD_CMD = "SC,2,11,3,1,4,1";     //标定开始命令
                    sRtn    = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("联合开始标定  ->> " + CCD_CMD);

                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 20;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 20:
                    if (Command.CCD_Resule && PVar.CCD_Data[0] == "SC")
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        InitTime.InitialTime();
                        StaWork.Step = 30;
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 30:
                    AddList2("机械手回待机位置开始!");
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.待机位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 32;
                    break;

                case 32:
                    if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.待机位置)
                    {
                        AddList2("机械手回待机位置OK!");
                        InitTime.InitialTime();
                        StaWork.Step = 34;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手回待机位置超时!");
                        ShowList("机械手回待机位置超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 34:
                    AddList2("机械手回PSA定位拍照位置开始!");
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.PSA定位拍照位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 36;
                    break;

                case 36:
                    if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.PSA定位拍照位置)
                    {
                        AddList2("机械手回待机位置OK!");
                        InitTime.InitialTime();
                        StaWork.Step = 45;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手PSA定位拍照位置超时!");
                        ShowList("机械手PSA定位拍照位置超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 45:
                    if (InitTime.TimeIsUp(500))    //等待机械手停稳
                    {
                        CalibCount += 1;
                        InitTime.InitialTime();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    AddList2("标定第" + CalibCount + "拍照");
                    CCD_CMD = "C2" + "," + EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U;;    //第一个点
                    sRtn    = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("标定命令  ->> " + CCD_CMD);

                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 60;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 60:
                    if (Command.CCD_Resule && PVar.CCD_Data[0] == "C2")
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        InitTime.InitialTime();
                        if (CalibCount < 12)
                        {
                            InitTime.InitialTime();
                            StaWork.Step = 70;     //11点标定继续
                        }
                        else
                        {
                            InitTime.InitialTime();
                            StaWork.Step = 100;    //11点标定结束
                        }
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 70:
                    switch (CalibCount)
                    {
                    case 2:
                    case 3:
                        CalibOffsetX = -2;
                        CalibOffsetY = 0;
                        CalibOffsetR = 0;
                        break;

                    case 4:
                    case 5:
                        CalibOffsetX = 0;
                        CalibOffsetY = 2;
                        CalibOffsetR = 0;
                        break;

                    case 6:
                    case 7:
                        CalibOffsetX = 2;
                        CalibOffsetY = 0;
                        CalibOffsetR = 0;
                        break;

                    case 8:
                        CalibOffsetX = 0;
                        CalibOffsetY = -2;
                        CalibOffsetR = 0;
                        break;

                    case 9:
                        CalibOffsetX = -2;
                        CalibOffsetY = 0;
                        CalibOffsetR = 0;
                        break;

                    case 10:
                        CalibOffsetX = 0;
                        CalibOffsetY = 0;
                        CalibOffsetR = -5;
                        break;

                    case 11:
                        CalibOffsetX = 0;
                        CalibOffsetY = 0;
                        CalibOffsetR = 10;
                        break;
                    }

                    AddList2("->>机械手 X:" + CalibOffsetX + ", Y:" + CalibOffsetY + ", R:" + CalibOffsetR);
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Move", "0", "5", CalibOffsetX.ToString(), CalibOffsetY.ToString(), "0", CalibOffsetR.ToString(), "0", "X", "0", "0", "0", "0", "5") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 80;
                    break;

                case 80:
                    if (EpsonRobot.sRobot_Status == "Move")
                    {
                        AddList2("<<-机械手" + EpsonRobot.Robot_StrData);
                        InitTime.InitialTime();
                        StaWork.Step = 45;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手回待机位置超时!");
                        ShowList("机械手回待机位置超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 100:
                    AddList2("机械手回预贴PSA位置开始!");
                    if (Frm_Engineering.fEngineering.Rbt_SendCmd("Step", RobotPosName.预贴PSA位置, "20", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "20") == false)
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    InitTime.InitialTime();
                    StaWork.Step = 110;
                    break;

                case 110:
                    if (EpsonRobot.sRobot_Status == "Step" + RobotPosName.预贴PSA位置)
                    {
                        AddList2("机械手回预贴PSA位置OK!");
                        InitTime.InitialTime();
                        StaWork.Step = 120;
                    }
                    else if (InitTime.TimeIsUp(6000))
                    {
                        AddList2("机械手PSA定位拍照位置超时!");
                        ShowList("机械手PSA定位拍照位置超时!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                        return;
                    }
                    break;

                case 120:
                    if (InitTime.TimeIsUp(500))    //等待机械手停稳
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 130;
                    }
                    break;

                case 130:
                    CCD_CMD = "C3" + "," + EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U;;    //第一个点
                    sRtn    = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("标定命令  ->> " + CCD_CMD);

                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 140;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 140:
                    if (Command.CCD_Resule && PVar.CCD_Data[0] == "C3")
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        InitTime.InitialTime();
                        InitTime.InitialTime();
                        StaWork.Step = 170;
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 170:
                    CCD_CMD = "C4" + "," + EpsonRobot.Robot_Fcs[2] + "," + EpsonRobot.Robot_Fcs[3] + "," + EpsonRobot.Robot_Fcs[5];    //第一个点
                    sRtn    = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("标定命令  ->> " + CCD_CMD);

                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 180;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 180:
                    if (Command.CCD_Resule && PVar.CCD_Data[0] == "C4")
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        InitTime.InitialTime();
                        InitTime.InitialTime();
                        StaWork.Step = 200;
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 200:
                    CCD_CMD = "EC";    //第一个点
                    sRtn    = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("标定命令  ->> " + CCD_CMD);

                    if (sRtn == 1)     //命令发送成功
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 210;
                    }
                    else
                    {
                        AddList2("命令发送失败!");
                        ShowList("命令发送失败!");
                        InitTime.InitialTime();
                        StaWork.Step = 1000;
                    }
                    break;

                case 210:
                    if (Command.CCD_Resule && PVar.CCD_Data[0] == "EC")
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        InitTime.InitialTime();
                        InitTime.InitialTime();
                        StaWork.Step = 800;
                        AddList2("标定结束!");
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 800:
                    AddList2("标定成功!");
                    ShowList("标定成功!");
                    StaWork.Result = true;
                    StaWork.State  = false;
                    StaWork.Step   = 0;
                    break;

                case 1000:
                    AddList2("标定失败!");
                    ShowList("标定失败!");
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 0;
                    break;

                //严重错误,急停处理
                case 10000:
                    Frm_Engineering.fEngineering.MacStop();
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                AddList2("标定失败!");
                ShowList("标定失败!");
                StaWork.Result = false;
                StaWork.State  = false;
                StaWork.Step   = 0;
                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);
            }
        }
Ejemplo n.º 19
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false || Manual.AutoMotionFlag[4])
                    {
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        StaWork.Step  = 20;
                    }
                    break;

                case 20:
                    //本站工作状态,工站使能,转盘工作状态,本站是否有产品
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (StaWork.State == false && PVar.Sta_Work[1].State == false && ((StaWork.Enable && StaWork.Result && PVar.Sta_Work[4].IsHaveHSG) || Manual.AutoMotionFlag[4]))
                        {
                            StaWork.State  = true;
                            StaWork.Result = false;

                            AddList("复检开始开始!");
                            Command.Com3_Send("LMD,SSW,00,3," + "000,");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            StaWork.Step = 10;
                        }
                    }
                    else
                    {
                        if (StaWork.State == false && PVar.Sta_Work[1].State == false && ((StaWork.Enable && StaWork.Result && PVar.Sta_Work[4].IsHaveHSG) || Manual.AutoMotionFlag[4]))
                        {
                            StaWork.State  = true;
                            StaWork.Result = false;
                            Gg.SetExDo(0, 0, Gg.OutPut2.机械手排线真空吸, 0);
                            AddList("复检开始开始!");
                            Command.Com3_Send("LMD,SSW,00,3," + "000,");
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            StaWork.Step = 10;
                        }
                    }

                    break;

                case 30:
                    if (Gg.GetExDi(0, Gg.InPut2.流水线对射感应4) == 1 && Gg.GetExDi(0, Gg.InPut2.流水线对射感应5) == 0)
                    {
                        //AddList("复检气缸复位OK!");
                        Iswritedata = true;
                        Command.Com3_Send("LMD,SPLN,00,4," + "255" + ",");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 40;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 6000)
                        {
                            AddList("复检气缸缩回信号异常!");
                            ShowList("复检气缸缩回信号异常!");
                            BufferStep   = 30;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

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

                case 45:
                    if (ERR_Count >= 2)
                    {
                        BVar.ProData[4, 2] = BVar.FileRorW.ReadINI("CCD程序 ", "颜色", "白色", PVar.PublicParPath);    //Frm_Engineering.fEngineering.comboBox_Unitcolor.Text;//产品颜色

                        BVar.ProData[4, 26] = "999";
                        BVar.ProData[4, 27] = "999";
                        BVar.ProData[4, 28] = "999";
                        BVar.ProData[4, 29] = "999";
                        BVar.ProData[4, 30] = "NG";
                        Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                        AddList("4站异常退出工作!");
                        ShowList("4站异常退出工作!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 150;
                    }
                    else
                    {
                        ERR_Count += 1;
                        if (ERR_Count == 2)
                        {
                            AddList("本站工作即将结束!");
                            ShowList("本站工作即将结束!");
                        }
                        else
                        {
                            AddList("还剩" + (2 - ERR_Count) + "次尝试,超出则本站工作结束!");
                            ShowList("还剩" + (2 - ERR_Count) + "次尝试,超出则本站工作结束!");
                        }
                        Command.Com3_Send("LMD,SPLN,00,4," + "255" + ",");
                        System.Threading.Thread.Sleep(150);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    sRtn = Command.TCP_CCD_Send(Command.相机复检);
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (sRtn == 1)     //命令发送成功
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 60;
                        }
                        else if (sRtn == 2)     //网络链接异常
                        {
                            AddList("网络链接异常!");
                            ShowList("网络链接异常!");
                            TimeOut = API.GetTickCount();
                            Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                            if (PVar.ParList.CheckSts[24])
                            {
                                BufferStep   = 45;
                                StaWork.Step = 8000;
                            }
                            else
                            {
                                Iswritedata  = false;
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 150;
                            }
                        }
                        else
                        {
                            AddList("网络命令发送失败!");
                            ShowList("网络命令发送失败!");
                            TimeOut = API.GetTickCount();
                            Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                            if (PVar.ParList.CheckSts[24])
                            {
                                BufferStep   = 45;
                                StaWork.Step = 8000;
                            }
                            else
                            {
                                Iswritedata  = false;
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 150;
                            }
                        }
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 60;
                    }
                    break;

                case 60:
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        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 > 3000)
                            {
                                AddList("等待复检角度数据超时!");
                                TimeOut = API.GetTickCount();
                                Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                                if (PVar.ParList.CheckSts[24])
                                {
                                    BufferStep   = 45;
                                    StaWork.Step = 8000;
                                }
                                else
                                {
                                    Iswritedata  = false;
                                    TimeOut      = API.GetTickCount();
                                    StaWork.Step = 150;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 200)
                        {
                            AddList("复检角度数据收到!");
                            CCD_Vale[1].X     = 0;
                            CCD_Vale[1].Y     = 0;
                            CCD_Vale[1].T     = 0;
                            CCD_Vale[1].CC    = 0;
                            CCD_Vale[1].Judge = 0;

                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 70;
                        }
                    }

                    break;

                case 70:
                    if (CCD_Vale[1].Judge == 0)
                    {
                        Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 80;
                    }
                    else if (CCD_Vale[1].Judge == 1)
                    {
                        AddList("复检角度模型搜索错误!");
                        ShowList("复检角度模型搜索错误!");
                        TimeOut = API.GetTickCount();
                        Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                        if (PVar.ParList.CheckSts[24])
                        {
                            BufferStep   = 45;
                            StaWork.Step = 8000;
                        }
                        else
                        {
                            Iswritedata  = false;
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 150;
                        }
                    }
                    else
                    {
                        AddList("CCD复检角度其他异常!");
                        ShowList("CCD复检角度其他异常!");
                        TimeOut = API.GetTickCount();
                        Command.Com3_Send("LMD,SPLN,00,4," + "000" + ",");
                        if (PVar.ParList.CheckSts[24])
                        {
                            BufferStep   = 45;
                            StaWork.Step = 8000;
                        }
                        else
                        {
                            Iswritedata  = false;
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 150;
                        }
                    }
                    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.流水线对射感应4) == 0 && Gg.GetExDi(0, Gg.InPut2.流水线对射感应5) == 1)
                    {
                        AddList("复检气缸伸出OK!");

                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 100;
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 8000)
                        {
                            AddList("复检气缸伸出信号异常!");
                            ShowList("复检气缸伸出信号异常!");
                            TimeOut      = API.GetTickCount();
                            BufferStep   = 90;
                            StaWork.Step = 8000;
                        }
                    }
                    break;

                case 100:
                    if (API.GetTickCount() - TimeOut > 900)
                    {
                        Command.Com3_Send("LMD,SPLN,00,3," + "255" + ",");
                    }

                    if (API.GetTickCount() - TimeOut > 1000)
                    {
                        ERR_Count    = 0;
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 110;
                    }
                    break;

                case 105:
                    if (ERR_Count >= 3)
                    {
                        BVar.ProData[4, 2] = BVar.FileRorW.ReadINI("CCD程序 ", "颜色", "白色", PVar.PublicParPath);    // Frm_Engineering.fEngineering.comboBox_Unitcolor.Text;//产品颜色

                        BVar.ProData[4, 26] = "999";
                        BVar.ProData[4, 27] = "999";
                        BVar.ProData[4, 28] = "999";
                        BVar.ProData[4, 29] = "999";
                        BVar.ProData[4, 30] = "NG";
                        Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                        AddList("4站异常退出工作!");
                        ShowList("4站异常退出工作!");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 150;
                    }
                    else
                    {
                        ERR_Count += 1;
                        if (ERR_Count == 3)
                        {
                            AddList("本站工作即将结束!");
                            ShowList("本站工作即将结束!");
                        }
                        else
                        {
                            AddList("还剩" + (3 - ERR_Count) + "次尝试,超出则本站工作结束!");
                            ShowList("还剩" + (3 - ERR_Count) + "次尝试,超出则本站工作结束!");
                        }
                        Command.Com3_Send("LMD,SPLN,00,3," + "255" + ",");
                        System.Threading.Thread.Sleep(150);
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 110;
                    }
                    break;

                case 110:
                    sRtn = Command.TCP_CCD_Send(Command.相机复检);
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        if (sRtn == 1)     //命令发送成功
                        {
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 120;
                        }
                        else if (sRtn == 2)     //网络链接异常
                        {
                            AddList("网络链接异常!");
                            ShowList("网络链接异常!");
                            TimeOut = API.GetTickCount();
                            if (PVar.ParList.CheckSts[24])
                            {
                                BufferStep   = 105;
                                StaWork.Step = 8000;
                            }
                            else
                            {
                                Iswritedata  = false;
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 150;
                            }
                        }
                        else
                        {
                            AddList("网络命令发送失败!");
                            ShowList("网络命令发送失败!");
                            TimeOut = API.GetTickCount();
                            Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                            if (PVar.ParList.CheckSts[24])
                            {
                                BufferStep   = 105;
                                StaWork.Step = 8000;
                            }
                            else
                            {
                                Iswritedata  = false;
                                TimeOut      = API.GetTickCount();
                                StaWork.Step = 150;
                            }
                        }
                    }
                    else
                    {
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 120;
                    }
                    break;

                case 120:
                    if (PVar.ParList.CheckSts[17] == false)
                    {
                        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]);

                            CCD_Vale[2].Up    = Convert.ToDouble(PVar.CCD2_Data[6]);
                            CCD_Vale[2].Down  = Convert.ToDouble(PVar.CCD2_Data[7]);
                            CCD_Vale[2].Left  = Convert.ToDouble(PVar.CCD2_Data[8]);
                            CCD_Vale[2].Right = Convert.ToDouble(PVar.CCD2_Data[9]);


                            BVar.ProData[4, 2] = BVar.FileRorW.ReadINI("CCD程序 ", "颜色", "白色", PVar.PublicParPath);    // Frm_Engineering.fEngineering.comboBox_Unitcolor.Text;//产品颜色

                            BVar.ProData[4, 26] = CCD_Vale[2].X.ToString("0.000");
                            BVar.ProData[4, 27] = CCD_Vale[2].Y.ToString("0.000");
                            BVar.ProData[4, 28] = CCD_Vale[2].T.ToString("0.000");
                            BVar.ProData[4, 29] = CCD_Vale[2].CC.ToString("0.000");
                            if (CCD_Vale[2].CC <= 0.05 && Math.Abs(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 > 5000)
                            {
                                AddList("等待复检同心度数据超时!");
                                TimeOut = API.GetTickCount();
                                Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                                if (PVar.ParList.CheckSts[24])
                                {
                                    BufferStep   = 105;
                                    StaWork.Step = 8000;
                                }
                                else
                                {
                                    Iswritedata  = false;
                                    TimeOut      = API.GetTickCount();
                                    StaWork.Step = 150;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (API.GetTickCount() - TimeOut > 200)
                        {
                            AddList("复检同心度数据收到!");
                            CCD_Vale[2].X     = 0;
                            CCD_Vale[2].Y     = 0;
                            CCD_Vale[2].T     = 0;
                            CCD_Vale[2].CC    = 0;
                            CCD_Vale[2].Judge = 0;


                            BVar.ProData[4, 2] = BVar.FileRorW.ReadINI("CCD程序 ", "颜色", "白色", PVar.PublicParPath);    // Frm_Engineering.fEngineering.comboBox_Unitcolor.Text;//产品颜色


                            BVar.ProData[4, 26] = CCD_Vale[2].X.ToString("0.000");
                            BVar.ProData[4, 27] = CCD_Vale[2].Y.ToString("0.000");
                            BVar.ProData[4, 28] = CCD_Vale[2].T.ToString("0.000");
                            BVar.ProData[4, 29] = CCD_Vale[2].CC.ToString("0.000");

                            if (CCD_Vale[2].CC <= 0.05 && CCD_Vale[2].T <= 1 && CCD_Vale[2].Up >= 0.1 && CCD_Vale[2].Up <= 0.3 && CCD_Vale[2].Down >= 0.1 && CCD_Vale[2].Down <= 0.3 && CCD_Vale[2].Left >= 0.1 && CCD_Vale[2].Left <= 0.3 && CCD_Vale[2].Right >= 0.1 && CCD_Vale[2].Right <= 0.3)
                            {
                                BVar.ProData[4, 30] = "OK";
                            }
                            else
                            {
                                BVar.ProData[4, 30] = "NG";
                            }
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 130;
                        }
                    }
                    break;

                case 130:
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 140;
                    break;

                case 140:
                    if (CCD_Vale[2].Judge == 0)
                    {
                        Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                        TimeOut      = API.GetTickCount();
                        StaWork.Step = 150;
                    }
                    else if (CCD_Vale[2].Judge == 1)
                    {
                        AddList("复检同心度模型搜索错误!");
                        ShowList("复检同心度模型搜索错误!");
                        TimeOut = API.GetTickCount();
                        Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                        if (PVar.ParList.CheckSts[24])
                        {
                            BufferStep   = 105;
                            StaWork.Step = 8000;
                        }
                        else
                        {
                            Iswritedata  = false;
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 150;
                        }
                    }
                    else
                    {
                        AddList("CCD复同心度度其他异常!");
                        ShowList("CCD复同心度度其他异常!");
                        TimeOut = API.GetTickCount();
                        Command.Com3_Send("LMD,SPLN,00,3," + "000" + ",");
                        if (PVar.ParList.CheckSts[24])
                        {
                            BufferStep   = 105;
                            StaWork.Step = 8000;
                        }
                        else
                        {
                            Iswritedata  = false;
                            TimeOut      = API.GetTickCount();
                            StaWork.Step = 150;
                        }
                    }
                    break;

                case 150:
                    Gg.SetExDo(0, 0, Gg.OutPut2.机械手排线真空吸, 0);
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 300;
                    break;

                ////复检数据处理
                case 300:
                    if (PVar.ParList.CheckSts[17])
                    {
                        BVar.ProData[4, 30] = "OK";
                    }
                    if (BVar.ProData[4, 30] == "OK")
                    {
                        StaWork.Result = true;
                    }
                    //写入数据
                    if (Iswritedata)
                    {
                        Write_FinalData();
                    }
                    if (PVar.ParList.CheckSts[48] == false)
                    {
                    }
                    TimeOut      = API.GetTickCount();
                    StaWork.Step = 800;
                    break;

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

                case 1000:
                    StaWork.Enable           = false;
                    StaWork.Result           = false;
                    StaWork.State            = false;
                    Manual.AutoMotionFlag[4] = false;
                    StaWork.Step             = 10;
                    break;

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    if (Manual.AutoMotionFlag[4])
                    {
                        if (Manual.HoldFlag[4])
                        {
                            Manual.HoldFlag[4] = false;
                            Frm_Engineering.fEngineering.CmdHold.Text      = "暂停";
                            Frm_Engineering.fEngineering.CmdHold.BackColor = Color.BurlyWood;
                            ShowList("运动已继续");
                        }
                        else
                        {
                            Manual.HoldFlag[4] = true;
                            Frm_Engineering.fEngineering.CmdHold.Text      = "继续";
                            Frm_Engineering.fEngineering.CmdHold.BackColor = Color.Red;
                            ShowList("运动已暂停");
                        }
                    }
                    else
                    {
                        PVar.IsSystemOnPauseMode              = true;
                        PVar.MacHold                          = true;
                        StaWork.StaHold                       = 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 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);
            }
        }
Ejemplo n.º 20
0
        public void UserLogin()
        {
            int i = 0;

            FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "PassWord.dat", PVar.Login);
            for (i = 0; i <= MainUserName.Items.Count - 1; i++)
            {
                if (PVar.IsOpenFrmLogin)
                {
                    if (Frm_Login.fLogin.MainUserName.Text == "Administrator" && Frm_Login.fLogin.MainPassword.Text == "zhanzw314177011")
                    {
                        Frm_Engineering.fEngineering.机械参数.Parent = Frm_Engineering.fEngineering.TabControl4;
                        PVar.LoginFrmEngineeringEnable           = true;
                        PVar.LoginFrmParEnable     = true;
                        PVar.LoginFrmParCCDEnable  = true;
                        PVar.LoginMachineParEnable = true;
                        PVar.LoginOutputEnable     = true;
                        PVar.LoginManualEnable     = true;
                        return;
                    }
                    Frm_Engineering.fEngineering.机械参数.Parent = null;
                    if (PVar.sOpenTargetForm == "Frm_Engineering" && MainUserName.Text == PVar.Login.NewUser[i] && PVar.Login.NewUserAuthority[i] == 3)
                    {
                        Interaction.MsgBox("该用户无权限,请重新选择用户!", Constants.vbOKOnly, "提示");
                        return;
                    }
                    if ((Frm_Login.fLogin.MainUserName.Text == PVar.Login.NewUser[i] && Frm_Login.fLogin.MainPassword.Text == PVar.Login.NewPassword[i] && Convert.ToString(Frm_Login.fLogin.MainUserName.Items[i]) != "") && (PVar.Login.NewUserAuthority[i] == 1 || PVar.Login.NewUserAuthority[i] == 2 || PVar.Login.NewUserAuthority[i] == 3))
                    {
                        if (PVar.Login.NewGroup[0] == "Post Safe" && PVar.Login.NewUserAuthority[i] == 1)
                        {
                            Temp = true;
                            break;
                        }
                        if (PVar.Login.NewGroup[1] == "Engineering" && PVar.Login.NewUserAuthority[i] == 2)
                        {
                            Temp = true;
                            break;
                        }
                        if (PVar.Login.NewGroup[2] == "FE2" && PVar.Login.NewUserAuthority[i] == 3)
                        {
                            Temp = true;
                            break;
                        }
                    }
                    else
                    {
                        Temp = false;
                    }
                }
                else
                {
                    if (PVar.sOpenTargetForm == "Frm_Engineering" && MainUserName.Text == PVar.Login.NewUser[i] && PVar.Login.NewUserAuthority[i] == 3)
                    {
                        Interaction.MsgBox("该用户无权限,请重新选择用户!", Constants.vbOKOnly, "提示");
                        return;
                    }
                    if ((MainUserName.Text == PVar.Login.NewUser[i] && MainPassword.Text == PVar.Login.NewPassword[i] && Convert.ToString(MainUserName.Items[i]) != "") && (PVar.Login.NewUserAuthority[i] == 0 || PVar.Login.NewUserAuthority[i] == 1 || PVar.Login.NewUserAuthority[i] == 2 || PVar.Login.NewUserAuthority[i] == 3))
                    {
                        if (PVar.Login.NewGroup[0] == "Post Safe" && PVar.Login.NewUserAuthority[i] == 1)
                        {
                            Temp = true;
                            break;
                        }
                        if (PVar.Login.NewGroup[1] == "Engineering" && PVar.Login.NewUserAuthority[i] == 2)
                        {
                            Temp = true;
                            break;
                        }
                        if (PVar.Login.NewGroup[2] == "FE2" && PVar.Login.NewUserAuthority[i] == 3)
                        {
                            Temp = true;
                            break;
                        }
                        else
                        {
                            Temp = true;
                            break;
                        }
                    }
                    else
                    {
                        Temp = false;
                    }
                }
            }
            if (Temp == true)
            {
                if (PVar.Login.NewUserAuthority[i] == 1) //Post Safe
                {
                    PVar.LoginFrmEngineeringEnable = true;
                    PVar.LoginFrmParEnable         = true;
                    PVar.LoginFrmParCCDEnable      = true;
                    PVar.LoginMachineParEnable     = true;
                    PVar.LoginOutputEnable         = true;
                    PVar.LoginManualEnable         = true;
                }
                if (PVar.Login.NewUserAuthority[i] == 2) //Engineering
                {
                    PVar.LoginFrmEngineeringEnable = true;
                    PVar.LoginFrmParEnable         = true;
                    PVar.LoginFrmParCCDEnable      = true;
                    PVar.LoginOutputEnable         = true;
                    PVar.LoginMachineParEnable     = true;
                    PVar.LoginManualEnable         = true;
                }
                if (PVar.Login.NewUserAuthority[i] == 3) //FE2
                {
                    PVar.LoginFrmEngineeringEnable = false;
                    PVar.LoginFrmParEnable         = false;
                    PVar.LoginOutputEnable         = true;
                }
                FunctionSub.Close_NumberKey_Process();
                //Temp = False
            }
            else
            {
                PVar.LoginFrmEngineeringEnable = false;
                PVar.LoginFrmParEnable         = false;
                PVar.LoginFrmParCCDEnable      = false;
                PVar.LoginOutputEnable         = false;
                PVar.LoginManualEnable         = false;
                PVar.LoginMachineParEnable     = false;
                if (Interaction.MsgBox("密码输入错误,请重新输入!", Constants.vbOKOnly, "提示") == Constants.vbOK)
                {
                    if (PVar.IsOpenFrmLogin)
                    {
                        Frm_Login.fLogin.MainPassword.Text = "";
                        Frm_Login.fLogin.MainPassword.Focus();
                    }
                    else
                    {
                        this.MainPassword.Text = "";
                        this.MainPassword.Focus();
                    }
                    return;
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 异常统计
        /// </summary>
        /// <param name="ErrInfo"></param>
        /// <remarks></remarks>
        public static void RecordErrInfo(string ErrInfo)
        {
            int ErrCounts = 0;

            switch (ErrInfo)
            {
            case "MEMErrCounts":
                PVar.MEMErrCounts = int.Parse(BVar.FileRorW.ReadINI("ErrStatistics", ErrInfo, System.Convert.ToString(0), PVar.BZ_ErrStatisticsPath));
                PVar.MEMErrCounts++;
                ErrCounts = PVar.MEMErrCounts;
                BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(PVar.MEMErrCounts), PVar.BZ_ErrStatisticsPath);
                if (FileRw.IsNotShow("Frm_Par"))
                {
                    Frm_Par.fPar.txt_ErrCount3.Text = System.Convert.ToString(PVar.MEMErrCounts);
                }
                break;

            case "PickCCDErr":
                PVar.PickCCDErrCounts = int.Parse(BVar.FileRorW.ReadINI("ErrStatistics", ErrInfo, System.Convert.ToString(0), PVar.BZ_ErrStatisticsPath));
                PVar.PickCCDErrCounts++;
                ErrCounts = PVar.PickCCDErrCounts;
                BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(PVar.PickCCDErrCounts), PVar.BZ_ErrStatisticsPath);
                if (FileRw.IsNotShow("Frm_Par"))
                {
                    Frm_Par.fPar.txt_ErrCount1.Text = System.Convert.ToString(PVar.PickCCDErrCounts);
                }
                break;

            case "PickErr":
                PVar.PickErrCounts = int.Parse(BVar.FileRorW.ReadINI("ErrStatistics", ErrInfo, System.Convert.ToString(0), PVar.BZ_ErrStatisticsPath));
                PVar.PickErrCounts++;
                ErrCounts = PVar.PickErrCounts;
                BVar.FileRorW.WriteINI("ErrStatistics", "PickErr", System.Convert.ToString(PVar.PickErrCounts), PVar.BZ_ErrStatisticsPath);
                if (FileRw.IsNotShow("Frm_Par"))
                {
                    Frm_Par.fPar.txt_ErrCount2.Text = System.Convert.ToString(PVar.PickErrCounts);
                }
                break;

            case "HsgSnErr":
                PVar.HsgSnErrCounts = int.Parse(BVar.FileRorW.ReadINI("ErrStatistics", ErrInfo, System.Convert.ToString(0), PVar.BZ_ErrStatisticsPath));
                PVar.HsgSnErrCounts++;
                ErrCounts = PVar.HsgSnErrCounts;
                BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(PVar.HsgSnErrCounts), PVar.BZ_ErrStatisticsPath);
                if (FileRw.IsNotShow("Frm_Par"))
                {
                    Frm_Par.fPar.txt_ErrCount9.Text = System.Convert.ToString(PVar.HsgSnErrCounts);
                }
                break;

            case "HsgErr":
                PVar.HsgErrCounts = int.Parse(BVar.FileRorW.ReadINI("ErrStatistics", ErrInfo, System.Convert.ToString(0), PVar.BZ_ErrStatisticsPath));
                PVar.HsgErrCounts++;
                ErrCounts = PVar.HsgErrCounts;
                BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(PVar.HsgErrCounts), PVar.BZ_ErrStatisticsPath);
                if (FileRw.IsNotShow("Frm_Par"))
                {
                    Frm_Par.fPar.txt_ErrCount9.Text = System.Convert.ToString(PVar.HsgErrCounts);
                }
                break;
            }

            BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(ErrCounts), PVar.BZ_ErrStatisticsPath);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 更新生产数据
        /// </summary>
        /// <remarks></remarks>
        public void CalculateYield()
        {
            string TimeNowDate     = "";
            string TimeBeforeMonth = "";

            TimeNowDate = DateTime.Now.ToString("yyyyMMdd");
            DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            TimeBeforeMonth          = System.Convert.ToString(dt.AddDays(-30).ToString("yyyyMMdd"));
            PVar.NgCountOfDay        = int.Parse(BVar.FileRorW.ReadINI("ProductCount", "NgCountOfDay", System.Convert.ToString(0), PVar.BZ_YieldDataFileName));
            PVar.NgCountOfMonth      = int.Parse(BVar.FileRorW.ReadINI("ProductCount", "NgCountOfMonth", System.Convert.ToString(0), PVar.BZ_YieldDataFileName));
            PVar.ProductCountOfDay   = int.Parse(BVar.FileRorW.ReadINI("ProductCount", "ProductCountOfDay", System.Convert.ToString(0), PVar.BZ_YieldDataFileName));
            PVar.ProductCountOfMonth = int.Parse(BVar.FileRorW.ReadINI("ProductCount", "ProductCountOfMonth", System.Convert.ToString(0), PVar.BZ_YieldDataFileName));
            PVar.RecordTimeOfDate    = BVar.FileRorW.ReadINI("ProductTime", "RecordTimeOfDate", TimeNowDate, PVar.BZ_YieldDataFileName);
            PVar.RecordTimeOfMonth   = BVar.FileRorW.ReadINI("ProductTime", "RecordTimeOfMonth", TimeNowDate, PVar.BZ_YieldDataFileName);

            FileRw.ReadYieldFile(PVar.BZ_YieldMonthDataFileName, PVar.YieldOfMonth);

            //**************************************记录当天日良率********************************************************
            if (double.Parse(TimeNowDate) - double.Parse(PVar.RecordTimeOfDate) == 0) //当前日期与记录日期相同
            {
                PVar.ProductCountOfDay++;
                PVar.NgCountOfDay                 = (BVar.ProData[4, 30] == "OK") ? PVar.NgCountOfDay : PVar.NgCountOfDay + 1;
                PVar.YieldOfMonth.NgCount[0]      = PVar.NgCountOfDay; //更新最新一天的产量
                PVar.YieldOfMonth.ProductCount[0] = PVar.ProductCountOfDay;
                PVar.YieldOfMonth.RecordTime[0]   = DateTime.Now;
            }
            else
            {
                PVar.ProductCountOfDay = 1;
                PVar.NgCountOfDay      = (BVar.ProData[4, 30] == "OK") ? 0 : 1;
                ExchangeYieldData();                                   //30天产量统计数据交换,ExchangeYieldData(0)为最新一天的产量,ExchangeYieldData(29)为30天前的产量
                PVar.YieldOfMonth.NgCount[0]      = PVar.NgCountOfDay; //更新最新一天的产量
                PVar.YieldOfMonth.ProductCount[0] = PVar.ProductCountOfDay;
                PVar.YieldOfMonth.RecordTime[0]   = DateTime.Now;
            }

            FileRw.WriteYieldFile(PVar.BZ_YieldMonthDataFileName, PVar.YieldOfMonth);
            BVar.FileRorW.WriteINI("ProductCount", "ProductCountOfDay", System.Convert.ToString(PVar.ProductCountOfDay), PVar.BZ_YieldDataFileName);
            BVar.FileRorW.WriteINI("ProductCount", "NgCountOfDay", System.Convert.ToString(PVar.NgCountOfDay), PVar.BZ_YieldDataFileName);
            BVar.FileRorW.WriteINI("ProductTime", "RecordTimeOfDate", TimeNowDate, PVar.BZ_YieldDataFileName); //更新当天日期
            PVar.DayYieldOfNg = Math.Round(System.Convert.ToDouble(((double)PVar.NgCountOfDay / PVar.ProductCountOfDay) * 100), 1);
            this.DRB_YieldRetest.BZ_NgRateDay = (int)PVar.DayYieldOfNg;                                        //日Ng率

            //**************************************记录当月良率********************************************************
            if (double.Parse(TimeBeforeMonth) - double.Parse(PVar.RecordTimeOfMonth) <= 0) //当前时间减30天小于记录的一个月后时间
            {
                PVar.ProductCountOfMonth++;
                PVar.NgCountOfMonth     = (BVar.ProData[4, 30] == "OK") ? PVar.NgCountOfMonth : PVar.NgCountOfMonth + 1;
                this.Lbl_StartTime.Text = System.Convert.ToString(dt.AddDays(-30).ToString("MM/dd/yy"));
                this.Lbl_EndTime.Text   = DateTime.Now.ToString("MM/dd/yy"); //结束日期为当前日期
            }
            else
            {
                PVar.ProductCountOfMonth = PVar.ProductCountOfMonth - PVar.YieldOfMonth.ProductCount[29] + 1;                                                                                 //更新月产量,总数减去30天前的产量
                PVar.NgCountOfMonth      = (BVar.ProData[4, 30] == "OK") ? (PVar.NgCountOfMonth - PVar.YieldOfMonth.NgCount[29]) : (PVar.NgCountOfMonth - PVar.YieldOfMonth.NgCount[29] + 1); //更新月NG数量,总数减去30天前的产量
                BVar.FileRorW.WriteINI("ProductTime", "RecordTimeOfMonth", DateTime.Now.ToString("yyyyMMdd"), PVar.BZ_YieldDataFileName);                                                     //更新月良率记录时间
                //Frm_Production.Lbl_StartTime.Text = YieldOfMonth.RecordTime(29).ToString("yyyyMMdd")   '开始日期为当前往前30天
                this.Lbl_StartTime.Text = System.Convert.ToString(dt.AddDays(-30).ToString("MM/dd/yy"));                                                                                      //开始日期为当前往前30天
                this.Lbl_EndTime.Text   = DateTime.Now.ToString("MM/dd/yy");                                                                                                                  //结束日期为当前日期
            }

            BVar.FileRorW.WriteINI("ProductCount", "ProductCountOfMonth", System.Convert.ToString(PVar.ProductCountOfMonth), PVar.BZ_YieldDataFileName);
            BVar.FileRorW.WriteINI("ProductCount", "NgCountOfMonth", System.Convert.ToString(PVar.NgCountOfMonth), PVar.BZ_YieldDataFileName);

            PVar.MonthYieldOfNg = Math.Round(System.Convert.ToDouble(((double)PVar.NgCountOfMonth / PVar.ProductCountOfMonth) * 100), 1);
            this.DRB_YieldRetest.BZ_NgRateMonth = (int)PVar.MonthYieldOfNg; //月Ng率
        }
Ejemplo n.º 23
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.Result = false;
                        StaWork.State  = false;
                        PressTime.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (StaWork.State == false && StaWork.Enable)
                    {
                        AddList("保压开始!");
                        StaWork.Enable = false;
                        StaWork.State  = true;
                        PressTime.InitialTime();
                        StaWork.Step = 30;
                    }
                    break;

                case 30:
                    if (EpsonRobot.RobotLivePos.Y > -200)    //判断机械手是否在流水线外
                    {
                        AddList("保压无杆气缸向左移动!");
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 1);
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 0);
                        Command.Com1_Send(Command.压力控制打开);
                        PressTime.InitialTime();
                        StaWork.Step = 40;
                    }
                    break;

                case 40:
                    if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 1 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 0)
                    {
                        PressTime.InitialTime();
                        StaWork.Step = 50;
                    }
                    else if (PressTime.TimeIsUp(8000))
                    {
                        AddList("保压无杆气缸左信号感应异常!");
                        ShowList("保压无杆气缸左信号感应异常!");
                        PressTime.InitialTime();
                        BufferStep   = 40;
                        StaWork.Step = 8000;
                    }
                    break;

                case 50:
                    if (PressTime.TimeIsUp(200))
                    {
                        BVar.ProData[2, 6] = Frm_Engineering.fEngineering.Press1_Text.Text;    //获取自重的压力值
                        Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.保压位置], PVar.ParAxis.Speed[Axis.保压Z轴]);
                        PressTime.InitialTime();
                        StaWork.Step = 60;
                    }
                    break;

                case 60:
                    if (Gg.ZSPD(0, Axis.保压Z轴))
                    {
                        PressTime.InitialTime();
                        StaWork.Step = 70;
                    }
                    break;

                case 70:
                    if (PressTime.TimeIsUp((int)PVar.ParList.Data[44] * 1000))    //配重块保压时间
                    {
                        AddList("保压时间为:" + PVar.ParList.Data[44] * 1000 + "S");
                        Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.初始位置], PVar.ParAxis.Speed[Axis.保压Z轴]);
                        PressTime.InitialTime();
                        StaWork.Step = 80;
                    }
                    break;

                case 80:
                    //保压轴和气缸复位
                    if (Gg.ZSPD(0, Axis.保压Z轴) && Gg.GetHomeDi(0, Axis.保压Z轴) == 1)
                    {
                        //保压站无杆气缸双头电磁阀向右
                        AddList("保压无杆气缸向右移动!");
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 0);
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 1);
                        PressTime.InitialTime();
                        StaWork.Step = 90;
                    }
                    break;

                case 90:
                    if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 0 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 1)
                    {
                        AddList("保压工作完成!");
                        PressTime.InitialTime();
                        StaWork.Step = 100;
                    }
                    else if (PressTime.TimeIsUp(5000))
                    {
                        AddList("保压无杆气缸右信号感应异常!");
                        ShowList("保压无杆气缸右信号感应异常!");
                        BufferStep   = 90;
                        StaWork.Step = 8000;
                    }
                    break;

                case 100:
                    //复位流水线2等待状态
                    PVar.Sta_Work[(int)BVar.工位.流水线2].IsReady = false;
                    PressTime.InitialTime();
                    StaWork.Step = 800;
                    break;

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

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

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    PVar.IsSystemOnPauseMode                        = true;
                    PVar.MacHold                                    = true;
                    StaWork.StaHold                                 = 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);
            }
        }
Ejemplo n.º 24
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        Line3Time.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (StaWork.State == false && StaWork.IsHaveFix)
                    {
                        AddList("组装开始!");
                        StaWork.State = true;

                        BVar.ProData[3, 1] = BVar.ProData[2, 1];    //Bezel条码
                        BVar.ProData[3, 3] = BVar.ProData[2, 3];    //载具条码
                        Line3Time.InitialTime();
                        StaWork.Step = 30;
                    }
                    else if (Line3Time.TimeIsUp(50))
                    {
                        StaWork.Step = 10;
                    }
                    break;

                case 30:
                    if (PVar.空跑)
                    {
                        if (Line3Time.TimeIsUp(2000))
                        {
                            AddList("载具流出感应到!");
                            Linechange.SetMotor3(true, 10);
                            Line3Time.InitialTime();
                            StaWork.Step = 40;
                        }
                    }
                    else
                    {
                        if (Linechange.LineOut() == 1)
                        {
                            AddList("载具流出感应到!");
                            Line3Time.InitialTime();
                            StaWork.Step = 40;
                            Linechange.SetMotor3(false, PVar.ParList.Data[43]);
                        }
                        else if (Line3Time.TimeIsUp(5000))
                        {
                            Line3Time.InitialTime();
                            StaWork.Step = 40;
                        }
                    }

                    break;

                case 40:
                    if (Line3Time.TimeIsUp(1000))
                    {
                        AddList("流水线3马达停止!");
                        Linechange.SetMotor3(false, PVar.ParList.Data[43]);
                        Line3Time.InitialTime();
                        StaWork.Step = 50;
                    }
                    break;

                case 50:
                    if (Linechange.LineOut() == 0)
                    {
                        AddList("载具已经取走!");
                        StaWork.IsHaveFix = false;
                        Line3Time.InitialTime();
                        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;

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    if (Manual.AutoMotionFlag[3])
                    {
                        if (Manual.HoldFlag[3])
                        {
                            Manual.HoldFlag[3] = false;
                            Frm_Engineering.fEngineering.CmdHoldPress.Text      = "暂停";
                            Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.BurlyWood;
                            ShowList("运动已继续");
                        }
                        else
                        {
                            Manual.HoldFlag[3] = true;
                            Frm_Engineering.fEngineering.CmdHoldPress.Text      = "继续";
                            Frm_Engineering.fEngineering.CmdHoldPress.BackColor = Color.Red;
                            ShowList("运动已暂停");
                        }
                    }
                    else
                    {
                        PVar.IsSystemOnPauseMode                        = true;
                        PVar.MacHold                                    = true;
                        StaWork.StaHold                                 = 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;

                //严重错误,急停处理
                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);
            }
        }
Ejemplo n.º 25
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State  = false;
                        StaWork.Result = false;
                        Line2Time.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (PVar.空跑)
                    {
                        if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveFix)
                        {
                            AddList("组装开始!");
                            StaWork.State  = true;
                            StaWork.Enable = false;

                            BVar.ProData[2, 1] = BVar.ProData[1, 1];    //Bezel条码
                            BVar.ProData[2, 3] = BVar.ProData[1, 3];    //载具条码
                            Frm_Engineering.fEngineering.Lab_Station2.Text = BVar.ProData[2, 1];

                            Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 1);
                            Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 1);
                            Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0);
                            Line2Time.InitialTime();
                            StaWork.Step = 30;
                        }
                        else
                        {
                            if (Line2Time.TimeIsUp(20))
                            {
                                Line2Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else    //********************************************
                    {
                        if (StaWork.State == false && StaWork.Enable && StaWork.IsHaveFix)
                        {
                            AddList("组装开始!");
                            StaWork.State  = true;
                            StaWork.Enable = false;

                            BVar.ProData[2, 1] = BVar.ProData[1, 1];    //Bezel条码
                            BVar.ProData[2, 3] = BVar.ProData[1, 3];    //载具条码
                            Frm_Engineering.fEngineering.Lab_Station2.Text = BVar.ProData[2, 1];

                            Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 1);
                            Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 1);
                            Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0);
                            Line2Time.InitialTime();
                            StaWork.Step = 30;
                        }
                        else if (StaWork.State == false && StaWork.Enable == false && StaWork.IsHaveFix)
                        {
                            AddList("没有条码,跳过组装!");
                            StaWork.Result = false;
                            Line2Time.InitialTime();
                            StaWork.Step = 5000;     //等待放行
                        }
                        else
                        {
                            StaWork.Step = 10;
                        }
                    }
                    break;

                case 30:
                    AddList("保压Z轴回初始位置!");
                    Gg.AbsMotion(0, Axis.保压Z轴, mFunction.Pos.TeachAxis1[Axis.tTag.保压, Axis.Point保压.初始位置], PVar.ParAxis.Speed[Axis.保压Z轴]);
                    Line2Time.InitialTime();
                    StaWork.Step = 40;
                    break;

                case 40:
                    //保压轴和气缸复位
                    if (Gg.ZSPD(0, Axis.保压Z轴) && Gg.GetHomeDi(0, Axis.保压Z轴) == 1)
                    {
                        //保压站无杆气缸双头电磁阀向右
                        AddList("保压Z轴OK!");
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸左, 0);
                        Gg.SetExDo(0, 0, Gg.OutPut1.保压无杆气缸右, 1);
                        Line2Time.InitialTime();
                        StaWork.Step = 50;
                    }
                    else if (Line2Time.TimeIsUp(8000))
                    {
                        AddList("保压Z轴运动到初始位置超时!");
                        ShowList("保压Z轴运动到初始位置超时!");
                        StaWork.Result = false;
                        Line2Time.InitialTime();
                        StaWork.Step = 10000;
                    }
                    break;

                case 50:
                    if (Gg.GetExDi(0, Gg.InPut1.保压无杆气缸左) == 0 && Gg.GetExDi(0, Gg.InPut1.保压无杆气缸右) == 1)
                    {
                        if (EpsonRobot.RobotLivePos.Y > -150)    //判断机械手是否在流水线外
                        {
                            Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1);
                        }
                        Line2Time.InitialTime();
                        StaWork.Step = 60;
                    }
                    else if (Line2Time.TimeIsUp(5000))
                    {
                        AddList("保压无杆气缸右信号感应异常!");
                        ShowList("保压无杆气缸右信号感应异常!");
                        StaWork.Result = false;
                        Line2Time.InitialTime();
                        StaWork.Step = 5000;      //等待放行
                    }
                    break;

                case 60:
                    if (Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 1)
                    {
                        AddList("载具夹紧气缸伸出信号OK!");
                        AddList("等待光源旋转气缸伸出信号感应!");
                        Line2Time.InitialTime();
                        StaWork.Step = 70;
                    }
                    else if (Line2Time.TimeIsUp(2000) && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 0)
                    {
                        AddList("保载具夹紧气缸伸出信号感应异常!");
                        Line2Time.InitialTime();
                        StaWork.Step = 70;    //小异常忽略
                    }
                    break;

                case 70:
                    if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 1)
                    {
                        AddList("光源旋转气缸伸出信号感应OK!");
                        Line2Time.InitialTime();
                        StaWork.Step = 200;
                    }
                    else
                    {
                        if (EpsonRobot.RobotLivePos.Y > -200)    //判断机械手是否在流水线外
                        {
                            Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1);
                        }
                    }
                    break;

                //相机拍照
                case 200:
                    CCD_CMD = "T31" + "," + BVar.ProData[2, 1] + "," +
                              EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U;
                    sRtn = Command.TCP_CCD_Send(CCD_CMD);
                    AddList("Bezel定位拍照");
                    if (PVar.空跑)
                    {
                        Line2Time.InitialTime();
                        StaWork.Step = 210;
                    }
                    else
                    {
                        if (sRtn == 1)     //命令发送成功
                        {
                            Line2Time.InitialTime();
                            StaWork.Step = 210;
                        }
                        else
                        {
                            AddList("T31命令发送失败!");
                            ShowList("T31命令发送失败!");
                            Line2Time.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 210:
                    if (PVar.空跑)
                    {
                        if (Line2Time.TimeIsUp(2000))
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 0);
                            Line2Time.InitialTime();
                            StaWork.Step = 220;
                        }
                    }
                    else    //****************************************************
                    {
                        if (Command.CCD_Resule && PVar.CCD_Data[0] == "T31")
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 0);
                            Line2Time.InitialTime();
                            StaWork.Step = 220;
                        }
                        else
                        {
                            if (Line2Time.TimeIsUp(5000))
                            {
                                AddList("等待CCD T31数据超时!");
                                ShowList("等待CCD T31数据超时!");
                                Line2Time.InitialTime();
                                StaWork.Step = 1000;
                            }
                        }
                    }
                    break;

                case 220:
                    if (PVar.空跑)
                    {
                        AddList("拍照OK,开始等待机械手开始工作结束");
                        Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 0);
                        PVar.Sta_Work[(int)BVar.工位.机械手].Enable = true;    //允许机械手开始工作,目前不考虑CT,后续提前并行
                        Line2Time.InitialTime();
                        StaWork.Step = 230;
                    }
                    else
                    {
                        if (PVar.CCD_Data[1] == "1")
                        {
                            AddList("拍照OK,开始等待机械手开始工作结束");

                            PVar.Sta_Work[(int)BVar.工位.机械手].Enable = true;    //允许机械手开始工作,目前不考虑CT,后续提前并行
                            Line2Time.InitialTime();
                            StaWork.Step = 230;
                        }
                        else
                        {
                            AddList("Bezel拍照NG,异常直接流出");
                            StaWork.Result = false;
                            Line2Time.InitialTime();
                            StaWork.Step = 5000;
                        }
                    }
                    break;

                case 230:
                    if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 0)
                    {
                        AddList("光源旋转气缸缩回信号感应OK!");
                        StaWork.IsReady = true;    //所有准备就绪,等待机械手完成
                        Line2Time.InitialTime();
                        StaWork.Step = 300;
                    }
                    else if (Line2Time.TimeIsUp(5000))
                    {
                        AddList("光源旋转气缸缩回超时!");
                        ShowList("光源旋转气缸缩回超时!");
                        Line2Time.InitialTime();
                        StaWork.Step = 5000;
                    }
                    break;



                //************************************************************************************************
                //等待机械手装配完成
                case 300:
                    if (StaWork.IsReady == false)
                    {
                        AddList("装配完成,开始复检!");
                        Line2Time.InitialTime();
                        StaWork.Step = 310;
                    }
                    break;

                case 310:
                    if (Gg.GetExDi(0, Gg.InPut1.光源旋转气缸缩回) == 0 && Gg.GetExDi(0, Gg.InPut1.光源旋转气缸伸出) == 1)
                    {
                        AddList("光源旋转气缸伸出信号感应OK!");
                        Line2Time.InitialTime();
                        StaWork.Step = 320;
                    }
                    else
                    {
                        if (EpsonRobot.RobotLivePos.Y > -150)    //判断机械手是否在流水线外
                        {
                            Gg.SetExDo(0, 0, Gg.OutPut1.光源旋转气缸, 1);
                        }
                    }
                    break;

                case 320:
                    CCD_CMD = "T33" + "," + BVar.ProData[2, 1] + "," +
                              EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U;
                    sRtn = Command.TCP_CCD_Send(CCD_CMD);
                    AddList("Bezel下相机复检拍照");
                    if (PVar.空跑)
                    {
                        Line2Time.InitialTime();
                        StaWork.Step = 330;
                    }
                    else
                    {
                        if (sRtn == 1)     //命令发送成功
                        {
                            Line2Time.InitialTime();
                            StaWork.Step = 330;
                        }
                        else
                        {
                            AddList("T33命令发送失败!");
                            ShowList("T33命令发送失败!");
                            Line2Time.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 330:
                    if (PVar.空跑)
                    {
                        if (Line2Time.TimeIsUp(1000))
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Line2Time.InitialTime();
                            StaWork.Step = 340;
                        }
                    }
                    else
                    {
                        if (Command.CCD_Resule && PVar.CCD_Data[0] == "T33")
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Line2Time.InitialTime();
                            StaWork.Step = 340;
                        }
                        else
                        {
                            if (Line2Time.TimeIsUp(5000))
                            {
                                AddList("等待CCD T33数据超时!");
                                ShowList("等待CCD T33数据超时!");
                                Line2Time.InitialTime();
                                StaWork.Step = 1000;
                            }
                        }
                    }
                    break;

                case 340:
                    if (PVar.空跑)
                    {
                        AddList("拍照OK");
                        Line2Time.InitialTime();
                        StaWork.Step = 350;
                    }
                    else
                    {
                        if (PVar.CCD_Data[1] == "1")
                        {
                            AddList("拍照OK");
                            Line2Time.InitialTime();
                            StaWork.Step = 350;
                        }
                        else
                        {
                            AddList("Bezel拍照NG,异常直接流出");
                            StaWork.Result = false;
                            Line2Time.InitialTime();
                            StaWork.Step = 5000;
                        }
                    }
                    break;

                case 350:
                    CCD_CMD = "T41" + "," + BVar.ProData[2, 1] + "," +
                              EpsonRobot.RobotLivePos.X + "," + EpsonRobot.RobotLivePos.Y + "," + EpsonRobot.RobotLivePos.U;
                    sRtn = Command.TCP_CCD_Send(CCD_CMD);
                    AddList("Bezel上相机复检拍照");
                    if (PVar.空跑)
                    {
                        Line2Time.InitialTime();
                        StaWork.Step = 360;
                    }
                    else
                    {
                        if (sRtn == 1)     //命令发送成功
                        {
                            Line2Time.InitialTime();
                            StaWork.Step = 360;
                        }
                        else
                        {
                            AddList("T41命令发送失败!");
                            ShowList("T41命令发送失败!");
                            Line2Time.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 360:
                    if (PVar.空跑)
                    {
                        if (Line2Time.TimeIsUp(1000))
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Line2Time.InitialTime();
                            StaWork.Step = 370;
                        }
                    }
                    else
                    {
                        if (Command.CCD_Resule && PVar.CCD_Data[0] == "T41")
                        {
                            AddList("<<- Recevied:" + PVar.CCD_StrData);
                            Line2Time.InitialTime();
                            StaWork.Step = 370;
                        }
                        else
                        {
                            if (Line2Time.TimeIsUp(5000))
                            {
                                AddList("等待CCD T41数据超时!");
                                ShowList("等待CCD T41数据超时!");
                                Line2Time.InitialTime();
                                StaWork.Step = 1000;
                            }
                        }
                    }
                    break;

                case 370:
                    if (PVar.空跑)
                    {
                        AddList("拍照OK,开始上传PDCA");
                        Line2Time.InitialTime();
                        StaWork.Step = 380;
                    }
                    else
                    {
                        if (PVar.CCD_Data[1] == "1")
                        {
                            AddList("拍照OK,开始上传PDCA");
                            Line2Time.InitialTime();
                            StaWork.Step = 380;
                        }
                        else
                        {
                            AddList("Bezel拍照NG,异常直接流出");
                            StaWork.Result = false;
                            Line2Time.InitialTime();
                            StaWork.Step = 5000;
                        }
                    }
                    break;

                case 380:

                    Line2Time.InitialTime();
                    StaWork.Step = 505;
                    break;

                //复检检测输出值
                //***********************************************

                case 505:
                    Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 0);
                    Gg.SetExDo(0, 0, Gg.OutPut1.载具夹紧气缸, 0);
                    Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品真空吸, 0);
                    Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 1);
                    Line2Time.InitialTime();
                    StaWork.Step = 510;
                    break;

                case 510:
                    if (Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸缩回) == 1 && Gg.GetExDi(0, Gg.InPut1.载具夹紧气缸伸出) == 0)
                    {
                        AddList("装配完成,等待放行!");
                        Line2Time.InitialTime();
                        StaWork.Step = 600;
                    }
                    else if (Line2Time.TimeIsUp(3000))
                    {
                        AddList("保载具夹紧气缸伸出信号感应异常!");
                        Line2Time.InitialTime();
                        StaWork.Step = 400;
                    }
                    break;

                case 600:
                    if (PVar.空跑)
                    {
                        if (PVar.Stop_Flag == false && Linechange.LineOut() == 0 && PVar.Sta_Work[(int)BVar.工位.流水线3].State == false)
                        {
                            AddList("载具开始放行,等待流水线3接收!");
                            Gg.SetExDo(0, 1, Gg.OutPut2.载具上产品破真空, 0);
                            Frm_Engineering.fEngineering.Txt_BarCode.Text = "";
                            Linechange.SetMotor2(true, PVar.ParList.Data[43]);
                            Linechange.SetMotor3(true, PVar.ParList.Data[43]);
                            Line2Time.InitialTime();
                            StaWork.Step = 610;
                        }
                        else
                        {
                            if (PVar.Stop_Flag)
                            {
                                StaWork.State = false;
                                Line2Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else    //******************************************************
                    {
                        //等待放行*****************************
                        if (PVar.Stop_Flag == false && Linechange.LineOut() == 0 && PVar.Sta_Work[(int)BVar.工位.流水线3].State == false)
                        {
                            AddList("载具开始放行,等待流水线3接收!");
                            Frm_Engineering.fEngineering.Txt_BarCode.Text = "";
                            Linechange.SetMotor2(true, PVar.ParList.Data[43]);
                            Linechange.SetMotor3(true, PVar.ParList.Data[43]);
                            Line2Time.InitialTime();
                            StaWork.Step = 610;
                        }
                    }
                    break;

                case 610:
                    if (PVar.空跑)
                    {
                        if (Line2Time.TimeIsUp(1000))
                        {
                            AddList("载具开始放行!");
                            Line2Time.InitialTime();
                            StaWork.Step = 620;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应4) == 0)
                        {
                            AddList("载具开始放行!");
                            Line2Time.InitialTime();
                            StaWork.Step = 620;
                        }
                        else if (Line2Time.TimeIsUp(5000))
                        {
                            AddList("流水线2放行载具超时!");
                            ShowList("流水线2放行载具超时!");
                            Line2Time.InitialTime();
                            StaWork.Step = 620;
                        }
                    }
                    break;

                case 620:
                    if (PVar.空跑)
                    {
                        if (Line2Time.TimeIsUp(1000))
                        {
                            AddList("流水线2载具开始放行完成!");
                            //*********************************************************应该可以开始接受上站载具
                            PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true;

                            Line2Time.InitialTime();
                            StaWork.Step = 630;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应5) == 0)
                        {
                            AddList("流水线2载具开始放行完成!");
                            //*********************************************************应该可以开始接受上站载具
                            PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true;
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 1);
                            Line2Time.InitialTime();
                            StaWork.Step = 630;
                        }
                        else if (Line2Time.TimeIsUp(5000))
                        {
                            AddList("流水线2放行载具超时!");
                            ShowList("流水线2放行载具超时!");
                            Line2Time.InitialTime();
                            StaWork.Step = 630;
                        }
                    }
                    break;

                case 630:
                    if (Line2Time.TimeIsUp(500))
                    {
                        AddList("流水线2载具放行完成!");
                        Gg.SetDo(0, Gg.OutPut0.阻挡气缸3, 1);
                        PVar.Sta_Work[(int)BVar.工位.流水线2].IsHaveFix = false;
                        PVar.Sta_Work[(int)BVar.工位.流水线3].IsHaveFix = true;
                        Linechange.SetMotor2(false, PVar.ParList.Data[43]);
                        Line2Time.InitialTime();
                        StaWork.Step = 650;
                    }
                    break;

                case 650:
                    if (Line2Time.TimeIsUp(200))
                    {
                        Line2Time.InitialTime();
                        StaWork.Step = 800;
                    }
                    break;

                case 800:
                    StaWork.Enable           = false;
                    StaWork.Result           = true;
                    StaWork.State            = false;
                    Manual.AutoMotionFlag[2] = false;
                    StaWork.Step             = 10;
                    break;

                case 1000:
                    StaWork.Enable           = false;
                    StaWork.Result           = false;
                    StaWork.State            = false;
                    Manual.AutoMotionFlag[2] = false;
                    StaWork.Step             = 10;
                    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);
            }
        }
Ejemplo n.º 26
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);
            }
        }
Ejemplo n.º 27
0
        public static void AutoRunTA(ref PVar.WorkType StaWork, String Name)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    StaWork.Result = false;
                    StaWork.State  = true;
                    ClearList2("");    //清空list
                    TestCount = 1;
                    string fileFinalData = "E:\\BZ-Data\\DAB\\TestData\\" + DateTime.Now.ToString("yyyyMM") + "\\" + Name + DateTime.Now.ToString("yyyyMM") + ".csv";
                    Path = fileFinalData;
                    InitTime.InitialTime();
                    StaWork.Step = 20;
                    break;

                case 20:
                    if (Name == "相机1静态")
                    {
                        CCD_CMD = "Send: T11," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    if (Name == "相机2静态")
                    {
                        CCD_CMD = "Send: T21," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    if (Name == "相机3静态")
                    {
                        CCD_CMD = "Send: T31," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    if (Name == "相机4静态")
                    {
                        CCD_CMD = "Send: T41," + DateTime.Now.ToString("yyyyMMdd") + "0,0,0";
                    }
                    sRtn = Command.TCP_CCD_Send(CCD_CMD);
                    AddList2("CCD命令  ->> " + CCD_CMD);
                    AddList2("静态测试拍照第" + TestCount + "次");
                    TestCount += 1;
                    InitTime.InitialTime();
                    StaWork.Step = 30;
                    //if (sRtn == 1) //命令发送成功
                    //    {
                    //    InitTime.InitialTime();
                    //    StaWork.Step = 30;
                    //    }
                    //else
                    //    {
                    //    AddList2("命令发送失败!");
                    //    ShowList("命令发送失败!");
                    //    InitTime.InitialTime();
                    //    StaWork.Step = 1000;
                    //    }
                    break;

                case 30:
                    if (Command.CCD_Resule == false)
                    {
                        AddList2("<<- Recevied:" + PVar.CCD_StrData);
                        //时间,CCD判断值,X,Y,R
                        string TestData = Convert.ToString(DateAndTime.TimeOfDay.TimeOfDay) + "," + PVar.CCD_Data[1] + "," + PVar.CCD_Data[2] + "," + PVar.CCD_Data[3] + "," + PVar.CCD_Data[4];
                        BVar.FileRorW.WriteTestDataCsv(TestData, Path);
                        InitTime.InitialTime();
                        StaWork.Step = 35;
                    }
                    else
                    {
                        if (InitTime.TimeIsUp(5000))
                        {
                            AddList2("等待CCD数据超时!");
                            ShowList("等待CCD数据超时!");
                            InitTime.InitialTime();
                            StaWork.Step = 1000;
                        }
                    }
                    break;

                case 35:
                    if (InitTime.TimeIsUp(1000))
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 40;
                    }
                    break;

                case 40:
                    if (TestCount <= Convert.ToInt16(Frm_Engineering.fEngineering.TextBox_Num.Text))
                    {
                        InitTime.InitialTime();
                        StaWork.Step = 20;
                    }
                    else
                    {
                        AddList2("测试完成!");
                        ShowList("测试完成!");
                        InitTime.InitialTime();
                        StaWork.Step = 800;
                    }
                    break;

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

                case 1000:
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 0;
                    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);
            }
        }
Ejemplo n.º 28
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.IsHaveFix = false;
                        StaWork.Result    = false;
                        StaWork.State     = false;
                        Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1);
                        Line0Time.InitialTime();
                        StaWork.Step = 20;
                    }
                    break;

                case 20:
                    if (PVar.空跑)
                    {
                        if (StaWork.State == false && Gg.GetExDi(1, Gg.InPut2.流水线对射感应1) == 0 && Linechange.LineIN() == 0)
                        {
                            //启动触发,载具感应触发,防呆无触发,说明有载具
                            AddList("启动开始!");
                            StaWork.State     = true;
                            StaWork.IsHaveFix = true;    //入口有载具
                            Line0Time.InitialTime();
                            StaWork.Step = 30;
                        }
                    }
                    else    //******************************************************
                    {
                        if (StaWork.State == false && Gg.GetDi(0, Gg.InPut0.启动按钮) == 1 && Gg.GetExDi(1, Gg.InPut2.流水线对射感应1) == 1 && Linechange.LineIN() == 0)
                        {
                            //启动触发,载具感应触发,防呆无触发,说明有载具
                            AddList("启动开始!");
                            StaWork.State     = true;
                            StaWork.IsHaveFix = true;    //入口有载具
                            Line0Time.InitialTime();
                            StaWork.Step = 30;
                        }
                    }
                    break;

                case 30:
                    if (PVar.空跑)
                    {
                        if (PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix == false && PVar.Stop_Flag == false && Gg.GetExDi(1, Gg.InPut2.流水线对射感应2) == 0 &&
                            Gg.GetExDi(1, Gg.InPut2.流水线对射感应3) == 0 && PVar.Sta_Work[(int)BVar.工位.流水线1].State == false)
                        {
                            StaWork.IsHaveFix = false;    //本站载具标志复位
                            AddList("载具开始放行,等待流水线1接收!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 0);
                            Linechange.SetMotor1(true, PVar.ParList.Data[43]);
                            Line0Time.InitialTime();
                            StaWork.Step = 40;
                        }
                        else
                        {
                            if (PVar.Stop_Flag)
                            {
                                StaWork.State = false;
                                Line0Time.InitialTime();
                                StaWork.Step = 10;
                            }
                        }
                    }
                    else    //*******************************************
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应1) == 0 || Linechange.LineIN() == 1)
                        {
                            AddList("载具感性信号异常,重新启动");
                            PVar.Sta_Work[0].IsHaveFix = false;
                            Line0Time.InitialTime();
                            StaWork.Step = 10;
                            return;
                        }
                        //等待放行*****************************
                        if (PVar.Stop_Flag == false && Gg.GetExDi(1, Gg.InPut2.流水线对射感应2) == 0 &&
                            Gg.GetExDi(1, Gg.InPut2.流水线对射感应3) == 0 && PVar.Sta_Work[(int)BVar.工位.流水线1].State == false)
                        {
                            StaWork.IsHaveFix = false;    //本站载具标志复位
                            AddList("载具开始放行,等待流水线1接收!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 0);
                            Linechange.SetMotor1(true, PVar.ParList.Data[43]);
                            Line0Time.InitialTime();
                            StaWork.Step = 40;
                        }
                    }
                    break;

                case 40:
                    if (PVar.空跑)
                    {
                        if (Line0Time.TimeIsUp(1000))
                        {
                            AddList("载具开始放行完成!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1);
                            Line0Time.InitialTime();
                            StaWork.Step = 50;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应1) == 0)
                        {
                            AddList("载具开始放行完成!");
                            Gg.SetDo(0, Gg.OutPut0.阻挡气缸1, 1);
                            Line0Time.InitialTime();
                            StaWork.Step = 50;
                        }
                    }
                    break;

                case 50:
                    if (PVar.空跑)
                    {
                        if (Line0Time.TimeIsUp(1000))
                        {
                            AddList("流水线对射感应2触发!");
                            AddList("流水线1开始减速!");
                            Linechange.SetMotor1(true, 10);
                            Line0Time.InitialTime();
                            StaWork.Step = 60;
                        }
                    }
                    else    //********************************************
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应2) == 1)
                        {
                            AddList("流水线对射感应2触发!");
                            Linechange.SetMotor1(true, 10);
                            Line0Time.InitialTime();
                            StaWork.Step = 60;
                        }
                    }
                    break;

                case 60:
                    if (PVar.空跑)
                    {
                        if (Line0Time.TimeIsUp(1000))
                        {
                            AddList("载具到达流水线1!");
                            Linechange.SetMotor1(true, 5);
                            Line0Time.InitialTime();
                            StaWork.Step = 70;
                        }
                    }
                    else
                    {
                        if (Gg.GetExDi(1, Gg.InPut2.流水线对射感应3) == 1)
                        {
                            AddList("载具到达流水线1!");
                            Line0Time.InitialTime();
                            StaWork.Step = 70;
                        }
                    }
                    break;

                case 70:
                    if (Line0Time.TimeIsUp(200))
                    {
                        PVar.Sta_Work[(int)BVar.工位.流水线1].IsHaveFix = true;
                        AddList("流水线1电机关闭!");
                        Linechange.SetMotor1(false, 0);
                        Line0Time.InitialTime();
                        StaWork.Step = 80;
                    }
                    break;

                case 80:
                    AddList("确认按钮是否松开?");
                    Line0Time.InitialTime();
                    StaWork.Step = 100;
                    break;

                case 100:
                    if (Gg.GetDi(0, Gg.InPut0.启动按钮) == 0)
                    {
                        AddList("按钮松开!");
                        Line0Time.InitialTime();
                        StaWork.Step = 800;
                    }
                    break;

                case 800:
                    Manual.AutoMotionFlag[0] = false;
                    StaWork.Enable           = false;
                    StaWork.State            = false;
                    StaWork.Step             = 10;
                    break;

                case 1000:
                    Manual.AutoMotionFlag[0] = false;
                    StaWork.Enable           = false;
                    StaWork.Result           = false;
                    StaWork.State            = false;
                    StaWork.Step             = 10;
                    break;

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    if (Manual.AutoMotionFlag[0])
                    {
                        if (Manual.HoldFlag[0])
                        {
                            Manual.HoldFlag[0] = false;
                            Frm_Engineering.fEngineering.CmdHoldS0.Text      = "暂停";
                            Frm_Engineering.fEngineering.CmdHoldS0.BackColor = Color.BurlyWood;
                            ShowList("运动已继续");
                        }
                        else
                        {
                            Manual.HoldFlag[0] = true;
                            Frm_Engineering.fEngineering.CmdHoldS0.Text      = "继续";
                            Frm_Engineering.fEngineering.CmdHoldS0.BackColor = Color.Red;
                            ShowList("运动已暂停");
                        }
                    }
                    else
                    {
                        PVar.IsSystemOnPauseMode                        = true;
                        PVar.MacHold                                    = true;
                        StaWork.StaHold                                 = 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;
                    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);
            }
        }
Ejemplo n.º 29
0
        private void Frm_load_Tick()
        {
            Frm_LoadProcess.Ex = "正在加载参数配置文件...    10%";
            Application.DoEvents();

            PVar.ReDimSpassWord(); //定义用户
            Frm_Engineering.fEngineering.DataGridView_par.RowCount = 12;
            ArrayInit();           //数组重新定义
            for (short i = 0; i <= 99; i++)
            {
                PVar.BarcodeArrayList[i] = BVar.FileRorW.ReadINI((i).ToString(), "SN", "", PVar.ListDataIniPath);
            }
            Frm_Engineering.ReadParAxis(PVar.ParAxisPath, PVar.ParAxis);//读取机械参数
            Frm_Par FrmPar = new DAB.Frm_Par();

            FrmPar.Par_Normal("Read"); //加载参数界面参数
            if (!PVar.IsReadParData)
            {
                if (Interaction.MsgBox("ReadParData()函数读取数据失败,程序拒绝加载!", Constants.vbExclamation, "重要参数文件") == Constants.vbOK)
                {
                    ProjectData.EndApp();
                }
            }

            mFunction.ReDimData();
            mFunction.ReadPosData(PVar.BZ_ParameterPath + "\\PosData.dat", mFunction.Pos);
            if (!PVar.IsReadPosData)
            {
                if (Interaction.MsgBox("ReadPosData()函数读取数据失败,程序拒绝加载!", Constants.vbExclamation, "重要参数文件") == Constants.vbOK)
                {
                    ProjectData.EndApp();
                }
            }

            Frm_LoadProcess.Ex = "正在初始化工程界面...    70%";
            Application.DoEvents();
            MainUserNameDisplay(); //新用户添加到主界面
            if (MainUserName.Items.Count <= 0)
            {
                PVar.Login.NewGroup[1]         = "Engineering";
                PVar.Login.NewUser[0]          = "Engineering";
                PVar.Login.NewPassword[0]      = "BZ";
                PVar.Login.NewUserAuthority[0] = 2;
                MainUserName.Items.Add(PVar.Login.NewUser[0]);
                Frm_Login.fLogin.MainUserName.Items.Add(PVar.Login.NewUser[0]);
                FileRw.WriteDatFilePassWord(PVar.BZ_ParameterPath + "PassWord.dat", PVar.Login);
            }
            PVar.LampStatus       = 10;
            Btn_Stop.BZ_BackColor = PVar.BZColor_SelectedEndBtn;
            Frm_Engineering.fEngineering.Show(this);
            Frm_Engineering.fEngineering.Visible = false;
            Frm_Production FrmProduction = new Frm_Production();

            FrmProduction.Show(this);
            Frm_Production.fProduction.Visible = false;
            Btn_Pause.Enabled         = false;
            Btn_Stop.Enabled          = false;
            PVar.IsOpenFrmEngineering = false;
            PVar.IsOpenFrmProduction  = false;
            Frm_Engineering.fEngineering.TestDataGridInit(); //加载表格数据
            Frm_LoadProcess.Ex = "正在初始化运动控制卡...    95%";
            Application.DoEvents();
            Gg.GTS_MotionInit(0, 8, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\GTS_Config\\GTS800-00.cfg");

            Gg.GTS_ExtmdlInit(1, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\GTS_Config\\ExtModule.cfg");
            Command.Com3_Send("LMD,4SPLN,00" + ",000,000,000,000,"); //关闭所有光源
            Frm_LoadProcess.Ex = "加载完成...    100%";
            Application.DoEvents();
            PVar.WorkMode = 0;
            //WriteCsvErrorCodePRE();
            this.Show();
        }