添加项目文件。

This commit is contained in:
zhusenlin
2026-01-15 15:06:36 +08:00
parent 4602f42483
commit 63abae1cbe
319 changed files with 197251 additions and 0 deletions

View File

@@ -0,0 +1,245 @@
namespace CowainHmi
{
partial class Dlg添加配方
{
/// <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.components = new System.ComponentModel.Container();
PCHMI.InterLock interLock1 = new PCHMI.InterLock();
PCHMI.DrawStyle drawStyle1 = new PCHMI.DrawStyle();
PCHMI.OPTLOG optlog1 = new PCHMI.OPTLOG();
PCHMI.ST_SW_IF sT_SW_IF1 = new PCHMI.ST_SW_IF();
PCHMI.ST_SW_IF sT_SW_IF2 = new PCHMI.ST_SW_IF();
PCHMI.ST_SW_IF sT_SW_IF3 = new PCHMI.ST_SW_IF();
PCHMI.ST_SW_IF sT_SW_IF4 = new PCHMI.ST_SW_IF();
PCHMI.GLINT glint1 = new PCHMI.GLINT();
this.label1 = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtName = new PCHMI.(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(41, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(94, 21);
this.label1.TabIndex = 51;
this.label1.Text = "配方名称";
//
// btnOk
//
this.btnOk.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOk.Location = new System.Drawing.Point(55, 145);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(118, 47);
this.btnOk.TabIndex = 52;
this.btnOk.Text = "添加";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(253, 145);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(118, 47);
this.btnCancel.TabIndex = 53;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtName
//
this.txtName.BackColor = System.Drawing.Color.White;
this.txtName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtName.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtName.ForeColor = System.Drawing.Color.Black;
this.txtName.HDADDR = "";
this.txtName.Image = null;
this.txtName.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.txtName.Location = new System.Drawing.Point(181, 37);
this.txtName.Name = "txtName";
this.txtName.PLC = ((uint)(0u));
this.txtName.Size = new System.Drawing.Size(190, 42);
this.txtName.TabIndex = 50;
this.txtName.Text = "0";
this.txtName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.txtName.Value = ((ulong)(0ul));
interLock1.HDADDR = "";
interLock1.PLC = ((uint)(0u));
interLock1. = ((uint)(1u));
interLock1. = "";
interLock1. = null;
interLock1. = "LOCK";
interLock1. = PCHMI.InterLock.DatType.BIT;
this.txtName. = interLock1;
this.txtName. = true;
this.txtName. = "";
this.txtName. = PCHMI..TypeEnum.;
this.txtName. = "";
this.txtName. = new System.Drawing.Point(0, 0);
drawStyle1. = 12;
drawStyle1. = System.Drawing.Color.Transparent;
drawStyle1. = System.Drawing.Color.Empty;
drawStyle1. = PCHMI.DrawStyle.STYPE.;
drawStyle1. = System.Drawing.Color.LightGray;
this.txtName. = drawStyle1;
this.txtName. = ((uint)(15u));
this.txtName. = ((uint)(0u));
this.txtName. = ((uint)(0u));
this.txtName..PLC = new uint[] {
((uint)(0u))};
this.txtName.. = new string[] {
""};
this.txtName.. = new PCHMI.FTYPE.ButtonType[] {
PCHMI.FTYPE.ButtonType.};
this.txtName.. = new string[] {
""};
this.txtName. = "";
this.txtName. = ((uint)(8u));
this.txtName. = false;
this.txtName. = new string[] {
null,
null,
null,
null,
null,
null,
null,
null};
optlog1. = "";
optlog1. = "";
this.txtName. = optlog1;
this.txtName. = PCHMI..DatType.String;
this.txtName. = "yyyy-MM-dd";
this.txtName..BkImg = null;
this.txtName.. = PCHMI.Employee.STSW.;
sT_SW_IF1.BkColor = System.Drawing.Color.Empty;
sT_SW_IF1.Img = null;
sT_SW_IF1.MaxVal = ((ulong)(0ul));
sT_SW_IF1.MinVal = ((ulong)(0ul));
sT_SW_IF1.Txt0 = "停止状态";
sT_SW_IF1.Txt1 = "Stop state";
sT_SW_IF1.Txt2 = "정지 상태";
sT_SW_IF1.Txt3 = "";
sT_SW_IF1.Txt4 = "";
sT_SW_IF1.Txt5 = "";
sT_SW_IF1.Txt6 = "";
sT_SW_IF1.Txt7 = "";
sT_SW_IF1.TxtColor = System.Drawing.Color.Black;
sT_SW_IF1.TxtNumber = "21";
sT_SW_IF2.BkColor = System.Drawing.Color.Empty;
sT_SW_IF2.Img = null;
sT_SW_IF2.MaxVal = ((ulong)(0ul));
sT_SW_IF2.MinVal = ((ulong)(0ul));
sT_SW_IF2.Txt0 = "待机状态";
sT_SW_IF2.Txt1 = "Waiting state";
sT_SW_IF2.Txt2 = "대기 상태";
sT_SW_IF2.Txt3 = "";
sT_SW_IF2.Txt4 = "";
sT_SW_IF2.Txt5 = "";
sT_SW_IF2.Txt6 = "";
sT_SW_IF2.Txt7 = "";
sT_SW_IF2.TxtColor = System.Drawing.Color.Black;
sT_SW_IF2.TxtNumber = "22";
sT_SW_IF3.BkColor = System.Drawing.Color.Empty;
sT_SW_IF3.Img = null;
sT_SW_IF3.MaxVal = ((ulong)(0ul));
sT_SW_IF3.MinVal = ((ulong)(0ul));
sT_SW_IF3.Txt0 = "工作状态";
sT_SW_IF3.Txt1 = "Working state";
sT_SW_IF3.Txt2 = "작업 상태";
sT_SW_IF3.Txt3 = "";
sT_SW_IF3.Txt4 = "";
sT_SW_IF3.Txt5 = "";
sT_SW_IF3.Txt6 = "";
sT_SW_IF3.Txt7 = "";
sT_SW_IF3.TxtColor = System.Drawing.Color.Black;
sT_SW_IF3.TxtNumber = "23";
sT_SW_IF4.BkColor = System.Drawing.Color.Empty;
sT_SW_IF4.Img = null;
sT_SW_IF4.MaxVal = ((ulong)(0ul));
sT_SW_IF4.MinVal = ((ulong)(0ul));
sT_SW_IF4.Txt0 = "检修状态";
sT_SW_IF4.Txt1 = "State of repair";
sT_SW_IF4.Txt2 = "점검 수리 상태";
sT_SW_IF4.Txt3 = "";
sT_SW_IF4.Txt4 = "";
sT_SW_IF4.Txt5 = "";
sT_SW_IF4.Txt6 = "";
sT_SW_IF4.Txt7 = "";
sT_SW_IF4.TxtColor = System.Drawing.Color.Black;
sT_SW_IF4.TxtNumber = "24";
this.txtName.. = new PCHMI.ST_SW_IF[] {
sT_SW_IF1,
sT_SW_IF2,
sT_SW_IF3,
sT_SW_IF4};
this.txtName..ID = ((uint)(0u));
this.txtName. = "100";
this.txtName. = "0";
this.txtName. = "";
this.txtName. = "null";
this.txtName. = ((uint)(0u));
glint1.HDADDR = "";
glint1.PLC = ((uint)(0u));
glint1. = "";
glint1. = System.Drawing.Color.Red;
glint1. = ((ushort)(1000));
this.txtName. = glint1;
this.txtName. = System.Drawing.Color.Black;
//
// Dlg添加配方
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(428, 237);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtName);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Dlg添加配方";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "添加配方";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private PCHMI. txtName;
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace CowainHmi
{
public partial class Dlg添加配方 : Form
{
private string pfName;
private string nameAddr;
private string plcVarName;
public Dlg添加配方(string pfName, string nameAddr, string plcVarName)
{
InitializeComponent();
this.txtName.Text = PCHMI.RT.GET_STRING(0, nameAddr, 15);
this.pfName = pfName;
this.nameAddr = nameAddr;
this.plcVarName = plcVarName;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
string name = this.txtName.Text;
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("配方名称不能为空!!", "提示");
return;
}
PCHMI.RT.SEND_STRING(0, nameAddr, name);
PCHMI.RT.SEND_SIEMENS_STRING(0, plcVarName, name);
new PCHMI.().SAVE_TECH(pfName); //保存指定配方文件名的配方
this.Close();
}
}
}

View File

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

176
CowainHmi/Common/LogSearch.Designer.cs generated Normal file
View File

@@ -0,0 +1,176 @@
namespace CowainHmi
{
partial class LogSearch
{
/// <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
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.label1 = new System.Windows.Forms.Label();
this.search = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.content = new System.Windows.Forms.TextBox();
this.logFileSelect = new System.Windows.Forms.Label();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.,
this.,
this.});
this.dataGridView1.Location = new System.Drawing.Point(3, 81);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(832, 473);
this.dataGridView1.TabIndex = 0;
//
// dateTimePicker1
//
this.dateTimePicker1.CustomFormat = "yyyy/MM/dd";
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.Location = new System.Drawing.Point(54, 42);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(100, 21);
this.dateTimePicker1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 46);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 3;
this.label1.Text = "时间";
//
// search
//
this.search.Location = new System.Drawing.Point(751, 41);
this.search.Name = "search";
this.search.Size = new System.Drawing.Size(75, 23);
this.search.TabIndex = 4;
this.search.Text = "查询";
this.search.UseVisualStyleBackColor = true;
this.search.Click += new System.EventHandler(this.search_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(160, 46);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 5;
this.label2.Text = "内容";
//
// content
//
this.content.Location = new System.Drawing.Point(195, 42);
this.content.Name = "content";
this.content.Size = new System.Drawing.Size(550, 21);
this.content.TabIndex = 7;
//
// logFileSelect
//
this.logFileSelect.AutoSize = true;
this.logFileSelect.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.logFileSelect.ForeColor = System.Drawing.Color.Blue;
this.logFileSelect.Location = new System.Drawing.Point(53, 15);
this.logFileSelect.Name = "logFileSelect";
this.logFileSelect.Size = new System.Drawing.Size(113, 12);
this.logFileSelect.TabIndex = 9;
this.logFileSelect.Text = "点击选择日志文件夹";
this.logFileSelect.Click += new System.EventHandler(this.logFileSelect_Click);
//
// 时间
//
this..DataPropertyName = "时间";
dataGridViewCellStyle1.Format = "yyyy-MM-dd HH:mm:ss";
this..DefaultCellStyle = dataGridViewCellStyle1;
this..HeaderText = "时间";
this..Name = "时间";
this..ReadOnly = true;
this..Width = 150;
//
// 操作员
//
this..DataPropertyName = "操作员";
this..HeaderText = "操作员";
this..Name = "操作员";
this..ReadOnly = true;
//
// 内容
//
this..DataPropertyName = "内容";
this..HeaderText = "内容";
this..Name = "内容";
this..ReadOnly = true;
this..Width = 500;
//
// LogSearch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.logFileSelect);
this.Controls.Add(this.content);
this.Controls.Add(this.label2);
this.Controls.Add(this.search);
this.Controls.Add(this.label1);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.dataGridView1);
this.Name = "LogSearch";
this.Size = new System.Drawing.Size(838, 560);
this.Load += new System.EventHandler(this.LogSearch_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button search;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox content;
private System.Windows.Forms.Label logFileSelect;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
}
}

