private static bool PropertyBoolCompare(GOP v, bool b, Func <bool, bool, bool> comparer) { if (v.type != GOP.ValueType.Bool) { return(false); } return(comparer(v.b, b)); }
private static bool PropertyStringCompare(GOP v, string s, Func <string, string, bool> comparer) { if (v.type != GOP.ValueType.Text || String.IsNullOrEmpty(v.text)) { return(false); } return(comparer(v.text, s)); }
private static bool PropertyFloatCompare(GOP v, float value, Func <float, float, bool> comparer) { if (v.type != GOP.ValueType.Number) { return(false); } return(comparer(v.number, value)); }
private static bool PropertyRangeCompare(GOP v, PropertyRange range, Func <float, PropertyRange, bool> comparer) { if (v.type != GOP.ValueType.Number) { return(false); } return(comparer(v.number, range)); }
private void DumpGOPFiles(string gopDir, string xlsxDir) { foreach (string gopFile in Directory.EnumerateFiles(gopDir, "*.gop", SearchOption.AllDirectories)) { Console.WriteLine("Dumping " + gopFile); using (Stream stream = File.OpenRead(gopFile)) { GOP gop = new GOP(stream); File.WriteAllBytes(gopFile.Replace(gopDir, xlsxDir) + ".xlsx", GOPToXLSX(gop)); } } }
private void XLSXToGOP(GOP gop, string file) { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (ExcelPackage pkg = new ExcelPackage(new FileInfo(file))) { ExcelWorksheet wksht = pkg.Workbook.Worksheets["Sheet1"]; for (int row = 0; row < gop.Records.GetLength(0); row++) { for (int col = 0; col < gop.Records.GetLength(1); col++) { gop.Records[row, col] = wksht.Cells[row + 2, col + 1].Value.ToString(); } } } }
public void TraverseGameObjectDirectory(string basePath) { var path = Path.Combine(basePath, Path.Combine(rootPath, name)); if (!Directory.Exists(path)) { hasChildren = false; return; } // check if it has files foreach (string file in Directory.GetFiles(path)) { string filename = Path.GetFileName(file); //Log(filename); if (filename.EndsWith(".png")) { string objectName = filename.Replace(".png", ""); GameObjectProxy GOP = new GameObjectProxy() { name = objectName, hasTexture = true, rootPath = Path.Combine(rootPath, name), hasChildren = false }; hasChildren = true; children[objectName] = GOP; } } // check if it has directories foreach (string directory in Directory.GetDirectories(path)) { string directoryName = new DirectoryInfo(directory).Name; //Log(directoryName); GameObjectProxy GOP; if (!children.TryGetValue(directoryName, out GOP)) { GOP = new GameObjectProxy() { name = directoryName, hasTexture = false, rootPath = Path.Combine(rootPath, name), hasChildren = true }; } hasChildren = true; children[directoryName] = GOP; GOP.TraverseGameObjectDirectory(basePath); } }
public void TraverseGameObjectPath(string path, string rootPath, string name) { Modding.Logger.LogDebug($"{path}:{rootPath}:{name}"); var pathSplit = path.Split(new Char[] { '/' }, 3); GameObjectProxy GOP = null; hasChildren = false; if (pathSplit.Length > 1) { hasChildren = true; if (!children.TryGetValue(pathSplit[1], out GOP)) { GOP = new GameObjectProxy() { name = pathSplit[1], hasTexture = false, }; } children[pathSplit[1]] = GOP; } if (GOP != null) { if (pathSplit.Length > 2) { GOP.TraverseGameObjectPath($"{pathSplit[1]}/{pathSplit[2]}", rootPath, name); } else { if (!GOP.hasTexture) // do not over ride existing texture { GOP.hasTexture = true; GOP.rootPath = rootPath; GOP.name = name; } } } else { if (!this.hasTexture) { this.hasTexture = true; this.rootPath = rootPath; this.name = name; } } Modding.Logger.LogDebug($"{this.hasTexture}:{this.rootPath}:{this.name}"); }
private void RewriteGOPFiles(string gopDir, string xlsxDir) { foreach (string gopFile in Directory.EnumerateFiles(gopDir, "*.gop", SearchOption.AllDirectories)) { string xlsxFile = gopFile.Replace(gopDir, xlsxDir) + ".xlsx"; if (File.Exists(xlsxFile)) { Console.WriteLine("Rewriting " + gopFile); using (Stream stream = File.Open(gopFile, FileMode.Open, FileAccess.ReadWrite)) { GOP gop = new GOP(stream); XLSXToGOP(gop, xlsxFile); stream.Seek(0, SeekOrigin.Begin); gop.Write(stream); } } } }
private byte[] GOPToXLSX(GOP gop) { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (ExcelPackage pkg = new ExcelPackage()) { ExcelWorksheet wksht = pkg.Workbook.Worksheets.Add("Sheet1"); for (int col = 0; col < gop.Elements.Count; col++) { wksht.Cells[1, col + 2].Value = gop.Elements[col].Name; } for (int row = 0; row < gop.Records.GetLength(0); row++) { for (int col = 0; col < gop.Records.GetLength(1); col++) { wksht.Cells[row + 2, col + 1].Value = gop.Records[row, col]; } } return(pkg.GetAsByteArray()); } }
private void InitController(RobGenericController Rgcr, RobControllerFactory CRM, int RobotCtrlNum, ProgressBar Pbar) { #region 机器人基本TCP Motion初始化 // Rgcr.moti String GetName = string.Empty; GetName = CRM.get_Name(); for (int i = 1; i <= RobotCtrlNum; i++) { GenericAccuracyProfile GP; GenericMotionProfile GMP; GenericToolProfile GTP; GenericObjFrameProfile GOP; bool ExistsObject; CRM.CreateGenericAccuracyProfile(out GP); GP.GetName(ref GetName); GetName = CRM.get_Name(); GP.SetAccuracyValue(i * 0.1); GP.SetName(i * 10 + "%"); GP.SetAccuracyType(AccuracyType.ACCURACY_TYPE_SPEED); GP.SetFlyByMode(false); Rgcr.HasAccuracyProfile((i * 10 + "%"), out ExistsObject); if (!ExistsObject) { Rgcr.AddAccuracyProfile(GP); } Pbar.PerformStep(); ///////////////////////////////////////////////////////////////////// CRM.CreateGenericObjFrameProfile(out GOP); GOP.SetObjectFrame(0, 0, 0, 0, 0, 0); GOP.SetName("Object_0" + i); Rgcr.HasObjFrameProfile(("Object_0" + i), out ExistsObject); if (!ExistsObject) { Rgcr.AddObjFrameProfile(GOP); } Pbar.PerformStep(); ///////////////////////////////////////////////////////////////////// CRM.CreateGenericMotionProfile(out GMP); GMP.SetSpeedValue(i * 0.1); GMP.SetName(i * 10 + "%"); GMP.SetMotionBasis(MotionBasis.MOTION_PERCENT); Rgcr.HasMotionProfile((i * 10 + "%"), out ExistsObject); if (!ExistsObject) { Rgcr.AddMotionProfile(GMP); } Pbar.PerformStep(); ///////////////////////////////////////////////////////////////////// // NwName = i < 9 ? ("Tool_0" + i) : ("Tool_" + i); string NwName = "Tool_0" + i; Rgcr.HasToolProfile(NwName, out ExistsObject); if (!ExistsObject) { try { int ToolNum = 0; Rgcr.GetToolProfileCount(out ToolNum); string Ctname = string.Empty; if (ToolNum < 16) { CRM.CreateGenericToolProfile(out GTP); Rgcr.AddToolProfile(GTP); //Object[] ToolLists = new object[ToolNum]; //Rgcr.GetToolProfiles(ToolLists); //for (int j = 1; j <= ToolNum; j++) //{ // Ctname = ((GenericToolProfile)ToolLists[i]).get_Name(); // ((GenericToolProfile)ToolLists[i]).set_Name(NwName); //} //GTP.GetName(Ctname); //GTP.SetToolMobility(true); //GTP.set_Name(NwName); } } catch (Exception) { throw; } //Object[] TooList = new object[99]; //Rgcr.GetToolProfiles(TooList); //int TotalTool; //Rgcr.GetToolProfileCount(out TotalTool); //GenericToolProfile ToolProfile =(GenericToolProfile)TooList[TotalTool-1]; //NwName = ToolProfile.get_Name(); //ToolProfile.set_Name(NwName); } Pbar.PerformStep(); } #endregion #region 机器人默认值设置 //Init Current Motion Profile \accuracy \ Tool Profile \Object bool ExistsObj; Rgcr.HasAccuracyProfile((100 + "%"), out ExistsObj); if (ExistsObj) { Rgcr.SetCurrentAccuracyProfile((100 + "%")); } Rgcr.HasObjFrameProfile("Object_01", out ExistsObj); if (ExistsObj) { Rgcr.SetCurrentObjFrameProfile("Object_01"); } Rgcr.HasMotionProfile((100 + "%"), out ExistsObj); if (ExistsObj) { Rgcr.SetCurrentMotionProfile((100 + "%")); } Rgcr.HasToolProfile("Tool_01", out ExistsObj); if (ExistsObj) { Rgcr.SetCurrentToolProfile("Tool_01"); } #endregion #region 机器日Taglist目录及RobotTask批量设置 //RobotTaskFactory Rtf = (RobotTaskFactory)Usp.GetTechnologicalObject("RobotTaskFactory"); object[] RobotTaskLists = new object[99]; //try //{ // Rtf.GetAllRobotTasks(RobotTaskLists); //} //catch (Exception) //{ // RobotTaskLists = null; //} //GetName = Rtf.get_Name(); Pbar.PerformStep(); #endregion object[] RTask = new object[50]; // Rtf.GetAllRobotTasks(RTask); foreach (RobotTask item in RTask) { if (item != null) { item.set_Description("安徽锐锋科技自动化产品,机器人轨迹,创建于:" + DateTime.Now); } } }