upper computer

Posted https

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了upper computer相关的知识,希望对你有一定的参考价值。

技术分享图片
  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Threading.Tasks;
  9 using System.Windows.Forms;
 10 using System.Windows.Forms.DataVisualization.Charting;
 11 using System.IO;
 12  
 13 namespace sw
 14 {
 15     public partial class Form1 : Form
 16     {
 17         Queue<string> dataQueue = new Queue<string>(100);
 18         int num =10;
 19         string datain;
 20  
 21         Boolean flag = true;
 22         
 23         public Form1()
 24         {
 25             InitializeComponent();
 26             serialInt();
 27             InitChart();
 28         }
 29         private void button1_Click(object sender, EventArgs e)
 30         {
 31             serialSetInt();
 32             
 33             this.timer1.Start();
 34             
 35         }
 36 
 37         private void button2_Click(object sender, EventArgs e)
 38         {
 39           
 40             if (flag == true)
 41             {
 42                 this.timer1.Stop();
 43                 if(serialPort1.IsOpen) serialPort1.Close();
 44                 flag = false;
 45                 button2.Text = "继续测量";
 46             }
 47             else
 48             {
 49                 this.timer1.Start();
 50                 if (!serialPort1.IsOpen) serialPort1.Open();
 51                 flag = true;
 52                 button2.Text = "暂停测量";
 53             }
 54             
 55         }
 56         private void button4_Click(object sender, EventArgs e)
 57         {
 58             this.timer1.Stop();
 59             if (serialPort1.IsOpen) serialPort1.Close();
 60             Close();
 61         }
 62     
 63 
 64         private void timer1_Tick(object sender, EventArgs e)
 65         {
 66             
 67             this.chart1.Series[0].Points.Clear();
 68 
 69             updateQueue();
 70             for (int i = 0; i < dataQueue.Count; i++)
 71             {
 72                 textBox1.Text = dataQueue.ElementAt(i);
 73                 this.chart1.Series[0].Points.AddXY(i, dataQueue.ElementAt(i));
 74 
 75             }
 76         }
 77 
 78 
 79         private void updateQueue()
 80         {
 81 
 82             if (dataQueue.Count > 90)
 83             {
 84                 //先出列
 85                 for (int i = 0; i < num; i++)
 86                 {
 87                     dataQueue.Dequeue();
 88                 }
 89             }
 90             for (int i = 0; i < num; i++)
 91             {
 92                  
 93                 dataQueue.Enqueue(datain);
 94 
 95             }
 96            // this.chart1.ChartAreas[0].AxisY.Maximum = Convert.ToDouble(dataQueue.Max()) + 5;
 97             //this.chart1.ChartAreas[0].AxisY.Minimum = Convert.ToDouble(dataQueue.Min()) +5;
 98 
 99 
100         }
101 
102 
103         private void serialSetInt()
104         {
105             if (serialPort1.IsOpen) serialPort1.Close();
106             serialPort1.PortName = comboBox1.Text;
107             if (!serialPort1.IsOpen) serialPort1.Open();
108             serialPort1.BaudRate = int.Parse(comboBox2.Text);
109 
110         }
111         private void serialInt()
112         {
113             string[] portList = System.IO.Ports.SerialPort.GetPortNames();
114             for (int i = 0; i < portList.Length; ++i)
115             {
116                 string name = portList[i];
117                 comboBox1.Items.Add(name);
118             }
119 
120             string[] BaudRateList = {  "1200","2400", "4800", "9600","19200","38400","57600","115200" };
121             for (int i = 0; i < BaudRateList.Length; i++)
122             {
123                 comboBox2.Items.Add(BaudRateList[i]);
124             }
125 
126         }
127 
128         private void InitChart()
129         {
130             //定义图表区域
131             this.chart1.ChartAreas.Clear();
132             ChartArea chartArea1 = new ChartArea( );
133             this.chart1.ChartAreas.Add(chartArea1);
134             //定义存储和显示点的容器
135             this.chart1.Series.Clear();
136             Series series1 = new Series( );
137             this.chart1.Series.Add(series1);
138             //设置图表显示样式
139             this.chart1.ChartAreas[0].AxisY.Minimum = 0;
140             this.chart1.ChartAreas[0].AxisY.Maximum =1000;
141             this.chart1.ChartAreas[0].AxisX.Interval = 20;
142             this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;
143             this.chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;
144             this.chart1.Series[0].Color = Color.Red;
145             this.chart1.Series[0].ChartType = SeriesChartType.Line;
146 
147         }
148 
149         private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
150         {
151             datain= serialPort1.ReadExisting();
152         }
153 
154     }
155 }
View Code

 

以上是关于upper computer的主要内容,如果未能解决你的问题,请参考以下文章

显示 Vue 组件的计算属性:[Vue 警告]

vue基础----过滤器filter

OpenGL 之 Compute Shader(通用计算并行加速)

self.method = environ ['REQUEST_METHOD']。upper()KeyError:'REQUEST_METHOD'使用uwsgi在EC2

活动(加载器 - 下载)+ 3 个片段(使用加载器 - 计算)

upper_bound 和 find 给出不同的结果