添加项目文件。
This commit is contained in:
115
CowainHmi/PlcDataTable/DlgEditPlcValue.Designer.cs
generated
Normal file
115
CowainHmi/PlcDataTable/DlgEditPlcValue.Designer.cs
generated
Normal file
@@ -0,0 +1,115 @@
|
||||
namespace CowainHmi.Common
|
||||
{
|
||||
partial class DlgEditPlcValue
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
PCHMI.InterLock interLock1 = new PCHMI.InterLock();
|
||||
PCHMI.INFORM inform1 = new PCHMI.INFORM();
|
||||
this.txtTag = new PCHMI.数据显示器();
|
||||
this.btnOk = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtTag
|
||||
//
|
||||
this.txtTag.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtTag.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
|
||||
this.txtTag.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.txtTag.HDADDR = "";
|
||||
this.txtTag.Location = new System.Drawing.Point(7, 9);
|
||||
this.txtTag.Margin = new System.Windows.Forms.Padding(27, 16, 27, 16);
|
||||
this.txtTag.Name = "txtTag";
|
||||
this.txtTag.PLC = ((uint)(0u));
|
||||
this.txtTag.Size = new System.Drawing.Size(261, 29);
|
||||
this.txtTag.TabIndex = 583;
|
||||
this.txtTag.Text = "0.00";
|
||||
this.txtTag.Value = ((ulong)(0ul));
|
||||
interLock1.HDADDR = "";
|
||||
interLock1.PLC = ((uint)(0u));
|
||||
interLock1.互锁启用值 = ((uint)(1u));
|
||||
interLock1.互锁地址 = "";
|
||||
interLock1.互锁显示图标 = null;
|
||||
interLock1.互锁显示文本 = "LOCK";
|
||||
interLock1.互锁类型 = PCHMI.InterLock.DatType.BIT;
|
||||
this.txtTag.互锁 = interLock1;
|
||||
this.txtTag.回车后触发TAB键 = false;
|
||||
this.txtTag.字符串长度 = ((uint)(10u));
|
||||
this.txtTag.安全级别 = ((uint)(0u));
|
||||
this.txtTag.小数位数 = ((uint)(2u));
|
||||
this.txtTag.总显示位数 = ((uint)(8u));
|
||||
this.txtTag.操作记录 = "";
|
||||
inform1.HDADDR = "";
|
||||
inform1.PLC = ((uint)(0u));
|
||||
inform1.Value = ((ulong)(1ul));
|
||||
inform1.类型 = PCHMI.INFORM.DatType.UINT16;
|
||||
this.txtTag.操作通知 = inform1;
|
||||
this.txtTag.数值改变事件参数 = "NULL";
|
||||
this.txtTag.数据类型 = PCHMI.数据显示器.DatType.SIEMENS_String;
|
||||
this.txtTag.最大值 = "32000000";
|
||||
this.txtTag.最小值 = "-30000000";
|
||||
this.txtTag.权限提示文本 = "";
|
||||
this.txtTag.输入方式 = PCHMI.数据显示器.INTYPE.软键盘;
|
||||
this.txtTag.键盘输入事件参数 = "NULL";
|
||||
this.txtTag.键盘进入方式 = PCHMI.数据显示器.KeyInMode.单击;
|
||||
this.txtTag.零抑制 = false;
|
||||
this.txtTag.零显示 = false;
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.Location = new System.Drawing.Point(92, 56);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Size = new System.Drawing.Size(85, 40);
|
||||
this.btnOk.TabIndex = 584;
|
||||
this.btnOk.Text = "确定";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
|
||||
//
|
||||
// DlgEditPlcValue
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(273, 108);
|
||||
this.Controls.Add(this.btnOk);
|
||||
this.Controls.Add(this.txtTag);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DlgEditPlcValue";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "修改值";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PCHMI.数据显示器 txtTag;
|
||||
private System.Windows.Forms.Button btnOk;
|
||||
}
|
||||
}
|
||||
59
CowainHmi/PlcDataTable/DlgEditPlcValue.cs
Normal file
59
CowainHmi/PlcDataTable/DlgEditPlcValue.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using CowainHmi.Helper;
|
||||
using PCHMI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace CowainHmi.Common
|
||||
{
|
||||
public partial class DlgEditPlcValue : Form
|
||||
{
|
||||
private PlcTagColumn tag;
|
||||
private string oldValue;
|
||||
public DlgEditPlcValue(PlcTagColumn tag)
|
||||
{
|
||||
InitializeComponent();
|
||||
if (Enum.TryParse<数据显示器.DatType>(tag.DatType.ToString(), out 数据显示器.DatType datType))
|
||||
{
|
||||
this.txtTag.数据类型 = datType;
|
||||
}
|
||||
this.txtTag.小数位数 = (uint)tag.DecimalPlaces;
|
||||
this.txtTag.字符串长度 = (uint)tag.StringLength;
|
||||
this.txtTag.Text = tag.VarValue;
|
||||
this.tag = tag;
|
||||
oldValue = tag.VarValue;
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show("确定要修改变量吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (tag.DatType == 字段.DatType.INT32 || tag.DatType == 字段.DatType.UINT32 || tag.DatType == 字段.DatType.UINT16 || tag.DatType == 字段.DatType.INT16)
|
||||
{
|
||||
if (int.TryParse(this.txtTag.Text, out int val))
|
||||
{
|
||||
this.tag.VarValue = tag.DecimalPlaces > 0 ? (val * tag.DecimalPlaces * 10).ToString() : val.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tag.VarValue = this.txtTag.Text;
|
||||
}
|
||||
PCHMI.OPTLOG.WLOG($"修改了变量值,名称:{this.tag.VarName},地址:{this.tag.Address},原值:{oldValue},新值:{this.tag.VarValue}");
|
||||
PlcValueHelper.SetValue(this.tag);
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
CowainHmi/PlcDataTable/DlgEditPlcValue.resx
Normal file
120
CowainHmi/PlcDataTable/DlgEditPlcValue.resx
Normal 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>
|
||||
91
CowainHmi/PlcDataTable/FrmAddRow.Designer.cs
generated
Normal file
91
CowainHmi/PlcDataTable/FrmAddRow.Designer.cs
generated
Normal file
@@ -0,0 +1,91 @@
|
||||
namespace CowainHmi
|
||||
{
|
||||
partial class FrmAddRow
|
||||
{
|
||||
/// <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.rowCountInput = new System.Windows.Forms.NumericUpDown();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.rowCountInput)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// rowCountInput
|
||||
//
|
||||
this.rowCountInput.Location = new System.Drawing.Point(116, 25);
|
||||
this.rowCountInput.Name = "rowCountInput";
|
||||
this.rowCountInput.Size = new System.Drawing.Size(120, 21);
|
||||
this.rowCountInput.TabIndex = 6;
|
||||
this.rowCountInput.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(77, 86);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(100, 30);
|
||||
this.button1.TabIndex = 5;
|
||||
this.button1.Text = "确定";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(20, 29);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(65, 12);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "增加的行数";
|
||||
//
|
||||
// FrmAddRow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(265, 132);
|
||||
this.Controls.Add(this.rowCountInput);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FrmAddRow";
|
||||
this.Text = "添加行";
|
||||
((System.ComponentModel.ISupportInitialize)(this.rowCountInput)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.NumericUpDown rowCountInput;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
27
CowainHmi/PlcDataTable/FrmAddRow.cs
Normal file
27
CowainHmi/PlcDataTable/FrmAddRow.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
|
||||
namespace CowainHmi
|
||||
{
|
||||
public partial class FrmAddRow : Form
|
||||
{
|
||||
public int RowCount { get; set; }
|
||||
public FrmAddRow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
RowCount = (int)this.rowCountInput.Value;
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
CowainHmi/PlcDataTable/FrmAddRow.resx
Normal file
120
CowainHmi/PlcDataTable/FrmAddRow.resx
Normal 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>
|
||||
251
CowainHmi/PlcDataTable/FrmPlcDataTable.Designer.cs
generated
Normal file
251
CowainHmi/PlcDataTable/FrmPlcDataTable.Designer.cs
generated
Normal file
@@ -0,0 +1,251 @@
|
||||
namespace CowainHmi
|
||||
{
|
||||
partial class FrmPlcDataTable
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.btnDel = new System.Windows.Forms.Button();
|
||||
this.btnAdd = new System.Windows.Forms.Button();
|
||||
this.btnImport = new System.Windows.Forms.Button();
|
||||
this.btnExport = new System.Windows.Forms.Button();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.dgvData = new System.Windows.Forms.DataGridView();
|
||||
this.VarName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.VarDesc = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.PLC = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Address = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DatType = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DecimalPlaces = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.StringLength = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.IsReadOnly = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.btnDel);
|
||||
this.panel1.Controls.Add(this.btnAdd);
|
||||
this.panel1.Controls.Add(this.btnImport);
|
||||
this.panel1.Controls.Add(this.btnExport);
|
||||
this.panel1.Controls.Add(this.btnSave);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(972, 55);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// btnDel
|
||||
//
|
||||
this.btnDel.Location = new System.Drawing.Point(102, 11);
|
||||
this.btnDel.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnDel.Name = "btnDel";
|
||||
this.btnDel.Size = new System.Drawing.Size(70, 35);
|
||||
this.btnDel.TabIndex = 5;
|
||||
this.btnDel.Text = "删除选中";
|
||||
this.btnDel.UseVisualStyleBackColor = true;
|
||||
this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
this.btnAdd.Location = new System.Drawing.Point(11, 11);
|
||||
this.btnAdd.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnAdd.Name = "btnAdd";
|
||||
this.btnAdd.Size = new System.Drawing.Size(70, 35);
|
||||
this.btnAdd.TabIndex = 4;
|
||||
this.btnAdd.Text = "添加";
|
||||
this.btnAdd.UseVisualStyleBackColor = true;
|
||||
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
|
||||
//
|
||||
// btnImport
|
||||
//
|
||||
this.btnImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnImport.Location = new System.Drawing.Point(699, 11);
|
||||
this.btnImport.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnImport.Name = "btnImport";
|
||||
this.btnImport.Size = new System.Drawing.Size(70, 35);
|
||||
this.btnImport.TabIndex = 3;
|
||||
this.btnImport.Text = "导入";
|
||||
this.btnImport.UseVisualStyleBackColor = true;
|
||||
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
|
||||
//
|
||||
// btnExport
|
||||
//
|
||||
this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnExport.Location = new System.Drawing.Point(791, 11);
|
||||
this.btnExport.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnExport.Name = "btnExport";
|
||||
this.btnExport.Size = new System.Drawing.Size(70, 35);
|
||||
this.btnExport.TabIndex = 1;
|
||||
this.btnExport.Text = "导出";
|
||||
this.btnExport.UseVisualStyleBackColor = true;
|
||||
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnSave.Location = new System.Drawing.Point(883, 11);
|
||||
this.btnSave.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(70, 35);
|
||||
this.btnSave.TabIndex = 0;
|
||||
this.btnSave.Text = "保存";
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// dgvData
|
||||
//
|
||||
this.dgvData.AllowUserToAddRows = false;
|
||||
this.dgvData.AllowUserToResizeRows = false;
|
||||
this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.VarName,
|
||||
this.VarDesc,
|
||||
this.PLC,
|
||||
this.Address,
|
||||
this.DatType,
|
||||
this.DecimalPlaces,
|
||||
this.StringLength,
|
||||
this.IsReadOnly});
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Yellow;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.dgvData.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.dgvData.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dgvData.Location = new System.Drawing.Point(0, 55);
|
||||
this.dgvData.Name = "dgvData";
|
||||
this.dgvData.RowHeadersWidth = 51;
|
||||
this.dgvData.RowTemplate.Height = 23;
|
||||
this.dgvData.Size = new System.Drawing.Size(972, 514);
|
||||
this.dgvData.TabIndex = 5;
|
||||
this.dgvData.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellClick);
|
||||
//
|
||||
// VarName
|
||||
//
|
||||
this.VarName.DataPropertyName = "VarName";
|
||||
this.VarName.FillWeight = 80F;
|
||||
this.VarName.HeaderText = "名称";
|
||||
this.VarName.MinimumWidth = 6;
|
||||
this.VarName.Name = "VarName";
|
||||
this.VarName.Width = 200;
|
||||
//
|
||||
// VarDesc
|
||||
//
|
||||
this.VarDesc.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.VarDesc.DataPropertyName = "VarDesc";
|
||||
this.VarDesc.HeaderText = "注释";
|
||||
this.VarDesc.MinimumWidth = 6;
|
||||
this.VarDesc.Name = "VarDesc";
|
||||
//
|
||||
// PLC
|
||||
//
|
||||
this.PLC.DataPropertyName = "PLC";
|
||||
this.PLC.HeaderText = "PLC";
|
||||
this.PLC.Name = "PLC";
|
||||
this.PLC.ReadOnly = true;
|
||||
this.PLC.Width = 60;
|
||||
//
|
||||
// Address
|
||||
//
|
||||
this.Address.DataPropertyName = "Address";
|
||||
this.Address.HeaderText = "地址";
|
||||
this.Address.MinimumWidth = 6;
|
||||
this.Address.Name = "Address";
|
||||
this.Address.ReadOnly = true;
|
||||
this.Address.Width = 80;
|
||||
//
|
||||
// DatType
|
||||
//
|
||||
this.DatType.DataPropertyName = "DatType";
|
||||
this.DatType.HeaderText = "数据类型";
|
||||
this.DatType.Name = "DatType";
|
||||
this.DatType.ReadOnly = true;
|
||||
//
|
||||
// DecimalPlaces
|
||||
//
|
||||
this.DecimalPlaces.DataPropertyName = "DecimalPlaces";
|
||||
this.DecimalPlaces.HeaderText = "小数位数";
|
||||
this.DecimalPlaces.Name = "DecimalPlaces";
|
||||
this.DecimalPlaces.ReadOnly = true;
|
||||
//
|
||||
// StringLength
|
||||
//
|
||||
this.StringLength.DataPropertyName = "StringLength";
|
||||
this.StringLength.HeaderText = "字符长度";
|
||||
this.StringLength.Name = "StringLength";
|
||||
this.StringLength.ReadOnly = true;
|
||||
//
|
||||
// IsReadOnly
|
||||
//
|
||||
this.IsReadOnly.DataPropertyName = "IsReadOnly";
|
||||
this.IsReadOnly.HeaderText = "只读";
|
||||
this.IsReadOnly.Name = "IsReadOnly";
|
||||
//
|
||||
// FrmPlcDataTable
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(972, 569);
|
||||
this.Controls.Add(this.dgvData);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FrmPlcDataTable";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "编辑监控数据地址";
|
||||
this.panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Button btnImport;
|
||||
private System.Windows.Forms.Button btnExport;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.DataGridView dgvData;
|
||||
private System.Windows.Forms.Button btnDel;
|
||||
private System.Windows.Forms.Button btnAdd;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn VarName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn VarDesc;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn PLC;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Address;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn DatType;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn DecimalPlaces;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn StringLength;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn IsReadOnly;
|
||||
}
|
||||
}
|
||||
192
CowainHmi/PlcDataTable/FrmPlcDataTable.cs
Normal file
192
CowainHmi/PlcDataTable/FrmPlcDataTable.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using CowainHmi.Alarm;
|
||||
using CowainHmi.UIEditor;
|
||||
using PCHMI;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static System.Windows.Forms.LinkLabel;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace CowainHmi
|
||||
{
|
||||
public partial class FrmPlcDataTable : Form
|
||||
{
|
||||
public static List<PlcTagColumn> Str2TagList(string txt)
|
||||
{
|
||||
List<PlcTagColumn> list = new List<PlcTagColumn>();
|
||||
if (!string.IsNullOrEmpty(txt))
|
||||
{
|
||||
string[] rows = Regex.Split(txt, "\r\n", RegexOptions.IgnoreCase);
|
||||
if (rows.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(rows[i]))
|
||||
{
|
||||
PlcTagColumn plcTagColumn = new PlcTagColumn(rows[i]);
|
||||
list.Add(plcTagColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public bool IsSaved { get; set; }
|
||||
public string SaveData { get; set; } = "";
|
||||
private BindingList<PlcTagColumn> tagList = new BindingList<PlcTagColumn>();
|
||||
public FrmPlcDataTable(string dataTxt)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.dgvData.AutoGenerateColumns = false;
|
||||
this.dgvData.DataSource = tagList;
|
||||
this.SaveData = dataTxt;
|
||||
var list = Str2TagList(dataTxt);
|
||||
foreach (var item in list)
|
||||
{
|
||||
tagList.Add(item);
|
||||
}
|
||||
if (tagList.Count == 0)
|
||||
{
|
||||
tagList.Add(new PlcTagColumn("请重命名", ""));
|
||||
}
|
||||
}
|
||||
public DataTable ExcelToDataTable(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Type type = Assembly.Load(File.ReadAllBytes(new FILE().GET_RELEASE_DIR() + "\\NPOI(2.3).dll")).GetType("NPOI.ExcelHelper");
|
||||
object obj = Activator.CreateInstance(type);
|
||||
return (DataTable)type.GetMethod("ExcelToDataTable").Invoke(obj, new object[1] { fileName });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
return new DataTable();
|
||||
}
|
||||
|
||||
|
||||
private void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.InitialDirectory = new FILE().GET_RELEASE_DIR();
|
||||
openFileDialog.Filter = "(*.xlsx)|*.xls";
|
||||
openFileDialog.RestoreDirectory = true;
|
||||
openFileDialog.FilterIndex = 1;
|
||||
if (openFileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DataTable dataTable = ExcelToDataTable(openFileDialog.FileName);
|
||||
if (dataTable != null && dataTable.Rows.Count > 0)
|
||||
{
|
||||
tagList.Clear();
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
int val = 0;
|
||||
PlcTagColumn tag = new PlcTagColumn
|
||||
{
|
||||
PLC = row["PLC"] != null ? (int.TryParse(row["PLC"].ToString(), out val) ? val : 0) : 0,
|
||||
Address = row["地址"] != null ? row["地址"].ToString() : "",
|
||||
DecimalPlaces = row["小数位数"] != null ? (int.TryParse(row["小数位数"].ToString(), out val) ? val : 0) : 0,
|
||||
StringLength = row["字符长度"] != null ? (int.TryParse(row["字符长度"].ToString(), out val) ? val : 0) : 0,
|
||||
VarName = row["名称"] != null ? row["名称"].ToString() : "",
|
||||
VarDesc = row["注释"] != null ? row["注释"].ToString() : "",
|
||||
IsReadOnly = row["只读"] != null ? (bool.TryParse(row["只读"].ToString(), out bool readOnly) ? readOnly : false) : false,
|
||||
DatType = row["数据类型"] != null ? (Enum.TryParse<字段.DatType>(row["数据类型"].ToString(), out 字段.DatType datType) ? datType : 字段.DatType.INT16) : 字段.DatType.INT16
|
||||
};
|
||||
tagList.Add(tag);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("文件内容不匹配!", "错误提示!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
Excel.Export(this.dgvData);
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (var item in this.tagList)
|
||||
{
|
||||
list.Add(item.ToString());
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
this.SaveData = string.Join("\r\n", list);
|
||||
}
|
||||
this.IsSaved = true;
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
FrmAddRow frmAddRow = new FrmAddRow();
|
||||
if (frmAddRow.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
for (int i = 0; i < frmAddRow.RowCount; i++)
|
||||
{
|
||||
tagList.Add(new PlcTagColumn("请重命名", ""));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.dgvData.SelectedRows.Count > 0)
|
||||
{
|
||||
// 显示确认对话框
|
||||
var result = MessageBox.Show("确定要删除选中的行吗?", "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 遍历所有选中行并删除
|
||||
foreach (DataGridViewRow row in dgvData.SelectedRows)
|
||||
{
|
||||
// 如果行不是新行(未保存的行),则删除
|
||||
if (!row.IsNewRow && row.Index >= 0)
|
||||
{
|
||||
dgvData.Rows.RemoveAt(row.Index);
|
||||
}
|
||||
}
|
||||
dgvData.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("请选择要删除的行。");
|
||||
}
|
||||
}
|
||||
|
||||
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex >= 2 && e.ColumnIndex <= 6 && e.RowIndex >= 0)
|
||||
{
|
||||
FrmTagEdit frmTagEdit = new FrmTagEdit(tagList[e.RowIndex]);
|
||||
if (frmTagEdit.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
tagList[e.RowIndex] = frmTagEdit.PlcTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
144
CowainHmi/PlcDataTable/FrmPlcDataTable.resx
Normal file
144
CowainHmi/PlcDataTable/FrmPlcDataTable.resx
Normal file
@@ -0,0 +1,144 @@
|
||||
<?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="VarName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="VarDesc.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="PLC.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Address.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="DatType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="DecimalPlaces.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="StringLength.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="IsReadOnly.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
231
CowainHmi/PlcDataTable/FrmTagEdit.Designer.cs
generated
Normal file
231
CowainHmi/PlcDataTable/FrmTagEdit.Designer.cs
generated
Normal file
@@ -0,0 +1,231 @@
|
||||
namespace CowainHmi.UIEditor
|
||||
{
|
||||
partial class FrmTagEdit
|
||||
{
|
||||
/// <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.label1 = new System.Windows.Forms.Label();
|
||||
this.udPLC = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtAddress = new System.Windows.Forms.TextBox();
|
||||
this.udDecimalPlaces = new System.Windows.Forms.NumericUpDown();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.udStringLength = new System.Windows.Forms.NumericUpDown();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.cbxType = new System.Windows.Forms.ComboBox();
|
||||
this.btnOk = new System.Windows.Forms.Button();
|
||||
this.txtVarName = new System.Windows.Forms.TextBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.txtVarDesc = new System.Windows.Forms.TextBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.udPLC)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.udDecimalPlaces)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.udStringLength)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(33, 96);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(23, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "PLC";
|
||||
//
|
||||
// udPLC
|
||||
//
|
||||
this.udPLC.Location = new System.Drawing.Point(119, 92);
|
||||
this.udPLC.Name = "udPLC";
|
||||
this.udPLC.Size = new System.Drawing.Size(222, 21);
|
||||
this.udPLC.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(33, 136);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(29, 12);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "地址";
|
||||
//
|
||||
// txtAddress
|
||||
//
|
||||
this.txtAddress.Location = new System.Drawing.Point(119, 132);
|
||||
this.txtAddress.Name = "txtAddress";
|
||||
this.txtAddress.Size = new System.Drawing.Size(222, 21);
|
||||
this.txtAddress.TabIndex = 3;
|
||||
//
|
||||
// udDecimalPlaces
|
||||
//
|
||||
this.udDecimalPlaces.Location = new System.Drawing.Point(119, 211);
|
||||
this.udDecimalPlaces.Name = "udDecimalPlaces";
|
||||
this.udDecimalPlaces.Size = new System.Drawing.Size(222, 21);
|
||||
this.udDecimalPlaces.TabIndex = 5;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(33, 216);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 12);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "小数位数";
|
||||
//
|
||||
// udStringLength
|
||||
//
|
||||
this.udStringLength.Location = new System.Drawing.Point(119, 251);
|
||||
this.udStringLength.Maximum = new decimal(new int[] {
|
||||
256,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.udStringLength.Name = "udStringLength";
|
||||
this.udStringLength.Size = new System.Drawing.Size(222, 21);
|
||||
this.udStringLength.TabIndex = 7;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(33, 256);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(53, 12);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "字符长度";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(33, 176);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(53, 12);
|
||||
this.label5.TabIndex = 8;
|
||||
this.label5.Text = "数据类型";
|
||||
//
|
||||
// cbxType
|
||||
//
|
||||
this.cbxType.FormattingEnabled = true;
|
||||
this.cbxType.Location = new System.Drawing.Point(119, 172);
|
||||
this.cbxType.Name = "cbxType";
|
||||
this.cbxType.Size = new System.Drawing.Size(222, 20);
|
||||
this.cbxType.TabIndex = 9;
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.Location = new System.Drawing.Point(119, 298);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Size = new System.Drawing.Size(110, 38);
|
||||
this.btnOk.TabIndex = 10;
|
||||
this.btnOk.Text = "确认";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
|
||||
//
|
||||
// txtVarName
|
||||
//
|
||||
this.txtVarName.Location = new System.Drawing.Point(119, 12);
|
||||
this.txtVarName.Name = "txtVarName";
|
||||
this.txtVarName.Size = new System.Drawing.Size(222, 21);
|
||||
this.txtVarName.TabIndex = 12;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(33, 16);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(29, 12);
|
||||
this.label6.TabIndex = 11;
|
||||
this.label6.Text = "名称";
|
||||
//
|
||||
// txtVarDesc
|
||||
//
|
||||
this.txtVarDesc.Location = new System.Drawing.Point(119, 52);
|
||||
this.txtVarDesc.Name = "txtVarDesc";
|
||||
this.txtVarDesc.Size = new System.Drawing.Size(222, 21);
|
||||
this.txtVarDesc.TabIndex = 14;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(33, 56);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(29, 12);
|
||||
this.label7.TabIndex = 13;
|
||||
this.label7.Text = "描述";
|
||||
//
|
||||
// FrmTagEdit
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(367, 359);
|
||||
this.Controls.Add(this.txtVarDesc);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.txtVarName);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.btnOk);
|
||||
this.Controls.Add(this.cbxType);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.udStringLength);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.udDecimalPlaces);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.txtAddress);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.udPLC);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FrmTagEdit";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "标签设置";
|
||||
((System.ComponentModel.ISupportInitialize)(this.udPLC)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.udDecimalPlaces)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.udStringLength)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.NumericUpDown udPLC;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txtAddress;
|
||||
private System.Windows.Forms.NumericUpDown udDecimalPlaces;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.NumericUpDown udStringLength;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.ComboBox cbxType;
|
||||
private System.Windows.Forms.Button btnOk;
|
||||
private System.Windows.Forms.TextBox txtVarName;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox txtVarDesc;
|
||||
private System.Windows.Forms.Label label7;
|
||||
}
|
||||
}
|
||||
54
CowainHmi/PlcDataTable/FrmTagEdit.cs
Normal file
54
CowainHmi/PlcDataTable/FrmTagEdit.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace CowainHmi.UIEditor
|
||||
{
|
||||
public partial class FrmTagEdit : Form
|
||||
{
|
||||
public PlcTagColumn PlcTag { get; set; }
|
||||
public FrmTagEdit(PlcTagColumn tag)
|
||||
{
|
||||
InitializeComponent();
|
||||
PlcTag = tag;
|
||||
List<KeyValuePair<string, 字段.DatType>> enumList = Enum.GetValues(typeof(字段.DatType))
|
||||
.Cast<字段.DatType>()
|
||||
.Select(e => new KeyValuePair<string, 字段.DatType>(e.ToString(), e))
|
||||
.ToList();
|
||||
// 绑定数据源
|
||||
cbxType.DisplayMember = "Key"; // 显示枚举的名称
|
||||
cbxType.ValueMember = "Value"; // 存储枚举的值
|
||||
cbxType.DataSource = enumList;
|
||||
this.udPLC.Value = tag.PLC;
|
||||
this.txtAddress.Text = tag.Address;
|
||||
this.cbxType.SelectedValue = tag.DatType;
|
||||
this.udDecimalPlaces.Value = tag.DecimalPlaces;
|
||||
this.udStringLength.Value = tag.StringLength;
|
||||
this.txtVarName.Text = tag.VarName;
|
||||
this.txtVarDesc.Text = tag.VarDesc;
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
PlcTag = new PlcTagColumn()
|
||||
{
|
||||
PLC = (int)this.udPLC.Value,
|
||||
Address = this.txtAddress.Text,
|
||||
DecimalPlaces = (int)this.udDecimalPlaces.Value,
|
||||
StringLength = (int)this.udStringLength.Value,
|
||||
DatType = (字段.DatType)this.cbxType.SelectedValue,
|
||||
VarName = this.txtVarName.Text,
|
||||
VarDesc = this.txtVarDesc.Text,
|
||||
};
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
CowainHmi/PlcDataTable/FrmTagEdit.resx
Normal file
120
CowainHmi/PlcDataTable/FrmTagEdit.resx
Normal 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>
|
||||
83
CowainHmi/PlcDataTable/PlcTagColumn.cs
Normal file
83
CowainHmi/PlcDataTable/PlcTagColumn.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CowainHmi
|
||||
{
|
||||
public class PlcTagColumn : INotifyPropertyChanged
|
||||
{
|
||||
private string varValue = "";
|
||||
private string address = "DB1.0";
|
||||
|
||||
public PlcTagColumn()
|
||||
{
|
||||
}
|
||||
|
||||
public PlcTagColumn(string varName, string varDesc)
|
||||
{
|
||||
VarName = varName;
|
||||
VarDesc = varDesc;
|
||||
}
|
||||
public PlcTagColumn(string text)
|
||||
{
|
||||
string[] array = Regex.Split(text, "<,>", RegexOptions.IgnoreCase);
|
||||
if (array.Length == 8)
|
||||
{
|
||||
int val = 0;
|
||||
VarName = array[0];
|
||||
VarDesc = array[1];
|
||||
PLC = int.TryParse(array[2], out val) ? val : 0;
|
||||
Address = array[3];
|
||||
DatType = Enum.TryParse<字段.DatType>(array[4], out 字段.DatType datType) ? datType : 字段.DatType.INT16;
|
||||
DecimalPlaces = int.TryParse(array[5], out val) ? val : 0;
|
||||
StringLength = int.TryParse(array[6], out val) ? val : 0;
|
||||
IsReadOnly = bool.TryParse(array[7], out bool readOnly) ? readOnly : false;
|
||||
}
|
||||
}
|
||||
|
||||
public string VarName { get; set; }
|
||||
public string VarDesc { get; set; }
|
||||
public int PLC { get; set; } = 0;
|
||||
public string Address
|
||||
{
|
||||
get => address;
|
||||
set
|
||||
{
|
||||
if (address != value)
|
||||
{
|
||||
address = value;
|
||||
OnPropertyChanged(nameof(Address));
|
||||
}
|
||||
}
|
||||
}
|
||||
public 字段.DatType DatType { get; set; } = 字段.DatType.INT16;
|
||||
public int DecimalPlaces { get; set; } = 0;
|
||||
public int StringLength { get; set; } = 10;
|
||||
public bool IsReadOnly { get; set; }
|
||||
public string VarValue
|
||||
{
|
||||
get => varValue;
|
||||
set
|
||||
{
|
||||
if (varValue != value)
|
||||
{
|
||||
varValue = value;
|
||||
OnPropertyChanged(nameof(VarValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{VarName}<,>{VarDesc}<,>{PLC}<,>{Address}<,>{DatType.ToString()}<,>{DecimalPlaces}<,>{StringLength}<,>{IsReadOnly.ToString()}";
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
121
CowainHmi/PlcDataTable/PlcValueHelper.cs
Normal file
121
CowainHmi/PlcDataTable/PlcValueHelper.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using PCHMI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CowainHmi.Helper
|
||||
{
|
||||
public class PlcValueHelper
|
||||
{
|
||||
public static string GetAddr(int plc, string addr)
|
||||
{
|
||||
return new VAR().GADDR(plc, addr);
|
||||
}
|
||||
public static string GetValueString(PlcTagColumn tag)
|
||||
{
|
||||
string address = GetAddr(tag.PLC, tag.Address);
|
||||
if (tag.DatType == 字段.DatType.String)
|
||||
{
|
||||
return PCHMI.VL.GET_STRING(tag.PLC, address, tag.StringLength);
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.SIEMENS_String)
|
||||
{
|
||||
return PCHMI.VL.GET_SIEMENS_STRING(tag.PLC, address, tag.StringLength);
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.DateTime)
|
||||
{
|
||||
return DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.BIT)
|
||||
{
|
||||
return PCHMI.VL.GET_BIT(tag.PLC, address).ToString();
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.INT32)
|
||||
{
|
||||
return new PClass().UuValue((ulong)PCHMI.VL.GET_INT32(tag.PLC, address), (uint)tag.DecimalPlaces, tag.DatType.ToString());
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.UINT32)
|
||||
{
|
||||
return new PClass().UuValue((ulong)PCHMI.VL.GET_UINT32(tag.PLC, address), (uint)tag.DecimalPlaces, tag.DatType.ToString());
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.INT16)
|
||||
{
|
||||
return new PClass().UuValue((ulong)PCHMI.VL.GET_INT16(tag.PLC, address), (uint)tag.DecimalPlaces, tag.DatType.ToString());
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.UINT16)
|
||||
{
|
||||
return new PClass().UuValue((ulong)PCHMI.VL.GET_UINT16(tag.PLC, address), (uint)tag.DecimalPlaces, tag.DatType.ToString());
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.F32)
|
||||
{
|
||||
return PCHMI.VL.GET_F32(tag.PLC, address).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Err Data Type";
|
||||
}
|
||||
}
|
||||
public static void UpdateTagValue(PlcTagColumn tag)
|
||||
{
|
||||
tag.VarValue = GetValueString(tag);
|
||||
}
|
||||
|
||||
public static void SetValue(PlcTagColumn tag)
|
||||
{
|
||||
string address = GetAddr(tag.PLC, tag.Address);
|
||||
if (tag.DatType == 字段.DatType.String)
|
||||
{
|
||||
PCHMI.RT.SEND_STRING(tag.PLC, address, tag.VarValue);
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.SIEMENS_String)
|
||||
{
|
||||
PCHMI.RT.SEND_SIEMENS_STRING(tag.PLC, address, tag.VarValue);
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.BIT)
|
||||
{
|
||||
if (ushort.TryParse(tag.VarValue, out ushort val))
|
||||
{
|
||||
PCHMI.RT.SEND_BIT(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.INT32)
|
||||
{
|
||||
if (int.TryParse(tag.VarValue, out int val))
|
||||
{
|
||||
PCHMI.RT.SEND_INT32(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.UINT32)
|
||||
{
|
||||
if (uint.TryParse(tag.VarValue, out uint val))
|
||||
{
|
||||
PCHMI.RT.SEND_UINT32(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.INT16)
|
||||
{
|
||||
if (short.TryParse(tag.VarValue, out short val))
|
||||
{
|
||||
PCHMI.RT.SEND_INT16(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.UINT16)
|
||||
{
|
||||
if (ushort.TryParse(tag.VarValue, out ushort val))
|
||||
{
|
||||
PCHMI.RT.SEND_UINT16(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
else if (tag.DatType == 字段.DatType.F32)
|
||||
{
|
||||
if (float.TryParse(tag.VarValue, out float val))
|
||||
{
|
||||
PCHMI.RT.SEND_F32(tag.PLC, address, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
37
CowainHmi/PlcDataTable/UIPlcDataEdit.cs
Normal file
37
CowainHmi/PlcDataTable/UIPlcDataEdit.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using PCHMI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Design;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace CowainHmi.UIEditor
|
||||
{
|
||||
public class UIPlcDataEdit : UITypeEditor
|
||||
{
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
IWindowsFormsEditorService windowsFormsEditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (windowsFormsEditorService != null)
|
||||
{
|
||||
FrmPlcDataTable frmPlcDataTable = new FrmPlcDataTable((string)value);
|
||||
frmPlcDataTable.ShowDialog();
|
||||
if (frmPlcDataTable.IsSaved)
|
||||
{
|
||||
return frmPlcDataTable.SaveData;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
132
CowainHmi/PlcDataTable/变量表格监控.Designer.cs
generated
Normal file
132
CowainHmi/PlcDataTable/变量表格监控.Designer.cs
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
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();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.dgvData = new System.Windows.Forms.DataGridView();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.VarName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.VarDesc = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Address = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.VarValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvData)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dgvData
|
||||
//
|
||||
this.dgvData.AllowUserToAddRows = false;
|
||||
this.dgvData.AllowUserToResizeRows = false;
|
||||
this.dgvData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.VarName,
|
||||
this.VarDesc,
|
||||
this.Address,
|
||||
this.VarValue});
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.dgvData.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.dgvData.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dgvData.Location = new System.Drawing.Point(0, 0);
|
||||
this.dgvData.Name = "dgvData";
|
||||
this.dgvData.ReadOnly = true;
|
||||
this.dgvData.RowHeadersWidth = 51;
|
||||
this.dgvData.RowTemplate.Height = 23;
|
||||
this.dgvData.Size = new System.Drawing.Size(839, 679);
|
||||
this.dgvData.TabIndex = 2;
|
||||
this.dgvData.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellClick);
|
||||
this.dgvData.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvData_RowPostPaint);
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// VarName
|
||||
//
|
||||
this.VarName.DataPropertyName = "VarName";
|
||||
this.VarName.HeaderText = "名称";
|
||||
this.VarName.MinimumWidth = 6;
|
||||
this.VarName.Name = "VarName";
|
||||
this.VarName.ReadOnly = true;
|
||||
//
|
||||
// VarDesc
|
||||
//
|
||||
this.VarDesc.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.VarDesc.DataPropertyName = "VarDesc";
|
||||
this.VarDesc.HeaderText = "注释";
|
||||
this.VarDesc.MinimumWidth = 6;
|
||||
this.VarDesc.Name = "VarDesc";
|
||||
this.VarDesc.ReadOnly = true;
|
||||
//
|
||||
// Address
|
||||
//
|
||||
this.Address.DataPropertyName = "Address";
|
||||
this.Address.HeaderText = "地址";
|
||||
this.Address.MinimumWidth = 6;
|
||||
this.Address.Name = "Address";
|
||||
this.Address.ReadOnly = true;
|
||||
this.Address.Visible = false;
|
||||
//
|
||||
// VarValue
|
||||
//
|
||||
this.VarValue.DataPropertyName = "VarValue";
|
||||
this.VarValue.HeaderText = "值";
|
||||
this.VarValue.MinimumWidth = 6;
|
||||
this.VarValue.Name = "VarValue";
|
||||
this.VarValue.ReadOnly = true;
|
||||
this.VarValue.Width = 80;
|
||||
//
|
||||
// 变量表格监控
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.dgvData);
|
||||
this.Name = "变量表格监控";
|
||||
this.Size = new System.Drawing.Size(839, 679);
|
||||
this.Load += new System.EventHandler(this.ucPlcDataTable_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvData)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dgvData;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn VarName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn VarDesc;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Address;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn VarValue;
|
||||
}
|
||||
}
|
||||
163
CowainHmi/PlcDataTable/变量表格监控.cs
Normal file
163
CowainHmi/PlcDataTable/变量表格监控.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using CowainHmi.Common;
|
||||
using CowainHmi.Helper;
|
||||
using CowainHmi.UIEditor;
|
||||
using PCHMI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace CowainHmi
|
||||
{
|
||||
public partial class 变量表格监控 : UserControl
|
||||
{
|
||||
private string varText = "";
|
||||
[Browsable(false)]
|
||||
public string TagText
|
||||
{
|
||||
get
|
||||
{
|
||||
return varText;
|
||||
}
|
||||
set
|
||||
{
|
||||
varText = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[Category("PCHMI")]
|
||||
[Description("设置变量表内容")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
[Editor(typeof(UIPlcDataEdit), typeof(UITypeEditor))]
|
||||
public string VarText
|
||||
{
|
||||
get => varText;
|
||||
set => varText = value;
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[Category("PCHMI")]
|
||||
[Description("DB块号,只有西门子PLC支持设置")]
|
||||
public int DB
|
||||
{
|
||||
get => dB;
|
||||
set
|
||||
{
|
||||
dB = value;
|
||||
SetDB();
|
||||
}
|
||||
}
|
||||
public List<PlcTagColumn> TagList { get => tagList.ToList(); }
|
||||
private BindingList<PlcTagColumn> tagList = new BindingList<PlcTagColumn>();
|
||||
private int dB;
|
||||
|
||||
public 变量表格监控()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.dgvData.AutoGenerateColumns = false;
|
||||
this.dgvData.DataSource = tagList;
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!PClass.SystemRun)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var item in tagList)
|
||||
{
|
||||
item.VarValue = PlcValueHelper.GetValueString(item);
|
||||
}
|
||||
//this.dgvData.Refresh();
|
||||
}
|
||||
private void SetDB()
|
||||
{
|
||||
foreach (var item in tagList)
|
||||
{
|
||||
if (DB > 0)
|
||||
{
|
||||
string address = PlcValueHelper.GetAddr(item.PLC, item.Address);
|
||||
string[] array = address.Split('.');
|
||||
if (address.StartsWith("DB") && array.Length > 1)
|
||||
{
|
||||
array[0] = $"DB{DB}";
|
||||
item.Address = string.Join(".", array);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ucPlcDataTable_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!PClass.SystemRun)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var list = FrmPlcDataTable.Str2TagList(varText);
|
||||
foreach (var item in list)
|
||||
{
|
||||
tagList.Add(item);
|
||||
}
|
||||
SetDB();
|
||||
this.timer1.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
private void dgvData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
||||
{
|
||||
new DataGridViewStyle().DgvRowPostPaint(this.dgvData, e);
|
||||
}
|
||||
|
||||
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == this.dgvData.Columns["VarValue"].Index && e.RowIndex >= 0)
|
||||
{
|
||||
if (tagList[e.RowIndex].IsReadOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (tagList[e.RowIndex].DatType != 字段.DatType.BIT)
|
||||
{
|
||||
DlgEditPlcValue editPlcValue = new DlgEditPlcValue(tagList[e.RowIndex]);
|
||||
editPlcValue.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
//是位变量,按下切换
|
||||
var result = MessageBox.Show("确定要切换变量吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string oldValue = tagList[e.RowIndex].VarValue;
|
||||
if (tagList[e.RowIndex].VarValue == "1")
|
||||
{
|
||||
tagList[e.RowIndex].VarValue = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
tagList[e.RowIndex].VarValue = "1";
|
||||
}
|
||||
PCHMI.OPTLOG.WLOG($"手动修改了数值,名称:{tagList[e.RowIndex].VarName}地址:{tagList[e.RowIndex].Address},原值:{oldValue},新值:{tagList[e.RowIndex].VarValue}");
|
||||
PlcValueHelper.SetValue(tagList[e.RowIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
135
CowainHmi/PlcDataTable/变量表格监控.resx
Normal file
135
CowainHmi/PlcDataTable/变量表格监控.resx
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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="VarName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="VarDesc.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Address.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="VarValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<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>
|
||||
Reference in New Issue
Block a user