Example #1
0
        private void BT_MatLab_Click(object sender, EventArgs e)
        {
            if (gv.RowCount == 0)
            {
                MessageBox.Show("没有路径");
                return;
            }
            if (CBE_RecipeName.EditValue.ToString() == "" || Frame == null)
            {
                MessageBox.Show("请先建立产品");
                return;
            }
            if ((FileName = PublicFunc.OpenDir_Show()) == null)
            {
                return;
            }



            TxtData.PublicData.ErrorCode = 0;
            TxtData.PublicData.ErrorLine = 0;
            OperIndex = 5;
            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollImport));
            Frm_Wait frM = new Frm_Wait(CBE_RecipeName.EditValue.ToString(), false);

            frM.ShowDialog();
            ViewPoint(GC_Cut, GV_Cut, db.GetDV_Trajpos(TrajName));
        }
Example #2
0
        public Frm_Main()
        {
            //卸载与安装
            if (!File.Exists(Application.StartupPath + "\\RobotPolish.mdb") && File.Exists(Application.StartupPath + "\\Backup\\RobotPolish.mdb"))
            {
                File.Copy(Application.StartupPath + "\\Backup\\RobotPolish.mdb", Application.StartupPath + "\\RobotPolish.mdb", true);
            }

            //2013.11.20
            //检查数据库是否存在

            if (!File.Exists(Application.StartupPath + "\\RobotPolish.mdb"))
            {
                MessageBox.Show("程序根目录中数据库文件RobotPolish.mdb不存在");
                System.Environment.Exit(System.Environment.ExitCode);
                this.Dispose();
                this.Close();
                return;
            }

            PublicFunc.Init();
            DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true;
            // PublicFunc.ReadXMLConfigure();

            InitializeComponent();
            BI_ListClose_ItemClick(this, null);
            TE_Title.Text = "抛光工艺管理软件";
            RC_Main.DefaultPageCategory.Expanded = true;
            RC_Main.Minimized = true;
            InitSkinGallery();



            db = new DataBaseManage();

            TxtData.XMLConfigure.RegCode = db.GetRegCode();
            TxtData.XMLConfigure.Reged   = true;
            //db.SaveCs8cConfigure();
            //PublicFunc.ReadCs8CConfigure();

            db.GetIp(ref TxtData.XMLConfigure.IpAddress, ref TxtData.XMLConfigure.RestrictCode);
            db.GetPopedom(ref TxtData.PublicData.ScreenEnable);

            TxtData.XMLConfigure.User = db.GetAutoLogin();
            TxtData.SoapData.Tool     = db.GetTool();

            if (TxtData.XMLConfigure.User != null)
            {
                TxtData.XMLConfigure.Login   = true;
                TxtData.XMLConfigure.PopeDom = db.GetUserPopm(TxtData.XMLConfigure.User);
                db.AddLog(TxtData.XMLConfigure.User + "登录");
            }
            PublicFunc.ReadXMLConfigure();


            poll = new Thread(new ThreadStart(PublicFunc.Poll));
            poll.Start();
        }
Example #3
0
        private void BT_ok_Click(object sender, EventArgs e)
        {
            if (TB_Code.Text.Trim() == "")
            {
                MessageBox.Show("输入不能为空!");
                return;
            }
            switch (Type)
            {
            case 1:
            {
                string[] data = TB_Code.Text.Trim().Split('.');
                if (data.Length != 4)
                {
                    MessageBox.Show("输入位数不正确!");
                    return;
                }
                TxtData.XMLConfigure.IpAddress = TB_Code.Text.Trim();
                break;
            }

            case 2:
            {
                if (TB_Code.Text.Trim().Length != 6)
                {
                    MessageBox.Show("输入位数不等于6!");
                    return;
                }

                //2014.08.08
                //修改加密方式

                int Ind = TxtData.XMLConfigure.RegCode.ToUpper().IndexOf(TB_Code.Text.Trim().ToUpper());
                if (Ind < 0 || Ind % 6 != 0)
                {
                    MessageBox.Show("输入不正确!");
                    return;
                }

                TxtData.XMLConfigure.RestrictCode = TB_Code.Text.Trim();
                break;
            }
            }

            if (!db.EditIp(TxtData.XMLConfigure.IpAddress, TxtData.XMLConfigure.RestrictCode))
            {
                MessageBox.Show("数据库出错");
                return;
            }
            if (Type == 2)
            {
                // TxtData.XMLConfigure.RestrictCode=
                PublicFunc.ReadXMLConfigure();
            }

            this.Close();
        }
