Beispiel #1
0
 private void InitDataGridViewIDPM()
 {
     if (System.IO.File.Exists(PVar.ListDataIniPathIPDM) == false)//写表头
     {
         string strtemp = "";
         for (int i = 0; i < PVar.DataGrid_IPDMCheckDataHeadName.Length; i++)
         {
             strtemp = strtemp + PVar.DataGrid_IPDMCheckDataHeadName[i] + ",";
         }
         strtemp = strtemp.Substring(0, strtemp.Length - 1);//去掉最后一个","
         Globals.csv.WriteStringToCsv(PVar.ListDataIniPathIPDM, strtemp);
     }
     Globals.dt_100data = Globals.csv.OpenCSV(PVar.ListDataIniPathIPDM);
     #region rebuild csv
     if (Globals.dt_100data.Columns.Count != PVar.DataGrid_IPDMCheckDataHeadName.Length)
     {
         //delete the old one
         FileRw.DeleteFile(PVar.ListDataIniPathIPDM);
         string strtemp = "";
         for (int i = 0; i < PVar.DataGrid_IPDMCheckDataHeadName.Length; i++)
         {
             strtemp = strtemp + PVar.DataGrid_IPDMCheckDataHeadName[i] + ",";
         }
         strtemp = strtemp.Substring(0, strtemp.Length - 1);//去掉最后一个","
         Globals.csv.WriteStringToCsv(PVar.ListDataIniPathIPDM, strtemp);
         Globals.dt_100data = Globals.csv.OpenCSV(PVar.ListDataIniPathIPDM);
     }
     #endregion
     this.dataGridView1.DataSource         = Globals.dt_100data;
     dataGridView1.AllowUserToAddRows      = false;
     dataGridView1.AllowUserToOrderColumns = false;
     dataGridView1.AllowUserToDeleteRows   = false;
     dataGridView1.AutoSizeColumnsMode     = DataGridViewAutoSizeColumnsMode.Fill;
 }
Beispiel #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);
 }
        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));
            }

            Force_S3.BZ_BackColor = PVar.BZColor_SelectedBtn;
            Force_S2.BZ_BackColor = Color.LightGray;

            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;
        }
Beispiel #4
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);
     }
 }
Beispiel #5
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]);
         }
     }
 }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
0
 private void MainUserNameDisplay()
 {
     MainUserName.Items.Clear();
     FileRw.ReadDatFilePassWord(PVar.BZ_ParameterPath + "PassWord.dat", PVar.Login);
     for (var i = 0; i <= 20; i++)
     {
         if (PVar.Login.NewUser[(int)i] != "" && PVar.Login.NewUser[(int)i] != null)
         {
             MainUserName.Items.Add(PVar.Login.NewUser[(int)i]);
         }
     }
     MainUserName.SelectedIndex = 0;
     MainPassword.Focus();
     //Call Start_NumberKey_Process()
     //MainPassword.SelectionStart = 0     '选取的起始位置设为0,即从头开始进行文本框内容的选取
     //MainPassword.SelectionLength = Len(MainPassword.Text)       '选取内容的长度为文本框已经接受的文本长度
 }
Beispiel #10
0
        /// <summary>
        /// 设备正常运行Log写入
        /// </summary>
        /// <param name="Msg"></param>
        /// <remarks></remarks>
        public static void WriteLog(string Msg)
        {
            string TempStr  = "";
            string TempStr1 = "";

            TempStr = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd");
            if (System.IO.Directory.Exists(TempStr))
            {
            }
            else
            {
                System.IO.Directory.CreateDirectory(TempStr);
            }
            TempStr  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_运行日志" + ".txt";
            TempStr1 = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + " " + Msg;
            FileRw.WriteDattxt(TempStr, TempStr1);
        }
Beispiel #11
0
        private void MainUserNameDisplay()
        {
            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)
                {
                    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;
            }
        }
Beispiel #12
0
 private void UserDelete_Click(object sender, EventArgs e)
 {
     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);
             }
         }
     }
 }
        /// <summary>
        /// 异常统计
        /// </summary>
        /// <param name="ErrInfo"></param>
        /// <remarks></remarks>
        public 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_MEMErrCounts.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_PickCCDErrCounts.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_PickErrCounts.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_HsgSnErrCounts.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_HsgSnErrCounts.Text = System.Convert.ToString(PVar.HsgErrCounts);
                }
                break;
            }

            BVar.FileRorW.WriteINI("ErrStatistics", ErrInfo, System.Convert.ToString(ErrCounts), PVar.BZ_ErrStatisticsPath);
        }
