Example #1
0
        /// <summary>
        /// Creates StorageAgents based on current Model and add them to the SimulationContext
        /// </summary>
        private void CreateStorageAgents()
        {
            var materials = _ganttContext.GptblMaterial;

            var stockpostings = _ganttContext.GptblStockquantityposting;

            foreach (var material in materials)
            {
                var initialStock = stockpostings.Single(x => x.MaterialId.Equals(material.MaterialId));

                var stockDefintion = new FCentralStockDefinition(
                    stockId: Int32.Parse(material.MaterialId),
                    materialName: material.Name,
                    initialQuantity: initialStock.Quantity.Value,
                    unit: material.QuantityUnitId,
                    price: material.ValueProduction.Value,
                    materialType: material.Info1,
                    deliveryPeriod: long.Parse(material.Info2)
                    );

                _simulation.SimulationContext.Tell(message: Directory.Instruction.Central
                                                   .CreateStorageAgents
                                                   .Create(message: stockDefintion, target: ActorPaths.StorageDirectory.Ref)
                                                   , sender: ActorPaths.StorageDirectory.Ref);

                System.Diagnostics.Debug.WriteLine($"Creating Stock for: {material.Name}");
            }
        }
Example #2
0
        public void CreateStorageAgents(FCentralStockDefinition stock)
        {
            var storage = Agent.Context.ActorOf(props: Storage.Props(actorPaths: Agent.ActorPaths
                                                                     , time: Agent.CurrentTime
                                                                     , debug: Agent.DebugThis
                                                                     , principal: Agent.Context.Self)
                                                , name: ("Storage(" + stock.StockId + " " + stock.MaterialName + ")").ToActorName());

            StorageManager.AddOrCreateRelation(storage, stock.StockId.ToString());
            Agent.Send(instruction: BasicInstruction.Initialize.Create(target: storage, message: StorageAgent.Behaviour.Factory.Central(stockDefinition: stock, simType: SimulationType)));
        }
 public CentralStockManager(FCentralStockDefinition stockDefinition)
 {
     _stockDefinition = stockDefinition;
     _quantity        = stockDefinition.InitialQuantity;
 }
Example #4
0
 public static IBehaviour Central(FCentralStockDefinition stockDefinition, SimulationType simType)
 {
     return(new Central(stockDefinition, simType));
 }
Example #5
0
 public Central(FCentralStockDefinition stockDefinition, SimulationType simType) : base(simulationType: simType)
 {
     _stockManager = new CentralStockManager(stockDefinition);
 }
Example #6
0
 public static CreateStorageAgents Create(FCentralStockDefinition message, IActorRef target)
 {
     return(new CreateStorageAgents(message: message, target: target));
 }