/// <summary> /// solve Tree /// </summary> /// <param name="request"></param> private void MaterialRequest(object o) { var p = o as ProductionOrder; var request = p.Message as MaterialRequest; if (request.Material.Materials != null) { foreach (var child in request.Material.Materials) { for (int i = 0; i < child.Quantity; i++) { var childRequest = new MaterialRequest(material: child, childRequests: null, parrent: request.Id, due: request.Due - request.Material.AssemblyDuration - child.AssemblyDuration, isHead: false); request.ChildRequests.Add(childRequest.Id, false); var po = new ProductionOrder(childRequest, Self); _SimulationContext.Tell(po, Self); } } } if (request.Material.IsReady) { ReadyItems.Enqueue(request); } else { WaitingItems.Add(request); } PushWork(); }
private void ProvideMaterial(object o) { var po = o as ProductionOrderFinished; var request = po.Message as MaterialRequest; if (request.Material.Name == "Table") { Logger.Log(LogLevel.Info, "Simulation: Table No: {arg} has finished", new object[] { ++MaterialCounter }); } //Console.WriteLine("Time: " + TimePeriod + " Number " + MaterialCounter + " Finished: " + request.Material.Name); if (!request.IsHead) { var parrent = WaitingItems.Single(x => x.Id == request.Parrent); parrent.ChildRequests[request.Id] = true; // now check if item can be deployd to ReadyQueue if (parrent.ChildRequests.All(x => x.Value == true)) { WaitingItems.Remove(parrent); ReadyItems.Enqueue(parrent); } } Machines.Remove(Sender); Machines.Add(Sender, true); PushWork(); }