/// <summary> /// methode die de wereld opzet /// </summary> public World() { WorldManager.AddNodes(); Robot r0 = CreateRobot(0, 0, 0); Robot r1 = CreateRobot(0, 0, 0); Robot r2 = CreateRobot(0, 0, 0); Robot r3 = CreateRobot(0, 0, 0); Vrachtwagen = CreateLorry(0, 0, 0); r0.Move(2, 2, 1); r1.Move(2, 2, 2); r2.Move(2, 2, 3); r3.Move(2, 2, 4); Vrachtwagen.Move(0, 0, -2); foreach (var punt in WorldManager.Points()) { if (punt.Id.Length == 1) { Shelf s = CreateShelf(0, 0, 0); punt.Shelf = s; WorldManager.AddShelf(punt); s.Move(punt.X, 0, punt.Z); punt.ShelfStatus = true; } if (punt.Id.Length == 4) { punt.ShelfStatus = false; } } }
public World() { robot1 = CreateRobot("r1", 0, 0.301, 0, 50); robot2 = CreateRobot("r2", 0, 0.301, -4, 100); robot3 = CreateRobot("r3", 0, 0.301, -8, 150); robot4 = CreateRobot("r4", 0, 0.301, -12, 200); thunderhawk = CreateTH(-150, 0.001, -21); MakeNodes(23 /* + 64*/); shelf1 = CreateShelf(-300, 1.401, -300); shelf2 = CreateShelf(-300, 1.401, -300); shelf3 = CreateShelf(-300, 1.401, -300); shelf4 = CreateShelf(-300, 1.401, -300); shelf5 = CreateShelf(-300, 1.401, -300); shelf6 = CreateShelf(-300, 1.401, -300); shelf7 = CreateShelf(-300, 1.401, -300); shelf8 = CreateShelf(-300, 1.401, -300); shelf9 = CreateShelf(-300, 1.401, -300); shelf10 = CreateShelf(-300, 1.401, -300); shelf11 = CreateShelf(-300, 1.401, -300); shelf12 = CreateShelf(-300, 1.401, -300); shelf13 = CreateShelf(-300, 1.401, -300); shelf14 = CreateShelf(-300, 1.401, -300); shelf15 = CreateShelf(-300, 1.401, -300); shelf16 = CreateShelf(-300, 1.401, -300); shelf17 = CreateShelf(-300, 1.401, -300); shelf18 = CreateShelf(-300, 1.401, -300); shelf19 = CreateShelf(-300, 1.401, -300); shelf20 = CreateShelf(-300, 1.401, -300); graph = new Graph(); graph = Graphy(); taskClass = new Tasks(this, this.worldObjects.ToList()); }
private Shelf CreateShelf(double x, double y, double z) { Shelf s = new Shelf(x, y, z, 0, 0, 0); worldObjects.Add(s); return(s); }
public Shelf CreateShelf(float x = 0f, float y = 0f, float z = 0f, float rx = 0f, float ry = 0f, float rz = 0f) { Shelf s = new Shelf(this, x, y, z, rx, ry, rz); _worldObjects.Add(s); return(s); }
public bool CancelReservation() { if (!this.IsReserved) { return(false); } this._reservedBy = null; return(true); }
public bool ReserveForCargo(Shelf cargo) { if (!IsAvailable || _reservedBy != null) { return(false); } this._reservedBy = cargo; return(true); }
public bool TryAddCargo(Shelf item) { if (this.HasFreeCargoSlots) { this.FreeCargoSlots[0].SetCargo(item); return(true); } return(false); }
public Shelf ReleaseCargo() { Shelf cargo = this._content; if (this.IsReserved && this._reservedBy == cargo) { CancelReservation(); } this._content = null; return(cargo); }
public RobotLoadTruckTask(Robot robot, Truck truck, Shelf item, CargoSlot destination) : base(robot) { this._item = item; this._destination = destination; this._truck = truck; if (!this._destination.ReserveForCargo(item)) { throw new InvalidOperationException("Robot.CargoTask could not reserve CargoSlot!"); } }
public World() { robot1 = CreateRobot("r1", 0, 0.891, 0, 50); robot2 = CreateRobot("r2", 0, 0.891, -4, 100); robot3 = CreateRobot("r3", 0, 0.891, -8, 150); robot4 = CreateRobot("r4", 0, 0.891, -12, 200); van = CreateTH(-150, 0.001, -21); MakeNodes(23 /* + 64*/); shelf1 = CreateShelf(-300, 1.801, -300); shelf2 = CreateShelf(-300, 1.801, -300); shelf3 = CreateShelf(-300, 1.801, -300); shelf4 = CreateShelf(-300, 1.801, -300); shelf5 = CreateShelf(-300, 1.801, -300); shelf6 = CreateShelf(-300, 1.801, -300); shelf7 = CreateShelf(-300, 1.801, -300); shelf8 = CreateShelf(-300, 1.801, -300); StartShelves(); }
public bool SetCargo(Shelf cargo) { if (IsAvailable) { ReserveForCargo(cargo); } if (IsAvailable || _reservedBy == cargo) { this._content = cargo; this._needsUpdate = true; } else { return(false); } return(true); }
/// <summary> /// Restock the shelves /// </summary> /// <param name="train">Train that brings the shelves</param> private void ShelfRestock(Train train) { ShelfTransporters forklift = forklifts.Find(x => x.Status() == false); Shelf shelf = shelfs.First(x => x.Status() == false && Math.Round(x.x, 1) == 16 && Math.Round(x.z, 1) == -2.4 && Math.Round(x.y, 1) == 1000); Node node = g.GetNodes().First(x => x.name.Contains("Res") && x.shelf == null); if (forklift != null && shelf != null && node != null) { forklift.Move(18, 0, 31); shelf.Move(18, 0, 31); forklift.AddShelf(shelf); forklift.AddTask(new ForkliftPickUp(shelf)); forklift.AddTask(new ForkliftMove(g.Shortest_Path("Forklift", node.name))); forklift.AddTask(new ForkliftDeliver(node, shelf)); forklift.AddTask(new ForkliftMove(g.Shortest_Path(node.name, "Forklift"))); forklift.AddTask(new ForkliftReset()); forklift.UpdateStatus(); train.itemRemove(); node.shelf = shelf; ShelfReplace.Add(node); } }
/// <summary> /// Constructor of ForkliftPickUp /// </summary> /// <param name="s">Shelf to pick up</param> public ForkliftPickUp(Shelf s) { this.shelf = s; }
private void MoveShelf(Robot r, Shelf s, double x, double y, double z) { s.Move(r.x, s.y, r.z); s.needsUpdate = true; }
/// <summary> /// Constructor of RobotDeliver /// </summary> /// <param name="shelf">Shelf</param> public RobotDeliver(Shelf shelf) { this.shelf = shelf; }
/// <summary> /// Constructor /// </summary> /// <param name="node">Node to place shelf on</param> /// <param name="shelf">Shelf to deliver</param> public ForkliftDeliver(Node node, Shelf shelf) { this.node = node; this.shelf = shelf; }
public bool TryAddCargo(Shelf item) => this._cargo.SetCargo(item);
/// <summary> /// Haalt de shelf van de robot af /// </summary> public void RemoveShelf() { this.Shelf = null; }
public void AddShelfToRobot(Robot r, Shelf s) { s._x = r._x; s._z = r._z; r.robotReady = false; }
/// <summary> /// Constructor of RobotPickUp /// </summary> /// <param name="node">Node</param> /// <param name="s">Shelf</param> public RobotPickUp(Node node, Shelf s) { this.node = node; this.shelf = s; }
/// <summary> /// Start de taak voor de robot en verwijdert de shelf van de robot /// </summary> /// <param name="r">robot</param> public void StartTask(Robot r) { this.shelf = r.ReturnShelf(); r.RemoveShelf(); node.Shelf = this.shelf; }
/// <summary> /// geeft de shelf en de node door /// </summary> /// <param name="n">node</param> public RobotPickUp(Node n) { this.shelf = n.Shelf; this.ShelfNode = n; }
/// <summary> /// Adds a shelf to the ShelfTransporter /// </summary> /// <param name="shelf">Shelf to add</param> public void AddShelf(Shelf shelf) { this.shelf = shelf; }
public override bool Update(int tick, int tickCount) { if (tasks.Count == 0 && !moving) { status = "idle"; } else if (tasks.Count > 0 && !moving) { if (tasks[0] is MoveTask) { MoveTask Task = tasks[0] as MoveTask; MoveTo(Task.getinfo()); CurrentPos = Task.getinfo(); if (Task.getinfo() == 'α') { status = "Omw to dock"; } else { status = "Omw to " + Task.getinfo(); } moving = true; } else if (tasks[0] is DropShelf) { DropShelf Task = tasks[0] as DropShelf; shelf.Move(Task.getinfo()[0], 0, Task.getinfo()[1]); shelf = null; tasks.RemoveAt(0); } else if (tasks[0] is PickupShelf) { PickupShelf Task = tasks[0] as PickupShelf; shelf = Task.getinfo(); shelf.Move(_x, 0.3, _z); tasks.RemoveAt(0); } } if (PathToDestNodes.Count > 0 && moving) { if (_x < PathToDestNodes[0].x) { //move right _rY = Math.PI / 2; _x += 0.125; } else if (_x > PathToDestNodes[0].x) { //move left _rY = -Math.PI / 2; _x -= 0.125; } else if (_z < PathToDestNodes[0].z) { //move up _rY = 0; _z += 0.125; } else if (_z > PathToDestNodes[0].z) { //move down _rY = Math.PI; _z -= 0.125; } if (shelf != null) { shelf.Move(_x, 0.3, _z); } if (x == PathToDestNodes[0].x && z == PathToDestNodes[0].z) { PathToDestNodes.RemoveAt(0); if (PathToDestNodes.Count == 0) { tasks.RemoveAt(0); moving = false; } } } return(true); }
/// <summary> /// Add shelf to list /// </summary> /// <param name="shelf">Shelfs</param> public void AddShelfToList(Shelf shelf) { shelfs.Add(shelf); }
/// <summary> /// removes the shelf from the ShelfTransporter /// </summary> public void RemoveShelf() { shelf = null; }
public void ChangeShelf(Shelf b) { this._shelf = b; }
public PickupShelf(Shelf shelf) { this.shelf = shelf; }
public void Update() { ThunderHawk thunderhawk = (ThunderHawk)worldObjects[4]; Robot robot1 = (Robot)worldObjects[0]; Robot robot2 = (Robot)worldObjects[1]; Robot robot3 = (Robot)worldObjects[2]; Robot robot4 = (Robot)worldObjects[3]; Shelf shelf1 = (Shelf)worldObjects[28 + (4 * cycles)]; Shelf shelf2 = (Shelf)worldObjects[29 + (4 * cycles)]; Shelf shelf3 = (Shelf)worldObjects[30 + (4 * cycles)]; Shelf shelf4 = (Shelf)worldObjects[31 + (4 * cycles)]; if (thunderhawk.thunderhawkHere == true) { robot1.ChangeThunderhawkHere(true); robot2.ChangeThunderhawkHere(true); robot3.ChangeThunderhawkHere(true); robot4.ChangeThunderhawkHere(true); } if (robot1.robotReady == true) { MoveShelf(robot1, shelf1, robot1.x, robot1.y, robot1.z); robot1.ChangeShelf(shelf1); robot1.ChangeRobotReady(false); robot1.ChangeRobotLoaded(true); ReadySetGo++; } if (robot2.robotReady == true) { MoveShelf(robot2, shelf2, robot2.x, robot2.y, robot2.z); robot2.ChangeShelf(shelf2); robot2.ChangeRobotReady(false); robot2.ChangeRobotLoaded(true); ReadySetGo++; } if (robot3.robotReady == true) { MoveShelf(robot3, shelf3, robot3.x, robot3.y, robot3.z); robot3.ChangeShelf(shelf3); robot3.ChangeRobotReady(false); robot3.ChangeRobotLoaded(true); ReadySetGo++; } if (robot4.robotReady == true) { MoveShelf(robot4, shelf4, robot4.x, robot4.y, robot4.z); robot4.ChangeShelf(shelf4); robot4.ChangeRobotReady(false); robot4.ChangeRobotLoaded(true); ReadySetGo++; } if (robot1.robotDropped == true) { world.RobotGoesBack(robot1, robot1.target, "A"); } if (robot2.robotDropped == true) { world.RobotGoesBack(robot2, robot2.target, "null1"); } if (robot3.robotDropped == true) { world.RobotGoesBack(robot3, robot3.target, "null2"); } if (robot4.robotDropped == true) { world.RobotGoesBack(robot4, robot4.target, "null3"); } if (ReadySetGo == 4) { thunderhawk.ChangeThunderhawkEmpty(true); robot1.ChangeRobotDone(false); robot2.ChangeRobotDone(false); robot3.ChangeRobotDone(false); robot4.ChangeRobotDone(false); ReadySetGo++; world.THHere(); } if (robot1.robotReset == true && robot2.robotReset == true && robot3.robotReset == true && robot4.robotReset == true) { ReadySetGo = 0; cycles++; robot1.RESET(); robot2.RESET(); robot3.RESET(); robot4.RESET(); thunderhawk.RESET(); } }