Ejemplo n.º 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}");
            }
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 3
0
 public CentralStockManager(FCentralStockDefinition stockDefinition)
 {
     _stockDefinition = stockDefinition;
     _quantity        = stockDefinition.InitialQuantity;
 }
Ejemplo n.º 4
0
 public static IBehaviour Central(FCentralStockDefinition stockDefinition, SimulationType simType)
 {
     return(new Central(stockDefinition, simType));
 }
Ejemplo n.º 5
0
 public Central(FCentralStockDefinition stockDefinition, SimulationType simType) : base(simulationType: simType)
 {
     _stockManager = new CentralStockManager(stockDefinition);
 }
Ejemplo n.º 6
0
 public static CreateStorageAgents Create(FCentralStockDefinition message, IActorRef target)
 {
     return(new CreateStorageAgents(message: message, target: target));
 }