修改
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
@@ -45,10 +45,18 @@
|
|||||||
<Reference Include="FastReport">
|
<Reference Include="FastReport">
|
||||||
<HintPath>..\public\FastReport.dll</HintPath>
|
<HintPath>..\public\FastReport.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
|
<Reference Include="UIAutomationProvider" />
|
||||||
|
<Reference Include="WindowsFormsIntegration" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Update="FrmUserControl\frmIOMonitorAuto.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Update="FrmUserControl\frmShiftCountRecord.cs">
|
<Compile Update="FrmUserControl\frmShiftCountRecord.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
101
CleanMachineHMI/FrmUserControl/IOBlock.Designer.cs
generated
Normal file
101
CleanMachineHMI/FrmUserControl/IOBlock.Designer.cs
generated
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
namespace CleanMachineHMI.FrmUserControl
|
||||||
|
{
|
||||||
|
partial class IOBlock
|
||||||
|
{
|
||||||
|
/// <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.panel62 = new System.Windows.Forms.Panel();
|
||||||
|
this.labelName = new Krypton.Toolkit.KryptonLabel();
|
||||||
|
this.cbt_value = new CleanMachineHMI.CircleButton();
|
||||||
|
this.labelCode = new Krypton.Toolkit.KryptonLabel();
|
||||||
|
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.panel62.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel62
|
||||||
|
//
|
||||||
|
this.panel62.BackColor = System.Drawing.Color.White;
|
||||||
|
this.panel62.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.panel62.Controls.Add(this.labelName);
|
||||||
|
this.panel62.Controls.Add(this.cbt_value);
|
||||||
|
this.panel62.Controls.Add(this.labelCode);
|
||||||
|
this.panel62.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel62.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel62.Name = "panel62";
|
||||||
|
this.panel62.Size = new System.Drawing.Size(222, 35);
|
||||||
|
this.panel62.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.Location = new System.Drawing.Point(50, 7);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(84, 15);
|
||||||
|
this.labelName.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.labelName.TabIndex = 3;
|
||||||
|
this.labelName.Values.Text = "kryptonLabel2";
|
||||||
|
//
|
||||||
|
// cbt_value
|
||||||
|
//
|
||||||
|
this.cbt_value.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255)))));
|
||||||
|
this.cbt_value.Location = new System.Drawing.Point(31, 3);
|
||||||
|
this.cbt_value.Name = "cbt_value";
|
||||||
|
this.cbt_value.Size = new System.Drawing.Size(23, 23);
|
||||||
|
this.cbt_value.TabIndex = 2;
|
||||||
|
this.cbt_value.UseVisualStyleBackColor = false;
|
||||||
|
//
|
||||||
|
// labelCode
|
||||||
|
//
|
||||||
|
this.labelCode.Location = new System.Drawing.Point(0, 6);
|
||||||
|
this.labelCode.Name = "labelCode";
|
||||||
|
this.labelCode.Size = new System.Drawing.Size(32, 17);
|
||||||
|
this.labelCode.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.labelCode.TabIndex = 2;
|
||||||
|
this.labelCode.Values.Text = "Y17";
|
||||||
|
//
|
||||||
|
// IOBlock
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.panel62);
|
||||||
|
this.Name = "IOBlock";
|
||||||
|
this.Size = new System.Drawing.Size(222, 35);
|
||||||
|
this.panel62.ResumeLayout(false);
|
||||||
|
this.panel62.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Panel panel62;
|
||||||
|
private Krypton.Toolkit.KryptonLabel labelName;
|
||||||
|
private CircleButton cbt_value;
|
||||||
|
private Krypton.Toolkit.KryptonLabel labelCode;
|
||||||
|
private System.Windows.Forms.ToolTip toolTip1;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
CleanMachineHMI/FrmUserControl/IOBlock.cs
Normal file
57
CleanMachineHMI/FrmUserControl/IOBlock.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
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 CleanMachineHMI.FrmUserControl
|
||||||
|
{
|
||||||
|
public partial class IOBlock : UserControl
|
||||||
|
{
|
||||||
|
public IOBlock()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.labelCode.Text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string IOName
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.labelName.Text = value;
|
||||||
|
this.toolTip1.SetToolTip(this.labelName, value);
|
||||||
|
// this.toolTip1.ToolTipTitle = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Value
|
||||||
|
{
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
|
||||||
|
this.cbt_value.BackColor = value ? Color.Lime : Color.Red;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
123
CleanMachineHMI/FrmUserControl/IOBlock.resx
Normal file
123
CleanMachineHMI/FrmUserControl/IOBlock.resx
Normal 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="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -16,7 +16,7 @@ using CleanMachine.Model.BAS;
|
|||||||
|
|
||||||
namespace CleanMachineHMI.FrmUserControl
|
namespace CleanMachineHMI.FrmUserControl
|
||||||
{
|
{
|
||||||
[FormType(EnumFormType.IoMonitor)]
|
|
||||||
public partial class frmIOMonitor : UserControl
|
public partial class frmIOMonitor : UserControl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
61
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.Designer.cs
generated
Normal file
61
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.Designer.cs
generated
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
namespace CleanMachineHMI.FrmUserControl
|
||||||
|
{
|
||||||
|
partial class frmIOMonitorAuto
|
||||||
|
{
|
||||||
|
/// <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.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// flowLayoutPanel1
|
||||||
|
//
|
||||||
|
this.flowLayoutPanel1.AutoScroll = true;
|
||||||
|
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||||
|
this.flowLayoutPanel1.Size = new System.Drawing.Size(1024, 672);
|
||||||
|
this.flowLayoutPanel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// frmIOMonitorAuto
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.flowLayoutPanel1);
|
||||||
|
this.Name = "frmIOMonitorAuto";
|
||||||
|
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
|
this.Size = new System.Drawing.Size(1024, 672);
|
||||||
|
this.Load += new System.EventHandler(this.frmIOMonitorNew_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||||
|
}
|
||||||
|
}
|
||||||
180
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.cs
Normal file
180
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.cs
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
using CleanMachineHMI.Domain.Enums;
|
||||||
|
using CleanMachineHMI.Utils;
|
||||||
|
using Krypton.Toolkit;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using CleanMachine.Model;
|
||||||
|
using CleanMachine.Model.BAS;
|
||||||
|
|
||||||
|
namespace CleanMachineHMI.FrmUserControl
|
||||||
|
{
|
||||||
|
[FormType(EnumFormType.IoMonitor)]
|
||||||
|
public partial class frmIOMonitorAuto : UserControl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public frmIOMonitorAuto()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmIOMonitorNew_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
initControl();
|
||||||
|
PlcOperationHelper.Instance.OnShowX_Y_Status += Show_X_Y_Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<PlcItem, IOBlock> buttons = new Dictionary<PlcItem, IOBlock>();
|
||||||
|
|
||||||
|
|
||||||
|
private CircleButton findeControl(PlcItem item)
|
||||||
|
{
|
||||||
|
var controlname = item.PlcItemDataType == PlcItemTypeDesc.X ? "cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0') :
|
||||||
|
"cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0');
|
||||||
|
var controls = this.Controls.Find(controlname, true);
|
||||||
|
return controls.Count() > 0 ? controls[0] as CircleButton : null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Show_X_Y_Status(IEnumerable<PlcItem> items)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (buttons.TryGetValue(item, out var btn))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item.PlcItemValue))
|
||||||
|
{
|
||||||
|
btn.Value = bool.Parse(item.PlcItemValue.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//btn = findeControl(item);
|
||||||
|
//buttons.Add(item, btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//private void Show_X_Y_Status(IEnumerable<PlcItem> items)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// BeginInvoke(new Action(() =>
|
||||||
|
// {
|
||||||
|
// foreach (var item in items)
|
||||||
|
// {
|
||||||
|
// if (item.PlcItemDataType == 2)
|
||||||
|
// {
|
||||||
|
// if (this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
||||||
|
// {
|
||||||
|
// CircleButton ctn = this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as CircleButton;
|
||||||
|
// if (string.IsNullOrEmpty(item.PlcItemValue))
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.FromArgb(191, 219, 255);
|
||||||
|
// }
|
||||||
|
// else if (bool.Parse(item.PlcItemValue.ToString()))
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.Lime;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.Red;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
||||||
|
// {
|
||||||
|
// CircleButton ctn = this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as CircleButton;
|
||||||
|
// if (string.IsNullOrEmpty(item.PlcItemValue))
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.FromArgb(191, 219, 255);
|
||||||
|
// }
|
||||||
|
// else if (bool.Parse(item.PlcItemValue.ToString()))
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.Lime;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ctn.BackColor = Color.Red;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }));
|
||||||
|
//}
|
||||||
|
private void initControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PlcOperationHelper.Instance.PlcItemMd_X_List != null && PlcOperationHelper.Instance.PlcItemMd_X_List.Count > 0)
|
||||||
|
{
|
||||||
|
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
|
||||||
|
foreach (PlcItem item in tempLst)
|
||||||
|
{
|
||||||
|
var IO = new IOBlock();
|
||||||
|
IO.Code = "X" + (int.Parse( item.PlcItemPriAddress)+1).ToString().PadLeft(2, '0');
|
||||||
|
IO.IOName = this.T(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode);
|
||||||
|
this.flowLayoutPanel1.Controls.Add(IO);
|
||||||
|
buttons.Add(item, IO);
|
||||||
|
//if (this.Controls.Find("klb_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
||||||
|
//{
|
||||||
|
// KryptonLabel label1 = this.Controls.Find("klb_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as KryptonLabel;
|
||||||
|
|
||||||
|
// label1.Text = this.T(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PlcOperationHelper.Instance.PlcItemMd_Y_List != null && PlcOperationHelper.Instance.PlcItemMd_Y_List.Count > 0)
|
||||||
|
{
|
||||||
|
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
|
||||||
|
foreach (PlcItem item in tempLst)
|
||||||
|
{
|
||||||
|
var IO = new IOBlock();
|
||||||
|
IO.Code = "Y" + (int.Parse(item.PlcItemPriAddress) + 1).ToString().PadLeft(2,'0');
|
||||||
|
IO.IOName = this.T(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode);
|
||||||
|
this.flowLayoutPanel1.Controls.Add(IO);
|
||||||
|
|
||||||
|
buttons.Add(item, IO);
|
||||||
|
|
||||||
|
//if (this.Controls.Find("klb_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
||||||
|
//{
|
||||||
|
// KryptonLabel label1 = this.Controls.Find("klb_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as KryptonLabel;
|
||||||
|
|
||||||
|
// label1.Text = this.T(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Show_X_Y_Status(PlcOperationHelper.Instance.PlcItemMd_X_List);
|
||||||
|
|
||||||
|
Show_X_Y_Status(PlcOperationHelper.Instance.PlcItemMd_Y_List);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
KryptonMessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.resx
Normal file
120
CleanMachineHMI/FrmUserControl/frmIOMonitorAuto.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>
|
||||||
@@ -161,13 +161,22 @@ namespace CleanMachineHMI
|
|||||||
|
|
||||||
private void RefreshPlcItem()
|
private void RefreshPlcItem()
|
||||||
{
|
{
|
||||||
|
Stopwatch stopWatch = new Stopwatch();
|
||||||
while (Global.SysThIsRunFlag)
|
while (Global.SysThIsRunFlag)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
stopWatch.Restart();
|
||||||
var haschange = false;
|
var haschange = false;
|
||||||
RefreshPlcItem_M(ref haschange);
|
RefreshPlcItem_M(ref haschange);
|
||||||
RefreshPlcItem_D(ref haschange);
|
RefreshPlcItem_D(ref haschange);
|
||||||
RefreshPlcItem_X(ref haschange);
|
RefreshPlcItem_X(ref haschange);
|
||||||
RefreshPlcItem_Y(ref haschange);
|
RefreshPlcItem_Y(ref haschange);
|
||||||
|
|
||||||
|
stopWatch.Stop();
|
||||||
|
|
||||||
|
TimeSpan ts = stopWatch.Elapsed;
|
||||||
|
LogHelper.WriteLog($"读取PLC时间:{ts.Milliseconds}", LogTypeEum.Run);
|
||||||
if (haschange)
|
if (haschange)
|
||||||
{
|
{
|
||||||
if (_synchronization != null)
|
if (_synchronization != null)
|
||||||
@@ -175,9 +184,16 @@ namespace CleanMachineHMI
|
|||||||
_synchronization.Post(this.DoOnReadFinish, null);
|
_synchronization.Post(this.DoOnReadFinish, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// thEvent.Set();
|
// thEvent.Set();
|
||||||
// ShowWarningMsg();
|
// ShowWarningMsg();
|
||||||
Thread.Sleep(100);
|
int sleeptime = 100 - ts.Milliseconds;
|
||||||
|
if (sleeptime<0)
|
||||||
|
{
|
||||||
|
sleeptime = 0;
|
||||||
|
}
|
||||||
|
Thread.Sleep(sleeptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,11 +225,11 @@ namespace CleanMachineHMI
|
|||||||
PlcOperationHelper.Instance.StartRead();
|
PlcOperationHelper.Instance.StartRead();
|
||||||
|
|
||||||
|
|
||||||
Thread th = new Thread(RefreshPlcItem)
|
//Thread th = new Thread(RefreshPlcItem)
|
||||||
{
|
//{
|
||||||
IsBackground = true
|
// IsBackground = true
|
||||||
};
|
//};
|
||||||
th.Start();
|
//th.Start();
|
||||||
|
|
||||||
|
|
||||||
//Thread th = new Thread(RefreshPlcItem_M)
|
//Thread th = new Thread(RefreshPlcItem_M)
|
||||||
@@ -271,7 +271,7 @@ namespace CleanMachineHMI
|
|||||||
label3Professional.BackColor = Color.Red;
|
label3Professional.BackColor = Color.Red;
|
||||||
isPlcConnStatus = false;
|
isPlcConnStatus = false;
|
||||||
|
|
||||||
LogHelper.WriteLog($"串口打开失败,PLC连接成功!", LogTypeEum.Run);
|
LogHelper.WriteLog($"串口打开失败,PLC连接失败!", LogTypeEum.Run);
|
||||||
}
|
}
|
||||||
|
|
||||||
MothedShowMessage = new dlgShowMessage(Test);
|
MothedShowMessage = new dlgShowMessage(Test);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace NX_LogUtility
|
|||||||
string filePath = strDir2 + fileDate + "_" + logType + ".log";
|
string filePath = strDir2 + fileDate + "_" + logType + ".log";
|
||||||
string DateString = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
string DateString = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||||
string Str = "发生时间:" + DateString + "|" + Txt + "\r\n";
|
string Str = "发生时间:" + DateString + "|" + Txt + "\r\n";
|
||||||
|
Console.WriteLine(Str);
|
||||||
WriteFile(strDir2, filePath, Str);
|
WriteFile(strDir2, filePath, Str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user