替换日志,日志写入文件
This commit is contained in:
84
精工涂胶检测项目/CVE.LogViewer/CVE.LogViewer.csproj
Normal file
84
精工涂胶检测项目/CVE.LogViewer/CVE.LogViewer.csproj
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{766CF29F-3629-470A-AEC7-D2AEAD685484}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CVE.LogViewer</RootNamespace>
|
||||
<AssemblyName>CVE.LogViewer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataGridViewAppender.cs" />
|
||||
<Compile Include="Helper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="LogConfig.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
144
精工涂胶检测项目/CVE.LogViewer/DataGridViewAppender.cs
Normal file
144
精工涂胶检测项目/CVE.LogViewer/DataGridViewAppender.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using log4net.Appender;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CVE.LogViewer
|
||||
{
|
||||
class DataGridViewAppender : AppenderSkeleton
|
||||
{
|
||||
private DataGridView _dataGridView;
|
||||
public DataGridView AppenderControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataGridView;
|
||||
}
|
||||
set
|
||||
{
|
||||
_dataGridView = value;
|
||||
}
|
||||
}
|
||||
public string FormName { get; set; }
|
||||
public string ListViewName { get; set; }
|
||||
/// <summary>
|
||||
/// 查找控件
|
||||
/// </summary>
|
||||
/// <param name="root"></param>
|
||||
/// <param name="ListViewName"></param>
|
||||
/// <returns></returns>
|
||||
private Control FindControlRecursive(Control root, string ListViewName)
|
||||
{
|
||||
if (root.Name == ListViewName) return root;
|
||||
foreach (Control c in root.Controls)
|
||||
{
|
||||
Control t = FindControlRecursive(c, ListViewName);
|
||||
if (t != null) return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示日志
|
||||
/// </summary>
|
||||
/// <param name="loggingEvent"></param>
|
||||
protected override void Append(log4net.Core.LoggingEvent loggingEvent)
|
||||
{
|
||||
//验证控件是否存在
|
||||
if (_dataGridView == null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(FormName) ||
|
||||
String.IsNullOrEmpty(ListViewName))
|
||||
return;
|
||||
|
||||
Form form = Application.OpenForms[FormName];
|
||||
if (form == null)
|
||||
return;
|
||||
|
||||
_dataGridView = (DataGridView)FindControlRecursive(form, ListViewName);
|
||||
|
||||
_dataGridView.Invoke(new Action(() =>
|
||||
{
|
||||
_dataGridView.Rows.Clear();
|
||||
DataGridViewTextBoxColumn logInfo = new DataGridViewTextBoxColumn();
|
||||
logInfo.Name = "Log Info";
|
||||
logInfo.DataPropertyName = "Log Info";
|
||||
logInfo.HeaderText = "Log Info";
|
||||
_dataGridView.Columns.Add(logInfo);
|
||||
_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
//设置自动换行
|
||||
_dataGridView.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
|
||||
//设置自动调整高度
|
||||
_dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
||||
_dataGridView.RowHeadersVisible = false;
|
||||
_dataGridView.ColumnHeadersVisible = false;
|
||||
_dataGridView.AllowDrop = false;
|
||||
_dataGridView.AllowUserToAddRows = false;
|
||||
_dataGridView.AllowUserToDeleteRows = false;
|
||||
_dataGridView.AllowUserToOrderColumns = false;
|
||||
_dataGridView.AllowUserToResizeColumns = false;
|
||||
_dataGridView.AllowUserToResizeRows = false;
|
||||
_dataGridView.MultiSelect = false;
|
||||
_dataGridView.ReadOnly = true;
|
||||
_dataGridView.CellBorderStyle = DataGridViewCellBorderStyle.None;
|
||||
if (_dataGridView == null)
|
||||
return;
|
||||
|
||||
form.FormClosing += (s, e) => _dataGridView = null;
|
||||
}));
|
||||
}
|
||||
if (!_dataGridView.IsHandleCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dataGridView.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//显示日志
|
||||
string str = String.Format("{0} {1}", loggingEvent.TimeStamp.ToString("yyyy/MM/dd HH:mm:ss.fff"), RenderLoggingEvent(loggingEvent));
|
||||
string level = loggingEvent.Level.ToString();
|
||||
|
||||
_dataGridView.BeginInvoke((MethodInvoker)delegate
|
||||
{
|
||||
//日志行数控制
|
||||
if (_dataGridView.Rows.Count > 500)
|
||||
{
|
||||
//大于200行清空显示
|
||||
_dataGridView.Rows.Clear();
|
||||
}
|
||||
DataGridViewRow row = new DataGridViewRow();
|
||||
|
||||
DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
|
||||
cell.Value = str;
|
||||
//根据等级控制显示颜色
|
||||
switch (level)
|
||||
{
|
||||
case "DEBUG":
|
||||
cell.Style.ForeColor = Color.Blue; //DarkBlue;
|
||||
break;
|
||||
case "INFO":
|
||||
cell.Style.ForeColor = Color.Black; //ForestGreen;
|
||||
break;
|
||||
case "WARN":
|
||||
cell.Style.ForeColor = Color.Orange;
|
||||
break;
|
||||
case "ERROR":
|
||||
cell.Style.ForeColor = Color.MediumVioletRed;
|
||||
break;
|
||||
case "FATAL":
|
||||
cell.Style.ForeColor = Color.Red;
|
||||
break;
|
||||
}
|
||||
row.Cells.Add(cell);
|
||||
//控制每次显示最新行
|
||||
_dataGridView.Rows.Add(row);
|
||||
_dataGridView.FirstDisplayedScrollingRowIndex = _dataGridView.Rows.Count - 1;
|
||||
_dataGridView.ClearSelection();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
54
精工涂胶检测项目/CVE.LogViewer/Helper.cs
Normal file
54
精工涂胶检测项目/CVE.LogViewer/Helper.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
namespace CVE.LogViewer
|
||||
{
|
||||
public class Helper
|
||||
{
|
||||
private const string FileName = "LogConfig.xml";
|
||||
public Stream GetXMLStream(string ConfigDir)
|
||||
{
|
||||
if (!System.IO.Directory.Exists(ConfigDir))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(ConfigDir);//不存在就创建目录
|
||||
}
|
||||
|
||||
string ConfigPath = ConfigDir + "\\" + FileName;
|
||||
//判断本地是否存在配置文件
|
||||
if (File.Exists(ConfigPath))
|
||||
{
|
||||
//导入本地配置文件
|
||||
Stream stream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read);
|
||||
return stream;
|
||||
}
|
||||
else
|
||||
{
|
||||
//载入程序集中配置文件
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var stream = assembly.GetManifestResourceStream(this.GetType(), FileName);
|
||||
try
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new FileNotFoundException("Could not find embedded mappings resource file.", FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//将默认配置文件保存至指定目录
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(stream);
|
||||
doc.Save(ConfigPath);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
精工涂胶检测项目/CVE.LogViewer/LogConfig.xml
Normal file
42
精工涂胶检测项目/CVE.LogViewer/LogConfig.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
|
||||
</configSections>
|
||||
<log4net>
|
||||
<root>
|
||||
<level value="ALL"/>
|
||||
<!---日志级别 从低到高 ALL DEBUG INFO WARN ERROR FATAL None-->
|
||||
<appender-ref ref="RollingLogFileAppender"/>
|
||||
<appender-ref ref="DataGridViewAppender" />
|
||||
</root>
|
||||
<!-- name属性指定其名称,type则是log4net.Appender命名空间的一个类的名称,意思是指定使用哪种介质-->
|
||||
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="Log\\"/>
|
||||
<!-- 输出到什么目录-->
|
||||
<appendToFile value="true"/>
|
||||
<!-- 是否到附加到文件中-->
|
||||
<rollingStyle value="Date"/>
|
||||
<!-- 文件创建方式,以日期的方式记录-->
|
||||
<datePattern value="'Log_'yyyy-MM-dd".txt""/>
|
||||
<!-- 文件格式-->
|
||||
<staticLogFileName value="false"/>
|
||||
<!--否采用静态文件名,文件名是否唯一-->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!---日志内容布局-->
|
||||
<param name="ConversionPattern" value="%date %-5level %message%newline"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<!---listView日志显示-->
|
||||
<appender name="DataGridViewAppender" type="CVE.LogViewer.DataGridViewAppender, CVE.LogViewer">
|
||||
<formName value="FrmMain"/>
|
||||
<listViewName value="dgv_Log"/>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="- %message" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4net>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
36
精工涂胶检测项目/CVE.LogViewer/Properties/AssemblyInfo.cs
Normal file
36
精工涂胶检测项目/CVE.LogViewer/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("CVE.LogViewer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CVE.LogViewer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("766cf29f-3629-470a-aec7-d2aead685484")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
32444
精工涂胶检测项目/CVE.LogViewer/lib/log4net.xml
Normal file
32444
精工涂胶检测项目/CVE.LogViewer/lib/log4net.xml
Normal file
File diff suppressed because it is too large
Load Diff
4
精工涂胶检测项目/CVE.LogViewer/packages.config
Normal file
4
精工涂胶检测项目/CVE.LogViewer/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.14" targetFramework="net471" />
|
||||
</packages>
|
||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.14.36109.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "精工涂胶检测项目", "精工涂胶检测项目\精工涂胶检测项目.csproj", "{10C424D2-36A1-4D94-A034-A6801A1B17B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CVE.LogViewer", "CVE.LogViewer\CVE.LogViewer.csproj", "{766CF29F-3629-470A-AEC7-D2AEAD685484}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -27,6 +29,18 @@ Global
|
||||
{10C424D2-36A1-4D94-A034-A6801A1B17B5}.Release|x64.Build.0 = Release|x64
|
||||
{10C424D2-36A1-4D94-A034-A6801A1B17B5}.Release|x86.ActiveCfg = Release|x86
|
||||
{10C424D2-36A1-4D94-A034-A6801A1B17B5}.Release|x86.Build.0 = Release|x86
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|x64.Build.0 = Debug|x64
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|x64.ActiveCfg = Release|x64
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|x64.Build.0 = Release|x64
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{766CF29F-3629-470A-AEC7-D2AEAD685484}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace 精工涂胶检测项目
|
||||
try
|
||||
{
|
||||
// 获取主窗体的 TCP 实例
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null) return;
|
||||
|
||||
TCPClass tcp = mainForm.myTcp; // ✅ 使用同一实例
|
||||
@@ -53,7 +53,7 @@ namespace 精工涂胶检测项目
|
||||
|
||||
private async void btn_PLCConfirm_Click(object sender, EventArgs e)
|
||||
{
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null)
|
||||
{
|
||||
MessageBox.Show("无法找到主窗体");
|
||||
@@ -76,7 +76,7 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mainForm.AddLog($"PLC连接失败: {ex.Message}", 2);
|
||||
//mainForm.AddLog($"PLC连接失败: {ex.Message}", 2);
|
||||
MessageBox.Show($"PLC连接失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace 精工涂胶检测项目
|
||||
private void FormCommunication_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
// 获取主窗体的 TCP 实例
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null) return;
|
||||
|
||||
TCPClass tcp = mainForm.myTcp; // ✅ 使用同一实例
|
||||
@@ -132,7 +132,7 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
|
||||
// 获取主窗体实例并更新配置
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm != null)
|
||||
{
|
||||
mainForm.modbusClient = new ModbusTcpClient(txb_ModbusTcpIP.Text, port);
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
public int Status = 0;
|
||||
public string account;
|
||||
private Form1 formMain;
|
||||
public FormLogin(Form1 formMain1)
|
||||
private FrmMain formMain;
|
||||
public FormLogin(FrmMain formMain1)
|
||||
{
|
||||
InitializeComponent();
|
||||
formMain = formMain1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace 精工涂胶检测项目
|
||||
{
|
||||
partial class Form1
|
||||
partial class FrmMain
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
@@ -29,10 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.tlp_MainContainer = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.label34 = new System.Windows.Forms.Label();
|
||||
this.label33 = new System.Windows.Forms.Label();
|
||||
this.pnl_LeftContainer1 = new System.Windows.Forms.Panel();
|
||||
this.lbl_ProductName = new System.Windows.Forms.Label();
|
||||
@@ -48,6 +48,7 @@
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.pnl_BottomContainer = new System.Windows.Forms.Panel();
|
||||
this.dgv_Log = new System.Windows.Forms.DataGridView();
|
||||
this.lvw_Log = new System.Windows.Forms.ListView();
|
||||
this.InfoTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.Information = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
@@ -56,6 +57,7 @@
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.pnl_MiddleContainer1 = new System.Windows.Forms.Panel();
|
||||
this.cogRecordDisplay1 = new Cognex.VisionPro.CogRecordDisplay();
|
||||
this.label34 = new System.Windows.Forms.Label();
|
||||
this.pnl_MiddleContainer2 = new System.Windows.Forms.Panel();
|
||||
this.cog3DDisplayV2WF1 = new Cognex.VisionPro3D.Cog3DDisplayV2WF();
|
||||
this.pnl_RightContainer1 = new System.Windows.Forms.Panel();
|
||||
@@ -115,6 +117,7 @@
|
||||
this.tlp_MainContainer.SuspendLayout();
|
||||
this.pnl_LeftContainer1.SuspendLayout();
|
||||
this.pnl_BottomContainer.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgv_Log)).BeginInit();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.pnl_MiddleContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.cogRecordDisplay1)).BeginInit();
|
||||
@@ -163,19 +166,6 @@
|
||||
this.tlp_MainContainer.Size = new System.Drawing.Size(1350, 722);
|
||||
this.tlp_MainContainer.TabIndex = 20;
|
||||
//
|
||||
// label34
|
||||
//
|
||||
this.label34.AutoSize = true;
|
||||
this.label34.BackColor = System.Drawing.Color.Lime;
|
||||
this.tlp_MainContainer.SetColumnSpan(this.label34, 2);
|
||||
this.label34.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label34.Location = new System.Drawing.Point(498, 492);
|
||||
this.label34.Name = "label34";
|
||||
this.label34.Size = new System.Drawing.Size(849, 40);
|
||||
this.label34.TabIndex = 54;
|
||||
this.label34.Text = "暂无异常";
|
||||
this.label34.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// label33
|
||||
//
|
||||
this.label33.AutoSize = true;
|
||||
@@ -367,6 +357,7 @@
|
||||
//
|
||||
this.pnl_BottomContainer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.tlp_MainContainer.SetColumnSpan(this.pnl_BottomContainer, 4);
|
||||
this.pnl_BottomContainer.Controls.Add(this.dgv_Log);
|
||||
this.pnl_BottomContainer.Controls.Add(this.lvw_Log);
|
||||
this.pnl_BottomContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pnl_BottomContainer.Location = new System.Drawing.Point(1, 533);
|
||||
@@ -375,6 +366,36 @@
|
||||
this.pnl_BottomContainer.Size = new System.Drawing.Size(1348, 188);
|
||||
this.pnl_BottomContainer.TabIndex = 0;
|
||||
//
|
||||
// dgv_Log
|
||||
//
|
||||
this.dgv_Log.AllowUserToAddRows = false;
|
||||
this.dgv_Log.AllowUserToDeleteRows = false;
|
||||
this.dgv_Log.AllowUserToResizeColumns = false;
|
||||
this.dgv_Log.AllowUserToResizeRows = false;
|
||||
this.dgv_Log.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dgv_Log.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
|
||||
this.dgv_Log.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dgv_Log.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
|
||||
this.dgv_Log.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgv_Log.ColumnHeadersVisible = false;
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.dgv_Log.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.dgv_Log.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dgv_Log.Location = new System.Drawing.Point(0, 0);
|
||||
this.dgv_Log.MultiSelect = false;
|
||||
this.dgv_Log.Name = "dgv_Log";
|
||||
this.dgv_Log.ReadOnly = true;
|
||||
this.dgv_Log.RowHeadersVisible = false;
|
||||
this.dgv_Log.RowTemplate.Height = 23;
|
||||
this.dgv_Log.Size = new System.Drawing.Size(1346, 186);
|
||||
this.dgv_Log.TabIndex = 17;
|
||||
//
|
||||
// lvw_Log
|
||||
//
|
||||
this.lvw_Log.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
@@ -393,6 +414,7 @@
|
||||
this.lvw_Log.TabIndex = 16;
|
||||
this.lvw_Log.UseCompatibleStateImageBehavior = false;
|
||||
this.lvw_Log.View = System.Windows.Forms.View.Details;
|
||||
this.lvw_Log.Visible = false;
|
||||
//
|
||||
// InfoTime
|
||||
//
|
||||
@@ -457,6 +479,19 @@
|
||||
this.cogRecordDisplay1.Size = new System.Drawing.Size(301, 488);
|
||||
this.cogRecordDisplay1.TabIndex = 3;
|
||||
//
|
||||
// label34
|
||||
//
|
||||
this.label34.AutoSize = true;
|
||||
this.label34.BackColor = System.Drawing.Color.Lime;
|
||||
this.tlp_MainContainer.SetColumnSpan(this.label34, 2);
|
||||
this.label34.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label34.Location = new System.Drawing.Point(498, 492);
|
||||
this.label34.Name = "label34";
|
||||
this.label34.Size = new System.Drawing.Size(849, 40);
|
||||
this.label34.TabIndex = 54;
|
||||
this.label34.Text = "暂无异常";
|
||||
this.label34.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// pnl_MiddleContainer2
|
||||
//
|
||||
this.pnl_MiddleContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
@@ -883,7 +918,7 @@
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.96633F));
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.1384F));
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 36.84211F));
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 126F));
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 131F));
|
||||
this.tableLayoutPanel3.Controls.Add(this.label18, 1, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label19, 2, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label65, 3, 0);
|
||||
@@ -905,9 +940,9 @@
|
||||
this.label18.AutoSize = true;
|
||||
this.label18.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||
this.label18.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label18.Location = new System.Drawing.Point(124, 0);
|
||||
this.label18.Location = new System.Drawing.Point(123, 0);
|
||||
this.label18.Name = "label18";
|
||||
this.label18.Size = new System.Drawing.Size(128, 226);
|
||||
this.label18.Size = new System.Drawing.Size(126, 226);
|
||||
this.label18.TabIndex = 2;
|
||||
this.label18.Text = "相机测量结果";
|
||||
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -918,9 +953,9 @@
|
||||
this.label19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
|
||||
this.label19.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label19.ForeColor = System.Drawing.Color.Black;
|
||||
this.label19.Location = new System.Drawing.Point(258, 0);
|
||||
this.label19.Location = new System.Drawing.Point(255, 0);
|
||||
this.label19.Name = "label19";
|
||||
this.label19.Size = new System.Drawing.Size(143, 226);
|
||||
this.label19.Size = new System.Drawing.Size(141, 226);
|
||||
this.label19.TabIndex = 3;
|
||||
this.label19.Text = "合格范围";
|
||||
this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -930,9 +965,9 @@
|
||||
this.label65.AutoSize = true;
|
||||
this.label65.BackColor = System.Drawing.Color.Yellow;
|
||||
this.label65.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label65.Location = new System.Drawing.Point(407, 0);
|
||||
this.label65.Location = new System.Drawing.Point(402, 0);
|
||||
this.label65.Name = "label65";
|
||||
this.label65.Size = new System.Drawing.Size(122, 226);
|
||||
this.label65.Size = new System.Drawing.Size(127, 226);
|
||||
this.label65.TabIndex = 47;
|
||||
this.label65.Text = "结果对比";
|
||||
this.label65.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -952,9 +987,9 @@
|
||||
this.label80.AutoSize = true;
|
||||
this.label80.BackColor = System.Drawing.Color.Yellow;
|
||||
this.label80.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label80.Location = new System.Drawing.Point(407, 226);
|
||||
this.label80.Location = new System.Drawing.Point(402, 226);
|
||||
this.label80.Name = "label80";
|
||||
this.label80.Size = new System.Drawing.Size(122, 226);
|
||||
this.label80.Size = new System.Drawing.Size(127, 226);
|
||||
this.label80.TabIndex = 62;
|
||||
this.label80.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
@@ -963,9 +998,9 @@
|
||||
this.label64.AutoSize = true;
|
||||
this.label64.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
|
||||
this.label64.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label64.Location = new System.Drawing.Point(258, 226);
|
||||
this.label64.Location = new System.Drawing.Point(255, 226);
|
||||
this.label64.Name = "label64";
|
||||
this.label64.Size = new System.Drawing.Size(143, 226);
|
||||
this.label64.Size = new System.Drawing.Size(141, 226);
|
||||
this.label64.TabIndex = 46;
|
||||
this.label64.Text = "74770~75008mm³";
|
||||
this.label64.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -975,9 +1010,9 @@
|
||||
this.label54.AutoSize = true;
|
||||
this.label54.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||
this.label54.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label54.Location = new System.Drawing.Point(124, 226);
|
||||
this.label54.Location = new System.Drawing.Point(123, 226);
|
||||
this.label54.Name = "label54";
|
||||
this.label54.Size = new System.Drawing.Size(128, 226);
|
||||
this.label54.Size = new System.Drawing.Size(126, 226);
|
||||
this.label54.TabIndex = 36;
|
||||
this.label54.Text = "0";
|
||||
this.label54.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -1080,7 +1115,7 @@
|
||||
this.退出登录ToolStripMenuItem.Text = "退出登录";
|
||||
this.退出登录ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
|
||||
//
|
||||
// Form1
|
||||
// FrmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@@ -1089,7 +1124,7 @@
|
||||
this.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.MinimumSize = new System.Drawing.Size(800, 600);
|
||||
this.Name = "Form1";
|
||||
this.Name = "FrmMain";
|
||||
this.Text = "OP30工位视觉涂胶检测系统";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
@@ -1100,6 +1135,7 @@
|
||||
this.pnl_LeftContainer1.ResumeLayout(false);
|
||||
this.pnl_LeftContainer1.PerformLayout();
|
||||
this.pnl_BottomContainer.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgv_Log)).EndInit();
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.pnl_MiddleContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.cogRecordDisplay1)).EndInit();
|
||||
@@ -1201,6 +1237,7 @@
|
||||
private System.Windows.Forms.Panel pnl_MiddleContainer1;
|
||||
private System.Windows.Forms.Panel pnl_MiddleContainer2;
|
||||
private System.Windows.Forms.Panel pnl_RightContainer1;
|
||||
private System.Windows.Forms.DataGridView dgv_Log;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@ using Cognex.VisionPro.QuickBuild;
|
||||
using Cognex.VisionPro.ToolBlock;
|
||||
using Cognex.VisionPro.ToolGroup;
|
||||
using Cognex.VisionPro3D;
|
||||
using HslCommunication.LogNet;
|
||||
using HslCommunication.Profinet.Knx;
|
||||
using log4net;
|
||||
using Microsoft.Office.Interop;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using S7.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -26,17 +29,19 @@ using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using Excel = Microsoft.Office.Interop.Excel;
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【BEGIN】
|
||||
//using Timer = System.Windows.Forms.Timer;
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【END】
|
||||
using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using Excel = Microsoft.Office.Interop.Excel;
|
||||
namespace 精工涂胶检测项目
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class FrmMain : Form
|
||||
{
|
||||
private ILog log = log4net.LogManager.GetLogger(typeof(FrmMain));
|
||||
|
||||
public TCPClass myTcp { get; private set; } // 公开属性
|
||||
string nowTimeYear = DateTime.Now.ToString("yyyy");
|
||||
string nowTimeMonth = DateTime.Now.ToString("MM");
|
||||
@@ -164,7 +169,7 @@ namespace 精工涂胶检测项目
|
||||
/// <summary>
|
||||
/// 主程序加载
|
||||
/// </summary>
|
||||
public Form1()
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
//InitComponent();
|
||||
@@ -194,12 +199,26 @@ namespace 精工涂胶检测项目
|
||||
catch (Exception ex)
|
||||
{
|
||||
string exe = ex.Message;
|
||||
AddLog("程序异常", 1);
|
||||
//AddLog("程序异常", 1);
|
||||
log.Error("程序异常");
|
||||
}
|
||||
modbusClient = new ModbusTcpClient("", 502); // 临时初始化
|
||||
|
||||
}
|
||||
|
||||
private void InitializeLogger()
|
||||
{
|
||||
try
|
||||
{
|
||||
CVE.LogViewer.Helper lib = new CVE.LogViewer.Helper();
|
||||
log4net.Config.XmlConfigurator.Configure(lib.GetXMLStream(AppDomain.CurrentDomain.BaseDirectory));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"配置日志出错:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
//private void InitComponent()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
@@ -214,6 +233,8 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeLogger();
|
||||
|
||||
HslCommunication.Authorization.SetAuthorizationCode("163b691b-ba10-44a1-9070-cac594d67965");
|
||||
Label数据重置();
|
||||
按钮使能初始化();
|
||||
@@ -226,11 +247,13 @@ namespace 精工涂胶检测项目
|
||||
//await Tcp自动重连();
|
||||
Modbus事件注册();
|
||||
await Modbus自动连接();
|
||||
AddLog("系统启动完成", 0);
|
||||
//AddLog("系统启动完成", 0);
|
||||
log.Info("系统启动完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog(ex.Message, 2);
|
||||
//AddLog(ex.Message, 2);
|
||||
log.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
private void StartHeartBeat()
|
||||
@@ -249,7 +272,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"Modbus心跳失败:{ex.Message}", 2);
|
||||
//AddLog($"Modbus心跳失败:{ex.Message}", 2);
|
||||
log.Error($"Modbus心跳失败:{ex.Message}");
|
||||
}
|
||||
};
|
||||
modbusHeartbeat.Start();
|
||||
@@ -270,10 +294,22 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
modbusClient.ConnectionStatusChanged += (s, connected) =>
|
||||
{
|
||||
AddLog(connected ? "Modbus连接成功" : "Modbus连接断开", connected ? 0 : 1);
|
||||
//AddLog(connected ? "Modbus连接成功" : "Modbus连接断开", connected ? 0 : 1);
|
||||
if (connected)
|
||||
{
|
||||
log.Info("Modbus连接成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Error("Modbus连接断开");
|
||||
}
|
||||
};
|
||||
|
||||
modbusClient.ErrorOccurred += (s, msg) => AddLog($"Modbus错误:{msg}", 2);
|
||||
modbusClient.ErrorOccurred += (s, msg) =>
|
||||
{
|
||||
//AddLog($"Modbus错误:{msg}", 2);
|
||||
log.Error($"Modbus错误:{msg}");
|
||||
};
|
||||
//modbusClient.DataReceived += (s, msg) => AddLog($"Modbus接收:{msg}", 0);
|
||||
//modbusClient.DataSent += (s, msg) => AddLog($"Modbus发送:{msg}", 0);
|
||||
}
|
||||
@@ -373,9 +409,11 @@ namespace 精工涂胶检测项目
|
||||
|
||||
if (trigger == "\u0001")
|
||||
{
|
||||
AddLog("相机收到PLC触发信号", 0);
|
||||
//AddLog("相机收到PLC触发信号", 0);
|
||||
log.Info("相机收到PLC触发信号");
|
||||
modbusClient.WriteSingleRegister("3", (short)1);//ResultAcq
|
||||
AddLog("给PLC回复,收到触发", 0);
|
||||
//AddLog("给PLC回复,收到触发", 0);
|
||||
log.Info("给PLC回复,收到触发");
|
||||
cog3DDisplayV2WF1.Clear();
|
||||
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【BEGIN】
|
||||
@@ -399,28 +437,33 @@ namespace 精工涂胶检测项目
|
||||
//{
|
||||
myToolBlock1.Run();
|
||||
//}
|
||||
AddLog("检测执行中", 0);
|
||||
//AddLog("检测执行中", 0);
|
||||
log.Info("检测执行中");
|
||||
}
|
||||
}
|
||||
|
||||
if (trigger == "\u0000" || trigger == "")
|
||||
{
|
||||
AddLog("相机收到PLC结束触发信号", 0);
|
||||
//AddLog("相机收到PLC结束触发信号", 0);
|
||||
log.Info("相机收到PLC结束触发信号");
|
||||
modbusClient.WriteSingleRegister("3", (short)0);
|
||||
AddLog("给PLC发送ResultAcq置零信号", 0);
|
||||
//AddLog("给PLC发送ResultAcq置零信号", 0);
|
||||
log.Info("给PLC发送ResultAcq置零信号");
|
||||
}
|
||||
|
||||
//触发标定程序
|
||||
if (trigger == "\u0002")
|
||||
{
|
||||
Vpro初始化();
|
||||
AddLog("收到PLC信号,切换到标定程序", 0);
|
||||
//AddLog("收到PLC信号,切换到标定程序", 0);
|
||||
log.Info("收到PLC信号,切换到标定程序");
|
||||
modbusClient.WriteSingleRegister("3", (short)1);//ResultAcq
|
||||
if (myJobManager.JobsRunningState == CogJobsRunningStateConstants.None)
|
||||
{
|
||||
myJobManager.Run();
|
||||
myToolBlock2.Run();
|
||||
AddLog("标定程序执行中", 0);
|
||||
//AddLog("标定程序执行中", 0);
|
||||
log.Info("标定程序执行中");
|
||||
modbusClient.WriteSingleRegister("3", (short)0);
|
||||
cog3DDisplayV2WF1.Clear();
|
||||
}
|
||||
@@ -460,7 +503,8 @@ namespace 精工涂胶检测项目
|
||||
if (resultAcq == "\u0001")
|
||||
{
|
||||
modbusClient.WriteSingleRegister("4", (short)0);//ModbusResult清除
|
||||
AddLog("给PLC发送/ModbusResult清除信号", 0);
|
||||
//AddLog("给PLC发送/ModbusResult清除信号", 0);
|
||||
log.Info("给PLC发送/ModbusResult清除信号");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -476,7 +520,8 @@ namespace 精工涂胶检测项目
|
||||
if (!mModbusPollTimer.Enabled)
|
||||
{
|
||||
mModbusPollTimer.Start();
|
||||
AddLog("Modbus实时读取已启动", 0);
|
||||
//AddLog("Modbus实时读取已启动", 0);
|
||||
log.Info("Modbus实时读取已启动");
|
||||
}
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【END】
|
||||
}
|
||||
@@ -551,7 +596,8 @@ namespace 精工涂胶检测项目
|
||||
myTcp.DataReceived += MyTcp_DataReceived;
|
||||
myTcp.ClientConnected += MyTcp_ClientConnected;
|
||||
myTcp.ClientDisconnected += MyTcp_ClientDisconnected;
|
||||
myTcp.ServerStatusChanged += (s, msg) => AddLog(msg, 1);
|
||||
//myTcp.ServerStatusChanged += (s, msg) => AddLog(msg, 1);
|
||||
myTcp.ServerStatusChanged += (s, msg) => log.Info(msg);
|
||||
}
|
||||
private void 按钮使能初始化()
|
||||
{
|
||||
@@ -605,7 +651,8 @@ namespace 精工涂胶检测项目
|
||||
if (mModbusPollTimer != null && mModbusPollTimer.Enabled)
|
||||
{
|
||||
mModbusPollTimer.Stop();
|
||||
AddLog("Modbus断线,已停止实时读取", 1);
|
||||
//AddLog("Modbus断线,已停止实时读取", 1);
|
||||
log.Warn("Modbus断线,已停止实时读取");
|
||||
}
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【END】
|
||||
}
|
||||
@@ -613,7 +660,8 @@ namespace 精工涂胶检测项目
|
||||
|
||||
private void _modbusClient_Disconnected(object sender, string e)
|
||||
{
|
||||
AddLog($"PLC连接断开:{e}", 1);
|
||||
//AddLog($"PLC连接断开:{e}", 1);
|
||||
log.Warn($"PLC连接断开:{e}");
|
||||
}
|
||||
|
||||
|
||||
@@ -732,7 +780,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"获取用户结果失败:{ex.Message}", 1);
|
||||
//AddLog($"获取用户结果失败:{ex.Message}", 1);
|
||||
log.Error($"获取用户结果失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -741,7 +790,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"获取产品SN失败:{ex.Message}", 1);
|
||||
//AddLog($"获取产品SN失败:{ex.Message}", 1);
|
||||
log.Error($"获取产品SN失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -750,20 +800,23 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"获取图像失败:{ex.Message}", 1);
|
||||
//AddLog($"获取图像失败:{ex.Message}", 1);
|
||||
log.Error($"获取图像失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
string rootPath = @"D:\Date";
|
||||
try
|
||||
{
|
||||
currentDateFolder = Form1.CreateCurrentDateFolder(rootPath);
|
||||
currentDateFolder = FrmMain.CreateCurrentDateFolder(rootPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"创建当前文件夹失败:{ex.Message}", 1);
|
||||
//AddLog($"创建当前文件夹失败:{ex.Message}", 1);
|
||||
log.Error($"创建当前文件夹失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
AddLog("当前文件夹已创建", 1);
|
||||
//AddLog("当前文件夹已创建", 1);
|
||||
log.Info("当前文件夹已创建");
|
||||
//图像显示需要改
|
||||
// ICogRecord ShowImageRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"].SubRecords["LastRun"].SubRecords["Image Source.OutputImage"];
|
||||
if (TXZH == "1")
|
||||
@@ -800,7 +853,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"保存图像失败:{ex.Message}", 1);
|
||||
//AddLog($"保存图像失败:{ex.Message}", 1);
|
||||
log.Error($"保存图像失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
cogRecordDisplay1.AutoFit = true;
|
||||
@@ -832,7 +886,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"获取数据失败:{ex.Message}", 1);
|
||||
//AddLog($"获取数据失败:{ex.Message}", 1);
|
||||
log.Error($"获取数据失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -908,7 +963,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"获取数据失败:{ex.Message}", 1);
|
||||
//AddLog($"获取数据失败:{ex.Message}", 1);
|
||||
log.Error($"获取数据失败:{ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1525,7 +1581,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"发送数据失败:{ex.Message}", 1);
|
||||
//AddLog($"发送数据失败:{ex.Message}", 1);
|
||||
log.Error($"发送数据失败:{ex.Message}");
|
||||
}
|
||||
|
||||
if (ProductSN == null)
|
||||
@@ -1590,12 +1647,14 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
workbook.Save();
|
||||
}
|
||||
AddLog("数据写入成功", 1);
|
||||
//AddLog("数据写入成功", 1);
|
||||
log.Info("数据写入成功");
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"数据写入失败:{ex.Message}", 1);
|
||||
//AddLog($"数据写入失败:{ex.Message}", 1);
|
||||
log.Info($"数据写入失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1679,12 +1738,14 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
workbook.Save();
|
||||
}
|
||||
AddLog("数据写入成功", 1);
|
||||
//AddLog("数据写入成功", 1);
|
||||
log.Info("数据写入成功");
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("数据写入成功", 1);
|
||||
//AddLog("数据写入成功", 1); //应该是失败吧???
|
||||
log.Error($"数据写入失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1717,7 +1778,7 @@ namespace 精工涂胶检测项目
|
||||
/// 客户端发送
|
||||
/// </summary>
|
||||
/// <param name="datastr"></param>
|
||||
private void CaptureSelfForm(Form1 form,string savePath)
|
||||
private void CaptureSelfForm(FrmMain form,string savePath)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(form.Width, form.Height))
|
||||
{
|
||||
@@ -1731,24 +1792,28 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
if (!myTcp.IsConnected)
|
||||
{
|
||||
AddLog("未连接到服务器/客户端,请先配置通讯", 1);
|
||||
//AddLog("未连接到服务器/客户端,请先配置通讯", 1);
|
||||
log.Warn("未连接到服务器/客户端,请先配置通讯");
|
||||
return;
|
||||
}
|
||||
|
||||
string message = datastr;
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
AddLog("发送内容不能为空", 1);
|
||||
//AddLog("发送内容不能为空", 1);
|
||||
log.Warn("发送内容不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(message);
|
||||
await myTcp.SendAsync(data);
|
||||
AddLog($"已发送数据: {message}", 0);
|
||||
//AddLog($"已发送数据: {message}", 0);
|
||||
log.Info($"已发送数据: {message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"发送失败: {ex.Message}", 2);
|
||||
//AddLog($"发送失败: {ex.Message}", 2);
|
||||
log.Error($"发送失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1761,17 +1826,20 @@ namespace 精工涂胶检测项目
|
||||
{
|
||||
if (string.IsNullOrEmpty(datastr))
|
||||
{
|
||||
AddLog("广播内容不能为空", 1);
|
||||
//AddLog("广播内容不能为空", 1);
|
||||
log.Warn("广播内容不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(datastr);
|
||||
await myTcp.BroadcastAsync(data);
|
||||
AddLog($"已广播: {datastr}", 0);
|
||||
//AddLog($"已广播: {datastr}", 0);
|
||||
log.Info($"已广播: {datastr}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"广播失败: {ex.Message}", 2);
|
||||
//AddLog($"广播失败: {ex.Message}", 2);
|
||||
log.Error($"广播失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1788,14 +1856,16 @@ namespace 精工涂胶检测项目
|
||||
this.btn_Auto.BackColor = Color.Red;
|
||||
this.btn_ManulTrigger.Enabled = true;
|
||||
|
||||
AddLog("切换为离线模式", 0);
|
||||
//AddLog("切换为离线模式", 0);
|
||||
log.Debug("切换为离线模式");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.btn_Auto.Text = "自动模式";
|
||||
this.btn_Auto.BackColor = Color.YellowGreen;
|
||||
this.btn_ManulTrigger.Enabled = false;
|
||||
AddLog("切换为自动模式", 0);
|
||||
//AddLog("切换为自动模式", 0);
|
||||
log.Debug("切换为自动模式");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1810,7 +1880,8 @@ namespace 精工涂胶检测项目
|
||||
myToolBlock2.Run();
|
||||
|
||||
button1State = true;
|
||||
AddLog("手动运行", 0);
|
||||
//AddLog("手动运行", 0);
|
||||
log.Debug("手动运行");
|
||||
}
|
||||
/// <summary>
|
||||
/// 日志清除按钮
|
||||
@@ -1832,25 +1903,26 @@ namespace 精工涂胶检测项目
|
||||
formCommunication.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实时LOG
|
||||
/// </summary>
|
||||
/// <param name="Log">日志内容</param>
|
||||
/// <param name="index">图片序号</param>
|
||||
public void AddLog(string log, int index)
|
||||
{
|
||||
if (lvw_Log.InvokeRequired)
|
||||
{
|
||||
lvw_Log.Invoke(new Action(() => AddLog(log, index)));
|
||||
return;
|
||||
}
|
||||
|
||||
ListViewItem list = new ListViewItem(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), index);
|
||||
list.SubItems.Add(log);
|
||||
lvw_Log.Items.Add(list);
|
||||
lvw_Log.Items[lvw_Log.Items.Count - 1].EnsureVisible();
|
||||
}
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【BEGIN】
|
||||
///// <summary>
|
||||
///// 实时LOG
|
||||
///// </summary>
|
||||
///// <param name="Log">日志内容</param>
|
||||
///// <param name="index">图片序号</param>
|
||||
//public void AddLog(string log, int index)
|
||||
//{
|
||||
// if (lvw_Log.InvokeRequired)
|
||||
// {
|
||||
// lvw_Log.Invoke(new Action(() => AddLog(log, index)));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// ListViewItem list = new ListViewItem(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), index);
|
||||
// list.SubItems.Add(log);
|
||||
// lvw_Log.Items.Add(list);
|
||||
// lvw_Log.Items[lvw_Log.Items.Count - 1].EnsureVisible();
|
||||
//}
|
||||
//≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡【END】
|
||||
|
||||
private void Label数据重置()
|
||||
{
|
||||
@@ -1889,19 +1961,22 @@ namespace 精工涂胶检测项目
|
||||
plc.Open();
|
||||
if (plc.IsConnected)
|
||||
{
|
||||
AddLog("PLC连接成功", 0);
|
||||
//AddLog("PLC连接成功", 0);
|
||||
log.Info("PLC连接成功");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region 事件处理方法
|
||||
private void MyTcp_ClientDisconnected(object sender, string e)
|
||||
{
|
||||
AddLog("Tcp客户端已断开", 0);
|
||||
//AddLog("Tcp客户端已断开", 0);
|
||||
log.Warn("Tcp客户端已断开");
|
||||
}
|
||||
|
||||
private void MyTcp_ClientConnected(object sender, ClientConnectedEventArgs e)
|
||||
{
|
||||
AddLog("Tcp客户端已连接", 0);
|
||||
//AddLog("Tcp客户端已连接", 0);
|
||||
log.Info("Tcp客户端已连接");
|
||||
}
|
||||
|
||||
private void MyTcp_DataReceived(object sender, DataReceivedEventArgs e)
|
||||
@@ -1909,7 +1984,8 @@ namespace 精工涂胶检测项目
|
||||
///TCP通讯,用不到
|
||||
try
|
||||
{
|
||||
AddLog($"收到来自 {e.ClientId} 的数据: {Encoding.UTF8.GetString(e.Data)}", 0);
|
||||
//AddLog($"收到来自 {e.ClientId} 的数据: {Encoding.UTF8.GetString(e.Data)}", 0);
|
||||
log.Debug($"收到来自 {e.ClientId} 的数据: {Encoding.UTF8.GetString(e.Data)}");
|
||||
|
||||
string reciveData = Encoding.UTF8.GetString(e.Data);
|
||||
string[] datas = reciveData.Split(',');
|
||||
@@ -1929,7 +2005,8 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLog("程序已离线", 0);
|
||||
//AddLog("程序已离线", 0);
|
||||
log.Debug("程序已离线");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1942,19 +2019,22 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLog("程序已离线", 0);
|
||||
//AddLog("程序已离线", 0);
|
||||
log.Debug("程序已离线");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLog("数据格式错误", 1);
|
||||
//AddLog("数据格式错误", 1);
|
||||
log.Error("数据格式错误");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog(ex.Message, 2);
|
||||
//AddLog(ex.Message, 2);
|
||||
log.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -2068,17 +2148,20 @@ namespace 精工涂胶检测项目
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLog("Tcp取消自动重连", 0);
|
||||
//AddLog("Tcp取消自动重连", 0);
|
||||
log.Info("Tcp取消自动重连");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog($"连接失败: {ex.Message}", 2);
|
||||
//AddLog($"连接失败: {ex.Message}", 2);
|
||||
log.Error($"连接失败: {ex.Message}");
|
||||
if (!ShowConfigDialog() && !myTcp.IsConnected)
|
||||
{
|
||||
_autoTcpReconnect = false;
|
||||
AddLog("用户取消连接,退出自动重连", 1);
|
||||
//AddLog("用户取消连接,退出自动重连", 1);
|
||||
log.Error("用户取消连接,退出自动重连");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAw
|
||||
CQAAAk1TRnQBSQFMAgEBAwEAAVABAgFQAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
CQAAAk1TRnQBSQFMAgEBAwEAAWgBAgFoAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
@@ -170,9 +170,6 @@
|
||||
AX8B8AEHAgAE/wH+AT8CAAs=
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="cogRecordDisplay1.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
@@ -184,6 +181,9 @@
|
||||
//8L
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
@@ -19,14 +19,14 @@ namespace 精工涂胶检测项目
|
||||
|
||||
private void FormVPP_Load(object sender, EventArgs e)
|
||||
{
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null) return;
|
||||
cogJobManagerEdit1.Subject = mainForm.myJobManager;
|
||||
}
|
||||
|
||||
private void FormVPP_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null) return;
|
||||
mainForm.myJobManager = cogJobManagerEdit1.Subject;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace 精工涂胶检测项目
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form_LoadingImage());
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FrmMain());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +194,13 @@ namespace 精工涂胶检测项目
|
||||
#region 客户端功能
|
||||
public async Task ConnectAsync(string ip, int port)
|
||||
{
|
||||
var mainForm = Application.OpenForms.OfType<Form1>().FirstOrDefault();
|
||||
var mainForm = Application.OpenForms.OfType<FrmMain>().FirstOrDefault();
|
||||
if (mainForm == null) return;
|
||||
|
||||
_tcpStatus = "Client";
|
||||
_client = new TcpClient();
|
||||
await _client.ConnectAsync(ip, port);
|
||||
mainForm.AddLog($"客户端已连接,主机IP:{ip},主机端口:{port}", 0);
|
||||
//mainForm.AddLog($"客户端已连接,主机IP:{ip},主机端口:{port}", 0);
|
||||
_clientStream = _client.GetStream();
|
||||
_ = ReceiveDataAsync();
|
||||
}
|
||||
|
||||
@@ -396,6 +396,10 @@
|
||||
<Reference Include="HslCommunication, Version=12.3.1.0, Culture=neutral, PublicKeyToken=3d72ad3b6b5ec0e3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HslCommunication.12.3.1\lib\net451\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
@@ -468,11 +472,11 @@
|
||||
<Compile Include="Form\FormCommunication.Designer.cs">
|
||||
<DependentUpon>FormCommunication.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Form\FormMain.cs">
|
||||
<Compile Include="Form\FrmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form\FormMain.Designer.cs">
|
||||
<DependentUpon>FormMain.cs</DependentUpon>
|
||||
<Compile Include="Form\FrmMain.Designer.cs">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Form\StatusChecker.cs" />
|
||||
<Compile Include="Form_LoadingImage.cs">
|
||||
@@ -497,8 +501,8 @@
|
||||
<EmbeddedResource Include="Form\FormCommunication.resx">
|
||||
<DependentUpon>FormCommunication.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form\FormMain.resx">
|
||||
<DependentUpon>FormMain.cs</DependentUpon>
|
||||
<EmbeddedResource Include="Form\FrmMain.resx">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form\FormSetParameter.resx">
|
||||
<DependentUpon>FormSetParameter.cs</DependentUpon>
|
||||
@@ -561,5 +565,11 @@
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CVE.LogViewer\CVE.LogViewer.csproj">
|
||||
<Project>{766cf29f-3629-470a-aec7-d2aead685484}</Project>
|
||||
<Name>CVE.LogViewer</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user