View File

@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace CowainHmi
{
public partial class LogSearch : UserControl
{
public LogSearch()
{
InitializeComponent();
dateTimePicker1.Value = DateTime.Now;
}
// 定义并添加自定义属性
[Browsable(true)]
[Category("Custom Properties")]
[Description("日志文件路径")]
public string LogFilePath
{
get;
set;
}
public class LogEntry
{
public DateTime { get; set; }
public string { get; set; }
public string { get; set; }
}
private void search_Click(object sender, EventArgs e)
{
List<LogEntry> list = new List<LogEntry>();
dataGridView1.DataSource = list;
// 读取并解析CSV文件
string logFolder = LogFilePath + @"\" + dateTimePicker1.Value.ToString("yyMMdd") + ".csv";
if (!File.Exists(logFolder))
{
MessageBox.Show("没有选择文件,或文件不存在!");
return;
}
var logEntries = ReadLogEntries(logFolder);
// 按时间段过滤日志条目
list = logEntries.Where(entry => entry..ToLower().Contains(content.Text.ToLower().Trim())).OrderByDescending(x=>x.).ToList();
dataGridView1.DataSource = list;
}
static List<LogEntry> ReadLogEntries(string filePath)
{
var logEntries = new List<LogEntry>();
int N = 1;
foreach (var line in File.ReadAllLines(filePath, Encoding.GetEncoding("GB2312")))
{
try
{
if (N == 1)
{
N++;
continue;
}
var parts = line.Split(',');
var time = DateTime.ParseExact(parts[0].Trim(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
string actionOperator= parts[1].Trim();
string content = "";
for (int i = 2; i < parts.Length; i++)
{
content = content +" "+ parts[i].Trim();
}
logEntries.Add(new LogEntry { = time,= actionOperator, = content });
}
catch (Exception ex)
{
//throw;
}
N++;
}
return logEntries;
}
public string ShowOpenFileDialog()
{
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
{
folderBrowserDialog.Description = "请选择一个文件夹";
folderBrowserDialog.ShowNewFolderButton = true;
folderBrowserDialog.SelectedPath = AppDomain.CurrentDomain.BaseDirectory;
DialogResult result = folderBrowserDialog.ShowDialog();
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
return folderBrowserDialog.SelectedPath;
}
else
{
return "";
}
}
}
private void logFileSelect_Click(object sender, EventArgs e)
{
LogFilePath = ShowOpenFileDialog();
logFileSelect.Text = LogFilePath;
if (logFileSelect.Text.Length<3)
{
logFileSelect.Text = "点击选择日志文件";
}
}
private void LogSearch_Load(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(LogFilePath))
{
logFileSelect.Text = "点击选择日志文件";
}
else
{
logFileSelect.Text= LogFilePath;
}
}
}
}

