Commit 850f5e4c by 李彦科

添加项目文件。

parent a1fba435
File added
File added
File added

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoTool", "DemoTool\DemoTool.csproj", "{D1F85F0C-2991-48BD-ACD7-952B40A30662}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D1F85F0C-2991-48BD-ACD7-952B40A30662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1F85F0C-2991-48BD-ACD7-952B40A30662}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1F85F0C-2991-48BD-ACD7-952B40A30662}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1F85F0C-2991-48BD-ACD7-952B40A30662}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E3E6ADB8-3537-4BC8-ACF2-075147157247}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<!--主IP地址-->
<add key="HomeIP" value="117.40.88.30"/>
<!--备IP地址-->
<add key="PrepareIP" value="127.0.0.1"/>
<!--日志存储地址-->
<add key="LogPath" value="D:/txt/"/>
<!--日志存储地址-->
<add key="DataPath" value="D:/DemoToolSystemData/"/>
</appSettings>
</configuration>
\ No newline at end of file
<?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>{D1F85F0C-2991-48BD-ACD7-952B40A30662}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>DemoTool</RootNamespace>
<AssemblyName>DemoTool</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<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="DllToolLib">
<HintPath>..\DLL\DllToolLib.dll</HintPath>
</Reference>
<Reference Include="ErrMsg">
<HintPath>..\DLL\ErrMsg.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DLL\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NPinyin">
<HintPath>..\DLL\NPinyin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<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" />
<Reference Include="VizConnectC">
<HintPath>..\DLL\VizConnectC.dll</HintPath>
</Reference>
<Reference Include="WWW">
<HintPath>..\DLL\WWW.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tool\Log.cs" />
<Compile Include="Tool\LogMsg.cs" />
<Compile Include="Tool\TcpTool.cs" />
<Compile Include="Tool\VizCommand.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.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>
<None Include="XMLDemo\Demo.json" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

