Пример #1
0
        /// <summary>
        /// Call this method for a single run without simulation.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="simulationId"></param>
        /// <returns></returns>
        public async Task InitializeMrp(MrpTask task, int simulationId)
        {
            await Task.Run(async() =>
            {
                _messageHub.SendToAllClients("Prepare InMemory Tables...", MessageType.info);
                rebuildNets        = new RebuildNets(_context);
                capacityScheduling = new CapacityScheduling(_context);
                _context           = InMemoryContext.CreateInMemoryContext();
                InMemoryContext.LoadData(_evaluationContext, _context);
                await PrepareSimulationContext();
                var simConfig = _context.SimulationConfigurations.Single(x => x.Id == simulationId);
                await OrderGenerator.GenerateOrders(_context, simConfig, simulationId);
                var simulationNumber = _context.GetSimulationNumber(simulationId, SimulationType.Central);
                //call initial central MRP-run
                await _processMrp.CreateAndProcessOrderDemand(task, _context, simulationId, _evaluationContext);
                if (task == MrpTask.Backward || task == MrpTask.Forward || task == MrpTask.GifflerThompson)
                {
                    var list = _context.ProductionOrderWorkSchedules.Select(schedule => new PowsSimulationItem(_context)
                    {
                        End                           = (task == MrpTask.Backward) ? schedule.EndBackward : (task == MrpTask.Forward) ? schedule.EndForward : schedule.End,
                        Start                         = (task == MrpTask.Backward) ? schedule.StartBackward : (task == MrpTask.Forward) ? schedule.StartForward : schedule.Start,
                        ProductionOrderId             = schedule.ProductionOrderId,
                        ProductionOrderWorkScheduleId = schedule.Id,
                        SimulationId                  = simulationId
                    })
                               .ToList();
                    _evaluationContext.SaveChanges();
                    FillSimulationWorkSchedules(list, simulationId, simulationNumber, task);
                }

                SimulationType simType = SimulationType.Central;
                switch (task)
                {
                case MrpTask.Forward:
                    simType = SimulationType.ForwardPlanning;
                    break;

                case MrpTask.Backward:
                    simType = SimulationType.BackwardPlanning;
                    break;
                }
                CopyResults.ExtractSimulationOrders(_context, _evaluationContext, simulationId, simulationNumber, simType);
                _messageHub.EndScheduler();
            });
        }
Пример #2
0
        private async Task <TimeTable <ISimulationItem> > InitializeSimulation(int simulationId, int simNumber, SimulationConfiguration simConfig)
        {
            _messageHub.SendToAllClients("Start Simulation...", MessageType.info);
            _context = InMemoryContext.CreateInMemoryContext();
            InMemoryContext.LoadData(_evaluationContext, _context);
            capacityScheduling = new CapacityScheduling(_context);
            rebuildNets        = new RebuildNets(_context);
            await PrepareSimulationContext();

            await OrderGenerator.GenerateOrders(_context, simConfig, simNumber);

            _workTimeGenerator = new WorkTimeGenerator(simConfig.Seed, simConfig.WorkTimeDeviation, simNumber);
            var timeTable = new TimeTable <ISimulationItem>(simConfig.RecalculationTime);

            UpdateStockExchangesWithInitialValues(simulationId, simNumber);

            //call the initial central planning
            await Recalculate(timeTable, simulationId, simNumber, new List <ProductionOrderWorkSchedule>());

            CreateMachinesReady(timeTable);
            timeTable = UpdateGoodsDelivery(timeTable, simulationId);
            return(timeTable);
        }