View File

@@ -0,0 +1,129 @@
<?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="时间.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="操作员.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="内容.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

105
CowainHmi/Common/数据记录.Designer.cs generated Normal file
View File

@@ -0,0 +1,105 @@
namespace CowainHmi
{
partial class
{
/// <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
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dgvData = new System.Windows.Forms.DataGridView();
this.dtpDate = new System.Windows.Forms.DateTimePicker();
this.btnQuery = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit();
this.SuspendLayout();
//
// dgvData
//
this.dgvData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvData.Location = new System.Drawing.Point(2, 40);
this.dgvData.Margin = new System.Windows.Forms.Padding(2);
this.dgvData.Name = "dgvData";
this.dgvData.ReadOnly = true;
this.dgvData.RowHeadersWidth = 62;
this.dgvData.RowTemplate.Height = 30;
this.dgvData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvData.Size = new System.Drawing.Size(781, 541);
this.dgvData.TabIndex = 0;
this.dgvData.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvData_RowPostPaint);
//
// dtpDate
//
this.dtpDate.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.dtpDate.Location = new System.Drawing.Point(11, 8);
this.dtpDate.Margin = new System.Windows.Forms.Padding(2);
this.dtpDate.Name = "dtpDate";
this.dtpDate.Size = new System.Drawing.Size(171, 30);
this.dtpDate.TabIndex = 1;
//
// btnQuery
//
this.btnQuery.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnQuery.Location = new System.Drawing.Point(225, 8);
this.btnQuery.Margin = new System.Windows.Forms.Padding(2);
this.btnQuery.Name = "btnQuery";
this.btnQuery.Size = new System.Drawing.Size(99, 28);
this.btnQuery.TabIndex = 2;
this.btnQuery.Text = "查询";
this.btnQuery.UseVisualStyleBackColor = true;
this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
//
// timer1
//
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucDataRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnQuery);
this.Controls.Add(this.dtpDate);
this.Controls.Add(this.dgvData);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "ucDataRecord";
this.Size = new System.Drawing.Size(783, 581);
this.Load += new System.EventHandler(this.ucDataRecord_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dgvData;
private System.Windows.Forms.DateTimePicker dtpDate;
private System.Windows.Forms.Button btnQuery;
private System.Windows.Forms.Timer timer1;
}
}

