private void CreateSimulationWorkSchedule(FCreateSimulationWork cws) { var ws = cws.Operation; var sws = new SimulationWorkschedule { CreatedForOrderId = string.Empty, WorkScheduleId = ws.Key.ToString(), Article = ws.Operation.Article.Name, WorkScheduleName = ws.Operation.Name, DueTime = (int)ws.DueTime, SimulationConfigurationId = Collector.simulationId.Value, SimulationNumber = Collector.simulationNumber.Value, SimulationType = Collector.simulationKind.Value, OrderId = "[" + cws.CustomerOrderId + "]", HierarchyNumber = ws.Operation.HierarchyNumber, // TODO this is now a fArticleKey (Guid) ProductionOrderId = "[" + cws.fArticleKey + "]", Parent = cws.IsHeadDemand.ToString(), ParentId = "[]", Time = (int)(Collector.Time), ArticleType = cws.ArticleType }; var edit = _updatedSimulationWork.FirstOrDefault(predicate: x => x.WorkScheduleId.Equals(value: ws.Key.ToString())); if (edit != null) { sws.Start = (int)edit.Start; sws.End = (int)(edit.Start + edit.Duration); sws.Machine = edit.Machine; _updatedSimulationWork.Remove(item: edit); } simulationWorkschedules.Add(item: sws); }
internal void CreateJobsFromArticle(FArticle fArticle) { var lastDue = fArticle.DueTime; var numberOfOperations = fArticle.Article.Operations.Count(); var operationCounter = 0; foreach (var operation in fArticle.Article.Operations.OrderByDescending(keySelector: x => x.HierarchyNumber)) { operationCounter++; var fJob = operation.ToOperationItem(dueTime: lastDue , productionAgent: Agent.Context.Self , firstOperation: (operationCounter == numberOfOperations) , currentTime: Agent.CurrentTime); Agent.DebugMessage( msg: $"Created operation: {operation.Name} | BackwardStart {fJob.BackwardStart} | BackwardEnd:{fJob.BackwardEnd} Key: {fJob.Key} ArticleKey: {fArticle.Key}"); Agent.DebugMessage( msg: $"Precondition test: {operation.Name} | {fJob.StartConditions.PreCondition} ? {operationCounter} == {numberOfOperations} | Key: {fJob.Key} ArticleKey: {fArticle.Key}"); lastDue = fJob.BackwardStart - operation.AverageTransitionDuration; OperationManager.AddOperation(fJob); // send update to collector var pub = new FCreateSimulationWork(operation: fJob , customerOrderId: fArticle.CustomerOrderId.ToString() , isHeadDemand: fArticle.IsHeadDemand , fArticleKey: fArticle.Key , fArticleName: fArticle.Article.Name , articleType: fArticle.Article.ArticleType.Name); Agent.Context.System.EventStream.Publish(@event: pub); } _articleToProduce = fArticle; SetForwardScheduling(); }