/// <summary> /// </summary> /// <param name="Lastpath">上一条轨迹的实例</param> /// <param name="length">直线的长度</param> public Path1(Path1 Lastpath, int length) { Point FinP = new Point(Lastpath.endX, Lastpath.endY); switch (Lastpath.Dire) { case Direction.DirUp: case Direction.DirTnLtU: case Direction.DirTnRtU: FinP.X = Lastpath.endX; FinP.Y = Lastpath.endY - length; _Dire = Direction.DirUp; break; case Direction.DirDown: case Direction.DirTnLtD: case Direction.DirTnRtD: FinP.X = Lastpath.endX; FinP.Y = Lastpath.endY + length; _Dire = Direction.DirDown; break; case Direction.DirLeft: case Direction.DirTnUtL: case Direction.DirTnDtL: FinP.X = Lastpath.endX - length; FinP.Y = Lastpath.endY; _Dire = Direction.DirLeft; break; case Direction.DirRight: case Direction.DirTnUtR: case Direction.DirTnDtR: FinP.X = Lastpath.endX + length; FinP.Y = Lastpath.endY; _Dire = Direction.DirRight; break; default: break; } _startX = Lastpath.endX; _startY = Lastpath.endY; _endX = FinP.X; _endY = FinP.Y; _CenterX = FinP.X; _CenterY = FinP.Y; _PathLength = length; _Interval = Config.AGVtime; }
public static void InitMap() ////初始化地图 { const int 间隔 = 200; Dictionary <int, Path1> list = Config.PathList; Point 原点 = new Point(Config.InitX, Config.InitY); Point p1 = new Point(350, 100); Point p2 = new Point(520, 100); list[11] = new Path1(p1, Direction.DirRight, 150); list[12] = new Path1(list[11], Direction.DirDown); list[13] = new Path1(list[12], 500); list[14] = new Path1(list[13], Direction.DirLeft); list[15] = new Path1(list[14], 150); list[16] = new Path1(list[15], Direction.DirUp); list[17] = new Path1(list[16], 500); list[18] = new Path1(list[17], Direction.DirRight); list[21] = new Path1(list[11], 170); list[22] = new Path1(list[21], Direction.DirDown); list[23] = new Path1(list[22], 500); list[24] = new Path1(list[23], Direction.DirLeft); list[25] = new Path1(list[24], 170); list[31] = new Path1(list[21], 170); list[32] = new Path1(list[31], Direction.DirDown); list[33] = new Path1(list[32], 500); list[34] = new Path1(list[33], Direction.DirLeft); list[35] = new Path1(list[34], 170); list[41] = new Path1(list[31], 170); list[42] = new Path1(list[41], Direction.DirDown); list[43] = new Path1(list[42], 500); list[44] = new Path1(list[43], Direction.DirLeft); list[45] = new Path1(list[44], 170); }
/// <summary> /// 画轨道:转弯圆弧(简化版) /// </summary> /// <param name="Lastpath">上一条轨迹的实例</param> /// <param name="DirFin">圆弧的最后方向</param> public Path1(Path1 Lastpath, Direction DirFin) { Point InitP = new Point(Lastpath.endX, Lastpath.endY); _rect = new Rectangle(InitP.X, InitP.Y, 20, 20); _startX = InitP.X; _startY = InitP.Y; switch (Lastpath.Dire) { case Direction.DirUp: case Direction.DirTnLtU: case Direction.DirTnRtU: if (DirFin == Direction.DirLeft) { _rect.Location = new Point(InitP.X - 20, InitP.Y - 10); _endX = _startX - 10; _endY = _startY - 10; _Dire = Direction.DirTnUtL; } else if (DirFin == Direction.DirRight) { _rect.Location = new Point(InitP.X, InitP.Y - 10); _endX = _startX + 10; _endY = _startY - 10; _Dire = Direction.DirTnUtR; } else { _endX = _startX; _endY = _startY; } _CenterX = _endX; _CenterY = _startY; break; case Direction.DirDown: case Direction.DirTnLtD: case Direction.DirTnRtD: if (DirFin == Direction.DirLeft) { _rect.Location = new Point(InitP.X - 20, InitP.Y - 10); _endX = _startX - 10; _endY = _startY + 10; _Dire = Direction.DirTnDtL; } else if (DirFin == Direction.DirRight) { _rect.Location = new Point(InitP.X, InitP.Y - 10); _endX = _startX + 10; _endY = _startY + 10; _Dire = Direction.DirTnDtR; } else { _endX = _startX; _endY = _startY; } _CenterX = _endX; _CenterY = _startY; break; case Direction.DirLeft: case Direction.DirTnUtL: case Direction.DirTnDtL: if (DirFin == Direction.DirUp) { _rect.Location = new Point(InitP.X - 10, InitP.Y - 20); _endX = _startX - 10; _endY = _startY - 10; _Dire = Direction.DirTnLtU; } else if (DirFin == Direction.DirDown) { _rect.Location = new Point(InitP.X - 10, InitP.Y); _endX = _startX - 10; _endY = _startY + 10; _Dire = Direction.DirTnLtD; } else { _endX = _startX; _endY = _startY; } _CenterX = _startX; _CenterY = _endY; break; case Direction.DirRight: case Direction.DirTnUtR: case Direction.DirTnDtR: if (DirFin == Direction.DirUp) { _rect.Location = new Point(InitP.X - 10, InitP.Y - 20); _endX = _startX + 10; _endY = _startY - 10; _Dire = Direction.DirTnRtU; } else if (DirFin == Direction.DirDown) { _rect.Location = new Point(InitP.X - 10, InitP.Y); _endX = _startX + 10; _endY = _startY + 10; _Dire = Direction.DirTnRtD; } else { _endX = _startX; _endY = _startY; } _CenterX = _startX; _CenterY = _endY; break; default: _endX = _startX; _endY = _startY; _CenterX = _startX; _CenterY = _endY; break; } _rect.X -= Config.MapInitX; _rect.Y -= Config.MapInitY; _PathLength = 15; _Interval = Config.AGVtime; }