void Poll(object target) { DataBaseManage db = new DataBaseManage(); double[] tool = db.GetTool(); if (tool == null || tool.Length != 6 || TxtData.SoapData.Tool == null || TxtData.SoapData.Tool.Length != 6) { TxtData.PublicData.ErrorCode = 42; return; } TxtData.MdbData.Tool = tool; //for (int i = 0; i < 6; i++) //{ // if (tool[i] != TxtData.MdbData.Tool[i]) // { // TxtData.PublicData.ErrorCode = 42; // return; // } //} //home double[] home = db.GetHome(); if (home == null || home.Length != 6 || TxtData.SoapData.Home == null || TxtData.SoapData.Home.Length != 6) { TxtData.PublicData.ErrorCode = 44; return; } for (int i = 0; i < 6; i++) { if (home[i] != TxtData.SoapData.Home[i]) { TxtData.PublicData.ErrorCode = 44; return; } } TxtData.MdbData.Home = home; //************************************** if (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 0) { TxtData.PublicData.ErrorCode = 34; return; } PolishTxt.MatlabFile = (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 2); // PolishTxt.Home = home; if (!db.SaveProduct(CBE_RecipeName.EditValue.ToString())) { TxtData.PublicData.ErrorCode = 34; return; } if (!System.IO.Directory.Exists(Application.StartupPath + "\\txt\\")) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\txt\\"); } if (!PolishTxt.Standard2Polish(Application.StartupPath + "\\txt\\Recipe.txt", Application.StartupPath + "\\txt\\" + CBE_RecipeName.EditValue.ToString() + ".txt")) { TxtData.PublicData.ErrorCode = 49; return; } FtpClient ftp = new FtpClient(TxtData.XMLConfigure.IpAddress); //******************************************* if (!ftp.UpLoad(Application.StartupPath + "\\txt\\" + CBE_RecipeName.EditValue.ToString().Trim() + @".txt", @"/usr/usrapp/txt")) // if (!ftp.UpLoadPolishTxt(CBE_RecipeName.EditValue.ToString().Trim())) { TxtData.PublicData.ErrorCode = 24; return; } SoapInstance.SoapRead.SoapSetAppname = @"Disk://RobotPolish/RobotPolish.pjx"; if (!SoapInstance.SoapRead.SetAppdata("sTxtSelected", CBE_RecipeName.EditValue.ToString() + ".txt")) { TxtData.PublicData.ErrorCode = 70; return; } // if (!SoapInstance.SoapRead.SetLibdata("read", "nZshift", -(int)ND_Z.Value)) { TxtData.PublicData.ErrorCode = 70; return; } //2015.01.20 if (!SoapInstance.SoapRead.SetAppAIO("io:aPressSet", (double)NUD_Press.Value)) { TxtData.PublicData.ErrorCode = 70; return; } if (!SoapInstance.SoapRead.SetAppAIO("io:aRevolu", (double)NUD_Speed.Value)) { TxtData.PublicData.ErrorCode = 70; return; } if (!SoapInstance.SoapRead.SetAppAIO("io:aRotation", (double)NUD_Rot.Value)) { TxtData.PublicData.ErrorCode = 70; return; } if (!SoapInstance.SoapRead.SetAppAIO("io:aTableSpeed", (double)NUD_Speed.Value)) { TxtData.PublicData.ErrorCode = 70; return; } if (!SoapInstance.SoapRead.SetAppdata("nVirtualKey", 272)) { TxtData.PublicData.ErrorCode = 70; return; } db.AddLog("下载产品" + CBE_RecipeName.Text); db.AddProductCount(CBE_Custom.Text, CBE_RecipeName.Text, 1);//while (TxtData.SoapData.InterfaceType == 9) //{// System.Threading.Thread.Sleep(10); //} TxtData.PublicData.ErrorCode = 40; }
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; } } }