Browse Source

sick雷达测试

jinwang 6 years ago
commit
75265ba76c
60 changed files with 4938 additions and 0 deletions
  1. 53 0
      .gitignore
  2. 6 0
      BorderUpon、/App.config
  3. 52 0
      BorderUpon、/BorderUpon、.csproj
  4. 94 0
      BorderUpon、/Program.cs
  5. 36 0
      BorderUpon、/Properties/AssemblyInfo.cs
  6. 6 0
      ChartTest/App.config
  7. 83 0
      ChartTest/ChartTest.csproj
  8. 171 0
      ChartTest/Form1.Designer.cs
  9. 131 0
      ChartTest/Form1.cs
  10. 120 0
      ChartTest/Form1.resx
  11. 22 0
      ChartTest/Program.cs
  12. 36 0
      ChartTest/Properties/AssemblyInfo.cs
  13. 71 0
      ChartTest/Properties/Resources.Designer.cs
  14. 117 0
      ChartTest/Properties/Resources.resx
  15. 30 0
      ChartTest/Properties/Settings.Designer.cs
  16. 7 0
      ChartTest/Properties/Settings.settings
  17. 6 0
      CheckTest/App.config
  18. 52 0
      CheckTest/CheckTest.csproj
  19. 153 0
      CheckTest/Program.cs
  20. 36 0
      CheckTest/Properties/AssemblyInfo.cs
  21. 6 0
      DataGathering/App.config
  22. 84 0
      DataGathering/DataGathering.csproj
  23. 74 0
      DataGathering/Form1.Designer.cs
  24. 174 0
      DataGathering/Form1.cs
  25. 120 0
      DataGathering/Form1.resx
  26. 256 0
      DataGathering/LogManager.cs
  27. 22 0
      DataGathering/Program.cs
  28. 36 0
      DataGathering/Properties/AssemblyInfo.cs
  29. 71 0
      DataGathering/Properties/Resources.Designer.cs
  30. 117 0
      DataGathering/Properties/Resources.resx
  31. 30 0
      DataGathering/Properties/Settings.Designer.cs
  32. 7 0
      DataGathering/Properties/Settings.settings
  33. 99 0
      DataGathering/log.cs
  34. 6 0
      Test/App.config
  35. 208 0
      Test/Form1.Designer.cs
  36. 376 0
      Test/Form1.cs
  37. 120 0
      Test/Form1.resx
  38. 256 0
      Test/LogManager.cs
  39. 22 0
      Test/Program.cs
  40. 36 0
      Test/Properties/AssemblyInfo.cs
  41. 71 0
      Test/Properties/Resources.Designer.cs
  42. 117 0
      Test/Properties/Resources.resx
  43. 30 0
      Test/Properties/Settings.Designer.cs
  44. 7 0
      Test/Properties/Settings.settings
  45. 86 0
      Test/Test.csproj
  46. 99 0
      Test/log.cs
  47. 55 0
      sickTest.sln
  48. 6 0
      sickTest/App.config
  49. 85 0
      sickTest/Form1.Designer.cs
  50. 170 0
      sickTest/Form1.cs
  51. 120 0
      sickTest/Form1.resx
  52. 229 0
      sickTest/LogManager.cs
  53. 22 0
      sickTest/Program.cs
  54. 36 0
      sickTest/Properties/AssemblyInfo.cs
  55. 71 0
      sickTest/Properties/Resources.Designer.cs
  56. 117 0
      sickTest/Properties/Resources.resx
  57. 30 0
      sickTest/Properties/Settings.Designer.cs
  58. 7 0
      sickTest/Properties/Settings.settings
  59. 94 0
      sickTest/log.cs
  60. 84 0
      sickTest/sickTest.csproj

+ 53 - 0
.gitignore

@@ -0,0 +1,53 @@
+!/DLLs/
+*.exe
+*.exp
+*.ilk
+*.lib
+*.ncb
+*.log
+*.pdb
+*.vcproj.*.user
+*.suo
+._*
+[Dd]ebug
+[Rr]elease
+obj/
+[Bb]in
+!packages/build/
+Bak/
+packages/
+[Rr]elease/
+Key/
+!NuGet.exe
+
+#Ignore thumbnails created by Windows
+Thumbs.db
+#Ignore files built by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
+.vs/
+#Nuget packages folder
+packages/

+ 6 - 0
BorderUpon、/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 52 - 0
BorderUpon、/BorderUpon、.csproj

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>BorderUpon_</RootNamespace>
+    <AssemblyName>BorderUpon、</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 94 - 0
BorderUpon、/Program.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace BorderUpon_
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            int[] arr = { 1, 2, 3, 5, 7, 8, 9, 15, 18, 19, 24 };
+            var query = arr.OrderBy(p => p).Aggregate<int, List<List<int>>>(null, (m, n) =>
+            {
+                if (m == null) return new List<List<int>>() { new List<int>() { n } };
+                if (m.Last().Last() != n - 1)
+                {
+                    m.Add(new List<int>() { n });
+                }
+                else
+                {
+                    m.Last().Add(n);
+                }
+                return m;
+            });
+            //List<int> aa = new List<int>();
+            int flag = 0;
+            for (int i = 0; i < query.Count; i++)
+            {
+                if (query[i].Count > 5)
+                {
+                    flag++;
+                }
+            }
+            //打印结果
+            //query.ForEach(p =>
+            //{
+            //    if (p.Count > 5)
+            //    {
+            //        Console.WriteLine("true");
+            //    }
+            //    else
+            //    {
+            //        Console.WriteLine("false");
+            //    }
+            //});
+            //Console.Read();
+        }
+        private static bool IsBorderUpon(int[] arr)
+        {
+            int max_num = 0;
+            int min_num = 65535;
+            int zero_count = 0;
+            for (int i = 0; i < 5; i++)
+            {
+                if (arr[i] == 0)
+                {
+                    zero_count++;
+                }
+                else
+                {
+                    if (arr[i] > max_num)
+                    {
+                        max_num = arr[i];
+                    }
+                    if (arr[i] < min_num)
+                    {
+                        min_num = arr[i];
+                    }
+                }
+            }
+
+            if (zero_count == 4 || zero_count == 5)
+            {
+                return true;
+            }
+            else if (zero_count == 0)
+            {
+                if ((max_num - min_num) == 4)
+                {
+                    return true;
+                }
+                return false;
+            }
+            else
+            {
+                if ((max_num - min_num) <= 4)
+                {
+                    return true;
+                }
+                return false;
+            }
+        }
+    }
+}

+ 36 - 0
BorderUpon、/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("BorderUpon、")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BorderUpon、")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("95883b42-b6d7-4d21-bec9-eba78fe035ce")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 6 - 0
ChartTest/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 83 - 0
ChartTest/ChartTest.csproj

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>ChartTest</RootNamespace>
+    <AssemblyName>ChartTest</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Windows.Forms.DataVisualization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Form1.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Form1.Designer.cs">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Form1.resx">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 171 - 0
ChartTest/Form1.Designer.cs