namespace DemoTool
{
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.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel1 = new System.Windows.Forms.Panel();
this.label42 = new System.Windows.Forms.Label();
this.label41 = new System.Windows.Forms.Label();
this.reStart_btn = new System.Windows.Forms.Button();
this.breakViz_btn = new System.Windows.Forms.Button();
this.connectViz_btn = new System.Windows.Forms.Button();
this.Resultlabel8 = new System.Windows.Forms.Label();
this.Resultlabel6 = new System.Windows.Forms.Label();
this.IPViz_lab1 = new System.Windows.Forms.Label();
this.IPViz_lab2 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.but_Lock = new System.Windows.Forms.Button();
this.label18 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.serialPort1 = new System.IO.Ports.SerialPort(this.components);
this.panel3 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.label10 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.txt_Tcp_IP = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txt_Tcp_Com = new System.Windows.Forms.TextBox();
this.panel5 = new System.Windows.Forms.Panel();
this.com_ComName = new System.Windows.Forms.ComboBox();
this.txt_BaudRate = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.but_Connect = new System.Windows.Forms.Button();
this.but_Close = new System.Windows.Forms.Button();
this.panel4 = new System.Windows.Forms.Panel();
this.label19 = new System.Windows.Forms.Label();
this.num_Delay_Jian = new System.Windows.Forms.NumericUpDown();
this.num_Delay_Jia = new System.Windows.Forms.NumericUpDown();
this.label12 = new System.Windows.Forms.Label();
this.but_Send_Data = new System.Windows.Forms.Button();
this.but_Stop_Data = new System.Windows.Forms.Button();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.Delay_Jia = new System.Windows.Forms.TextBox();
this.txt_One_Data = new System.Windows.Forms.TextBox();
this.txt_ALL_Data = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel6.SuspendLayout();
this.panel5.SuspendLayout();
this.panel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.num_Delay_Jian)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.num_Delay_Jia)).BeginInit();
this.SuspendLayout();
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.label42);
this.panel1.Controls.Add(this.label41);
this.panel1.Controls.Add(this.reStart_btn);
this.panel1.Controls.Add(this.breakViz_btn);
this.panel1.Controls.Add(this.connectViz_btn);
this.panel1.Controls.Add(this.Resultlabel8);
this.panel1.Controls.Add(this.Resultlabel6);
this.panel1.Controls.Add(this.IPViz_lab1);
this.panel1.Controls.Add(this.IPViz_lab2);
this.panel1.Location = new System.Drawing.Point(469, 12);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(427, 319);
this.panel1.TabIndex = 54;
//
// label42
//
this.label42.AutoSize = true;
this.label42.BackColor = System.Drawing.Color.Black;
this.label42.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label42.ForeColor = System.Drawing.Color.White;
this.label42.Location = new System.Drawing.Point(41, 113);
this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(34, 21);
this.label42.TabIndex = 14;
this.label42.Text = "IP2";
//
// label41
//
this.label41.AutoSize = true;
this.label41.BackColor = System.Drawing.Color.Black;
this.label41.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label41.ForeColor = System.Drawing.Color.White;
this.label41.Location = new System.Drawing.Point(41, 52);
this.label41.Name = "label41";
this.label41.Size = new System.Drawing.Size(38, 21);
this.label41.TabIndex = 13;
this.label41.Text = "IP1:";
//
// reStart_btn
//
this.reStart_btn.BackColor = System.Drawing.Color.Black;
this.reStart_btn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.reStart_btn.ForeColor = System.Drawing.Color.White;
this.reStart_btn.Location = new System.Drawing.Point(303, 227);
this.reStart_btn.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.reStart_btn.Name = "reStart_btn";
this.reStart_btn.Size = new System.Drawing.Size(100, 56);
this.reStart_btn.TabIndex = 12;
this.reStart_btn.Text = "重启软件";
this.reStart_btn.UseVisualStyleBackColor = false;
this.reStart_btn.Click += new System.EventHandler(this.reStart_btn_Click);
//
// breakViz_btn
//
this.breakViz_btn.BackColor = System.Drawing.Color.Black;
this.breakViz_btn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.breakViz_btn.ForeColor = System.Drawing.Color.White;
this.breakViz_btn.Location = new System.Drawing.Point(303, 127);
this.breakViz_btn.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.breakViz_btn.Name = "breakViz_btn";
this.breakViz_btn.Size = new System.Drawing.Size(100, 59);
this.breakViz_btn.TabIndex = 10;
this.breakViz_btn.Text = "断开连接";
this.breakViz_btn.UseVisualStyleBackColor = false;
this.breakViz_btn.Click += new System.EventHandler(this.breakViz_btn_Click);
//
// connectViz_btn
//
this.connectViz_btn.BackColor = System.Drawing.Color.Black;
this.connectViz_btn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.connectViz_btn.ForeColor = System.Drawing.Color.White;
this.connectViz_btn.Location = new System.Drawing.Point(299, 23);
this.connectViz_btn.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.connectViz_btn.Name = "connectViz_btn";
this.connectViz_btn.Size = new System.Drawing.Size(104, 66);
this.connectViz_btn.TabIndex = 9;
this.connectViz_btn.Text = "连接Viz";
this.connectViz_btn.UseVisualStyleBackColor = false;
this.connectViz_btn.Click += new System.EventHandler(this.connectViz_btn_Click);
//
// Resultlabel8
//
this.Resultlabel8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Resultlabel8.ForeColor = System.Drawing.Color.Red;
this.Resultlabel8.Location = new System.Drawing.Point(51, 246);
this.Resultlabel8.Name = "Resultlabel8";
this.Resultlabel8.Size = new System.Drawing.Size(224, 37);
this.Resultlabel8.TabIndex = 8;
this.Resultlabel8.Text = "请连接viz";
this.Resultlabel8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Resultlabel6
//
this.Resultlabel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Resultlabel6.ForeColor = System.Drawing.Color.Red;
this.Resultlabel6.Location = new System.Drawing.Point(51, 185);
this.Resultlabel6.Name = "Resultlabel6";
this.Resultlabel6.Size = new System.Drawing.Size(224, 37);
this.Resultlabel6.TabIndex = 8;
this.Resultlabel6.Text = "请连接viz";
this.Resultlabel6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// IPViz_lab1
//
this.IPViz_lab1.BackColor = System.Drawing.Color.Black;
this.IPViz_lab1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.IPViz_lab1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.IPViz_lab1.ForeColor = System.Drawing.Color.White;
this.IPViz_lab1.Location = new System.Drawing.Point(106, 42);
this.IPViz_lab1.Name = "IPViz_lab1";
this.IPViz_lab1.Size = new System.Drawing.Size(169, 33);
this.IPViz_lab1.TabIndex = 6;
this.IPViz_lab1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// IPViz_lab2
//
this.IPViz_lab2.BackColor = System.Drawing.Color.Black;
this.IPViz_lab2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.IPViz_lab2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.IPViz_lab2.ForeColor = System.Drawing.Color.White;
this.IPViz_lab2.Location = new System.Drawing.Point(106, 103);
this.IPViz_lab2.Name = "IPViz_lab2";
this.IPViz_lab2.Size = new System.Drawing.Size(169, 33);
this.IPViz_lab2.TabIndex = 7;
this.IPViz_lab2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// panel2
//
this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel2.Controls.Add(this.but_Lock);
this.panel2.Controls.Add(this.label18);
this.panel2.Controls.Add(this.textBox4);
this.panel2.Controls.Add(this.label11);
this.panel2.Controls.Add(this.label16);
this.panel2.Controls.Add(this.button3);
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.label6);
this.panel2.Controls.Add(this.label5);
this.panel2.Controls.Add(this.label4);
this.panel2.Controls.Add(this.button1);
this.panel2.Controls.Add(this.textBox3);
this.panel2.Controls.Add(this.textBox2);
this.panel2.Controls.Add(this.textBox1);
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.label1);
this.panel2.Location = new System.Drawing.Point(9, 525);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(451, 333);
this.panel2.TabIndex = 55;
//
// but_Lock
//
this.but_Lock.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.but_Lock.ForeColor = System.Drawing.Color.White;
this.but_Lock.Location = new System.Drawing.Point(344, 11);
this.but_Lock.Name = "but_Lock";
this.but_Lock.Size = new System.Drawing.Size(102, 43);
this.but_Lock.TabIndex = 26;
this.but_Lock.Text = "解锁";
this.but_Lock.UseVisualStyleBackColor = false;
this.but_Lock.Click += new System.EventHandler(this.but_Lock_Click);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label18.Location = new System.Drawing.Point(212, 53);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(54, 28);
this.label18.TabIndex = 25;
this.label18.Text = "毫秒";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(117, 275);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 21);
this.textBox4.TabIndex = 24;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label11.Location = new System.Drawing.Point(65, 275);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(44, 24);
this.label11.TabIndex = 23;
this.label11.Text = "毫秒";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label16.Location = new System.Drawing.Point(18, 11);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(180, 24);
this.label16.TabIndex = 22;
this.label16.Text = "下方为测试数据展示:";
//
// button3
//
this.button3.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button3.Enabled = false;
this.button3.ForeColor = System.Drawing.Color.White;
this.button3.Location = new System.Drawing.Point(278, 258);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(129, 43);
this.button3.TabIndex = 21;
this.button3.Text = "继续";
this.button3.UseVisualStyleBackColor = false;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button2.Enabled = false;
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(278, 197);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(129, 43);
this.button2.TabIndex = 20;
this.button2.Text = "停止";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label6.Location = new System.Drawing.Point(84, 228);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(27, 24);
this.label6.TabIndex = 19;
this.label6.Text = "秒";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label5.Location = new System.Drawing.Point(84, 176);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(27, 24);
this.label5.TabIndex = 18;
this.label5.Text = "分";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label4.Location = new System.Drawing.Point(84, 119);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(27, 24);
this.label4.TabIndex = 17;
this.label4.Text = "时";
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.ControlText;
this.button1.Enabled = false;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(278, 129);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(129, 43);
this.button1.TabIndex = 16;
this.button1.Text = "24秒计时测试";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(117, 228);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 21);
this.textBox3.TabIndex = 15;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(117, 176);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 14;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(117, 119);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 13;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(16, 53);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(33, 28);
this.label3.TabIndex = 12;
this.label3.Text = "时";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(86, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(33, 28);
this.label2.TabIndex = 11;
this.label2.Text = "分";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(150, 53);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(33, 28);
this.label1.TabIndex = 10;
this.label1.Text = "秒";
//
// panel3
//
this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel3.Controls.Add(this.panel6);
this.panel3.Controls.Add(this.panel5);
this.panel3.Controls.Add(this.but_Connect);
this.panel3.Controls.Add(this.but_Close);
this.panel3.Location = new System.Drawing.Point(12, 12);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(451, 213);
this.panel3.TabIndex = 56;
//
// panel6
//
this.panel6.Controls.Add(this.label10);
this.panel6.Controls.Add(this.label8);
this.panel6.Controls.Add(this.txt_Tcp_IP);
this.panel6.Controls.Add(this.label9);
this.panel6.Controls.Add(this.txt_Tcp_Com);
this.panel6.Location = new System.Drawing.Point(19, 10);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(428, 82);
this.panel6.TabIndex = 26;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label10.Location = new System.Drawing.Point(332, 39);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(78, 24);
this.label10.TabIndex = 24;
this.label10.Text = "连接状态";
this.label10.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label8.Location = new System.Drawing.Point(45, 54);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(78, 24);
this.label8.TabIndex = 18;
this.label8.Text = "端口号:";
//
// txt_Tcp_IP
//
this.txt_Tcp_IP.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_Tcp_IP.Location = new System.Drawing.Point(107, 8);
this.txt_Tcp_IP.Name = "txt_Tcp_IP";
this.txt_Tcp_IP.Size = new System.Drawing.Size(175, 32);
this.txt_Tcp_IP.TabIndex = 13;
this.txt_Tcp_IP.Text = "117.40.88.14";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label9.Location = new System.Drawing.Point(45, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(44, 24);
this.label9.TabIndex = 17;
this.label9.Text = "IP:";
//
// txt_Tcp_Com
//
this.txt_Tcp_Com.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Tcp_Com.Location = new System.Drawing.Point(153, 46);
this.txt_Tcp_Com.Name = "txt_Tcp_Com";
this.txt_Tcp_Com.Size = new System.Drawing.Size(129, 32);
this.txt_Tcp_Com.TabIndex = 14;
this.txt_Tcp_Com.Text = "26";
//
// panel5
//
this.panel5.Controls.Add(this.com_ComName);
this.panel5.Controls.Add(this.txt_BaudRate);
this.panel5.Controls.Add(this.label15);
this.panel5.Controls.Add(this.label7);
this.panel5.Location = new System.Drawing.Point(19, 104);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(296, 104);
this.panel5.TabIndex = 25;
//
// com_ComName
//
this.com_ComName.Enabled = false;
this.com_ComName.Font = new System.Drawing.Font("宋体", 20F);
this.com_ComName.FormattingEnabled = true;
this.com_ComName.Location = new System.Drawing.Point(143, 16);
this.com_ComName.Name = "com_ComName";
this.com_ComName.Size = new System.Drawing.Size(139, 35);
this.com_ComName.TabIndex = 26;
//
// txt_BaudRate
//
this.txt_BaudRate.Enabled = false;
this.txt_BaudRate.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_BaudRate.Location = new System.Drawing.Point(177, 68);
this.txt_BaudRate.Name = "txt_BaudRate";
this.txt_BaudRate.Size = new System.Drawing.Size(105, 32);
this.txt_BaudRate.TabIndex = 25;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label15.Location = new System.Drawing.Point(31, 68);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(78, 24);
this.label15.TabIndex = 24;
this.label15.Text = "波特率:";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label7.Location = new System.Drawing.Point(31, 14);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(83, 24);
this.label7.TabIndex = 22;
this.label7.Text = "Com口:";
//
// but_Connect
//
this.but_Connect.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.but_Connect.ForeColor = System.Drawing.Color.White;
this.but_Connect.Location = new System.Drawing.Point(321, 103);
this.but_Connect.Name = "but_Connect";
this.but_Connect.Size = new System.Drawing.Size(129, 43);
this.but_Connect.TabIndex = 21;
this.but_Connect.Text = "连接";
this.but_Connect.UseVisualStyleBackColor = false;
this.but_Connect.Click += new System.EventHandler(this.but_Connect_Click);
//
// but_Close
//
this.but_Close.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.but_Close.ForeColor = System.Drawing.Color.White;
this.but_Close.Location = new System.Drawing.Point(321, 165);
this.but_Close.Name = "but_Close";
this.but_Close.Size = new System.Drawing.Size(129, 43);
this.but_Close.TabIndex = 20;
this.but_Close.Text = "断开";
this.but_Close.UseVisualStyleBackColor = false;
this.but_Close.Click += new System.EventHandler(this.but_Close_Click);
//
// panel4
//
this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel4.Controls.Add(this.label19);
this.panel4.Controls.Add(this.num_Delay_Jian);
this.panel4.Controls.Add(this.num_Delay_Jia);
this.panel4.Controls.Add(this.label12);
this.panel4.Controls.Add(this.but_Send_Data);
this.panel4.Controls.Add(this.but_Stop_Data);
this.panel4.Controls.Add(this.label13);
this.panel4.Controls.Add(this.label14);
this.panel4.Controls.Add(this.Delay_Jia);
this.panel4.Controls.Add(this.txt_One_Data);
this.panel4.Location = new System.Drawing.Point(9, 240);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(451, 254);
this.panel4.TabIndex = 57;
//
// label19
//
this.label19.AutoSize = true;
this.label19.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label19.Location = new System.Drawing.Point(24, 194);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(95, 24);
this.label19.TabIndex = 25;
this.label19.Text = "总延迟秒:";
//
// num_Delay_Jian
//
this.num_Delay_Jian.DecimalPlaces = 1;
this.num_Delay_Jian.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.num_Delay_Jian.Increment = new decimal(new int[] {
1,
0,
0,
65536});
this.num_Delay_Jian.Location = new System.Drawing.Point(144, 135);
this.num_Delay_Jian.Name = "num_Delay_Jian";
this.num_Delay_Jian.Size = new System.Drawing.Size(120, 33);
this.num_Delay_Jian.TabIndex = 24;
//
// num_Delay_Jia
//
this.num_Delay_Jia.DecimalPlaces = 1;
this.num_Delay_Jia.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.num_Delay_Jia.Increment = new decimal(new int[] {
1,
0,
0,
65536});
this.num_Delay_Jia.Location = new System.Drawing.Point(144, 85);
this.num_Delay_Jia.Name = "num_Delay_Jia";
this.num_Delay_Jia.Size = new System.Drawing.Size(120, 33);
this.num_Delay_Jia.TabIndex = 15;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label12.Location = new System.Drawing.Point(22, 135);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(102, 24);
this.label12.TabIndex = 22;
this.label12.Text = "延迟秒数-:";
//
// but_Send_Data
//
this.but_Send_Data.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.but_Send_Data.ForeColor = System.Drawing.Color.White;
this.but_Send_Data.Location = new System.Drawing.Point(317, 127);
this.but_Send_Data.Name = "but_Send_Data";
this.but_Send_Data.Size = new System.Drawing.Size(129, 43);
this.but_Send_Data.TabIndex = 21;
this.but_Send_Data.Text = "发送";
this.but_Send_Data.UseVisualStyleBackColor = false;
this.but_Send_Data.Click += new System.EventHandler(this.but_Send_Data_Click);
//
// but_Stop_Data
//
this.but_Stop_Data.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.but_Stop_Data.ForeColor = System.Drawing.Color.White;
this.but_Stop_Data.Location = new System.Drawing.Point(321, 206);
this.but_Stop_Data.Name = "but_Stop_Data";
this.but_Stop_Data.Size = new System.Drawing.Size(129, 43);
this.but_Stop_Data.TabIndex = 20;
this.but_Stop_Data.Text = "停止";
this.but_Stop_Data.UseVisualStyleBackColor = false;
this.but_Stop_Data.Click += new System.EventHandler(this.but_Stop_Data_Click);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label13.Location = new System.Drawing.Point(22, 94);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(108, 24);
this.label13.TabIndex = 18;
this.label13.Text = "延迟秒数+:";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Bold);
this.label14.Location = new System.Drawing.Point(65, 43);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(61, 24);
this.label14.TabIndex = 17;
this.label14.Text = "数据:";
//
// Delay_Jia
//
this.Delay_Jia.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Delay_Jia.Location = new System.Drawing.Point(144, 189);
this.Delay_Jia.Name = "Delay_Jia";
this.Delay_Jia.Size = new System.Drawing.Size(103, 32);
this.Delay_Jia.TabIndex = 14;
this.Delay_Jia.Text = "650";
//
// txt_One_Data
//
this.txt_One_Data.Font = new System.Drawing.Font("微软雅黑", 14F);
this.txt_One_Data.Location = new System.Drawing.Point(144, 38);
this.txt_One_Data.Name = "txt_One_Data";
this.txt_One_Data.Size = new System.Drawing.Size(193, 32);
this.txt_One_Data.TabIndex = 13;
//
// txt_ALL_Data
//
this.txt_ALL_Data.Location = new System.Drawing.Point(469, 363);
this.txt_ALL_Data.Multiline = true;
this.txt_ALL_Data.Name = "txt_ALL_Data";
this.txt_ALL_Data.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txt_ALL_Data.Size = new System.Drawing.Size(430, 500);
this.txt_ALL_Data.TabIndex = 58;
//
// label17
//
this.label17.AutoSize = true;
this.label17.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label17.Location = new System.Drawing.Point(466, 335);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(88, 25);
this.label17.TabIndex = 59;
this.label17.Text = "数据记录";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.ClientSize = new System.Drawing.Size(932, 870);
this.Controls.Add(this.label17);
this.Controls.Add(this.txt_ALL_Data);
this.Controls.Add(this.panel4);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "24SCountDown";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel6.ResumeLayout(false);
this.panel6.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.num_Delay_Jian)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.num_Delay_Jia)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label42;
private System.Windows.Forms.Label label41;
private System.Windows.Forms.Button reStart_btn;
private System.Windows.Forms.Button breakViz_btn;
private System.Windows.Forms.Button connectViz_btn;
private System.Windows.Forms.Label Resultlabel8;
private System.Windows.Forms.Label Resultlabel6;
private System.Windows.Forms.Label IPViz_lab1;
private System.Windows.Forms.Label IPViz_lab2;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.IO.Ports.SerialPort serialPort1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button but_Connect;
private System.Windows.Forms.Button but_Close;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_Tcp_Com;
private System.Windows.Forms.TextBox txt_Tcp_IP;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.ComboBox com_ComName;
private System.Windows.Forms.TextBox txt_BaudRate;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button but_Send_Data;
private System.Windows.Forms.Button but_Stop_Data;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox Delay_Jia;
private System.Windows.Forms.TextBox txt_One_Data;
private System.Windows.Forms.TextBox txt_ALL_Data;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.NumericUpDown num_Delay_Jia;
private System.Windows.Forms.NumericUpDown num_Delay_Jian;
private System.Windows.Forms.Button but_Lock;
private System.Windows.Forms.Label label19;
}
}
using DemoTool.Tool;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.IO.Ports;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Timer = System.Windows.Forms.Timer;
namespace DemoTool
{
public partial class Form1 : Form
{
//变色按钮列表
List<Button> buttonList = new List<Button>();
VizCommand sendCommend = new VizCommand();//Viz命令
List<string> IPlist = new List<string>(); //创建Viz Ip列表
string TxtPath = "";
string AllMiao;
LogMsg LogMsg = new LogMsg();
public Form1()
{
InitializeComponent();
}
#region Viz连接操作
/// <summary>
/// /设置点击的按钮为绿色
/// </summary>
void SetGreen(Button button)
{
if (buttonList.Contains(button))
{
for (int i = 0; i < buttonList.Count; i++)
{
buttonList[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
}
button.BackColor = Color.Red;
}
else
{
buttonList.Add(button);
for (int i = 0; i < buttonList.Count; i++)
{
buttonList[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
}
button.BackColor = Color.Red;
}
}
private void connectViz_btn_Click(object sender, EventArgs e)
{
SetGreen(this.connectViz_btn);
Task task = Task.Run(() =>
{
ConnectVizFunc();
});
}
private void ConnectVizFunc()
{
if (IPlist.Count != 0)
{
sendCommend.ConnectViz(IPlist);
//遍历ip列表
for (int i = 0; i < IPlist.Count; i++)
{
if (sendCommend.IsConnectVizList[i] == true)
{
if (i == 0)
{
IPViz_lab1.ForeColor = Color.Lime;
Resultlabel6.Invoke(new Action(() =>
{
Resultlabel6.Text = "IP1-Viz引擎连接成功!";
}));
Resultlabel6.ForeColor = Color.Lime;
//ReturnDebug.DebugMessage("IP地址为:" + IPlist[0] + "连接成功!", DebugMessageType.ok);
}
else if (i == 1)
{
IPViz_lab2.ForeColor = Color.Lime;
Resultlabel8.Invoke(new Action(() =>
{
Resultlabel8.Text = "IP2-Viz引擎连接成功!";
}));
Resultlabel8.ForeColor = Color.Lime;
//ReturnDebug.DebugMessage("IP地址为:" + IPlist[1] + "连接成功!", DebugMessageType.ok);
}
}
else if (sendCommend.IsConnectVizList[i] == false)
{
if (i == 0)
{
IPViz_lab1.ForeColor = Color.Red;
MessageBox.Show("IP1-有Viz引擎连接失败!");
Resultlabel6.Invoke(new Action(() =>
{
Resultlabel6.Text = "IP1-有Viz引擎连接失败!";
}));
Resultlabel6.ForeColor = Color.Red;
//ReturnDebug.DebugMessage("IP1-地址为:" + IPlist[0] + "连接失败!", DebugMessageType.err);
}
else if (i == 1)
{
IPViz_lab2.ForeColor = Color.Red;
Resultlabel8.Invoke(new Action(() =>
{
Resultlabel8.Text = "IP2-Viz引擎连接失败!";
}));
Resultlabel8.ForeColor = Color.Red;
//ReturnDebug.DebugMessage("IP2-地址为:" + IPlist[1] + "连接失败!", DebugMessageType.err);
}
}
}
}
else
{
//ReturnDebug.DebugMessage("没有可供选择的引擎连接!请添加要连接引擎的IP地址:", DebugMessageType.err);
}
}
private void breakViz_btn_Click(object sender, EventArgs e)
{
SetGreen(this.breakViz_btn);
for (int i = 0; i < sendCommend._poolList.Count; i++)
{
sendCommend._poolList[i].Disconnect();
sendCommend._poolList[i].Dispose();
IPViz_lab1.ForeColor = Color.White;
IPViz_lab2.ForeColor = Color.White;
Resultlabel6.ForeColor = Color.Red;
Resultlabel6.Text = "引擎已断开,请连接Viz...";
Resultlabel8.ForeColor = Color.Red;
Resultlabel8.Text = "引擎已断开,请连接Viz...";
}
}
private void reStart_btn_Click(object sender, EventArgs e)
{
SetGreen(this.reStart_btn);
DialogResult dr = MessageBox.Show("是否重启?", "提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK) //如果单击“是”按钮
{
System.Windows.Forms.Application.Restart();
}
else if (dr == DialogResult.Cancel)
{
}
}
//string[] COM_Name = new string[] { "COM1", "COM2", "COM3", "COM4","COM5","COM6","COM7" };
List<string> Com_Name = new List<string>() { "COM1", "COM2", "COM3", "COM4" };
public void LoadSum()
{
try
{
AllMiao = Delay_Jia.Text;
IPViz_lab1.Text = ConfigurationManager.AppSettings["HomeIP"].ToString();
IPViz_lab2.Text = ConfigurationManager.AppSettings["PrepareIP"].ToString();
TxtPath = ConfigurationManager.AppSettings["LogPath"].ToString();
//imageLocation = ConfigurationManager.AppSettings["ImageLocation"].ToString();
//teamImageLocation = ConfigurationManager.AppSettings["TeamImageLocation"].ToString();
//imageDefaultLocation = ConfigurationManager.AppSettings["ImageDefaultLocation"].ToString();
IPlist.Clear();
IPlist.Add(IPViz_lab1.Text.Trim());
IPlist.Add(IPViz_lab2.Text.Trim());
foreach (var item in Com_Name)
{
com_ComName.Items.Add(item);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
#endregion
//当前应用程序集的执行目录
string dir = AppDomain.CurrentDomain.BaseDirectory;
//当前应用程序集的执行的上级目录
//dir = Path.GetFullPath("..");
private void Form1_Load(object sender, EventArgs e)
{
LoadSum();
//button1.Enabled = false;
//button2.Enabled = false;
//button3.Enabled = false;
}
//string转换int帮助函数
public int ConvertInt32(string name)
{
if (name != "" && name != null)
{
return Convert.ToInt32(name);
}
else
{
return 0;
}
}
int Hose, Minut, Second, MS = 0;
bool IsSecond = true;
bool IsMS;
/// <summary>
/// 停止
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
this.timer1.Stop();
this.timer1.Enabled = false;
}
/// <summary>
/// 继续
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
this.timer1.Start();
this.timer1.Enabled = true;
}
/// <summary>
/// 24秒测试开始
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click_1(object sender, EventArgs e)
{
try
{
Hose = ConvertInt32(textBox1.Text.Trim());
if (ConvertInt32(textBox2.Text.Trim()) > 60)
{
MessageBox.Show("不能大于60分钟");
return;
}
else
{
Minut = ConvertInt32(textBox2.Text.Trim());
}
if (ConvertInt32(textBox3.Text.Trim()) >= 60)
{
MessageBox.Show("不能大于60秒");
return;
}
else
{
Second = ConvertInt32(textBox3.Text.Trim());
}
this.timer1.Start();
this.timer1.Enabled = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Second != 0 && Second >= 11)
{
timer1.Interval = 1000;
Second--;
//给Viz发东西
//try
//{
// sendCommend.SendViz24(Second.ToString());
//}
//catch (Exception ex)
//{
// Console.WriteLine(ex.Message);
//}
}
// 处理毫秒
else if (Second != 0 && Second <= 10)
{
timer1.Interval = 110;
if (MS == 0 && Second != 0)
{
if (Second != 0)
{
Second--;
MS = 9;
}
if (Second == 0)
{
MS = 0;
}
}
else
{
MS--;
//sendCommend.SendViz24(Second.ToString() + "." + MS.ToString());
}
}
if (Second == 0)
{
if (Minut != 0)
{
Second += 60;
Minut--;
}
}
if (Minut == 0)
{
if (Hose != 0)
{
Minut += 60;
Hose--;
}
}
label3.Text = Hose.ToString();
label2.Text = Minut.ToString();
label1.Text = Second.ToString();
label18.Text = MS.ToString();
if (Second != 0 && Second > 10)
{
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(Second.ToString()));
}
}
else
{
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(Second.ToString() + "." + MS.ToString()));
}
}
}
string data;
public string TimeDataSend(string str)
{
data = "";
data += str.Replace(" ", "") + "*";
if (num_Delay_Jia.Text == "0.0")
{
data += "0".Replace(" ", "") + "*";
}
else
{
data += num_Delay_Jia.Text.Replace(" ", "") + "*";
}
if (num_Delay_Jian.Text == "0.0")
{
data += "0".Replace(" ", "");
}
else
{
data += num_Delay_Jian.Text.Replace(" ", "");
}
//data += num_Delay_Jian.Text.Replace(" ", "") ;
Console.WriteLine("当前秒钟数据====>" + data);
return data;
}
public void OpenSbar()
{
if (serialPort1.IsOpen == false)
{
serialPort1.Open();
}
serialPort1.DataReceived += new SerialDataReceivedEventHandler(SBar_DataReceived);
}
private void SBar_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//this.labelCode.Text = "等待中...";
Thread.Sleep(100);
string str_Buff = serialPort1.ReadExisting();
str_Buff = System.Text.RegularExpressions.Regex.Replace(str_Buff, @"[^0-9a-zA-Z]+", "");
//获取到的数据
string Code = str_Buff.Trim();
}
private void but_Connect_Click(object sender, EventArgs e)
{
if (txt_Tcp_IP.Text.Trim() != "" && txt_Tcp_IP.Text.Trim() != null && txt_Tcp_Com.Text.Trim() != "" && txt_Tcp_Com.Text.Trim() != null)
{
SetGreen(this.but_Connect);
txt_ALL_Data.AppendText("IP形式连接\r\n");
Client();
}
//串口暂时未能使用
else if (com_ComName.Text != null && com_ComName.Text != "" && txt_BaudRate.Text != "" && txt_BaudRate.Text != null)
{
txt_ALL_Data.AppendText("COM口形式连接\r\n");
setPort();
}
}
/// <summary>
/// 断开所有通信的连接
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_Close_Click(object sender, EventArgs e)
{
//关闭Socket
CloseSocket();
//关闭串口
ClosePort();
}
//public void send_data(SerialPort st, string send_txt, out string msg)
//{
// if (com_sta == "关闭")
// {
// byte[] send = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00 };
// string[] gam = send_txt.Trim().Split(' ');
// for (int i = 0; i < gam.Length; i++)
// {
// send[i] = Convert.ToByte(gam[i], 16);
// }
// string yh = modbus.ToModbusCRC16(send_txt, true);
// send[gam.Length] = Convert.ToByte(yh.Substring(0, 2), 16);
// send[gam.Length + 1] = Convert.ToByte(yh.Substring(2, 2), 16);
// string str = "";
// foreach (var xs in send)
// {
// str += Convert.ToString(xs, 16).ToUpper().Length == 1 ? "0" + Convert.ToString(xs, 16).ToUpper() + " " : Convert.ToString(xs, 16).ToUpper() + " ";
// }
// //发送
// try
// {
// Thread.Sleep(5);
// st.Write(send, 0, send.Length);
// msg = "准备就绪";
// }
// catch { msg = "erro"; }
// }
// else
// {
// msg = "端口没打开!";
// }
//}
#region Socket链接方式
Socket socket;
Thread threadSocket;
bool IsReceive = true;
public void Client()
{
try
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(IPAddress.Parse(txt_Tcp_IP.Text), int.Parse(txt_Tcp_Com.Text));
label10.Text = "IP形式连接成功";
txt_ALL_Data.AppendText("IP形式连接成功\r\n");
threadSocket = new Thread(OnSendOrReceive);
threadSocket.IsBackground = true;
threadSocket.Start(socket);
threadSocket = new Thread(SokcetDempo);
threadSocket.IsBackground = true;
threadSocket.Start();
//ThreadPool.QueueUserWorkItem(OnSendOrReceive, socket);
//this.but_Connect.Enabled = false;
//but_Close.Enabled = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
label10.Text = "IP形式连接失败";
txt_ALL_Data.AppendText("IP形式连接失败\r\n");
MessageBox.Show("IP形式连接失败");
}
}
bool isOk;
string isSum = "0";
Queue<byte[]> HoseQueue = new Queue<byte[]>();
//Thread txtRead= new Thread()
Log log = new Log();
private void OnSendOrReceive(object sk)
{
var socket = sk as Socket;
int r = 0;
bool temp = false;
int tempCt = 0;
string text = "";
string strText = "";
while (true)
{
try
{
//客户端连接成功后,服务器应该接受客户端发来的消息
byte[] buffer2 = new byte[20];
//实际接收到的字节数组
r = socket.Receive(buffer2);
byte[] buffer = new byte[20];
for (int i = 0; i < buffer2.Length; i++)
{
try
{
if (buffer2[i].ToString("X8").Replace("0", "") == "CD")
{
if (i == 8)
{
buffer = buffer2;
for (int k = 0; k <= 8; k++)
{
try
{
text += buffer[k].ToString("X2") + " ";
strText += buffer[k].ToString() + " ";
}
catch
{
}
}
break;
}
else
{
if (!temp)
{
temp = true;
}
else
{
temp = false;
tempCt = 0;
break;
}
}
}
if (temp)
{
buffer[tempCt] = buffer2[i + 1];
tempCt++;
text += buffer2[i + 1].ToString("X2") + " ";
strText += buffer2[i + 1].ToString() + " ";
}
}
catch (Exception ex)
{
LogMsg.WriteErrLogMsg("重置接受到的字节出错:" + ex.Message);
}
}
HoseQueue.Enqueue(buffer);
this.BeginInvoke(new EventHandler(delegate
{
try
{
//string TxtPath = @"D:\txt\txt123\";
string postPath = TxtPath + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".log";
if (Directory.Exists(TxtPath) == false)
{
Directory.CreateDirectory(postPath);
}
else
{
//log.deleteLog(@"D:\txt");
using (System.IO.StreamWriter file = new System.IO.StreamWriter(postPath, true))
{
//string swTxt = BitConverter.ToString(buffer).Replace(" - ", "");
file.WriteLine(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + text + " " + strText);
text = "";
strText = "";
}
}
if (txt_ALL_Data.TextLength > 20 * 10000)
{
txt_ALL_Data.Text = "";
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}));
#region 未加队列之前处理
//if (IsReceive)
//{
// //24秒
// sumTwo = buffer[5].ToString();
// //24秒之后的毫秒
// Hmiao = buffer[4].ToString();
// #region 接受16进制的状态码
// //正常跑动
// if ((buffer[0].ToString("X2") == "21" && buffer[1].ToString("X2") == "00") || (buffer[0].ToString("X2") == "60" && buffer[1].ToString("X2") == "00") || (buffer[0].ToString("X2") == "20" && buffer[1].ToString("X2") == "00"))
// {
// Hmiao = Hmiao.Substring(0, 1);
// if (int.Parse(sumTwo) >= 5)
// {
// //24
// if (isSum!=sumTwo && int.Parse(sumTwo)<24)
// {
// if (int.Parse(sumTwo) == 5 && int.Parse(Hmiao) <= 1)
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----五秒----" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo));
// }
// WuMiao = true;
// }
// else
// {
// if(WuMiao == true)
// {
// //什么都不干
// }
// else
// {
// //这里再加1发
// string txtSum = (int.Parse(sumTwo) + 1).ToString();
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + txtSum + "----大于五秒+1----" + Hmiao + "\r\n");
// isOk = false;
// isSum = "0";
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(txtSum));
// }
// }
// }
// }
// }
// else
// {
// WuMiao = false;
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// }
// }
// }
// //14秒和24秒复位
// if (buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "00" &&(buffer[5].ToString("X2") == "0E"|| buffer[5].ToString("X2") == "18"))
// {
// WuMiao = false;
// if (int.Parse(sumTwo) >= 5)
// {
// Hmiao = Hmiao.Substring(0, 1);
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo + "." + Hmiao;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "-.-.-.-.-.-.-.-.-" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo));
// }
// isOk = true;
// isSum = sumTwo;
// }
// else
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// }
// }
// }
// //清屏
// if ((buffer[0].ToString("X2") == "10" && buffer[1].ToString("X2") == "00")||((buffer[0].ToString("X2") == "11" && buffer[1].ToString("X2") == "00") || ((buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "01"))))
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// WuMiao = false;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":清屏\r\n");
// }));
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(" "));
// }
// }
// //03 00 24秒到0时 01 00 只走时间 24秒为0时
// if ((buffer[0].ToString("X2") == "03" && buffer[1].ToString("X2") == "00" && buffer[5].ToString("X2") == "00") || ((buffer[0].ToString("X2") == "01" && buffer[1].ToString("X2") == "00" && buffer[5].ToString("X2") == "00")) || ((buffer[0].ToString("X2") == "02" && buffer[1].ToString("X2") == "00")))
// {
// //给Viz发送数据
// if (sendCommend != null)
// {
// WuMiao = false;
// sendCommend.SendViz24(TimeDataSend("0.0"));
// }
// }
// #region 同时停止
// //if (buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "00")
// //{
// // Hmiao = Hmiao.Substring(0, 1);
// // if(int.Parse(sumTwo) >= 5)
// // {
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo + "." + Hmiao;
// // txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "-.-.-.-.-.-.-.-.-" + Hmiao + "\r\n");
// // isOk = true;
// // isSum = sumTwo;
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// // }
// // }
// // else
// // {
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo;
// // txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// // }
// // }
// //}
// #endregion
// //只走时间 24秒不走
// #region MyRegion
// if ((buffer[0].ToString("X2") == "01" && buffer[1].ToString("X2") == "00") )
// {
// isOk = true;
// isSum = sumTwo;
// WuMiao = false;
// Hmiao = Hmiao.Substring(0, 1);
// if (int.Parse(sumTwo) >= 5)
// {
// if (int.Parse(Hmiao) != 0&&(!(buffer[5].ToString("X2") == "0E" || buffer[5].ToString("X2") == "18")))
// {
// sumTwo = (int.Parse(sumTwo) + 1).ToString();
// }
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----大于五秒----" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo));
// }
// }
// else
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// }
// }
// //给Viz发送数据
// //if (sendCommend != null)
// //{
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// //}
// }
// #endregion
// #endregion
// #region 状态码未改
// //if (int.Parse(sumTwo) <= 24)
// //{
// // if ((buffer[1] == 0 || buffer[1] == 21 || buffer[1] == 08) && buffer[0] == 0)
// // {
// // if (int.Parse(sumTwo) >= 5)
// // {
// // try
// // {
// // if (isOk == true && (buffer[5] == 14 || buffer[5] == 24))
// // {
// // Hmiao = Hmiao.Substring(0, 1);
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo + "." + Hmiao;
// // txt_ALL_Data.AppendText(sumTwo + "-.-.-.-.-.-.-.-.-" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// // }
// // }
// // else
// // {
// // if (isSum != int.Parse(sumTwo))
// // {
// // if (int.Parse(sumTwo) == 5)
// // {
// // if (int.Parse(Hmiao) != 0 && int.Parse(sumTwo) != 24)
// // {
// // //这里再加1发
// // string txtSum = (int.Parse(sumTwo) + 1).ToString();
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo;
// // txt_ALL_Data.AppendText(txtSum + "--------" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(txtSum));
// // }
// // isOk = false;
// // isSum = 0;
// // }
// // else
// // {
// // Hmiao = Hmiao.Substring(0, 1);
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo + "." + Hmiao;
// // txt_ALL_Data.AppendText(sumTwo + "+++++++++" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// // }
// // isOk = false;
// // isSum = 0;
// // }
// // }
// // else
// // {
// // //这里再加1发
// // string txtSum = (int.Parse(sumTwo) + 1).ToString();
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo;
// // txt_ALL_Data.AppendText(txtSum + "--------" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(txtSum));
// // }
// // isOk = false;
// // isSum = 0;
// // }
// // }
// // else
// // {
// // Hmiao = Hmiao.Substring(0, 1);
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo + "." + Hmiao;
// // txt_ALL_Data.AppendText(sumTwo + "." + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// // }
// // }
// // }
// // }
// // catch (Exception ex)
// // {
// // Console.WriteLine(ex.Message);
// // }
// // }
// // else
// // {
// // Hmiao = Hmiao.Substring(0, 1);
// // this.BeginInvoke(new EventHandler(delegate
// // {
// // txt_One_Data.Text = sumTwo + "." + Hmiao;
// // txt_ALL_Data.AppendText(sumTwo + "+.+.+.+.+.+" + Hmiao + "\r\n");
// // }));
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// // }
// // }
// // }
// // else
// // {
// // if (buffer[1] == 18 || buffer[1] == 10 || buffer[1] == 11 || buffer[1] == 14 || buffer[1] == 1)
// // {
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(" "));
// // }
// // }
// // else
// // {
// // //给Viz发送数据
// // if (sendCommend != null)
// // {
// // sendCommend.SendViz24(TimeDataSend(sumTwo));
// // isOk = true;
// // isSum = int.Parse(sumTwo);
// // }
// // }
// // }
// //}
// #endregion
//}
//else
//{
// Thread.Sleep(1);
//}
#endregion
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
LogMsg.WriteErrLogMsg("当前Receive接受出错:"+ex.Message);
this.BeginInvoke(new EventHandler(delegate
{
//txt_ALL_Data.AppendText("IP形式接受数据失败\r\n");
}));
}
}
}
Timer timerTwo = new Timer();
public void SokcetDempo()
{
string sumTwo = "0";
string Hmiao = "0";
bool WuMiao = false;
string HmiaoTwo = "0";
string JLText = "";
bool IsQP = false;
while (true)
{
try
{
#region 加队列之后处理
if (HoseQueue.Count>0)
{
byte[] buffer = new byte[20];
buffer=HoseQueue.Dequeue();
if (buffer != null)
{
sumTwo = buffer[5].ToString();
//24秒之后的毫秒
Hmiao = buffer[4].ToString();
HmiaoTwo = Hmiao;
Hmiao = Hmiao.Substring(0, 1);
JLText = "";
#region 接受16进制的状态码
//正常跑动
if ((buffer[0].ToString("X2") == "21" && buffer[1].ToString("X2") == "00") || (buffer[0].ToString("X2") == "60" && buffer[1].ToString("X2") == "00") || (buffer[0].ToString("X2") == "20" && buffer[1].ToString("X2") == "00"))
{
if(buffer[2]==0 && buffer[3] <= 24)
{
if(IsQP == true)
{
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":大时钟小于24清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
else
{
if(buffer[5] == 0)
{
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":大时钟小于24清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
else
{
if (int.Parse(sumTwo) >= 5)
{
//24
if (isSum != sumTwo && int.Parse(sumTwo) < 24)
{
if (int.Parse(sumTwo) == 5 && int.Parse(Hmiao) <= 1)
{
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----五秒----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
WuMiao = true;
}
else
{
if (WuMiao == true)
{
//什么都不干
}
else
{
if (int.Parse(HmiaoTwo) >= 10)
{
//这里再加1发
sumTwo = (int.Parse(sumTwo) + 1).ToString();
JLText = "+1 ";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----大于五秒+1----" + JLText + HmiaoTwo + "\r\n");
isOk = false;
isSum = "0";
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
}
}
}
}
else
{
if (int.Parse(HmiaoTwo) < 10)
{
Hmiao = "0";
}
WuMiao = false;
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
}
}
}
}
}
else
{
IsQP = false;
if (int.Parse(sumTwo) >= 5)
{
//24
if (isSum != sumTwo && int.Parse(sumTwo) < 24)
{
if (int.Parse(sumTwo) == 5 && int.Parse(Hmiao) <= 1)
{
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----五秒----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
WuMiao = true;
}
else
{
if (WuMiao == true)
{
//什么都不干
}
else
{
if (int.Parse(HmiaoTwo) >= 10)
{
//这里再加1发
sumTwo = (int.Parse(sumTwo) + 1).ToString();
JLText = "+1 ";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----大于五秒+1----" + JLText + HmiaoTwo + "\r\n");
isOk = false;
isSum = "0";
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
}
}
}
}
else
{
if (int.Parse(HmiaoTwo) < 10)
{
Hmiao = "0";
}
WuMiao = false;
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
}
}
}
}
//14秒和24秒复位
if (buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "00" && (buffer[5].ToString("X2") == "0E" || buffer[5].ToString("X2") == "18"))
{
WuMiao = false;
if (buffer[2] == 0 && buffer[3] <= 24 )
{
IsQP = true;
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":大时钟小于24清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
else
{
IsQP = false;
if (int.Parse(sumTwo) >= 5)
{
if (int.Parse(HmiaoTwo) >= 10)
{
//这里再加1发
sumTwo = (int.Parse(sumTwo) + 1).ToString();
JLText = "+1 ";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo + "." + Hmiao;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + " 14And24复位" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
isOk = true;
isSum = sumTwo;
}
else
{
if (int.Parse(HmiaoTwo) < 10)
{
Hmiao = "0";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒24And14----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
}
}
}
}
else if (buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "00")
{
WuMiao = false;
if (buffer[2] == 0 && buffer[3] <= 24 && buffer[5] == 0)
{
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":大时钟小于24清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
else
{
if (int.Parse(sumTwo) >= 5)
{
if (int.Parse(HmiaoTwo) >= 10)
{
//这里再加1发
sumTwo = (int.Parse(sumTwo) + 1).ToString();
JLText = "+1 ";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo + "." + Hmiao;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + JLText + sumTwo + "-.-.-.-.-.-.-.-.-" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
}
else
{
if (int.Parse(HmiaoTwo) < 10)
{
Hmiao = "0";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
}
}
}
}
//清屏
if ((buffer[0].ToString("X2") == "10" && buffer[1].ToString("X2") == "00") || ((buffer[0].ToString("X2") == "11" && buffer[1].ToString("X2") == "00") || ((buffer[0].ToString("X2") == "00" && buffer[1].ToString("X2") == "01"))))
{
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
//03 00 24秒到0时 01 00 只走时间 24秒为0时
if ((buffer[0].ToString("X2") == "03" && buffer[1].ToString("X2") == "00" && buffer[5].ToString("X2") == "00") || ((buffer[0].ToString("X2") == "01" && buffer[1].ToString("X2") == "00" && buffer[5].ToString("X2") == "00")) || ((buffer[0].ToString("X2") == "02" && buffer[1].ToString("X2") == "00")))
{
//给Viz发送数据
if (sendCommend != null)
{
WuMiao = false;
sendCommend.SendViz24(TimeDataSend("0.0"));
}
}
//只走时间 24秒不走
if ((buffer[0].ToString("X2") == "01" && buffer[1].ToString("X2") == "00"))
{
isOk = true;
isSum = sumTwo;
WuMiao = false;
if (buffer[2] == 0 && buffer[3] <= 24 )
{
this.BeginInvoke(new EventHandler(delegate
{
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":大时钟小于24清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
else
{
if (int.Parse(sumTwo) >= 5)
{
if (int.Parse(HmiaoTwo) >= 10 && !(buffer[5].ToString("X2") == "18"))
{
sumTwo = (int.Parse(sumTwo) + 1).ToString();
JLText = "+1 ";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + JLText + sumTwo + "----大于五秒只走时间 24秒不走----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo));
}
}
else
{
if (int.Parse(HmiaoTwo) < 10)
{
Hmiao = "0";
}
this.BeginInvoke(new EventHandler(delegate
{
txt_One_Data.Text = sumTwo;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + sumTwo + "----小于五秒只走时间 24秒不走----" + HmiaoTwo + "\r\n");
}));
//给Viz发送数据
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
}
}
}
//给Viz发送数据
//if (sendCommend != null)
//{
// sendCommend.SendViz24(TimeDataSend(sumTwo));
//}
}
//01 01状态码清屏
if(buffer[0].ToString("X2") == "01" && buffer[1].ToString("X2") == "01" && buffer[3]<=24)
{
this.BeginInvoke(new EventHandler(delegate
{
IsQP = true;
WuMiao = false;
txt_ALL_Data.AppendText(DateTime.Now.ToString("HH-mm-ss-fff") + ":0101状态清屏\r\n");
}));
if (sendCommend != null)
{
sendCommend.SendViz24(TimeDataSend(" "));
}
}
#endregion
}
//24秒
}
else
{
Thread.Sleep(1);
}
#endregion
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
LogMsg.WriteErrLogMsg("当前运行的逻辑进Cath:" + ex.Message);
}
}
}
#region 早先队列处理
// if (HoseQueue.Count >= 1)
// {
// if (buffer == null)
// {
// buffer = HoseQueue.Dequeue();
// }
// buffer2 = HoseQueue.Dequeue();
// if (buffer[5] != buffer2[5] && buffer[5] > 5)
// {
// if (buffer[1] == 0 || buffer[1] == 21 || buffer[1] == 08)
// {
// string sumTwo = buffer[5].ToString();
// //24秒之后的毫秒
// string Hmiao = buffer[4].ToString();
// //string str = Encoding.UTF8.GetString(buffer, 1, r - 1);
// if (int.Parse(sumTwo) >= 5)
// {
// if (buffer[0] == 0 && buffer[1] == 0 && buffer[4] == 0 || buffer[5] == 14)
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(sumTwo + "--------" + Hmiao + "\r\n");
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo));
// }
// }));
// }
// else
//{
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo;
// txt_ALL_Data.AppendText(sumTwo + "--------" + Hmiao + "\r\n");
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo));
// }
// }));
//}
// }
// }
// buffer = buffer2;
//Thread.Sleep(680);
// }
// else
//{
// string sumTwo = buffer[5].ToString();
// //24秒之后的毫秒
// string Hmiao = buffer[4].ToString();
// Hmiao = Hmiao.Substring(0, 1);
// if (int.Parse(sumTwo) < 5)
// {
// Hmiao = Hmiao.Substring(0, 1);
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = sumTwo + "." + Hmiao;
// txt_ALL_Data.AppendText(sumTwo + "." + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(sumTwo + "." + Hmiao));
// }
// }
// if (buffer[5] == 14 || buffer[5] == 24 && buffer[1] == 0)
// {
// this.BeginInvoke(new EventHandler(delegate
// {
// txt_One_Data.Text = buffer[5].ToString();
// txt_ALL_Data.AppendText(buffer[5] + "." + Hmiao + "\r\n");
// }));
// //给Viz发送数据
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(buffer[5].ToString()));
// }
// }
// buffer = buffer2;
//}
// }
// else
//{
// if (buffer != null)
// {
// if (buffer[1] == 18 || buffer[1] == 10 || buffer[1] == 11 || buffer[1] == 14 || buffer[1] == 1)
// {
// if (sendCommend != null)
// {
// sendCommend.SendViz24(TimeDataSend(""));
// }
// }
// }
// //给Viz发送数据
// //if (sendCommend != null)
// //{
// // sendCommend.SendViz24(TimeDataSend(" "));
// //}
// Thread.Sleep(1);
//}
#endregion
public void CloseSocket()
{
try
{
if (socket == null)
return;
if (!socket.Connected)
return;
try
{
socket.Shutdown(SocketShutdown.Both);
}
catch
{
}
try
{
socket.Close();
}
catch
{
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
#endregion
#region 自定义串口代码
public static SerialPort serialPort = new SerialPort();
public void setPort()
{
serialPort.PortName = com_ComName.Text;
serialPort.BaudRate = int.Parse(txt_BaudRate.Text);
if (serialPort.IsOpen == false)
{
serialPort.Open();
}
//serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived);
threadSocket = new Thread(SerialPortShow);
threadSocket.IsBackground = true;
threadSocket.Start();
threadSocket = new Thread(SokcetDempo);
threadSocket.IsBackground = true;
threadSocket.Start();
}
public void SerialPortShow()
{
serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived);
}
private void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
bool temp = false;
int tempCt = 0;
string text = "";
string strText = "";
//防止读取不全的情况 等待10ms
Thread.Sleep(10);
byte[] buffer2 = new byte[20];//获取缓冲区的的字节数
//int reslut2 = serialPort.ReadByte();
// buffer: 将输入写入到其中的字节数组。
// offset:要写入字节的 buffer 中的偏移量。
// count:最多读取的字节数。 如果 count 大于输入缓冲区中的字节数,则读取较少的字节。
int reslut = serialPort.Read(buffer2, 0, buffer2.Length);
//serialPort.ReadTo("CD");
//if (reslut <= 0)
//{
// return;
//}
//string strResult = Encoding.ASCII.GetString(m_recvBytes, 0, m_recvBytes.Length);//转换成字符串格式的
byte[] buffer = new byte[20];
for (int i = 0; i < buffer2.Length; i++)
{
try
{
if (buffer2[i].ToString("X8").Replace("0", "") == "CD")
{
if (i == 8)
{
buffer = buffer2;
for (int k = 0; k <= 8; k++)
{
try
{
text += buffer[k].ToString("X2") + " ";
strText += buffer[k].ToString() + " ";
}
catch
{
}
}
break;
}
else
{
if (!temp)
{
temp = true;
}
else
{
temp = false;
tempCt = 0;
break;
}
}
}
if (temp)
{
buffer[tempCt] = buffer2[i + 1];
tempCt++;
text += buffer2[i + 1].ToString("X2") + " ";
strText += buffer2[i + 1].ToString() + " ";
}
}
catch (Exception ex)
{
LogMsg.WriteErrLogMsg("重置接受到的字节出错:" + ex.Message);
}
}
HoseQueue.Enqueue(buffer);
this.BeginInvoke(new EventHandler(delegate
{
try
{
//string TxtPath = @"D:\txt\txt123\";
string postPath = TxtPath + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".log";
if (Directory.Exists(TxtPath) == false)
{
Directory.CreateDirectory(postPath);
}
else
{
//log.deleteLog(@"D:\txt");
using (System.IO.StreamWriter file = new System.IO.StreamWriter(postPath, true))
{
//string swTxt = BitConverter.ToString(buffer).Replace(" - ", "");
file.WriteLine(DateTime.Now.ToString("HH-mm-ss-fff") + ": " + text + " " + strText);
text = "";
strText = "";
}
}
if (txt_ALL_Data.TextLength > 20 * 10000)
{
txt_ALL_Data.Text = "";
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}));
//this.Invoke((EventHandler)(delegate
//{
// //txt_Tcp_Com.Text = m_recvBytes[4].ToString();
// txt_One_Data.Text = buffer2[5].ToString();
// txt_ALL_Data.AppendText(buffer2[5] + "\r\n");
//}));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private void but_Lock_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定要解锁吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
button1.Enabled = true;
button2.Enabled = true;
button3.Enabled = true;
but_Lock.Text = "锁住";
}
else
{
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
but_Lock.Text = "解锁";
}
}
public void ClosePort()
{
try
{
if (serialPort.IsOpen == true)
{
serialPort.Close();
}
//serialPort.DataReceived -= new SerialDataReceivedEventHandler(_serialPort_DataReceived);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
#endregion
/// <summary>
/// 发送数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_Send_Data_Click(object sender, EventArgs e)
{
SetGreen(this.but_Send_Data);
IsReceive = true;
}
Thread threadTwo;
/// <summary>
/// 停止发送
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_Stop_Data_Click(object sender, EventArgs e)
{
SetGreen(this.but_Stop_Data);
IsReceive = false;
//threadTwo = new Thread(SokcetDempo);
}
}
}
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serialPort1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 17</value>
</metadata>
</root>
\ No newline at end of file

namespace DemoTool
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(170, 239);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(170, 178);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 1;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
}
}
\ No newline at end of file
using DemoTool.Tool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DemoTool
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
Log log = new Log();
string text = "";
private void button1_Click(object sender, EventArgs e)
{
//byte[] buffer2 = { 0x01, 0x01, 0x00, 0x04, 0x05, 0x18, Convert.ToByte("AB"), Convert.ToByte("CD") };
byte[] buffer = { 32, 0, 12, 0, 0, 14,2, Convert.ToByte(171), Convert.ToByte(205) };
for (int i = 0; i <= 8; i++)
{
text+= buffer[i].ToString("X2")+" ";
}
//string time = DateTime.Now.ToString("YY-MMdd");
////string TxtPath = @"D:\txt\txt123\"+ time+".log";
//string TxtPath = @"D:\txt\txt123\";
//string postPath = TxtPath + DateTime.Now.ToString("yyyy-MMdd") + ".log";
//if (Directory.Exists(TxtPath) == false)
//{
// Directory.CreateDirectory(postPath);
//}
//else
//{
// //string postPath = TxtPath + DateTime.Now.ToString("yyyy-MMddHH") + ".txt";//路径+文件名
// log.deleteLog(@"D:\txt");
// using (System.IO.StreamWriter file = new System.IO.StreamWriter(postPath, true))
// {
// string swTxt = BitConverter.ToString(buffer).Replace(" - ", "");
// file.WriteLine(swTxt);
// }
//using (StreamWriter sw = File.AppendText(TxtPath))
//{
// string swTxt = BitConverter.ToString(buffer).Replace(" - ", "");
// //DirectoryInfo dinfo = new DirectoryInfo(@"D:\txt\");
// //DirectoryInfo dinfo2 = new DirectoryInfo(@"D:\txt");
// //FileSystemInfo[] fsin = dinfo.GetDirectories();
// //FileSystemInfo[] fsin2 = dinfo2.GetDirectories();
// log.deleteLog("D:/txt/");
// sw.WriteLine(swTxt);
//}
//}
//for (int i = 0; i < buffer.Length; i++)
//{
// if (buffer[i].ToString("X8").Replace("0", "") == "AB")
// {
// string sumTwo = buffer[i - 2].ToString();
// string Hmiao = buffer[i - 3].ToString();
// }
//}
}
}
}
<?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>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DemoTool
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DemoTool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DemoTool")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d1f85f0c-2991-48bd-acd7-952b40a30662")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace DemoTool.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("DemoTool.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;
}
}
}
}
<?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>
\ No newline at end of file
//------------------------------------------------------------------------------
// <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 DemoTool.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;
}
}
}
}
<?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>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DemoTool.Tool
{
public class Log
{
string fileName;
public void CHelpIni(string filename)
{
FileInfo fileinfo = new FileInfo(filename);
if (!fileinfo.Exists)
{
StreamWriter sw = new StreamWriter(filename, false, Encoding.UTF8);
try
{
sw.WriteLine("#config.ini");
sw.Close();
}
catch
{
throw new ApplicationException("Ini文件不存在");
}
}
fileName = fileinfo.FullName;
}
static Thread threadLog;
public void deleteLog(object pathName)
{
var path = pathName as string;
int days = 2;
if (days < 1)
{
return;
}
List<String> listSave = new List<String>();//保存时间的字符串日期关键部分
            int saveDays = 0;//要保存的天数0
            for (int i = 0; i < days; i++)
{
listSave.Add("-" + DateTime.Now.AddDays(saveDays).ToString("MMdd"));//把要保存的日期添加进去
                saveDays--;//向后推移。
            }
listSave.RemoveAt(0);
//获取根目录下的所有文件夹
DirectoryInfo dinfo = new DirectoryInfo(path);
List<String> listAll = new List<string>();
FileSystemInfo[] fsin = dinfo.GetDirectories();
foreach (FileSystemInfo item in fsin)
{
listAll.Add(item.FullName);
}
for (int i = 0; i < listAll.Count; i++)
{
DirectoryInfo cdinfo = new DirectoryInfo(listAll[i]);
FileSystemInfo[] cfsin = cdinfo.GetFiles();
foreach (FileSystemInfo item in cfsin)
{
try
{
if (item.Name.Contains("log"))
{
bool result = false;
for (int j = 0; j < listSave.Count; j++)
{
if (item.FullName.Contains(listSave[j]))
{
result = true;//代表此日志需要保存
}
}
if (result)
{
//代表此日志需要删除
FileInfo file = new FileInfo(item.FullName);
file.Delete();
}
}
}
catch (Exception)
{
}
}
}
}
//public static void DeleteLog(object path)
//{
// if (threadLog != null)
// {
// try
// {
// threadLog.Abort();
// }
// catch (Exception)
// {
// }
// finally
// {
// threadLog = null;
// }
// }
// threadLog = new Thread(deleteLog);
// threadLog.IsBackground = true;
// threadLog.Start(path);
//}
}
}
using DllToolLib;
using ErrMsg;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoTool.Tool
{
public class LogMsg
{
public static void WriteErrLogMsg(string msg)
{
try
{
//string path = string.Format("{0}\\err_{1}.log", ConfigurationManager.AppSettings["LogPath"].ToString(), DateTime.Now.ToString("yyyyMMdd"));
string path = string.Format("{0}\\err_{1}.log", ConfigurationManager.AppSettings["LogPath"].ToString(), DateTime.Now.ToString("yyyyMMdd"));
string log_item = string.Format("{0}: {1}", DateTime.Now.ToString("hh:mm:ss"), "ChineseBridgeSystem、" + msg + "\r\n");
DebugEventArgs d1 = new DebugEventArgs(DebugType.err, "DemoTool24S、" + msg);
//Debug.OnRetrunDebug(d1);
FileIO.WriteTextFile(log_item, path, true, Encoding.UTF8);
}
catch (Exception ex)
{
; Console.WriteLine(ex.Message);
}
}
public static void WriteDataLogMsg(string data, string msg)
{
try
{
string path = string.Format("{0}\\{1}data_{2}.log", ConfigurationManager.AppSettings["DataPath"].ToString(), data, DateTime.Now.ToString("yyyyMMdd"));
string log_item = string.Format("{0}: {1}", DateTime.Now.ToString("hh:mm:ss"), "ChineseBridgeSystem、" + msg + "\r\n");
DebugEventArgs d1 = new DebugEventArgs(DebugType.err, "ChineseBridgeSystem、" + msg);
//Debug.OnRetrunDebug(d1);
FileIO.WriteTextFile(log_item, path, true, Encoding.UTF8);
}
catch (Exception ex)
{
; Console.WriteLine(ex.Message);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DemoTool.Tool
{
public class TcpTool
{
Socket socket; //定义一个Socket
public void SokcetCliet(string ip,string com)
{
try
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(IPAddress.Parse(ip), int.Parse(com));
ThreadPool.QueueUserWorkItem(OnSendOrReceive, socket);
//this.but_Client.Enabled = false;
//button1.Enabled = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
//ShowMsg("连接成功");
}
private void OnSendOrReceive(object sk)
{
var socket = sk as Socket;
while (true)
{
try
{
//客户端连接成功后,服务器应该接受客户端发来的消息
byte[] buffer = new byte[1024 * 1024 * 5];
//char[] vs = new char[1024 * 1024 * 5];
//实际接收到的字节数组
int r = socket.Receive(buffer);
if (r == 0)
{
break;
}
if (buffer[0] == 0)
{
//Encoding.ASCII.GetBytes(vs, 1, r - 1);
string str = Encoding.UTF8.GetString(buffer, 1, r - 1);
//ShowMsg(socket.RemoteEndPoint + ":" + str);
}
else if (buffer[1] == 1)
{
SaveFileDialog save = new SaveFileDialog();
save.InitialDirectory = @"C:\Users\18502\Desktop";
save.Title = "请选择要保存的文件";
save.Filter = "所有文件|*.*";
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
// public class Time
// {
// namespace MyTimerDemo
// {
// public partial class Form1 : Form
// {
// #region 私有变量 定义
// /// <summary>
// /// 记录每次启动定时器的时间
// /// </summary>
// private DateTime startTime;
// /// <summary>
// /// 定时器已走时间
// /// </summary>
// private TimeSpan span;
// /// <summary>
// /// 记录每次暂停时定时器已走时间
// /// </summary>
// private TimeSpan pauseSpan;
// /// <summary>
// /// 时间(秒)
// /// </summary>
// private int time;
// /// <summary>
// /// 是否倒计时
// /// </summary>
// private bool bDown;
// /// <summary>
// /// 误差测试临时变量
// /// </summary>
// private int iCount = 0;
// #endregion
// public Form1()
// {
// InitializeComponent();
// timer1.Interval = 1; //每毫秒执行一次
// time = 0; //初始化时间
// //倒计时设定,如果时间为0则正计时,否则倒计时
// if (time == 0)
// {
// bDown = false;
// }
// else
// {
// bDown = true;
// }
// label1.Text = string.Format("00:00:{0}:000", time.ToString("00"));
// label2.Text = time.ToString("00");
// }
// /// <summary>
// /// 开始/暂停
// /// </summary>
// private void btnStartPause_Click(object sender, EventArgs e)
// {
// timer1.Enabled = !timer1.Enabled;
// if (timer1.Enabled) //开始
// {
// btnStartPause.Text = "Pause";
// //启动定时器,务必修改启动时间
// startTime = DateTime.Now;
// }
// else //暂停
// {
// btnStartPause.Text = "Start";
// //暂停,记录定时器当前已走时间
// pauseSpan = span;
// }
// }
// /// <summary>
// /// 停止定时器
// /// </summary>
// private void btnStop_Click(object sender, EventArgs e)
// {
// timer1.Enabled = false;
// btnStartPause.Enabled = true;
// btnStartPause.Text = "Start";
// pauseSpan = new TimeSpan(0); //将上次暂停 记录的已走时间清零
// label1.Text = string.Format("00:00:{0}:000", time.ToString("00"));
// label2.Text = time.ToString("00");
// }
// private void timer1_Tick(object sender, EventArgs e)
// {
// //刷新定时器已走时间
// //注意务必加上 上次暂停记录的已走时间
// span = (DateTime.Now - startTime).Add(pauseSpan);
// if (bDown) //倒计时
// {
// //若时间倒到0,定时器停止工作
// if (span.Ticks >= time * TimeSpan.TicksPerSecond)
// {
// btnStartPause.Enabled = false;
// timer1.Enabled = false;
// }
// else
// {
// DateTime spanDt = new DateTime(
// time * TimeSpan.TicksPerSecond - span.Ticks);
// label1.Text = spanDt.ToString("HH:mm:ss:fff");
// label2.Text = (time - span.TotalSeconds).ToString("00");
// }
// }
// else //正计时
// {
// DateTime spanDt = new DateTime(span.Ticks);
// label1.Text = spanDt.ToString("HH:mm:ss:fff");
// label2.Text = span.TotalSeconds.ToString("00");
// //误差测试,在正计时进行 --> 简单、方便:)
// iCount += timer1.Interval;
// label3.Text = (iCount / 1000).ToString("00");
// }
// }
// }
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VizConnectC;
namespace DemoTool.Tool
{
/// <summary>
/// 表示vs与viz的一些联系操作
/// </summary>
class VizCommand
{
//实例化列表
public List<VizEnginePool> _poolList = new List<VizEnginePool>();
public List<bool> IsConnectVizList = new List<bool>();
public List<string> EnableIPList = new List<string>();
public VizEnginePool vizEnginePool = new VizEnginePool();
public string EnbleIPOne;
public bool IsConnectVizOne;
/// <summary>
/// 主备连接Viz
/// hostList表示连接的引擎的列表
/// </summary>
public void ConnectViz(List<string> IPlist)
{
_poolList.Clear();
EnableIPList.Clear();
//遍历
for (int i = 0; i < IPlist.Count; i++)
{
VizEnginePool _pool = new VizEnginePool();
bool IsConnectViz = false;//别处用来判断是否与引擎处于连接状态
_pool.Disconnect();
_pool.CleanRendererList();
_pool.AddRenderer(IPlist[i], 6100);
if (_pool.Connect())
{
IsConnectViz = true;
IsConnectVizOne = true;
EnableIPList.Add(IPlist[i]);
}
else
{
IsConnectViz = false;
}
IsConnectVizList.Add(IsConnectViz);
_poolList.Add(_pool);
}
}
/// <summary>
/// 单个连接Viz
/// hostList表示连接的引擎的列表
/// </summary>
public void ConnectOneViz(string IPlist)
{
//VizEnginePool _pool = new VizEnginePool();
bool IsConnectViz = false;//别处用来判断是否与引擎处于连接状态
vizEnginePool.Disconnect();
vizEnginePool.CleanRendererList();
vizEnginePool.AddRenderer(IPlist, 6100);
if (vizEnginePool.Connect())
{
IsConnectViz = true;
}
else
{
IsConnectViz = false;
}
IsConnectVizOne = IsConnectViz;
}
/// <summary>
/// 下场动画
/// </summary>
public void Continue()
{
for (int i = 0; i < _poolList.Count; i++)
{
if (_poolList[i].IsConnected)
{
_poolList[i].Send("RENDERER*STAGE CONTINUE");//播放动画
}
}
}
//加载场景发送数据
public void SendViz24(string data)
{
for (int i = 0; i < _poolList.Count; i++)
{
try
{
if (_poolList[i].IsConnected)
{
_poolList[i].Send("RENDERER SET_OBJECT SCENE*Arena/Scenes/VizArenaMain");
_poolList[i].Send("RENDERER*SCRIPT INVOKE Data " + "\"" + data + "\"");
//_poolList[i].Send("RENDERER*SCRIPT INVOKE GuangGao " + guangGaoPath);
//_poolList[i].Send("RENDERER*STAGE START");//播放动画
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
/// <summary>
/// 只发数据
/// </summary>
/// <param name="data"></param>
public void SendViz24Two(string data)
{
for (int i = 0; i < _poolList.Count; i++)
{
if (_poolList[i].IsConnected)
{
_poolList[i].Send("RENDERER*SCRIPT INVOKE Data " + "\"" + data + "\"");
}
}
}
}
}
{
"StudentInfo" :[
{
"uid": 19,
"nickname": "莫珉豪",
"score": 218,
"nationality": "波兰赛区",
"zone": "北京赛区",
"weigh": 1,
"rise": 1,
"rank": 1
},
{
"uid": 2,
"nickname": "丽莎",
"score": 222,
"nationality": "塔吉克斯坦赛区",
"zone": "北京赛区",
"weigh": 2,
"rise": 1,
"rank": 2
},
{
"uid": 3,
"nickname": "阮氏河银",
"score": 231,
"nationality": "越南-河内赛区",
"zone": "北京赛区",
"weigh": 3,
"rise": 1,
"rank": 3
},
{
"uid": 26,
"nickname": "高孜凯",
"score": 185,
"nationality": "美国-纽约赛区",
"zone": "北京赛区",
"weigh": 4,
"rise": 1,
"rank": 4
},
{
"uid": 24,
"nickname": "齐乐",
"score": 205,
"nationality": "巴西赛区",
"zone": "北京赛区",
"weigh": 5,
"rise": 0,
"rank": 5
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment