Exemple #1
0
        private void StartProductionAgent(FArticle fArticle)
        {
            _forwardScheduleTimeCalculator = new ForwardScheduleTimeCalculator(fArticle: fArticle);
            // check for Children
            if (fArticle.Article.ArticleBoms.Any())
            {
                Agent.DebugMessage(
                    msg: "Article: " + fArticle.Article.Name + " (" + fArticle.Key + ") is last leave in BOM.");
            }

            if (fArticle.Article.Operations == null)
            {
                throw new Exception("Production agent without operations");
            }


            // Ask the Directory Agent for Service
            RequestHubAgentsFromDirectoryFor(agent: Agent, operations: fArticle.Article.Operations);
            // And create Operations
            CreateJobsFromArticle(fArticle: fArticle);

            var requiredDispoAgents = OperationManager.CreateRequiredArticles(articleToProduce: fArticle
                                                                              , requestingAgent: Agent.Context.Self
                                                                              , currentTime: Agent.CurrentTime);

            for (var i = 0; i < requiredDispoAgents; i++)
            {
                // create Dispo Agents for to provide required articles
                var agentSetup = AgentSetup.Create(agent: Agent,
                                                   behaviour: DispoAgent.Behaviour.Factory.Get(simType: SimulationType.None));
                var instruction = Guardian.Instruction.CreateChild.Create(setup: agentSetup,
                                                                          target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);
                Agent.Send(instruction: instruction);
            }
        }
Exemple #2
0
        /// <summary>
        /// Startup with Creating Dispo Agent for current Item.
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="orderItem"></param>
        public void StartOrder(T_CustomerOrderPart orderItem)
        {
            // create Request Item
            _fArticle = orderItem.ToRequestItem(requester: Agent.Context.Self, currentTime: Agent.CurrentTime);
            // Tell Guardian to create Dispo Agent
            var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: DispoAgent.Behaviour.Factory.Get(simType: Agent.Behaviour.SimulationType));
            var instruction = Guardian.Instruction.CreateChild.Create(setup: agentSetup, target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);

            Agent.Send(instruction: instruction);
            // init end
        }
Exemple #3
0
        private void CreateContractAgent(T_CustomerOrderPart orderPart)
        {
            _orderQueue.Enqueue(item: orderPart);
            DebugMessage(msg: $"Creating Contract Agent for order {orderPart.CustomerOrderId} with {orderPart.Article.Name} DueTime {orderPart.CustomerOrder.DueTime}");
            var agentSetup  = AgentSetup.Create(agent: this, behaviour: ContractAgent.Behaviour.Factory.Get(simType: _simulationType));
            var instruction = CreateChild.Create(setup: agentSetup
                                                 , target: ActorPaths.Guardians
                                                 .Single(predicate: x => x.Key == GuardianType.Contract)
                                                 .Value
                                                 , source: this.Self);

            Send(instruction: instruction);
        }
Exemple #4
0
        private void CreateContractAgent(T_CustomerOrder order)
        {
            _productionContext.CustomerOrders.Add(order);
            _productionContext.SaveChanges();

            var orderPart = order.CustomerOrderParts.First();

            _orderQueue.Enqueue(item: orderPart);
            Agent.DebugMessage(msg: $"Creating Contract Agent for order {orderPart.CustomerOrderId} with {orderPart.Article.Name} DueTime {orderPart.CustomerOrder.DueTime}");
            var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: ContractAgent.Behaviour.Factory.Get(simType: _simulationType));
            var instruction = Instruction.CreateChild.Create(setup: agentSetup
                                                             , target: Agent.ActorPaths.Guardians
                                                             .Single(predicate: x => x.Key == GuardianType.Contract)
                                                             .Value
                                                             , source: Agent.Context.Self);

            Agent.Send(instruction: instruction);
        }
        internal void ResponseFromSystemForBom(M_Article article)
        {
            // Update
            var dueTime = _fArticle.DueTime;

            if (article.Operations != null)
            {
                dueTime = _fArticle.DueTime - article.Operations.Sum(selector: x => x.Duration + x.AverageTransitionDuration);
            }
            // TODO: Object that handles the different operations- current assumption is all operations are handled as a sequence (no alternative/parallel plans)

            _fArticle = _fArticle.UpdateCustomerOrderAndDue(id: _fArticle.CustomerOrderId, due: dueTime, storage: _fArticle.StorageAgent)
                        .UpdateArticle(article: article);

            // Creates a Production Agent for each element that has to be produced
            for (var i = 0; i < _quantityToProduce; i++)
            {
                var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: ProductionAgent.Behaviour.Factory.Get(simType: SimulationType.None));
                var instruction = CreateChild.Create(setup: agentSetup, target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);
                Agent.Send(instruction: instruction);
            }
        }