Beispiel #14
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        if (Once == false)
                        {
                            if (BVar.FileRorW.ReadINI("Material_index", "是否片料", "有", PVar.PublicParPath) == "有")
                            {
                                StaWork.IsHavePianliao = true;
                            }
                            else
                            {
                                StaWork.IsHavePianliao = false;
                            }
                        }
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        //StaWork.Step = 20;
                    }
                    break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

                //遇到异常,设备先暂停,确定后处理************************
                case 8000:
                    PVar.IsSystemOnPauseMode                        = true;
                    PVar.MacHold                                    = true;
                    PVar.Stop_Flag                                  = false;
                    Frm_Main.fMain.Btn_Start.Enabled                = false;
                    Frm_Main.fMain.Btn_Pause.Enabled                = true;
                    Frm_Main.fMain.Btn_Stop.Enabled                 = false;
                    Frm_Main.fMain.Btn_Start.BZ_BackColor           = PVar.BZColor_UnselectedBtn;
                    Frm_Main.fMain.Btn_Pause.BZ_BackColor           = PVar.BZColor_SelectedEndBtn;
                    Frm_Main.fMain.Btn_Stop.BZ_BackColor            = PVar.BZColor_UnselectedBtn;
                    Frm_Engineering.fEngineering.Auto_Timer.Enabled = false;
                    PVar.LampStatus                                 = 20;
                    StaWork.Step                                    = BufferStep;
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(exc.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
Beispiel #15
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        StaWork.Step  = 20;
                    }
                    break;

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

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

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

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

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

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

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

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

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

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

                //严重错误,急停处理
                case 10000:
                    Frm_Engineering.fEngineering.MacStop();
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(exc.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        PVar.Sta_Work[1].IsHaveHSG = false;
                        StaWork.Result             = false;
                        StaWork.State = false;
                        StaWork.Step  = 20;
                        //PVar.Sta_Work[1].Step = 20;
                    }
                    break;

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


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

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

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

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

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

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

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

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

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

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

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

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

                //严重错误,急停处理
                case 10000:
                    Frm_Engineering.fEngineering.MacStop();
                    break;
                }
            }
            catch (Exception exc)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(exc.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + exc.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
Beispiel #18
0
        public static void AutoRun(ref PVar.WorkType StaWork)
        {
            try
            {
                switch (StaWork.Step)
                {
                case 10:
                    if (PVar.Stop_Flag == false)
                    {
                        StaWork.State = false;
                        TimeOut       = API.GetTickCount();
                        //StaWork.Step = 20;
                    }
                    break;

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

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

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

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


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

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

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

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

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

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

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


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

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

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

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

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

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

                case 1000:
                    StaWork.Enable = false;
                    StaWork.Result = false;
                    StaWork.State  = false;
                    StaWork.Step   = 10;
                    break;
                }
            }
            catch (Exception ex)
            {
                string Error_Str  = "";
                string Error_Str1 = "";
                Frm_Engineering.fEngineering.MacStop();
                MessageBox.Show(ex.Message);
                Error_Str  = PVar.BZ_LogPath + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_代码异常记录" + ".txt";
                Error_Str1 = "\r\n" + "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※" + "\r\n" +
                             "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "\r\n" + ex.ToString();
                FileRw.WriteDattxt(Error_Str, Error_Str1);
            }
        }
Beispiel #19
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 (Interaction.MsgBox("密码不能为空,请重新输入!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                    {
                        return;
                    }
                }
            }
            else
            {
                if (Interaction.MsgBox("账户不能为空,请重新输入!", (int)Constants.vbOKCancel + Constants.vbQuestion, "提示") != Constants.vbOK)
                {
                    return;
                }
            }
        }
Beispiel #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++)
            {
                #region IsOpenFrmLogin true
                if (PVar.IsOpenFrmLogin)
                {
                    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;
                            PVar.isShowAxisPara = false;
                            break;
                        }
                        if (PVar.Login.NewGroup[1] == "Engineering" && PVar.Login.NewUserAuthority[i] == 2)
                        {
                            Temp = true;
                            PVar.isShowAxisPara = true;
                            break;
                        }
                        if (PVar.Login.NewGroup[2] == "FE2" && PVar.Login.NewUserAuthority[i] == 3)
                        {
                            Temp = true;
                            PVar.isShowAxisPara = false;
                            break;
                        }
                    }
                    else
                    {
                        Temp = false;
                    }
                }
                #endregion
                #region isOpenFrmlogion 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;
                    }
                }
                #endregion
            }
            #region password OK
            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
            }
            #endregion
            #region password err
            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;
                }
            }
            #endregion
        }
Beispiel #21
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 BZGUI.Frm_Par();
            Frm_Parameter FrmParameter = new Frm_Parameter();

            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_MotionInit(1, 4, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\GTS_Config\\GTS400-01.cfg");

            Gg.GTS_ExtmdlInit(2, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\GTS_Config\\ExtModule.cfg");
            Command.Com3_Send("LMD,4SPLN,00" + ",000,000,000,000,"); //关闭所有光源
            if (PVar.IsCOM3_Working == false)
            {
                AddList("光源控制器通信异常!");
                ShowList("光源控制器通信异常!");
            }
            else
            {
                AddList("光源控制器通信OK!");
            }
            Frm_LoadProcess.Ex = "加载完成...    100%";
            Application.DoEvents();
            PVar.WorkMode = 0;
            //WriteCsvErrorCodePRE();
            this.Show();
        }
Beispiel #22
0
        public void Par_Normal(string Sts)
        {
            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])
            {
                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;
            }
        }
        /// <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", TimeBeforeMonth, 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, 28] == "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, 28] == "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", TimeBeforeMonth, PVar.BZ_YieldDataFileName); //更新以当前向后推30天的日期
            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, 28] == "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, 28] == "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率
        }