View File

@@ -0,0 +1,283 @@
using PCHMI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CowainHmi
{
public partial class : UserControl
{
public enum TrigerType
{
1,
,
}
private TrigerType trigType;
[Category("PCHMI"), DisplayName("触发方式")]
public TrigerType TrigType
{
get
{
return this.trigType;
}
set
{
this.trigType = value;
}
}
private uint PlcId = 0;
[Category("PCHMI"), DisplayName("PLC编号")]
public uint PLC
{
get
{
return this.PlcId;
}
set
{
this.PlcId = value;
}
}
private string trigger_bit;
[Category("PCHMI"), DisplayName("触发位地址")]
[Editor(typeof(StringText), typeof(UITypeEditor))]
public string HDADDR
{
get
{
return this.trigger_bit;
}
set
{
this.trigger_bit = value;
}
}
private Column[] _columns;
[Category("PCHMI"), DisplayName("列设置")]
public Column[] Columns
{
get
{
return this._columns;
}
set
{
this._columns = value;
}
}
private uint dtim = 2000;
[Category("PCHMI"), DisplayName("间隔触发时间")]
public uint Dtime
{
get
{
return this.dtim;
}
set
{
this.dtim = value;
}
}
private string filePath;
[Category("PCHMI"), DisplayName("文件夹")]
public string FilePath
{
get
{
return this.filePath;
}
set
{
this.filePath = value;
}
}
public ()
{
InitializeComponent();
}
private void ucDataRecord_Load(object sender, EventArgs e)
{
this.dgvData.AllowUserToAddRows = false;
this.dgvData.AllowUserToDeleteRows = false;
this.timer1.Enabled = true;
}
private ushort trigValueLast;
private int tickCount;
private bool firstRead = true;
private void timer1_Tick(object sender, EventArgs e)
{
if (PClass.IsPlcLink((int)PLC) && !string.IsNullOrEmpty(HDADDR))
{
ushort num = PCHMI.VL.GET_BIT((int)this.PLC, this.HDADDR);
if (firstRead)
{
this.Columns.Select(x => GetPlcData(x)).ToList();
firstRead = false;
}
if (this.TrigType == TrigerType.1)
{
if (num > 0 && trigValueLast == 0)
{
WriteCsv();
PCHMI.RT.SEND_BIT((int)this.PLC, this.HDADDR, 0);
}
}
else if (this.TrigType == TrigerType.)
{
if (num != trigValueLast)
{
WriteCsv();
PCHMI.RT.SEND_BIT((int)this.PLC, this.HDADDR, 0);
}
}
else
{
//定时触发
this.tickCount += 200;
if (this.tickCount >= Dtime)
{
this.tickCount = 0;
WriteCsv();
}
}
trigValueLast = num;
}
}
private object lockObj = new object();
private void btnQuery_Click(object sender, EventArgs e)
{
string fileName = string.Format($"{FilePath}\\{this.dtpDate.Value.ToString("yyyyMMdd")}.csv");
QueryData(fileName);
}
private void QueryData(string fileName)
{
this.dgvData.Columns.Clear();
this.dgvData.AllowUserToAddRows = false;
this.dgvData.AllowUserToDeleteRows = false;
//索引电脑上是否有对应名称的文件 如果没有 则以变量fileName创建一个csv文件 并填好表头
lock (lockObj)
{
if (!System.IO.File.Exists(fileName))
{
MessageBox.Show("没有记录", "提示");
return;
}
}
foreach (var item in this.Columns)
{
var dgvc = new DataGridViewTextBoxColumn();
dgvc.HeaderText = item.;
dgvc.SortMode = DataGridViewColumnSortMode.NotSortable;
//dgvc.Width = item.显示宽度;
dgvc.ReadOnly = true;
}
this.dgvData.DataSource = CsvHelper.CsvToDataTable(fileName);
}
private void WriteCsv()
{
#region
//根据日期生成文件名
string fileName = string.Format($"{filePath}\\{DateTime.Now.ToString("yyyyMMdd")}.csv");
lock (lockObj)
{
//索引电脑上是否有对应名称的文件 如果没有 则以变量fileName创建一个csv文件 并填好表头
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
if (!System.IO.File.Exists(fileName))
{
//写标题
var names = this.Columns.Select(x => x.).ToList();
CsvHelper.WriteLine(fileName, names);
}
var datas = this.Columns.Select(x => GetPlcData(x)).ToList();
CsvHelper.WriteLine(fileName, datas);
}
QueryData(fileName);
#endregion
}
private string GetPlcData(Column column)
{
if (column. == .DatType.String)
{
return PCHMI.VL.GET_STRING((int)column.PLC, column.ACT, column.);
}
else if (column. == .DatType.SIEMENS_String)
{
return PCHMI.VL.GET_SIEMENS_STRING((int)column.PLC, column.ACT, column.);
}
else if (column. == .DatType.DateTime)
{
return DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
}
else if (column. == .DatType.BIT)
{
return PCHMI.VL.GET_BIT((int)column.PLC, column.ACT).ToString();
}
else if (column. == .DatType.INT32)
{
return new PClass().UuValue((ulong)PCHMI.VL.GET_INT32((int)column.PLC, column.ACT), (uint)column., column..ToString());
}
else if (column. == .DatType.UINT32)
{
return new PClass().UuValue((ulong)PCHMI.VL.GET_UINT32((int)column.PLC, column.ACT), (uint)column., column..ToString());
}
else if (column. == .DatType.INT16)
{
return new PClass().UuValue((ulong)PCHMI.VL.GET_INT16((int)column.PLC, column.ACT), (uint)column., column..ToString());
}
else if (column. == .DatType.UINT16)
{
return new PClass().UuValue((ulong)PCHMI.VL.GET_UINT16((int)column.PLC, column.ACT), (uint)column., column..ToString());
}
//else if (column.类型 == 字段.DatType.F32)
//{
// return new PClass().UuValue((ulong)PCHMI.VL.GET_F32((int)column.PLC, column.ACT), (uint)column.小数位数, column.类型.ToString());
//}
else if (column. == .DatType.F32)
{
return PCHMI.VL.GET_F32((int)column.PLC, column.ACT).ToString();
}
else
{
return "Err Data Type";
}
}
private void dgvData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
new DataGridViewStyle().DgvRowPostPaint(this.dgvData, e);
}
}
}

View File

@@ -0,0 +1,123 @@
<?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>
</root>