Example #4
0
        private void BT_File_Click(object sender, EventArgs e)
        {
            string FileName = null;

            if ((FileName = PublicFunc.OpenDir_Show()) == null)
            {
                return;
            }
            TE_File.Text = FileName;
        }
Example #5
0
        /// <summary>
        /// 把机器码生成文本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BBI_SaveToolCodeTxt_ItemClick(object sender, ItemClickEventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show("RobotPolish注册码.txt", "TXT文件(*.txt)|*.txt")) == null)
            {
                return;
            }
            PublicFunc.SaveTxt(FileName, BSI_ToolCode.Caption);
        }
Example #6
0
        private void BT_X2_Click(object sender, EventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show(Application.StartupPath, "XLS文件|*.xls")) == null)
            {
                return;
            }
            gv2.ExportToXls(FileName);
        }
Example #7
0
        private void BT_P2_Click(object sender, EventArgs e)
        {
            string FileName;

            if ((FileName = PublicFunc.SfD_Show(Application.StartupPath, "PDF文件|*.pdf")) == null)
            {
                return;
            }
            gv2.ExportToPdf(FileName);
        }
Example #8
0
        private void BT_OutPort_Click(object sender, EventArgs e)
        {
            if ((FileName = PublicFunc.SfD_Show()) == null)
            {
                return;
            }
            TxtData.PublicData.ErrorCode = 0;

            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollOutport));
            Frm_Wait frm = new Frm_Wait("", false);

            frm.ShowDialog();
            Frm_StaubliPreset_Load(this, null);
        }
Example #9
0
        private void BT_EditIP_Click(object sender, EventArgs e)
        {
            string  Buff = TxtData.XMLConfigure.IpAddress;
            Edit_Ip frm  = new Edit_Ip(1);

            frm.ShowDialog();
            // Frm_Cs8cConfig_Load(this, null);
            db.GetIp(ref TxtData.XMLConfigure.IpAddress, ref TxtData.XMLConfigure.RestrictCode);
            PublicFunc.ReadXMLConfigure();
            if (TxtData.XMLConfigure.IpAddress != Buff)
            {
                MessageBox.Show("请关闭软件并重新打开");
            }
        }
Example #10
0
        private void BT_OutPort_Click(object sender, EventArgs e)
        {
            string FileName;

            if (gv.RowCount == 0)
            {
                MessageBox.Show("没有日志记录");
                return;
            }
            if ((FileName = PublicFunc.SfD_Show(Application.StartupPath, "XLS文件|*.xls")) == null)
            {
                return;
            }
            gv.ExportToXls(FileName);
        }
Example #11
0
        private void BT_OutPort_Click(object sender, EventArgs e)
        {
            if (CBE_PresetName.Properties.Items.Count == 0)
            {
                MessageBox.Show("没有工艺");
                return;
            }
            if ((FileName = PublicFunc.SfD_Show()) == null)
            {
                return;
            }
            TxtData.PublicData.ErrorCode = 0;

            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollOutport));
            Frm_Wait frm = new Frm_Wait("", false);

            frm.ShowDialog();
        }
Example #12
0
        private void BT_OutPut_Click(object sender, EventArgs e)
        {
            if (CBE_RecipeName.EditValue.ToString() == "")
            {
                MessageBox.Show("无产品");
                return;
            }
            if ((FileName = PublicFunc.SfD_Show(CBE_RecipeName.EditValue.ToString() + ".txt")) == null)
            {
                return;
            }
            TxtData.PublicData.ErrorCode = 0;
            OperIndex = 1;
            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollImport));
            Frm_Wait frm = new Frm_Wait(CBE_RecipeName.EditValue.ToString(), false);

            frm.ShowDialog();
        }
Example #13
0
        private void BT_Diff_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定需要以第一个工具为标准工具进行\nZ轴 10mm 方向的差分吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }

            string[] data  = db.GetPresetList("TOOL", 1);
            double[] ddata = new double[6];

            if (data == null)
            {
                return;
            }
            for (int i = 0; i < 6; i++)
            {
                if (!double.TryParse(data[i], out ddata[i]))
                {
                    MessageBox.Show("数据转换不成功");
                    return;
                }
            }

            double[][] Buff = PublicFunc.DiffTool(ddata);


            if (Buff == null)
            {
                MessageBox.Show("转换不成功");
                return;
            }


            if (db.EditPresetList(Buff))
            {
                MessageBox.Show("成功");
            }
            else
            {
                MessageBox.Show("失败");
            }

            Frm_StaubliPreset_Load(this, null);
        }
