コード例 #1
0
        public Form1()
        {
            InitializeComponent();

            SimConstants = new SimulationConstants();
            Sim          = new Simulation();

            SimRandomValue   = new RandomValue();
            SimEntityFactory = new EntityFactory(SimRandomValue);
            SimEventFactory  = new EventFactory(Sim, SimRandomValue);
            SimDisplay       = new Display(Sim, CalendarGrid, QueueGrid, statsBox, txtCurrentTime);

            Sim.EventFactory  = SimEventFactory;
            Sim.EntityFactory = SimEntityFactory;
            Sim.SimConstants  = SimConstants;
            Sim.SimDisplay    = SimDisplay;
        }
コード例 #2
0
ファイル: Simulation.cs プロジェクト: DBeath/event-simulator
        // Intitialise all the parameters for the current simulation.
        public void IntitialiseSimulation(SimulationConstants startSimConstants)
        {
            SimConstants = startSimConstants;
            SimDisplay.CreateColumns();
            SimDisplay.ClearDataGridView();

            // Create the queues.
            foreach (KeyValuePair <string, int[]> productType in SimConstants.ProductType)
            {
                if (QueueDict.ContainsKey(productType.Key))
                {
                    QueueDict.Remove(productType.Key);
                }
                QueueDict.Add(productType.Key, new EntityQueue(productType.Key, EventFactory, productType.Value[1], productType.Value[2]));
            }

            // Intitialise the statistics for this simulation.
            Stats = new Statistics(this);

            //Create the entities.
            EntityList = EntityFactory.CreateEntities(SimConstants);

            // Get the End Replication Entity and create the End Replication Event.
            int index = EntityList.FindIndex(e => e.EntityId == 1);

            EventFactory.CreateEndReplication(EntityList.ElementAt(index));
            EntityList.RemoveAt(index);


            // Create the arrive events.
            foreach (Entity entity in EntityList)
            {
                EventFactory.CreateArrive(entity);
            }

            CurrentInQueue = 0;
            CurrentTime    = SimConstants.SimulationStartTime;
        }