Demo entry 6360252

分析变量

   

Submitted by anonymous on May 01, 2017 at 09:03
Language: C#. Code size: 1.9 kB.

        private void timer1_Tick(object sender, EventArgs e)
        {
            runNum++;
            if (runNum>runTime)
            {
                int carCountPH;   
                int index = comboBox1.SelectedIndex;                      //用户选定的数据分析变量
                switch (index)
                {
                    case 0://交通量 车流量
                        carCountPH = (int)(60 / Double.Parse(textBox1.Text) * carCount);
                        dataGridView2.Rows[0].Cells[0].Value = DateTime.Now.ToString("hh:mm:ss");
                        dataGridView2.Rows[0].Cells[1].Value = carCountPH;
                        break; 
                    case 1://车速
                        dataGridView2.Rows[0].Cells[0].Value = DateTime.Now.ToString("hh:mm:ss");
                        dataGridView2.Rows[0].Cells[1].Value = Math.Round(speed / carCount,2);
                        break;
                    case 2://车头时距
                        timeHeadWay = Double.Parse(textBox1.Text)*60 / carCount;  //车头时距
                        dataGridView2.Rows[0].Cells[0].Value = DateTime.Now.ToString("hh:mm:ss");
                        dataGridView2.Rows[0].Cells[1].Value = timeHeadWay;
                        break;
                    case 3://时间占有率
                        dataGridView2.Rows[0].Cells[0].Value = DateTime.Now.ToString("hh:mm:ss");
                        dataGridView2.Rows[0].Cells[1].Value =(Math.Round(timeTotal / lastTime,3)*100).ToString()+"%";
                        break;
                }
                runNum = 0;
                runTime = 0;
                speed = 0;
                timeTotal = 0;
                carCount = 0;
                timer1.Stop();
                comboBox1.Enabled = true;
                label1.Enabled = true;
                button1.Enabled = true;
            }
        }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).