@@ -0,0 +1,171 @@
+namespace ChartTest
+{
+    partial class Form1
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
+            this.textBox1 = new System.Windows.Forms.TextBox();
+            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.textBox3 = new System.Windows.Forms.TextBox();
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // chart1
+            // 
+            chartArea2.Name = "ChartArea1";
+            this.chart1.ChartAreas.Add(chartArea2);
+            legend2.Name = "Legend1";
+            this.chart1.Legends.Add(legend2);
+            this.chart1.Location = new System.Drawing.Point(107, 108);
+            this.chart1.Name = "chart1";
+            series2.ChartArea = "ChartArea1";
+            series2.Legend = "Legend1";
+            series2.Name = "Series1";
+            this.chart1.Series.Add(series2);
+            this.chart1.Size = new System.Drawing.Size(703, 300);
+            this.chart1.TabIndex = 0;
+            this.chart1.Text = "chart1";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(207, 476);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(156, 54);
+            this.button1.TabIndex = 1;
+            this.button1.Text = "启动";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(504, 476);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(130, 54);
+            this.button2.TabIndex = 2;
+            this.button2.Text = "停止";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(104, 45);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(57, 19);
+            this.label1.TabIndex = 3;
+            this.label1.Text = "角度:";
+            // 
+            // textBox1
+            // 
+            this.textBox1.Location = new System.Drawing.Point(167, 35);
+            this.textBox1.Name = "textBox1";
+            this.textBox1.Size = new System.Drawing.Size(45, 25);
+            this.textBox1.TabIndex = 4;
+            this.textBox1.Text = "-45";
+            // 
+            // textBox2
+            // 
+            this.textBox2.Location = new System.Drawing.Point(294, 35);
+            this.textBox2.Name = "textBox2";
+            this.textBox2.Size = new System.Drawing.Size(69, 25);
+            this.textBox2.TabIndex = 5;
+            this.textBox2.Text = "225";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(244, 41);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(28, 19);
+            this.label2.TabIndex = 6;
+            this.label2.Text = "到";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(490, 41);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(66, 19);
+            this.label3.TabIndex = 7;
+            this.label3.Text = "误差:";
+            // 
+            // textBox3
+            // 
+            this.textBox3.Location = new System.Drawing.Point(562, 35);
+            this.textBox3.Name = "textBox3";
+            this.textBox3.Size = new System.Drawing.Size(72, 25);
+            this.textBox3.TabIndex = 8;
+            this.textBox3.Text = "40";
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(871, 592);
+            this.Controls.Add(this.textBox3);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.textBox2);
+            this.Controls.Add(this.textBox1);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.chart1);
+            this.Name = "Form1";
+            this.Text = "Form1";
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox textBox3;
+    }
+}
+

+ 131 - 0
ChartTest/Form1.cs

@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
+
+namespace ChartTest
+{
+    public partial class Form1 : Form
+    {
+        private static bool isover = false;
+        public Form1()
+        {
+            InitializeComponent();                       
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            isover = false;
+            Task.Factory.StartNew(() =>
+            {
+                while (!isover)
+                {
+                    this.Invoke(new Action(() =>
+                    {
+                        List<string> origindata = ReadLog();
+                        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
+                        sw.Start();
+                        List<double> listx = new List<double>();
+                        List<double> listy = new List<double>();
+                        int startDegree = (Convert.ToInt32(this.textBox1.Text) + 45) * 3;
+                        int endDegree = (Convert.ToInt32(this.textBox2.Text) + 45) * 3 + 1;                        
+                        List<int> origindataTransformed = new List<int>();
+                        origindataTransformed = origindata.ConvertAll<int>(x => Convert.ToInt32(x));
+                        for (int i = startDegree; i < endDegree; i++)
+                        {
+                            double x = origindataTransformed[i] * Math.Cos((-45 + 0.333 * i) * Math.PI / 180);
+                            double y = origindataTransformed[i] * Math.Sin((-45 + 0.333 * i) * Math.PI / 180);
+                            listx.Add(x);
+                            listy.Add(y);
+                        }
+                        this.chart1.Series[0].Points.Clear();
+                        InitChart(listx,listy);
+                        sw.Stop();
+                        Console.WriteLine(sw.ElapsedMilliseconds + "ms");
+                    }));
+                    Thread.Sleep(5000);
+                }
+            });
+            //List<string> origindata = ReadLog();
+            //List<int> origindataTransformed = new List<int>();
+            //origindataTransformed = origindata.ConvertAll<int>(x => Convert.ToInt32(x));
+            //for(int i = 0; i < origindataTransformed.Count; i++)
+            //{
+            //    double x = origindataTransformed[i] * Math.Cos((-45 + 0.333 * i) * Math.PI / 180);
+            //    double y = origindataTransformed[i] * Math.Sin((-45 + 0.333 * i) * Math.PI / 180);
+            //    listx.Add(x);
+            //    listy.Add(y);
+            //}
+            //InitChart();
+
+        }
+
+        /// <summary>
+        /// 初始化图表
+        /// </summary>
+        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.Line;
+            for (int i = 0; i < listx.Count; i++)
+            {
+                this.chart1.Series[0].Points.AddXY(listx[i], listy[i]);
+            }
+        }
+
+        private static List<string> ReadLog()
+        {
+            List<string> digitList = new List<string>();
+            string filePath = "log//data0.txt";
+            try
+            {
+                List<string> logLines = null;
+                if (File.Exists(filePath))
+                {
+                    logLines = new List<string>(File.ReadAllLines(filePath));
+                }
+                if (logLines != null)
+                {
+                    for (int i = 0; i < logLines.Count; i++)
+                    {
+                        string logLine = logLines[i];
+                        digitList.Add(logLine);
+                    }
+                }
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); }
+            return digitList;
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            isover = true;
+        }
+    }
+}

+ 120 - 0
ChartTest/Form1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 22 - 0
ChartTest/Program.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ChartTest
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new Form1());
+        }
+    }
+}

+ 36 - 0
ChartTest/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("ChartTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ChartTest")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("96088b83-c38e-4c2d-a2f3-b9e90f721df9")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
ChartTest/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ChartTest.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChartTest.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
ChartTest/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
ChartTest/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ChartTest.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
ChartTest/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 6 - 0
CheckTest/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 52 - 0
CheckTest/CheckTest.csproj

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{410E5B3C-ECEB-4768-B94B-70EF01B185FF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>CheckTest</RootNamespace>
+    <AssemblyName>CheckTest</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 153 - 0
CheckTest/Program.cs

@@ -0,0 +1,153 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+
+namespace CheckTest
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            List<string> dd = ReadLog();
+            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
+            sw.Start();
+            List<double> listy = new List<double>();
+            List<double> listx = new List<double>();
+            List<int> vadd = new List<int>();
+            vadd = dd.ConvertAll<int>(x => Convert.ToInt32(x));
+            for (int k = 166; k < 646; k++)
+            {
+                double x = vadd[k] * Math.Sin((-135 + 0.33 * k) * Math.PI / 180);
+                double y = vadd[k] * Math.Cos((-135 + 0.33 * k) * Math.PI / 180);
+                listy.Add(y);
+                listx.Add(x);
+            }
+            List<double> dis = lineFit(listx, listy);
+            bool isHinder = IsHinder(dis, 20);
+            sw.Stop();
+            Console.WriteLine("结果:"+isHinder);
+            Console.WriteLine(sw.ElapsedMilliseconds + "ms");
+            Console.Read();
+        }
+
+        private static List<string> ReadLog()
+        {
+            List<string> digitList = new List<string>();
+            string filePath = "log//data0.txt";
+            try
+            {
+                List<string> logLines = null;
+                if (File.Exists(filePath))
+                {
+                    logLines = new List<string>(File.ReadAllLines(filePath));
+                }
+                if (logLines != null)
+                {
+                    for (int i = 0; i < logLines.Count; i++)
+                    {
+                        string logLine = logLines[i];
+                        digitList.Add(logLine);
+                    }
+                }
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); }
+            return digitList;
+        }
+
+        private static List<double> lineFit(List<double> x, List<double> y)
+        {
+            double a, b, c;
+            int size = x.Count;
+            if (size < 2)
+            {
+                a = 0;
+                b = 0;
+                c = 0;
+                return null;
+            }
+            double x_mean = 0;
+            double y_mean = 0;
+            for (int i = 0; i < size; i++)
+            {
+                x_mean += x[i];
+                y_mean += y[i];
+            }
+            x_mean /= size;
+            y_mean /= size; //至此,计算出了 x y 的均值
+
+            double Dxx = 0, Dxy = 0, Dyy = 0;
+            for (int i = 0; i < size; i++)
+            {
+                Dxx += (x[i] - x_mean) * (x[i] - x_mean);
+                Dxy += (x[i] - x_mean) * (y[i] - y_mean);
+                Dyy += (y[i] - y_mean) * (y[i] - y_mean);
+            }
+
+            double lambda = ((Dxx + Dyy) - Math.Sqrt((Dxx - Dyy) * (Dxx - Dyy) + 4 * Dxy * Dxy)) / 2.0;
+            double den = Math.Sqrt(Dxy * Dxy + (lambda - Dxx) * (lambda - Dxx));
+            a = Dxy / den;
+            b = (lambda - Dxx) / den;
+            c = -a * x_mean - b * y_mean;
+            Console.WriteLine(a+"  "+b+"  "+c);
+            List<double> dis = new List<double>();
+            for (int i = 0; i < size; i++)
+            {
+                double d = Math.Abs(a * x[i] + b * y[i] + c) / Math.Sqrt(a * a + b * b);
+                dis.Add(d);
+            }
+            return dis;
+        }
+
+        private static bool IsHinder(List<double> testdata, double deviation)
+        {
+            bool isHinder = true;
+            //Data errordata = new Data();
+            List<int> recorddata = new List<int>();
+            for(int i = 0; i < testdata.Count; i++)
+            {
+                if (testdata[i] > deviation)
+                {
+                    //errordata.key = i;
+                    //errordata.value = testdata[i];
+                    Console.WriteLine(i+" "+testdata[i]);
+                    recorddata.Add(i);
+                }
+            }
+            if (recorddata.Count <= 5||IsBorderUpon(recorddata,5)<1)
+            {
+                isHinder = false;
+            }
+            return isHinder;
+        }
+
+        private static int IsBorderUpon(List<int> arr ,int num)
+        {
+            var query = arr.OrderBy(p => p).Aggregate<int, List<List<int>>>(null, (m, n) =>
+            {
+                if (m == null) return new List<List<int>>() { new List<int>() { n } };
+                if (m.Last().Last() != n - 1)
+                {
+                    m.Add(new List<int>() { n });
+                }
+                else
+                {
+                    m.Last().Add(n);
+                }
+                return m;
+            });
+            int flag = 0;
+            for (int i = 0; i < query.Count; i++)
+            {
+                if (query[i].Count > 5)
+                {
+                    flag++;
+                }
+            }
+            return flag;
+        }
+
+    }
+}