Example #14
0
        void DataRefresh()
        {
            try
            {
                if (TxtData.SoapData.SoapStaus)
                {
                    FtpClient ftp = new FtpClient(TxtData.XMLConfigure.IpAddress);
                    ftp.DownLoadLog();

                    if (!PublicFunc.ReadCs8CLog(out date, out Txt))
                    {
                        return;
                    }

                    if (date != null && Txt != null)
                    {
                        DataView dv = new DataView();
                        dv.Table = new System.Data.DataTable("Sequen");
                        dv.Table.Columns.Add();
                        dv.Table.Columns.Add();
                        dv.Table.Rows.Clear();
                        for (int i = Txt.Length - 1; i >= 0; i--)
                        {
                            if (Txt[i] != null && Txt[i].IndexOf("COM-PC:") < 0)
                            {
                                dv.Table.Rows.Add((object[])new string[] { date[i], Txt[i] });
                            }
                        }


                        GC_Alarm.DataSource   = dv;
                        gv.Columns[0].Caption = "日期";
                        gv.Columns[1].Caption = "报警信息";
                    }
                }
            }
            catch
            {
            }
        }
Example #15
0
        private void BT_Import_Click(object sender, EventArgs e)
        {
            if (gv.RowCount != 0)
            {
                MessageBox.Show("产品已存在路径");
                return;
            }
            if (CBE_RecipeName.EditValue.ToString() == "" || Frame == null)
            {
                MessageBox.Show("请先建立产品");
                return;
            }
            if ((FileName = PublicFunc.OpenDir_Show()) == null)
            {
                return;
            }
            string[] frm = new string[6];

            if (!PublicFunc.IsFrame(FileName, Frame, ref frm))
            {
                if (MessageBox.Show(
                        "导入文本中的产品坐标系不一致,是否继续导入?" + "\n新建产品坐标系是:"
                        + Frame[0].ToString() + "," + Frame[1].ToString() + "," + Frame[2].ToString() + "," + Frame[3].ToString() + ","
                        + Frame[4].ToString() + "," + Frame[5].ToString() + "\n文本坐标系是:"
                        + frm[0].ToString() + "," + frm[1].ToString() + "," + frm[2].ToString() + "," + frm[3].ToString() + ","
                        + frm[4].ToString() + "," + frm[5].ToString(), "产品坐标系不一致", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            TxtData.PublicData.ErrorCode = 0;
            TxtData.PublicData.ErrorLine = 0;
            OperIndex = 3;
            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(PollImport));
            Frm_Wait frM = new Frm_Wait(CBE_RecipeName.EditValue.ToString(), false);

            frM.ShowDialog();
            CBE_RecipeName_TextChanged(this, null);
        }
Example #16
0
        void PollImport(object target)
        {
            DataBaseManage db = new DataBaseManage();

            switch (OperIndex)
            {
            //导出
            case 1:
            {
                //2015.02.05
                if (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 0)
                {
                    TxtData.PublicData.ErrorCode = 34;
                    return;
                }
                PolishTxt.MatlabFile = (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 2);
                //



                TxtData.PublicData.ErrorCode = (db.SaveProduct(Application.StartupPath + "\\buff.txt", CBE_RecipeName.EditValue.ToString())) ? 0 : 34;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }
                PolishTxt.Home = db.GetHome();



                TxtData.PublicData.ErrorCode = (PolishTxt.Standard2Polish(Application.StartupPath + "\\buff.txt", FileName)) ? 40 : 49;
                break;
            }
            //删除产品

            case 2:
            {
                TxtData.PublicData.ErrorCode = (db.DeleteRecipe(CBE_RecipeName.EditValue.ToString())) ? 40 : 32;
                break;
            }
            //导入

            case 3:
            {
                //TxtData.PublicData.ErrorCode = PublicFunc.IsTool(FileName)? 0 : 41;
                //if (TxtData.PublicData.ErrorCode != 0)
                //{
                //    return;
                //}

                //PolishTxt t = new PolishTxt();
                //  PolishTxt.Home = db.GetHome();

                PolishTxt.Home = db.GetHome();
                string BuffFileName = "";
                if (PolishTxt.IsMatlabFile(FileName))
                {
                    //把matlab文件转换为一般的文件
                    //2015.02.05

                    BuffFileName = Application.StartupPath + "\\Txt\\buffRecipe.txt";
                    // PolishTxt.MatlabFile = true;

                    TxtData.PublicData.ErrorCode = PolishTxt.ReadMatlabFile(FileName, true) ? 0 : 71;
                    if (TxtData.PublicData.ErrorCode != 0)
                    {
                        return;
                    }


                    TxtData.PublicData.ErrorCode = db.GetRecipe(CBE_RecipeName.EditValue.ToString(), ref PolishTxt.MatlabTool, ref PolishTxt.MatlabFrame) ? 0 : 72;
                    if (TxtData.PublicData.ErrorCode != 0)
                    {
                        return;
                    }


                    //2015.02.05
                    //重点函数在这里
                    TxtData.PublicData.ErrorCode = PublicFunc.MatalData() ? 0 : 73;
                    if (TxtData.PublicData.ErrorCode != 0)
                    {
                        return;
                    }



                    TxtData.PublicData.ErrorCode = PolishTxt.Matlab2Recipe(BuffFileName) ? 0 : 74;
                    if (TxtData.PublicData.ErrorCode != 0)
                    {
                        return;
                    }
                }
                else
                {
                    BuffFileName = FileName;
                }



                TxtData.PublicData.ErrorCode = PolishTxt.Polish2Standard(BuffFileName, Application.StartupPath + "\\Txt\\buff.txt") ? 0 : 49;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }
                TxtData.PublicData.ErrorLine = db.ImportProduct(Application.StartupPath + "\\Txt\\buff.txt", CBE_RecipeName.EditValue.ToString());
                TxtData.PublicData.ErrorCode = (TxtData.PublicData.ErrorLine == 0) ? 0 : 20;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }
                TxtData.PublicData.ErrorCode = (db.EditRecipeOffline(CBE_RecipeName.EditValue.ToString(), PolishTxt.MatlabFile)) ? 40 : 20;



                // return;
                break;
            }

            //删除路径
            case 4:
            {
                //2013.11.19
                //TxtData.PublicData.ErrorCode = (db.DeleteTraj(TrajName,true)) ? 40 : 32;
                TxtData.PublicData.ErrorCode = (db.DeleteTraj(CBE_RecipeName.EditValue.ToString(), TxtData.PublicData.DeleteTrajIndex)) ? 40 : 32;
                break;
            }

            //导入速度
            case 5:
            {
                TxtData.PublicData.ErrorCode = (PolishTxt.ReadMatlabFileCount(FileName) == GV_Cut.RowCount)? 0 : 46;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }

                double[,] da = PolishTxt.ReadMatlabFile(FileName);
                TxtData.PublicData.ErrorCode = (da != null) ? 0 : 47;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }
                //TxtData.PublicData.ErrorLine = db.ImportProduct(FileName, CBE_RecipeName.EditValue.ToString());
                //TxtData.PublicData.ErrorCode = (TxtData.PublicData.ErrorLine == 0) ? 40 : 20;
                // return;

                TxtData.PublicData.ErrorCode = db.BatchPointSpeed(TrajName, da) ? 40 : 48;

                break;
            }


            case 6:
            {
                TxtData.PublicData.ErrorCode = (db.SaveProduct(Application.StartupPath + "\\buff.txt", CBE_RecipeName.EditValue.ToString())) ? 0 : 34;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }

                TxtData.PublicData.ErrorCode = (PolishTxt.Part2Standard(TxtData.PolishData.PartMatlabFile, Application.StartupPath + "\\buff.txt", Application.StartupPath + "\\partbuff.txt")) ? 0 : 62;

                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }

                TxtData.PublicData.ErrorCode = (db.AddRecipe(TxtData.PolishData.PartRecipeName, 1, new double[] { 0, 0, 0, 0, 0, 0 }, new double[] { 0, 0, 0, 0, 0, 0 }, TxtData.PolishData.PartRecipeRemark)) ? 0 : 63;
                if (TxtData.PublicData.ErrorCode != 0)
                {
                    return;
                }

                TxtData.PublicData.ErrorCode = (db.ImportProduct(Application.StartupPath + "\\partbuff.txt", TxtData.PolishData.PartRecipeName) == 0) ? 40 : 64;

                break;
            }
            }
        }