|
@@ -1,11 +1,14 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Net.Sockets;
|
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
+using System.Drawing;
|
|
|
+using System.Windows.Forms.DataVisualization.Charting;
|
|
|
|
|
|
namespace DataGathering
|
|
|
{
|
|
@@ -70,12 +73,71 @@ namespace DataGathering
|
|
|
aws = aws + validNum[j] + " ";
|
|
|
}
|
|
|
validdatalist.Add(aws);
|
|
|
+
|
|
|
+ this.Invoke(new Action(() =>
|
|
|
+ {
|
|
|
+ System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
|
|
|
+ sw.Start();
|
|
|
+ aws.TrimEnd(' ');
|
|
|
+ List<double> listy = new List<double>();
|
|
|
+ List<double> listx = new List<double>();
|
|
|
+ string[] origindata = aws.Split(' ');
|
|
|
+ origindata = origindata.Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
|
|
+ int[] origindataTransformed = Array.ConvertAll<string, int>(origindata, int.Parse);
|
|
|
+ //int startDegree = (Convert.ToInt32(this.textBox1.Text) + 45) * 3;
|
|
|
+ //int endDegree = (Convert.ToInt32(this.textBox2.Text) + 45) * 3 + 1;
|
|
|
+ for (int k = 0; k < origindataTransformed.Length; k++)
|
|
|
+ {
|
|
|
+ double x = origindataTransformed[k] * Math.Cos((45 + 0.333 * k) * Math.PI / 180);
|
|
|
+ double y = origindataTransformed[k] * Math.Sin((45 + 0.333 * k) * Math.PI / 180);
|
|
|
+ Log.WriteCredence(x + " " + y);
|
|
|
+ listy.Add(y);
|
|
|
+ listx.Add(x);
|
|
|
+ }
|
|
|
+ this.chart1.Series[0].Points.Clear();
|
|
|
+
|
|
|
+ sw.Stop();
|
|
|
+ Console.WriteLine(sw.ElapsedMilliseconds + "ms");
|
|
|
+ }));
|
|
|
}
|
|
|
}
|
|
|
+ Thread.Sleep(200);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void InitChart(List<double> listx, List<double> listy)
|
|
|
+ {
|
|
|
+ //定义图表区域
|
|
|
+ this.chart1.ChartAreas.Clear();
|
|
|
+ ChartArea chartArea1 = new ChartArea("C1");
|
|
|
+ this.chart1.ChartAreas.Add(chartArea1);
|
|
|
+ //定义存储和显示点的容器
|
|
|
+ this.chart1.Series.Clear();
|
|
|
+ Series series1 = new Series("S1");
|
|
|
+ series1.ChartArea = "C1";
|
|
|
+ this.chart1.Series.Add(series1);
|
|
|
+ //设置图表显示样式
|
|
|
+ //this.chart1.ChartAreas[0].AxisY.Minimum = 0;
|
|
|
+ //this.chart1.ChartAreas[0].AxisY.Maximum = 100;
|
|
|
+ //this.chart1.ChartAreas[0].AxisX.Interval = 5;
|
|
|
+ this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;
|
|
|
+ this.chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;
|
|
|
+ //设置标题
|
|
|
+ this.chart1.Titles.Clear();
|
|
|
+ this.chart1.Titles.Add("S01");
|
|
|
+ this.chart1.Titles[0].Text = "雷达显示";
|
|
|
+ this.chart1.Titles[0].ForeColor = Color.RoyalBlue;
|
|
|
+ this.chart1.Titles[0].Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
|
|
|
+ //设置图表显示样式
|
|
|
+ this.chart1.Series[0].Color = Color.Red;
|
|
|
+ this.chart1.Series[0].ChartType = SeriesChartType.Point;
|
|
|
+ for (int i = 0; i < listx.Count; i++)
|
|
|
+ {
|
|
|
+ this.chart1.Series[0].Points.AddXY(listx[i], listy[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
isok = true;
|
|
@@ -102,14 +164,6 @@ namespace DataGathering
|
|
|
stream.Write(b, 0, b.Length);
|
|
|
return 1;
|
|
|
}
|
|
|
- //if (cmd.Equals(endCmd))
|
|
|
- //{
|
|
|
- // byte[] byteStartCmd = HexStringToBinary(endCmd);
|
|
|
- // string result = HexStringToASCII(byteStartCmd);
|
|
|
- // byte[] b = Encoding.UTF8.GetBytes(result);
|
|
|
- // stream.Write(b, 0, b.Length);
|
|
|
- // return 2;
|
|
|
- //}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -170,5 +224,43 @@ namespace DataGathering
|
|
|
catch (Exception) { }
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ private void button3_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ List<string> datalist = new List<string>();
|
|
|
+ datalist.Clear();
|
|
|
+ flag = sendCmd(startCmd);
|
|
|
+ byte[] buffer = new byte[bufferSize];
|
|
|
+ stream.Read(buffer, 0, buffer.Length);
|
|
|
+ string str = HexStringToASCII(buffer);
|
|
|
+ datalist.Add(str);
|
|
|
+ string ss = validStr(datalist[0], "sRA LMDscandata 1 ", " not defined 0 0 0");
|
|
|
+ string[] data = ss.Split(' ');
|
|
|
+ string number = data[22];
|
|
|
+ int a = Convert.ToInt32(number, 16);
|
|
|
+ int[] validNum = new int[a];
|
|
|
+ string aws = "";
|
|
|
+ for (int j = 0; j < a; j++)
|
|
|
+ {
|
|
|
+ validNum[j] = Convert.ToInt32(data[23 + j], 16);
|
|
|
+ aws = aws + validNum[j] + " ";
|
|
|
+ }
|
|
|
+ aws.TrimEnd(' ');
|
|
|
+ List<double> listy = new List<double>();
|
|
|
+ List<double> listx = new List<double>();
|
|
|
+ string[] origindata = aws.Split(' ');
|
|
|
+ origindata = origindata.Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
|
|
+ int[] origindataTransformed = Array.ConvertAll<string, int>(origindata, int.Parse);
|
|
|
+ //int startDegree = (Convert.ToInt32(this.textBox1.Text) + 45) * 3;
|
|
|
+ //int endDegree = (Convert.ToInt32(this.textBox2.Text) + 45) * 3 + 1;
|
|
|
+ for (int k = 0; k < origindataTransformed.Length; k++)
|
|
|
+ {
|
|
|
+ double x = origindataTransformed[k] * Math.Cos((45 + 0.333 * k) * Math.PI / 180);
|
|
|
+ double y = origindataTransformed[k] * Math.Sin((45 + 0.333 * k) * Math.PI / 180);
|
|
|
+ Log.WriteCredence(x + " " + y);
|
|
|
+ //listy.Add(y);
|
|
|
+ //listx.Add(x);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|