private void BuildFileIO(List <ProcessData> dataCollection) { Dictionary <String, IOInfo> dictionary = new Dictionary <string, IOInfo>(); foreach (ProcessData processData in dataCollection) { foreach (KeyValuePair <int, ThreadData> pair in processData.Threads) { foreach (IOData ioData in pair.Value.IORequests) { IOInfo info = null; if (!dictionary.TryGetValue(ioData.FileName, out info)) { dictionary.Add(ioData.FileName, info = new IOInfo() { Name = ioData.FileName }); } info.Add(ioData); } } } FileIO = dictionary.Values.ToList(); FileIO.ForEach(item => item.Normalize()); FileIO.Sort((a, b) => - a.TotalDuration.CompareTo(b.TotalDuration)); }
public void IOTableIni() { string SqlCommand = "SELECT * FROM IO;"; using (connection = new SQLiteConnection()) { // 建立SQLiteDataReader物件 using (SQLiteDataReader reader = ExecuteReader(SqlCommand)) { while (reader.Read()) { //讀取成功 IOInfo IO = new IOInfo { Address = reader["Address"].ToString(), Point = reader["Point"].ToString(), Location = reader["Location"].ToString(), Info = reader["Info"].ToString() }; IOList.Add(IO); } } } }
internal WirePath GetPath(Point start, Point end, IOInfo startIO, IOInfo endIO, bool pathToWire) { List <Point> pathAsTurns = new List <Point>(); List <int> allBoardPoses = new List <int>(); List <int> boardPosTurns = new List <int>(); MoveDirs prevDir = MoveDirs.None; Point boardPos = end; Point actualPos = end * CellSize; while (boardPos != start) { allBoardPoses.Add(CellIndex(boardPos)); ScorePath path = GetCellScorePath(boardPos); if (path.DirFrom != prevDir) { pathAsTurns.Add(actualPos); if (prevDir != MoveDirs.None) { boardPosTurns.Add(CellIndex(boardPos)); } } prevDir = path.DirFrom; boardPos = path.DirFrom.MovePoint(boardPos); actualPos = actualPos + path.DirFrom.MovePoint(Point.Zero) * CellSize; } allBoardPoses.Add(CellIndex(start)); pathAsTurns.Add(actualPos); pathAsTurns.Reverse(); boardPosTurns.Reverse(); return(new WirePath(startIO, endIO, pathAsTurns, allBoardPoses, boardPosTurns, pathToWire)); }
private WirePath PathLine(RouterBoard board, IOInfo start, IOInfo end, Rectangle?startRect, Rectangle?endRect, List <WirePath> allPaths) { board.ReloadCheckpoint(); Point relativeStart = board.GetRelativeBoardPos(start.DirIO.Position); Point relativeEnd = board.GetRelativeBoardPos(end.DirIO.Position); //Start position may lie inside the component rectangle //and therefore the is no way to reach it. //This here makes a straight path out of the component //so it's possible to find a path. if (endRect.HasValue) { Rectangle endRectRelative = board.GetRelativeBoard(endRect.Value); Point endGo = relativeEnd; MoveDirs allowedDir = end.DirIO.InitialDir.Reverse(); do { board.SetCellAllowedMoves(endGo, allowedDir); endGo = allowedDir.MovePoint(endGo); } while (endRectRelative.Within(endGo)); } else { board.SetCellAllowedMoves(relativeEnd, end.DirIO.InitialDir.Reverse()); } if (startRect.HasValue) { Rectangle startRectRelative = board.GetRelativeBoard(startRect.Value); Point startGo = relativeStart; MoveDirs allowedDir = start.DirIO.InitialDir.Reverse(); do { board.SetCellAllowedMoves(startGo, allowedDir); startGo = allowedDir.Reverse().MovePoint(startGo); } while (startRectRelative.Within(startGo)); } foreach (var path in allPaths) { MoveDirs wireType; if (path.StartIO.DirIO.Position == start.DirIO.Position || path.EndIO.DirIO.Position == end.DirIO.Position) { wireType = MoveDirs.FriendWire; } else { wireType = MoveDirs.EnemyWire; } path.PlaceOnBoard(board, wireType); } ref ScorePath startScore = ref board.GetCellScorePath(relativeEnd);
internal WirePath(IOInfo startIO, IOInfo endIO, List <Point> path, List <int> boardPositions, List <int> boardPosTurns, bool startsFromWire) { this.StartIO = startIO; this.EndIO = endIO; this.Path = path; this.BoardPositions = boardPositions; this.BoardPosTurns = boardPosTurns; this.StartsFromWire = startsFromWire; (this.FromIO, this.ToIO) = GetConCondition(); }
/// <summary> /// 加载位置信息 /// </summary> private void LoadIOPos() { //入料去区 #region 加载入料区信息 //加载1入料区 IOInfo infoOne = new IOInfo(); infoOne.AreaCode = "LIN"; infoOne.Code = "1"; //位置 IOPos ioposOne = new IOPos(); ioposOne.LowPos = "X=284.275,Y=495.800,Z=323.899,U=179.721,V=-0.599,W=-179.446"; //低端位置 ioposOne.HighPos = ""; //高端位置 infoOne.IoPosition = ioposOne; infoOne.IoFlag = 1; infoOne.i = 2; infoOne.j = 0; ioInfoList.Add(infoOne); //加载2 IOInfo infoTwo = new IOInfo(); infoTwo.AreaCode = "LIN"; infoTwo.Code = "2"; //位置 IOPos ioposTwo = new IOPos(); ioposTwo.LowPos = "X=158.804,Y=495.800,Z=323.344,U=179.721,V=-0.599,W=-179.446"; //低端位置 ioposTwo.HighPos = ""; //高端位置 infoTwo.IoPosition = ioposTwo; infoTwo.IoFlag = 1; infoTwo.i = 1; infoTwo.j = 3; ioInfoList.Add(infoTwo); //加载3 IOInfo infoThree = new IOInfo(); infoThree.AreaCode = "LIN"; infoThree.Code = "3"; //位置 IOPos ioposThree = new IOPos(); ioposThree.LowPos = "X=157.809,Y=722.095,Z=328.533,U=179.721,V=-0.600,W=-179.446"; //低端位置 ioposThree.HighPos = ""; //高端位置 infoThree.IoPosition = ioposThree; infoThree.IoFlag = 1; infoThree.i = 1; infoThree.j = 2; ioInfoList.Add(infoThree); //加载4 IOInfo infoFour = new IOInfo(); infoFour.AreaCode = "LIN"; infoFour.Code = "4"; //位置 IOPos ioposFour = new IOPos(); ioposFour.LowPos = "X=282.637,Y=723.612,Z=329.961,U=179.720,V=-0.600,W=-179.446"; //低端位置 ioposFour.HighPos = ""; //高端位置 infoFour.IoPosition = ioposFour; infoFour.IoFlag = 1; infoFour.i = 1; infoFour.j = 0; ioInfoList.Add(infoFour); #endregion #region 加载1A区信息 //加载1A第一个格子信息 IOInfo info1AOne = new IOInfo(); info1AOne.AreaCode = "1A"; info1AOne.Code = "1"; //位置 IOPos iopos1AOne = new IOPos(); iopos1AOne.LowPos = "X=516.601,Y=55.497,Z=398.994,U=90.857,V=0.247,W=-178.960"; //低端位置 iopos1AOne.HighPos = "X=516.601,Y=55.497,Z=398.994,U=90.857,V=0.247,W=-178.960"; //高端位置 info1AOne.IoPosition = iopos1AOne; info1AOne.i = 1; info1AOne.j = 0; ioInfoList.Add(info1AOne); //加载1ATWO信息 IOInfo info1ATwo = new IOInfo(); info1ATwo.AreaCode = "1A"; info1ATwo.Code = "2"; //位置 IOPos iopos1ATwo = new IOPos(); iopos1ATwo.LowPos = "X=516.601,Y=-70.497,Z=398.994,U=90.857,V=0.247,W=-178.960"; //低端位置 iopos1ATwo.HighPos = "X=516.601,Y=-70.497,Z=398.994,U=90.857,V=0.247,W=-178.960"; //高端位置 info1ATwo.IoPosition = iopos1ATwo; info1ATwo.i = 1; info1ATwo.j = 1; ioInfoList.Add(info1ATwo); #endregion #region 加载2A区信息 IOInfo info2AOne = new IOInfo(); info2AOne.AreaCode = "2A"; info2AOne.Code = "1"; //位置 IOPos iopos2AOne = new IOPos(); iopos2AOne.LowPos = "X=505.032,Y=84.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //低端位置 iopos2AOne.HighPos = "X=505.032,Y=84.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //高端位置 info2AOne.IoPosition = iopos2AOne; info2AOne.i = 0; info2AOne.j = 0; ioInfoList.Add(info2AOne); IOInfo info2ATwo = new IOInfo(); info2ATwo.AreaCode = "2A"; info2ATwo.Code = "2"; //位置 IOPos iopos2ATwo = new IOPos(); iopos2ATwo.LowPos = "X=505.032,Y=-41.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //低端位置 iopos2ATwo.HighPos = "X=505.032,Y=-41.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //高端位置 info2ATwo.IoPosition = iopos2ATwo; info2ATwo.i = 3; info2ATwo.j = 4; ioInfoList.Add(info2ATwo); IOInfo info2AThree = new IOInfo(); info2AThree.AreaCode = "2A"; info2AThree.Code = "3"; //位置 IOPos iopos2AThree = new IOPos(); iopos2AThree.LowPos = "X=505.032,Y=-166.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //低端位置 iopos2AThree.HighPos = "X=505.032,Y=-166.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //高端位置 info2AThree.IoPosition = iopos2AThree; info2AThree.i = 0; info2AThree.j = 2; ioInfoList.Add(info2AThree); IOInfo info2AFour = new IOInfo(); info2AFour.AreaCode = "2A"; info2AFour.Code = "4"; //位置 IOPos iopos2AFour = new IOPos(); iopos2AFour.LowPos = "X=505.032,Y=-291.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //低端位置 iopos2AFour.HighPos = "X=505.032,Y=-291.099,Z=257.127,U=91.143,V=0.247,W=-178.960"; //高端位置 info2AFour.IoPosition = iopos2AFour; info2AFour.i = 0; info2AFour.j = 3; ioInfoList.Add(info2AFour); #endregion #region 加载出料区信息 IOInfo infoOutOne = new IOInfo(); infoOutOne.AreaCode = "LOUT"; infoOutOne.Code = "1"; //位置 IOPos ioposoutOne = new IOPos(); ioposoutOne.LowPos = "X=292.560,Y=-725.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //低端位置 ioposoutOne.HighPos = "X=292.560,Y=-725.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //高端位置 infoOutOne.IoPosition = ioposoutOne; infoOutOne.i = 4; infoOutOne.j = 0; ioInfoList.Add(infoOutOne); IOInfo infoOutTwo = new IOInfo(); infoOutTwo.AreaCode = "LOUT"; infoOutTwo.Code = "2"; //位置 IOPos ioposoutTwo = new IOPos(); ioposoutTwo.LowPos = "X=167.560,Y=-725.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //低端位置 ioposoutTwo.HighPos = "X=167.560,Y=-725.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //高端位置 infoOutTwo.IoPosition = ioposoutTwo; infoOutTwo.i = 3; infoOutTwo.j = 3; ioInfoList.Add(infoOutTwo); IOInfo infoOutThree = new IOInfo(); infoOutThree.AreaCode = "LOUT"; infoOutThree.Code = "3"; //位置 IOPos ioposoutThree = new IOPos(); ioposoutThree.LowPos = "X=167.560,Y=-499.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //低端位置 ioposoutThree.HighPos = "X=167.560,Y=-499.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //高端位置 infoOutThree.IoPosition = ioposoutThree; infoOutThree.i = 4; infoOutThree.j = 2; ioInfoList.Add(infoOutThree); IOInfo infoOutFour = new IOInfo(); infoOutFour.AreaCode = "LOUT"; infoOutFour.Code = "4"; //位置 IOPos ioposoutFour = new IOPos(); ioposoutFour.LowPos = "X=292.560,Y=-499.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //低端位置 ioposoutFour.HighPos = "X=292.560,Y=-499.862,Z=334.467,U=1.469,V=0.525,W=-179.598"; //高端位置 infoOutFour.IoPosition = ioposoutFour; infoOutFour.i = 4; infoOutFour.j = 3; ioInfoList.Add(infoOutFour); #endregion }