Exemplo n.º 1
0
        private void toolStripButton_Start_Click(object sender, EventArgs e)
        {
            double p1, p2;

            p1 = Distrib.GetAvg(AvgCount / 3, 780, 175, TPeak1, 1) +
                 Distrib.GetAvg(AvgCount / 3, TPeak1, 35, TPeak1, 1) +
                 Distrib.GetAvg(AvgCount / 3, TPeak2, 35, TPeak1, 1);

            p2 = Distrib.GetAvg(AvgCount / 3, 780, 175, TPeak2, 1) +
                 Distrib.GetAvg(AvgCount / 3, TPeak1, 35, TPeak2, 1) +
                 Distrib.GetAvg(AvgCount / 3, TPeak2, 35, TPeak2, 1);

            divider = Math.Max(p1, p2) * 0.15;

            pictureBox1.Image = null;

            pictureBox1.Image = new Bitmap(180, 100);

            i      = 0;
            Count  = 0;
            LCount = 0;
            ccc    = 0;

            toolStripMenuItem_Stop.Enabled  = true;
            toolStripButton_Stop.Enabled    = true;
            toolStripButton_Start.Enabled   = false;
            toolStripMenuItem_Start.Enabled = false;
            toolStripButton_pause.Enabled   = true;

            toolStripMenuItem_ModelSettings.Enabled = false;
            toolStripMenuItem_ExportStat.Enabled    = false;

            route.Reset();
            bus.Reset();

            ModelTimer.Enabled = true;
        }
Exemplo n.º 2
0
        private void ModelTimer_Tick(object sender, EventArgs e)
        {
            if (i == 0)
            {
                Statistics.Clear();
                Statistics.Reset();
            }

            if (i == 1440)
            {
                ModelTimer.Enabled = false;
                Statistics.Count   = Count;
                PrintStatistics();

                toolStripMenuItem_ModelSettings.Enabled = true;
                toolStripMenuItem_Stop.Enabled          = false;
                toolStripButton_Stop.Enabled            = false;
                toolStripButton_Start.Enabled           = true;
                toolStripMenuItem_Start.Enabled         = true;

                toolStripButton_pause.Enabled = false;
                ModelTimer.Tag = 0;
                toolStripButton_pause.Image = imageList1.Images[0];

                return;
            }

            if (i % 8 == 7)
            {
                int h = 99 - (int)(ccc / divider);
                for (int y = 99; y >= h; y--)
                {
                    (pictureBox1.Image as Bitmap).SetPixel((int)(i / 8), y, Color.Green);
                }
                pictureBox1.Invalidate();
                ccc = 0;
            }

            LCount = 0;

            for (int k = 0; k < route.StationsCount; k++)
            {
                LCount += Distrib.Get(AvgCount / 3, 780, 175, i, route.StationsCount);
                LCount += Distrib.Get(AvgCount / 3, TPeak1, 35, i, route.StationsCount);
                LCount += Distrib.Get(AvgCount / 3, TPeak2, 35, i, route.StationsCount);
            }
            Count += LCount;
            ccc   += LCount;

            for (int k = 0; k < LCount; k++)
            {
                route.SetPassenger(Distrib.SetPassengerToStation(route.StationsCount), i, Distrib.OutStation(route.StationsCount));
            }

            for (int k = 0; k < route.StationsCount; k++)
            {
                if (route.QueueSize(k) > Statistics.MaxQueueLenght)
                {
                    Statistics.MaxQueueLenght  = route.QueueSize(k);
                    Statistics.MaxQueueStation = k;
                    Statistics.MaxQueueTime    = i;
                }
            }

            if (i != 0 && i % bus.RidingTime == 0)
            {
                bus.ThrowPassenger(i);
                int n = bus.FreeSeat;
                for (int j = 0; j < n; j++)
                {
                    bus.SetPassenger(route.DequeuePassenger(bus.CurrentStation));
                }
                bus.Ride(route.StationsCount);
            }

            listBox_ModelStations.Items.Clear();

            for (int k = 0; k < route.StationsCount; k++)
            {
                listBox_ModelStations.Items.Add("Остановка №: " + (k + 1) + "\t" + route.QueueSize(k) + " человек на остановке");
            }

            toolStripStatusLabel2.Text = ((i / 60).ToString() + ":" + (i % 60).ToString());

            toolStripStatusLabel1.Text = "Количество людей в ТС: " + (bus.BusCapacity - bus.FreeSeat);
            listBox_ModelStations.SetSelected(bus.CurrentStation, true);

            toolStripProgressBar1.Value = i++;
        }