+ 36 - 0
CheckTest/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("CheckTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CheckTest")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("410e5b3c-eceb-4768-b94b-70ef01b185ff")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 6 - 0
DataGathering/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 84 - 0
DataGathering/DataGathering.csproj

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{1A3CF0DE-6841-4A05-A77B-D820571065F6}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>DataGathering</RootNamespace>
+    <AssemblyName>DataGathering</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Form1.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Form1.Designer.cs">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </Compile>
+    <Compile Include="log.cs" />
+    <Compile Include="LogManager.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Form1.resx">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 74 - 0
DataGathering/Form1.Designer.cs

@@ -0,0 +1,74 @@
+namespace DataGathering
+{
+    partial class Form1
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(158, 216);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(96, 43);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "开始";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(389, 215);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(100, 44);
+            this.button2.TabIndex = 1;
+            this.button2.Text = "结束";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Name = "Form1";
+            this.Text = "Form1";
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+    }
+}
+

+ 174 - 0
DataGathering/Form1.cs

@@ -0,0 +1,174 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DataGathering
+{
+    public partial class Form1 : Form
+    {
+        private TcpClient tcpClient;
+        NetworkStream stream;
+        private int bufferSize = 4096;
+        private string startCmd = "02 73 52 4E 20 4C 4D 44 73 63 61 6E 64 61 74 61 03";
+        int flag = 0;
+        private bool isok = false;
+        private static readonly object Lock = new object();
+        List<string> validdatalist;
+        public Form1()
+        {
+            InitializeComponent();
+            tcpClient = new TcpClient();
+            tcpClient.Connect(IPAddress.Parse("192.168.1.31"), 2111);
+            Console.WriteLine("连接成功");
+            stream = tcpClient.GetStream();
+            validdatalist = new List<string>();
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            isok = false;
+            List<string> datalist = new List<string>();
+            Task.Factory.StartNew(() =>
+            {
+                while (!isok)
+                {
+                    lock (Lock)
+                    {
+                        datalist.Clear();
+                        flag = sendCmd(startCmd);
+                        byte[] buffer = new byte[bufferSize];
+                        stream.Read(buffer, 0, buffer.Length);
+                        string str = HexStringToASCII(buffer);
+                        datalist.Add(str);
+                    }
+                    Thread.Sleep(200);
+                }
+            });
+            //string testimg = "";
+            Task.Factory.StartNew(() =>
+            {
+                while (!isok)
+                {
+                    lock (Lock)
+                    {
+                        for (int i = 0; i < datalist.Count; i++)
+                        {
+                            string ss = validStr(datalist[i], "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] + " ";
+                            }
+                            validdatalist.Add(aws);
+                        }
+                    }
+                }
+            });
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            isok = true;
+            for (int i = 0; i < validdatalist.Count; i++)
+            {
+                string temp = validdatalist[i];
+                string[] tempdata = temp.Split(' ');
+                for (int j = 0; j < tempdata.Length; j++)
+                {
+                    Log.WriteData("data" + i, tempdata[j]);
+                }
+            }
+            Environment.Exit(0);
+            this.Close();
+        }
+
+        private int sendCmd(string cmd)
+        {
+            if (cmd.Equals(startCmd))
+            {
+                byte[] byteStartCmd = HexStringToBinary(startCmd);
+                string result = HexStringToASCII(byteStartCmd);
+                byte[] b = Encoding.UTF8.GetBytes(result);
+                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;
+        }
+
+        private static string HexStringToASCII(byte[] bt)
+        {
+            //byte[] bt = HexStringToBinary(hexstring);
+            string lin = "";
+            for (int i = 0; i < bt.Length; i++)
+            {
+                lin = lin + bt[i] + " ";
+            }
+
+
+            string[] ss = lin.Trim().Split(new char[] { ' ' });
+            char[] c = new char[ss.Length];
+            int a;
+            for (int i = 0; i < c.Length; i++)
+            {
+                a = Convert.ToInt32(ss[i]);
+                c[i] = Convert.ToChar(a);
+            }
+
+            string b = new string(c);
+            return b;
+        }
+
+        private static byte[] HexStringToBinary(string hexstring)
+        {
+
+            string[] tmpary = hexstring.Trim().Split(' ');
+            byte[] buff = new byte[tmpary.Length];
+            for (int i = 0; i < buff.Length; i++)
+            {
+                buff[i] = Convert.ToByte(tmpary[i], 16);
+            }
+            return buff;
+        }
+
+        private static string validStr(string sourse, string startstr, string endstr)
+        {
+            string result = string.Empty;
+            int startindex, endindex;
+            try
+            {
+                startindex = sourse.IndexOf(startstr);
+                if (startindex == -1)
+                {
+                    return result;
+                }
+                string tmpstr = sourse.Substring(startindex + startstr.Length);
+                endindex = tmpstr.IndexOf(endstr);
+                if (endindex == -1)
+                {
+                    return result;
+                }
+                result = tmpstr.Remove(endindex);
+            }
+            catch (Exception) { }
+            return result;
+        }
+    }
+}

+ 120 - 0
DataGathering/Form1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 256 - 0
DataGathering/LogManager.cs

@@ -0,0 +1,256 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace DataGathering
+{
+    /// <summary>
+    /// 日志管理
+    /// </summary>
+    public class LogManager
+    {
+        private string filepath = "log";
+        //public static string logAddressStr = "filepath";
+        //public static string logAddress;
+        DateTime time;                                        //文件创建时间
+        private string logFileExtName = "log";     //日志文件扩展名
+        private Encoding logFileEncoding = Encoding.UTF8;   //日志文件编码格式
+        private string logFileName = string.Empty;  //日志文件名
+        private string logPath = "";            //日志文件路径
+        private bool writeLogTime = true;     //log文件是否写时间
+        private bool writeStatus = false;        //是否写入标志位
+        private static object obj = new object();
+        /// <summary>
+        /// 配置文件初始化
+        /// </summary>
+        public static void Init()
+        {
+            //try
+            //{
+            //    logAddress = ConfigurationManager.AppSettings[logAddressStr];
+            //}
+            //catch
+            //{
+            //    Console.WriteLine("配置文件有误");
+            //}
+        }
+        /// <summary>
+        /// 日志文件路径
+        /// </summary>
+        public string CreateLogPath()
+        {
+            if (!Directory.Exists(filepath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(filepath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            if (logPath == null || logPath == string.Empty || time.ToString("yyyy-MM-dd") != System.DateTime.Now.ToString("yyyy-MM-dd"))
+            {
+                try
+                {
+                    time = System.DateTime.Now;
+                    logPath = System.IO.Path.Combine(filepath, time.ToString("yyyy-MM-dd"));
+                }
+                catch
+                {
+                    Console.WriteLine("路径合成失败");
+                }
+            }
+            if (!logPath.EndsWith(@"\"))
+            {
+                logPath += @"\";
+            }
+            if (!Directory.Exists(logPath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(logPath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            return logPath;
+        }
+        /// <summary>
+        /// 写日志
+        /// </summary>
+        public void WriteLog(LogType logType, string logFile, string msg)
+        {
+            CreateLogPath();
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    logFileName = string.Format("{0}{1}.{2}", logPath, logType, this.logFileExtName);
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        //是否写时间
+                        if (logType == LogType.PROCESS)
+                        {
+                            writeLogTime = true;
+                        }
+                        else
+                        {
+                            writeLogTime = false;
+                        }
+                        ////sql类型
+                        //if (logType == LogType.DATABASE)
+                        //{
+                        //    writeStatus = true;
+                        //}
+                        //else
+                        //{
+                        //    writeStatus = false;
+                        //}
+                        if (writeLogTime)
+                        {
+                            sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:") + logFile + ":" + msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(logFile + "" + msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+        /// <summary>
+        /// log类型不定
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            this.WriteLog(logType, logFile.ToString(), msg);
+        }
+        /// <summary>
+        /// log类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, string msg)
+        {
+            this.WriteLog(logType, string.Empty, msg);
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        public List<string> ReadLog()
+        {
+            List<string> digitList = new List<string>();
+            //string date = System.DateTime.Now.ToString("yyyy-MM-dd");
+            //string filePath = logAddress + "\\\\" + date + "\\\\" + "CREDENCES.log";
+            string filePath = filepath + "\\\\" + "CREDENCES.log";
+            try
+            {
+                List<string> logLines = null;
+                if (File.Exists(filePath))
+                {
+                    logLines = new List<string>(File.ReadAllLines(filePath));
+                    File.Delete(filePath);
+                }
+                if (logLines != null)
+                {
+                    for (int i = 0; i < 300; i++)
+                    {
+                        string logLine = logLines[i];
+                        digitList.Add(logLine);
+                        logLines.RemoveAt(i);
+                    }
+                    File.WriteAllLines(filePath, logLines.ToArray());
+                }
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); }
+            return digitList;
+        }
+        public void WriteCredence(string msg)
+        {
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    string logname = string.Format("{0}.{1}", "CREDENCES", this.logFileExtName);
+                    logFileName = filepath + "\\" + logname;
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        if (msg.Length == 8)
+                        {
+                            sw.WriteLine(msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+
+        public void WriteData(string name, string msg)
+        {
+            CreateLogPath();
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    string logname = string.Format("{0}.{1}", name, "txt");
+                    //logFileName = filepath + "\\" + logname;
+                    logFileName = logPath + "\\" + logname;
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        if (msg.Length == 8)
+                        {
+                            sw.WriteLine(msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+
+
+
+
+    }
+    /// <summary>
+    /// log类型
+    /// </summary>
+    public enum LogFile
+    {
+        LOG,
+        RESET,
+        ERROR,
+        WARNING,
+        INFO,
+        ERROR_NUMBERPLATE
+    }
+    /// <summary>
+    /// log文件类型
+    /// </summary>
+    public enum LogType
+    {
+        PROCESS,
+        CREDENCES
+    }
+}

+ 22 - 0
DataGathering/Program.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DataGathering
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new Form1());
+        }
+    }
+}

+ 36 - 0
DataGathering/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("DataGathering")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DataGathering")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("1a3cf0de-6841-4a05-a77b-d820571065f6")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
DataGathering/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace DataGathering.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataGathering.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
DataGathering/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
DataGathering/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace DataGathering.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
DataGathering/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 99 - 0
DataGathering/log.cs

@@ -0,0 +1,99 @@
+using System.Collections.Generic;
+
+namespace DataGathering
+{
+    public static class Log
+    {
+        private static LogManager logManager;
+        static Log()
+        {
+            LogManager.Init();
+            logManager = new LogManager();
+        }
+        /// <summary>
+        /// 写文件类型
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, logFile, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 文件类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, string.Empty, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 数据库异常的标志位
+        /// 0表示update,1表示insert
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="status"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string status, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, status, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        /// <param name="count"></param>      
+        public static List<string> ReadLog()
+        {
+            List<string> digitList = null;
+            try
+            {
+                digitList = logManager.ReadLog();
+            }
+            catch { }
+            return digitList;
+        }
+
+        public static void WriteCredence(string msg)
+        {
+            try
+            {
+                logManager.WriteCredence(msg);
+            }
+            catch { }
+        }
+
+        public static void WriteData(string name, string msg)
+        {
+            try
+            {
+                logManager.WriteData(name, msg);
+            }
+            catch { }
+        }
+    }
+}

+ 6 - 0
Test/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 208 - 0
Test/Form1.Designer.cs

@@ -0,0 +1,208 @@
+namespace Test
+{
+    partial class Form1
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            this.button1 = new System.Windows.Forms.Button();
+            this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
+            this.button2 = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
+            this.textBox1 = new System.Windows.Forms.TextBox();
+            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
+            this.textBox3 = new System.Windows.Forms.TextBox();
+            this.button3 = new System.Windows.Forms.Button();
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button1.Location = new System.Drawing.Point(587, 743);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(91, 58);
+            this.button1.TabIndex = 1;
+            this.button1.Text = "开始";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // chart1
+            // 
+            chartArea6.Name = "ChartArea1";
+            this.chart1.ChartAreas.Add(chartArea6);
+            legend6.Name = "Legend1";
+            this.chart1.Legends.Add(legend6);
+            this.chart1.Location = new System.Drawing.Point(26, 69);
+            this.chart1.Name = "chart1";
+            series6.ChartArea = "ChartArea1";
+            series6.Legend = "Legend1";
+            series6.Name = "Series1";
+            this.chart1.Series.Add(series6);
+            this.chart1.Size = new System.Drawing.Size(1764, 623);
+            this.chart1.TabIndex = 2;
+            this.chart1.Text = "chart1";
+            // 
+            // button2
+            // 
+            this.button2.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button2.Location = new System.Drawing.Point(1032, 743);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(103, 58);
+            this.button2.TabIndex = 3;
+            this.button2.Text = "结束";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(109, 31);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(52, 15);
+            this.label1.TabIndex = 4;
+            this.label1.Text = "角度:";
+            // 
+            // textBox1
+            // 
+            this.textBox1.Location = new System.Drawing.Point(194, 21);
+            this.textBox1.Name = "textBox1";
+            this.textBox1.Size = new System.Drawing.Size(100, 25);
+            this.textBox1.TabIndex = 5;
+            this.textBox1.Text = "-45";
+            // 
+            // textBox2
+            // 
+            this.textBox2.Location = new System.Drawing.Point(376, 21);
+            this.textBox2.Name = "textBox2";
+            this.textBox2.Size = new System.Drawing.Size(100, 25);
+            this.textBox2.TabIndex = 6;
+            this.textBox2.Text = "225";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(315, 31);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(22, 15);
+            this.label2.TabIndex = 7;
+            this.label2.Text = "到";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(1180, 30);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(52, 15);
+            this.label3.TabIndex = 8;
+            this.label3.Text = "结果:";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(1238, 31);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(23, 15);
+            this.label4.TabIndex = 9;
+            this.label4.Text = "-1";
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label5.Location = new System.Drawing.Point(679, 31);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(66, 19);
+            this.label5.TabIndex = 10;
+            this.label5.Text = "误差:";
+            // 
+            // textBox3
+            // 
+            this.textBox3.Location = new System.Drawing.Point(751, 25);
+            this.textBox3.Name = "textBox3";
+            this.textBox3.Size = new System.Drawing.Size(53, 25);
+            this.textBox3.TabIndex = 11;
+            this.textBox3.Text = "40";
+            // 
+            // button3
+            // 
+            this.button3.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button3.Location = new System.Drawing.Point(797, 743);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(98, 58);
+            this.button3.TabIndex = 12;
+            this.button3.Text = "暂停";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1791, 837);
+            this.Controls.Add(this.button3);
+            this.Controls.Add(this.textBox3);
+            this.Controls.Add(this.label5);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.textBox2);
+            this.Controls.Add(this.textBox1);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.chart1);
+            this.Controls.Add(this.button1);
+            this.Name = "Form1";
+            this.Text = "Form1";
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.TextBox textBox3;
+        private System.Windows.Forms.Button button3;
+    }
+}
+

+ 376 - 0
Test/Form1.cs

@@ -0,0 +1,376 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+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.Windows.Forms.DataVisualization.Charting;
+
+namespace Test
+{
+    public partial class Form1 : Form
+    {
+        private TcpClient tcpClient;
+        NetworkStream stream;
+        private int bufferSize = 4096;
+        private string startCmd = "02 73 52 4E 20 4C 4D 44 73 63 61 6E 64 61 74 61 03";
+        private string endCmd = "02 73 45 4E 20 4C 4D 44 73 63 61 6E 64 61 74 61 20 30 03";
+        int flag = 0;
+        private bool isok = false;
+        private static readonly object Lock = new object();
+        List<string> validdatalist;
+        public Form1()
+        {
+            InitializeComponent();
+            tcpClient = new TcpClient();
+            tcpClient.Connect(IPAddress.Parse("192.168.1.31"), 2111);
+            Console.WriteLine("连接成功");
+            stream = tcpClient.GetStream();
+            validdatalist = new List<string>();
+        }
+        //开始
+        private void button1_Click(object sender, EventArgs e)
+        {
+            isok = false;
+            List<string> datalist = new List<string>();
+            Task.Factory.StartNew(() =>
+            {
+                while (!isok)
+                {
+                    lock (Lock)
+                    {
+                        datalist.Clear();
+                        flag = sendCmd(startCmd);
+                        byte[] buffer = new byte[bufferSize];
+                        stream.Read(buffer, 0, buffer.Length);
+                        string str = HexStringToASCII(buffer);
+                        datalist.Add(str);
+                    }
+                    Thread.Sleep(200);
+                }
+            });
+            //string testimg = "";
+            Task.Factory.StartNew(() =>
+            {
+                while (!isok)
+                {
+                    lock (Lock)
+                    {
+                        for (int i = 0; i < datalist.Count; i++)
+                        {
+                            string ss = validStr(datalist[i], "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] + " ";
+                            }
+                            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 = startDegree; k < endDegree; 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);
+                                    listy.Add(y);
+                                    listx.Add(x);
+                                }
+                                this.chart1.Series[0].Points.Clear();
+                                InitChart(listx, listy);
+                                List<double> dis = lineFit(listx, listy);
+                                double difference = Convert.ToDouble(this.textBox3.Text);
+                                bool isHinder = IsHinder(dis, difference);
+                                this.label4.Text = isHinder.ToString();
+                                sw.Stop();
+                                Console.WriteLine(sw.ElapsedMilliseconds + "ms");
+                                if (isHinder)
+                                {
+                                    Console.WriteLine("结果:" + isHinder);
+                                    Console.WriteLine(sw.ElapsedMilliseconds + "ms");
+                                }
+                            }));
+                            
+                        }
+                    }
+                    Thread.Sleep(10);
+                }
+            });
+
+        }
+
+        private int sendCmd(string cmd)
+        {
+            if (cmd.Equals(startCmd))
+            {
+                byte[] byteStartCmd = HexStringToBinary(startCmd);
+                string result = HexStringToASCII(byteStartCmd);
+                byte[] b = Encoding.UTF8.GetBytes(result);
+                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;
+        }
+        /// <summary>
+        /// 将一条十六进制字符串转换为ASCII
+        /// </summary>
+        /// <param name="hexstring">一条十六进制字符串</param>
+        /// <returns>返回一条ASCII码</returns>
+        private static string HexStringToASCII(byte[] bt)
+        {
+            //byte[] bt = HexStringToBinary(hexstring);
+            string lin = "";
+            for (int i = 0; i < bt.Length; i++)
+            {
+                lin = lin + bt[i] + " ";
+            }
+
+
+            string[] ss = lin.Trim().Split(new char[] { ' ' });
+            char[] c = new char[ss.Length];
+            int a;
+            for (int i = 0; i < c.Length; i++)
+            {
+                a = Convert.ToInt32(ss[i]);
+                c[i] = Convert.ToChar(a);
+            }
+
+            string b = new string(c);
+            return b;
+        }
+
+        /// <summary>
+        /// 16进制字符串转换为二进制数组
+        /// </summary>
+        /// <param name="hexstring">用空格切割字符串</param>
+        /// <returns>返回一个二进制字符串</returns>
+        private static byte[] HexStringToBinary(string hexstring)
+        {
+
+            string[] tmpary = hexstring.Trim().Split(' ');
+            byte[] buff = new byte[tmpary.Length];
+            for (int i = 0; i < buff.Length; i++)
+            {
+                buff[i] = Convert.ToByte(tmpary[i], 16);
+            }
+            return buff;
+        }
+
+        private static string validStr(string sourse, string startstr, string endstr)
+        {
+            string result = string.Empty;
+            int startindex, endindex;
+            try
+            {
+                startindex = sourse.IndexOf(startstr);
+                if (startindex == -1)
+                {
+                    return result;
+                }
+                string tmpstr = sourse.Substring(startindex + startstr.Length);
+                endindex = tmpstr.IndexOf(endstr);
+                if (endindex == -1)
+                {
+                    return result;
+                }
+                result = tmpstr.Remove(endindex);
+            }
+            catch (Exception) { }
+            return result;
+        }
+
+
+        /// <summary>
+        /// 初始化图表
+        /// </summary>
+        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.Line;
+            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;
+            for (int i = 0; i < validdatalist.Count; i++)
+            {
+                string temp = validdatalist[i];
+                string[] tempdata = temp.Split(' ');
+                for (int j = 0; j < tempdata.Length; j++)
+                {
+                    Log.WriteData("data" + i, tempdata[j]);
+                }
+            }
+            Environment.Exit(0);
+            this.Close();
+        }
+
+        /// <summary>
+        /// 线性拟合
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <returns></returns>
+        private static List<double> lineFit(List<double> x, List<double> y)
+        {
+            double a, b, c;
+            int size = x.Count;
+            if (size < 2)
+            {
+                a = 0;
+                b = 0;
+                c = 0;
+                return null;
+            }
+            double x_mean = 0;
+            double y_mean = 0;
+            for (int i = 0; i < size; i++)
+            {
+                x_mean += x[i];
+                y_mean += y[i];
+            }
+            x_mean /= size;
+            y_mean /= size; //至此,计算出了 x y 的均值
+
+            double Dxx = 0, Dxy = 0, Dyy = 0;
+            for (int i = 0; i < size; i++)
+            {
+                Dxx += (x[i] - x_mean) * (x[i] - x_mean);
+                Dxy += (x[i] - x_mean) * (y[i] - y_mean);
+                Dyy += (y[i] - y_mean) * (y[i] - y_mean);
+            }
+
+            double lambda = ((Dxx + Dyy) - Math.Sqrt((Dxx - Dyy) * (Dxx - Dyy) + 4 * Dxy * Dxy)) / 2.0;
+            double den = Math.Sqrt(Dxy * Dxy + (lambda - Dxx) * (lambda - Dxx));
+            a = Dxy / den;
+            b = (lambda - Dxx) / den;
+            c = -a * x_mean - b * y_mean;
+            //Console.WriteLine(a + "  " + b + "  " + c);
+            List<double> dis = new List<double>();
+            for (int i = 0; i < size; i++)
+            {
+                double d = Math.Abs(a * x[i] + b * y[i] + c) / Math.Sqrt(a * a + b * b);
+                dis.Add(d);
+                Log.WriteLog(LogType.PROCESS, d + "");
+            }
+            return dis;
+        }
+        /// <summary>
+        /// 是否有障碍物
+        /// </summary>
+        /// <param name="testdata"></param>
+        /// <param name="deviation"></param>
+        /// <returns></returns>
+
+        private static bool IsHinder(List<double> testdata, double deviation)
+        {
+            bool isHinder = true;
+            //Data errordata = new Data();
+            List<int> recorddata = new List<int>();
+            for (int i = 0; i < testdata.Count; i++)
+            {
+                if (testdata[i] > deviation)
+                {
+                    //errordata.key = i;
+                    //errordata.value = testdata[i];
+                    //Console.WriteLine(i + " " + testdata[i]);
+                    recorddata.Add(i);
+                }
+            }
+            if (recorddata.Count <= 5 || IsBorderUpon(recorddata, 10) < 1)
+            {
+                isHinder = false;
+            }
+            return isHinder;
+        }
+        /// <summary>
+        /// 连续判断
+        /// </summary>
+        /// <param name="arr"></param>
+        /// <param name="num"></param>
+        /// <returns></returns>
+
+        private static int IsBorderUpon(List<int> arr, int num)
+        {
+            var query = arr.OrderBy(p => p).Aggregate<int, List<List<int>>>(null, (m, n) =>
+            {
+                if (m == null) return new List<List<int>>() { new List<int>() { n } };
+                if (m.Last().Last() != n - 1)
+                {
+                    m.Add(new List<int>() { n });
+                }
+                else
+                {
+                    m.Last().Add(n);
+                }
+                return m;
+            });
+            int flag = 0;
+            for (int i = 0; i < query.Count; i++)
+            {
+                if (query[i].Count > 5)
+                {
+                    flag++;
+                }
+            }
+            return flag;
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            isok = true;
+        }
+    }
+}

+ 120 - 0
Test/Form1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 256 - 0
Test/LogManager.cs

@@ -0,0 +1,256 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Test
+{
+    /// <summary>
+    /// 日志管理
+    /// </summary>
+    public class LogManager
+    {
+        private string filepath = "log";
+        //public static string logAddressStr = "filepath";
+        //public static string logAddress;
+        DateTime time;                                        //文件创建时间
+        private string logFileExtName = "log";     //日志文件扩展名
+        private Encoding logFileEncoding = Encoding.UTF8;   //日志文件编码格式
+        private string logFileName = string.Empty;  //日志文件名
+        private string logPath = "";            //日志文件路径
+        private bool writeLogTime = true;     //log文件是否写时间
+        private bool writeStatus = false;        //是否写入标志位
+        private static object obj = new object();
+        /// <summary>
+        /// 配置文件初始化
+        /// </summary>
+        public static void Init()
+        {
+            //try
+            //{
+            //    logAddress = ConfigurationManager.AppSettings[logAddressStr];
+            //}
+            //catch
+            //{
+            //    Console.WriteLine("配置文件有误");
+            //}
+        }
+        /// <summary>
+        /// 日志文件路径
+        /// </summary>
+        public string CreateLogPath()
+        {
+            if (!Directory.Exists(filepath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(filepath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            if (logPath == null || logPath == string.Empty || time.ToString("yyyy-MM-dd") != System.DateTime.Now.ToString("yyyy-MM-dd"))
+            {
+                try
+                {
+                    time = System.DateTime.Now;
+                    logPath = System.IO.Path.Combine(filepath, time.ToString("yyyy-MM-dd"));
+                }
+                catch
+                {
+                    Console.WriteLine("路径合成失败");
+                }
+            }
+            if (!logPath.EndsWith(@"\"))
+            {
+                logPath += @"\";
+            }
+            if (!Directory.Exists(logPath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(logPath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            return logPath;
+        }
+        /// <summary>
+        /// 写日志
+        /// </summary>
+        public void WriteLog(LogType logType, string logFile, string msg)
+        {
+            CreateLogPath();
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    logFileName = string.Format("{0}{1}.{2}", logPath, logType, this.logFileExtName);
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        //是否写时间
+                        if (logType == LogType.PROCESS)
+                        {
+                            writeLogTime = true;
+                        }
+                        else
+                        {
+                            writeLogTime = false;
+                        }
+                        ////sql类型
+                        //if (logType == LogType.DATABASE)
+                        //{
+                        //    writeStatus = true;
+                        //}
+                        //else
+                        //{
+                        //    writeStatus = false;
+                        //}
+                        if (writeLogTime)
+                        {
+                            sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:") + logFile + ":" + msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(logFile + "" + msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+        /// <summary>
+        /// log类型不定
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            this.WriteLog(logType, logFile.ToString(), msg);
+        }
+        /// <summary>
+        /// log类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, string msg)
+        {
+            this.WriteLog(logType, string.Empty, msg);
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        public List<string> ReadLog()
+        {
+            List<string> digitList = new List<string>();
+            //string date = System.DateTime.Now.ToString("yyyy-MM-dd");
+            //string filePath = logAddress + "\\\\" + date + "\\\\" + "CREDENCES.log";
+            string filePath = filepath + "\\\\" + "CREDENCES.log";
+            try
+            {
+                List<string> logLines = null;
+                if (File.Exists(filePath))
+                {
+                    logLines = new List<string>(File.ReadAllLines(filePath));
+                    File.Delete(filePath);
+                }
+                if (logLines != null)
+                {
+                    for (int i = 0; i < 300; i++)
+                    {
+                        string logLine = logLines[i];
+                        digitList.Add(logLine);
+                        logLines.RemoveAt(i);
+                    }
+                    File.WriteAllLines(filePath, logLines.ToArray());
+                }
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); }
+            return digitList;
+        }
+        public void WriteCredence(string msg)
+        {
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    string logname = string.Format("{0}.{1}", "CREDENCES", this.logFileExtName);
+                    logFileName = filepath + "\\" + logname;
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        if (msg.Length == 8)
+                        {
+                            sw.WriteLine(msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+
+        public void WriteData(string name, string msg)
+        {
+            CreateLogPath();
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    string logname = string.Format("{0}.{1}", name, "txt");
+                    //logFileName = filepath + "\\" + logname;
+                    logFileName = logPath + "\\" + logname;
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        if (msg.Length == 8)
+                        {
+                            sw.WriteLine(msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+
+
+
+
+    }
+    /// <summary>
+    /// log类型
+    /// </summary>
+    public enum LogFile
+    {
+        LOG,
+        RESET,
+        ERROR,
+        WARNING,
+        INFO,
+        ERROR_NUMBERPLATE
+    }
+    /// <summary>
+    /// log文件类型
+    /// </summary>
+    public enum LogType
+    {
+        PROCESS,
+        CREDENCES
+    }
+}

+ 22 - 0
Test/Program.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Test
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new Form1());
+        }
+    }
+}

+ 36 - 0
Test/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Test")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("f663f0e0-bf14-4a86-870f-6be4952df2b0")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
Test/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Test.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
Test/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
Test/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Test.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
Test/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 86 - 0
Test/Test.csproj

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>Test</RootNamespace>
+    <AssemblyName>Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Windows.Forms.DataVisualization" />
+    <Reference Include="System.Windows.Forms.DataVisualization.Design" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Form1.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Form1.Designer.cs">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </Compile>
+    <Compile Include="log.cs" />
+    <Compile Include="LogManager.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Form1.resx">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 99 - 0
Test/log.cs

@@ -0,0 +1,99 @@
+using System.Collections.Generic;
+
+namespace Test
+{
+    public static class Log
+    {
+        private static LogManager logManager;
+        static Log()
+        {
+            LogManager.Init();
+            logManager = new LogManager();
+        }
+        /// <summary>
+        /// 写文件类型
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, logFile, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 文件类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, string.Empty, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 数据库异常的标志位
+        /// 0表示update,1表示insert
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="status"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string status, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, status, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        /// <param name="count"></param>      
+        public static List<string> ReadLog()
+        {
+            List<string> digitList = null;
+            try
+            {
+                digitList = logManager.ReadLog();
+            }
+            catch { }
+            return digitList;
+        }
+
+        public static void WriteCredence(string msg)
+        {
+            try
+            {
+                logManager.WriteCredence(msg);
+            }
+            catch { }
+        }
+
+        public static void WriteData(string name, string msg)
+        {
+            try
+            {
+                logManager.WriteData(name, msg);
+            }
+            catch { }
+        }
+    }
+}

+ 55 - 0
sickTest.sln

@@ -0,0 +1,55 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.438
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sickTest", "sickTest\sickTest.csproj", "{E2A82D4A-294C-49FD-8590-275302F699A1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckTest", "CheckTest\CheckTest.csproj", "{410E5B3C-ECEB-4768-B94B-70EF01B185FF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BorderUpon、", "BorderUpon、\BorderUpon、.csproj", "{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChartTest", "ChartTest\ChartTest.csproj", "{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGathering", "DataGathering\DataGathering.csproj", "{1A3CF0DE-6841-4A05-A77B-D820571065F6}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E2A82D4A-294C-49FD-8590-275302F699A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E2A82D4A-294C-49FD-8590-275302F699A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E2A82D4A-294C-49FD-8590-275302F699A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E2A82D4A-294C-49FD-8590-275302F699A1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F663F0E0-BF14-4A86-870F-6BE4952DF2B0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{410E5B3C-ECEB-4768-B94B-70EF01B185FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{410E5B3C-ECEB-4768-B94B-70EF01B185FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{410E5B3C-ECEB-4768-B94B-70EF01B185FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{410E5B3C-ECEB-4768-B94B-70EF01B185FF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{95883B42-B6D7-4D21-BEC9-EBA78FE035CE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{96088B83-C38E-4C2D-A2F3-B9E90F721DF9}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1A3CF0DE-6841-4A05-A77B-D820571065F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1A3CF0DE-6841-4A05-A77B-D820571065F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1A3CF0DE-6841-4A05-A77B-D820571065F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1A3CF0DE-6841-4A05-A77B-D820571065F6}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {035811D3-0FB6-403F-AEA1-9E0D79169922}
+	EndGlobalSection
+EndGlobal

+ 6 - 0
sickTest/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 85 - 0
sickTest/Form1.Designer.cs

@@ -0,0 +1,85 @@
+namespace sickTest
+{
+    partial class Form1
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // richTextBox1
+            // 
+            this.richTextBox1.Location = new System.Drawing.Point(12, 12);
+            this.richTextBox1.Name = "richTextBox1";
+            this.richTextBox1.Size = new System.Drawing.Size(776, 264);
+            this.richTextBox1.TabIndex = 0;
+            this.richTextBox1.Text = "";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(158, 368);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(141, 59);
+            this.button1.TabIndex = 1;
+            this.button1.Text = "开始";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(405, 368);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(149, 59);
+            this.button2.TabIndex = 2;
+            this.button2.Text = "结束";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 528);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.richTextBox1);
+            this.Name = "Form1";
+            this.Text = "Form1";
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.RichTextBox richTextBox1;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+    }
+}
+

+ 170 - 0
sickTest/Form1.cs

@@ -0,0 +1,170 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace sickTest
+{
+    public partial class Form1 : Form
+    {
+        private TcpClient tcpClient;
+        NetworkStream stream;
+        private int bufferSize = 0x8000;
+        private string startCmd = "02 73 45 4E 20 4C 4D 44 73 63 61 6E 64 61 74 61 20 31 03";
+        private string endCmd = "02 73 45 4E 20 4C 4D 44 73 63 61 6E 64 61 74 61 20 30 03";
+        int flag = 0;
+        public Form1()
+        {
+            InitializeComponent();
+            tcpClient = new TcpClient();
+            tcpClient.Connect(IPAddress.Parse("192.168.1.31"), 2111);
+            Console.WriteLine("连接成功");
+            stream = tcpClient.GetStream();
+        }
+        //开始
+        private void button1_Click(object sender, EventArgs e)
+        {
+            //byte[] byteStartCmd = HexStringToBinary(startCmd);
+            //string result = HexStringToASCII(byteStartCmd);
+            //byte[] b = Encoding.UTF8.GetBytes(result);
+            //stream.Write(b, 0, b.Length);
+            //byte[] data = new byte[bufferSize];
+            //stream.Read(data, 0, bufferSize);
+            //stream.Close();
+            //string str = HexStringToASCII(data);
+            // 初始化一个缓存区
+            flag = sendCmd(startCmd);
+            byte[] buffer = new byte[bufferSize];
+            int read = 0;
+            int block;
+            Task.Factory.StartNew(() =>
+            {
+                while ((block = stream.Read(buffer, read, buffer.Length - read)) > 0 && flag != 2)
+                {
+                    // 重新设定读取位置
+                    read += block;
+
+                    // 检查是否到达了缓存的边界,检查是否还有可以读取的信息
+                    if (read == buffer.Length)
+                    {
+                        // 尝试读取一个字节
+                        int nextByte = stream.ReadByte();
+
+                        // 读取失败则说明读取完成可以返回结果
+                        if (nextByte == -1)
+                        {
+                            Console.WriteLine("读取失败");
+                            //return buffer;
+                        }
+
+                        // 调整数组大小准备继续读取
+                        byte[] newBuf = new byte[buffer.Length * 2];
+                        Array.Copy(buffer, newBuf, buffer.Length);
+                        newBuf[read] = (byte)nextByte;
+
+                        // buffer是一个引用(指针),这里意在重新设定buffer指针指向一个更大的内存
+                        buffer = newBuf;
+                        read++;
+                    }
+                    Thread.Sleep(1);
+                }
+            });
+            Task.Factory.StartNew(() =>
+            {
+                string str;
+                while (buffer != null && flag != 2)
+                {
+                    str = System.Text.Encoding.Default.GetString(buffer);
+                    Log.WriteLog(LogType.PROCESS, str);
+                    //this.Invoke(new Action(() =>
+                    //{
+                    //    str = System.Text.Encoding.Default.GetString(buffer);
+                    //    this.richTextBox1.Text = str;
+                    //    Thread.Sleep(1000);
+                    //    this.richTextBox1.Clear();
+                    //    string[] data = str.Split(' ');
+                    //    if (data.Length >= 25) 
+                    //    {
+                    //        Console.WriteLine(data[25]);
+                    //    }
+                    //}));
+                    Thread.Sleep(1000);
+                }
+            });
+        }
+        //结束
+        private void button2_Click(object sender, EventArgs e)
+        {
+            flag = sendCmd(endCmd);
+        }
+
+        private int sendCmd(string cmd)
+        {
+            if (cmd.Equals(startCmd))
+            {
+                byte[] byteStartCmd = HexStringToBinary(startCmd);
+                string result = HexStringToASCII(byteStartCmd);
+                byte[] b = Encoding.UTF8.GetBytes(result);
+                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;
+        }
+        /// <summary>
+        /// 将一条十六进制字符串转换为ASCII
+        /// </summary>
+        /// <param name="hexstring">一条十六进制字符串</param>
+        /// <returns>返回一条ASCII码</returns>
+        private static string HexStringToASCII(byte[] bt)
+        {
+            //byte[] bt = HexStringToBinary(hexstring);
+            string lin = "";
+            for (int i = 0; i < bt.Length; i++)
+            {
+                lin = lin + bt[i] + " ";
+            }
+
+
+            string[] ss = lin.Trim().Split(new char[] { ' ' });
+            char[] c = new char[ss.Length];
+            int a;
+            for (int i = 0; i < c.Length; i++)
+            {
+                a = Convert.ToInt32(ss[i]);
+                c[i] = Convert.ToChar(a);
+            }
+
+            string b = new string(c);
+            return b;
+        }
+
+        /// <summary>
+        /// 16进制字符串转换为二进制数组
+        /// </summary>
+        /// <param name="hexstring">用空格切割字符串</param>
+        /// <returns>返回一个二进制字符串</returns>
+        private static byte[] HexStringToBinary(string hexstring)
+        {
+
+            string[] tmpary = hexstring.Trim().Split(' ');
+            byte[] buff = new byte[tmpary.Length];
+            for (int i = 0; i < buff.Length; i++)
+            {
+                buff[i] = Convert.ToByte(tmpary[i], 16);
+            }
+            return buff;
+        }
+    }
+}

+ 120 - 0
sickTest/Form1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 229 - 0
sickTest/LogManager.cs

@@ -0,0 +1,229 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace sickTest
+{
+    /// <summary>
+    /// 日志管理
+    /// </summary>
+    public class LogManager
+    {
+        private string filepath = "log";
+        //public static string logAddressStr = "filepath";
+        //public static string logAddress;
+        DateTime time;                                        //文件创建时间
+        private string logFileExtName = "log";     //日志文件扩展名
+        private Encoding logFileEncoding = Encoding.UTF8;   //日志文件编码格式
+        private string logFileName = string.Empty;  //日志文件名
+        private string logPath = "";            //日志文件路径
+        private bool writeLogTime = true;     //log文件是否写时间
+        private bool writeStatus = false;        //是否写入标志位
+        private static object obj = new object();
+        /// <summary>
+        /// 配置文件初始化
+        /// </summary>
+        public static void Init()
+        {
+            //try
+            //{
+            //    logAddress = ConfigurationManager.AppSettings[logAddressStr];
+            //}
+            //catch
+            //{
+            //    Console.WriteLine("配置文件有误");
+            //}
+        }
+        /// <summary>
+        /// 日志文件路径
+        /// </summary>
+        public string CreateLogPath()
+        {
+            if (!Directory.Exists(filepath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(filepath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            if (logPath == null || logPath == string.Empty || time.ToString("yyyy-MM-dd") != System.DateTime.Now.ToString("yyyy-MM-dd"))
+            {
+                try
+                {
+                    time = System.DateTime.Now;
+                    logPath = System.IO.Path.Combine(filepath, time.ToString("yyyy-MM-dd"));
+                }
+                catch
+                {
+                    Console.WriteLine("路径合成失败");
+                }
+            }
+            if (!logPath.EndsWith(@"\"))
+            {
+                logPath += @"\";
+            }
+            if (!Directory.Exists(logPath))
+            {
+                try
+                {
+                    Directory.CreateDirectory(logPath);
+                }
+                catch
+                {
+                    Console.WriteLine("创建文件路径失败");
+                }
+            }
+            return logPath;
+        }
+        /// <summary>
+        /// 写日志
+        /// </summary>
+        public void WriteLog(LogType logType, string logFile, string msg)
+        {
+            CreateLogPath();
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    logFileName = string.Format("{0}{1}.{2}", logPath, logType, this.logFileExtName);
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        //是否写时间
+                        if (logType == LogType.PROCESS)
+                        {
+                            writeLogTime = true;
+                        }
+                        else
+                        {
+                            writeLogTime = false;
+                        }
+                        ////sql类型
+                        //if (logType == LogType.DATABASE)
+                        //{
+                        //    writeStatus = true;
+                        //}
+                        //else
+                        //{
+                        //    writeStatus = false;
+                        //}
+                        if (writeLogTime)
+                        {
+                            sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:") + logFile + ":" + msg);
+                        }
+                        else
+                        {
+                            sw.WriteLine(logFile + "" + msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+        /// <summary>
+        /// log类型不定
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            this.WriteLog(logType, logFile.ToString(), msg);
+        }
+        /// <summary>
+        /// log类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public void WriteLog(LogType logType, string msg)
+        {
+            this.WriteLog(logType, string.Empty, msg);
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        public List<string> ReadLog()
+        {
+            List<string> digitList = new List<string>();
+            //string date = System.DateTime.Now.ToString("yyyy-MM-dd");
+            //string filePath = logAddress + "\\\\" + date + "\\\\" + "CREDENCES.log";
+            string filePath = filepath + "\\\\" + "CREDENCES.log";
+            try
+            {
+                List<string> logLines = null;
+                if (File.Exists(filePath))
+                {
+                    logLines = new List<string>(File.ReadAllLines(filePath));
+                    File.Delete(filePath);
+                }
+                if (logLines != null)
+                {
+                    for (int i = 0; i < 300; i++)
+                    {
+                        string logLine = logLines[i];
+                        digitList.Add(logLine);
+                        logLines.RemoveAt(i);
+                    }
+                    File.WriteAllLines(filePath, logLines.ToArray());
+                }
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); }
+            return digitList;
+        }
+        public void WriteCredence(string msg)
+        {
+            lock (obj)
+            {
+                try
+                {
+                    //创建log文件
+                    string logname = string.Format("{0}.{1}", "CREDENCES", this.logFileExtName);
+                    logFileName = filepath + "\\" + logname;
+                    using (StreamWriter sw = new StreamWriter(logFileName, true, logFileEncoding))
+                    {
+                        if (msg.Length == 8)
+                        {
+                            sw.WriteLine(msg);
+                        }
+                        else
+                        {
+                            //sw.WriteLine("0" + msg);
+                            sw.WriteLine(msg);
+                        }
+                    }
+                }
+                catch { }
+            }
+        }
+
+
+
+    }
+    /// <summary>
+    /// log类型
+    /// </summary>
+    public enum LogFile
+    {
+        LOG,
+        RESET,
+        ERROR,
+        WARNING,
+        INFO,
+        ERROR_NUMBERPLATE
+    }
+    /// <summary>
+    /// log文件类型
+    /// </summary>
+    public enum LogType
+    {
+        PROCESS,
+        CREDENCES
+    }
+}

+ 22 - 0
sickTest/Program.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace sickTest
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new Form1());
+        }
+    }
+}

+ 36 - 0
sickTest/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("sickTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("sickTest")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("e2a82d4a-294c-49fd-8590-275302f699a1")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
sickTest/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace sickTest.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("sickTest.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
sickTest/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
sickTest/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace sickTest.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
sickTest/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 94 - 0
sickTest/log.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace sickTest
+{
+    public static class Log
+    {
+        private static LogManager logManager;
+        static Log()
+        {
+            LogManager.Init();
+            logManager = new LogManager();
+        }
+        /// <summary>
+        /// 写文件类型
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="logFile"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, LogFile logFile, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, logFile, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 文件类型为null
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, string.Empty, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 数据库异常的标志位
+        /// 0表示update,1表示insert
+        /// </summary>
+        /// <param name="logType"></param>
+        /// <param name="status"></param>
+        /// <param name="msg"></param>
+        public static void WriteLog(LogType logType, string status, string msg)
+        {
+            try
+            {
+                logManager.WriteLog(logType, status, msg);
+            }
+            catch
+            {
+
+            }
+        }
+        /// <summary>
+        /// 读日志文件
+        /// </summary>
+        /// <param name="sqlStatus"></param>
+        /// <param name="sqlMsg"></param>
+        /// <param name="count"></param>      
+        public static List<string> ReadLog()
+        {
+            List<string> digitList = null;
+            try
+            {
+                digitList = logManager.ReadLog();
+            }
+            catch { }
+            return digitList;
+        }
+
+        public static void WriteCredence(string msg)
+        {
+            try
+            {
+                logManager.WriteCredence(msg);
+            }
+            catch { }
+        }
+    }
+}

+ 84 - 0
sickTest/sickTest.csproj

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{E2A82D4A-294C-49FD-8590-275302F699A1}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>sickTest</RootNamespace>
+    <AssemblyName>sickTest</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Form1.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Form1.Designer.cs">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </Compile>
+    <Compile Include="log.cs" />
+    <Compile Include="LogManager.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Form1.resx">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>