Compare commits

...
2 Commits
Author SHA1 Message Date
gf zhou 4419a4de3c oee相关修改 2025-04-17 18:37:22 +08:00
gf zhou 9c5ef7bb31 416 添加OEE报警相关 2025-04-17 09:20:19 +08:00
13 changed files with 1533 additions and 239 deletions

No files matched your search

+11 -2
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper">
<HintPath>..\..\CsvHelper.dll</HintPath>
<HintPath>Z:\WHProjects\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="HslCommunication, Version=7.0.1.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
<HintPath>..\packages\HslCommunication.7.0.1\lib\net451\HslCommunication.dll</HintPath>
@@ -103,6 +103,10 @@
<Compile Include="form\editForm\Angleaddress_Insert.Designer.cs">
<DependentUpon>Angleaddress_Insert.cs</DependentUpon>
</Compile>
<Compile Include="form\editForm\OEEaddress_Insert.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="form\editForm\OEEaddress_Insert.Designer.cs" />
<Compile Include="form\editForm\Torqueaddress_Insert.cs">
<SubType>Form</SubType>
</Compile>
@@ -175,6 +179,10 @@
<Compile Include="form\LoadingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="form\OEEaddress_Manage.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="form\OEEaddress_Manage.Designer.cs" />
<Compile Include="form\ScanForm_DZ.cs">
<SubType>Form</SubType>
</Compile>
@@ -250,6 +258,7 @@
<Compile Include="form\MaterialScanForm.Designer.cs">
<DependentUpon>MaterialScanForm.cs</DependentUpon>
</Compile>
<Compile Include="mod\database\t_oeeaddress.cs" />
<Compile Include="mod\database\t_imageposition.cs" />
<Compile Include="mod\database\t_lineplc.cs" />
<Compile Include="mod\database\t_materialcall.cs" />
+96 -86
View File
@@ -114,6 +114,7 @@ namespace WindowsFormsApp1
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.oEE地址管理ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.plcStatusGroupBox.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
@@ -135,9 +136,9 @@ namespace WindowsFormsApp1
this.plcStatusGroupBox.Controls.Add(this.plcStatusTableLayout);
this.plcStatusGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.plcStatusGroupBox.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
this.plcStatusGroupBox.Location = new System.Drawing.Point(3, 931);
this.plcStatusGroupBox.Location = new System.Drawing.Point(3, 969);
this.plcStatusGroupBox.Name = "plcStatusGroupBox";
this.plcStatusGroupBox.Size = new System.Drawing.Size(1754, 90);
this.plcStatusGroupBox.Size = new System.Drawing.Size(1754, 94);
this.plcStatusGroupBox.TabIndex = 9;
this.plcStatusGroupBox.TabStop = false;
this.plcStatusGroupBox.Text = "PLC连接状态";
@@ -151,7 +152,7 @@ namespace WindowsFormsApp1
this.plcStatusTableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.plcStatusTableLayout.Location = new System.Drawing.Point(3, 40);
this.plcStatusTableLayout.Name = "plcStatusTableLayout";
this.plcStatusTableLayout.Size = new System.Drawing.Size(1748, 47);
this.plcStatusTableLayout.Size = new System.Drawing.Size(1748, 51);
this.plcStatusTableLayout.TabIndex = 0;
//
// menuStrip1
@@ -279,7 +280,8 @@ namespace WindowsFormsApp1
this.扭力角度扭矩设置ToolStripMenuItem,
this.螺丝枪扭力设置ToolStripMenuItem,
this.扭力曲线配置ToolStripMenuItem,
this.压力曲线设置ToolStripMenuItem});
this.压力曲线设置ToolStripMenuItem,
this.oEE地址管理ToolStripMenuItem});
this.扫码枪配置ToolStripMenuItem.Enabled = false;
this.扫码枪配置ToolStripMenuItem.Name = "扫码枪配置ToolStripMenuItem";
this.扫码枪配置ToolStripMenuItem.Size = new System.Drawing.Size(230, 45);
@@ -371,13 +373,13 @@ namespace WindowsFormsApp1
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 6;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 101F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 105F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 59.66998F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 35.03736F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 96F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5.292663F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1760, 1068);
this.tableLayoutPanel1.Size = new System.Drawing.Size(1760, 1112);
this.tableLayoutPanel1.TabIndex = 6;
//
// tableLayoutPanel3
@@ -390,12 +392,12 @@ namespace WindowsFormsApp1
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel2, 0, 0);
this.tableLayoutPanel3.Location = new System.Drawing.Point(5, 54);
this.tableLayoutPanel3.Location = new System.Drawing.Point(5, 56);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(1750, 89);
this.tableLayoutPanel3.Size = new System.Drawing.Size(1750, 93);
this.tableLayoutPanel3.TabIndex = 4;
//
// tableLayoutPanel2
@@ -424,7 +426,7 @@ namespace WindowsFormsApp1
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(1740, 77);
this.tableLayoutPanel2.Size = new System.Drawing.Size(1740, 81);
this.tableLayoutPanel2.TabIndex = 3;
//
// linemode
@@ -436,7 +438,7 @@ namespace WindowsFormsApp1
this.linemode.Location = new System.Drawing.Point(975, 1);
this.linemode.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.linemode.Name = "linemode";
this.linemode.Size = new System.Drawing.Size(245, 75);
this.linemode.Size = new System.Drawing.Size(245, 79);
this.linemode.TabIndex = 16;
this.linemode.Text = "MachineID";
this.linemode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -449,7 +451,7 @@ namespace WindowsFormsApp1
this.当前时间.Location = new System.Drawing.Point(1487, 1);
this.当前时间.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.当前时间.Name = "当前时间";
this.当前时间.Size = new System.Drawing.Size(247, 75);
this.当前时间.Size = new System.Drawing.Size(247, 79);
this.当前时间.TabIndex = 11;
this.当前时间.Text = "当前状态:";
this.当前时间.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -462,7 +464,7 @@ namespace WindowsFormsApp1
this.操作人员ID.Location = new System.Drawing.Point(1231, 1);
this.操作人员ID.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.操作人员ID.Name = "操作人员ID";
this.操作人员ID.Size = new System.Drawing.Size(245, 75);
this.操作人员ID.Size = new System.Drawing.Size(245, 79);
this.操作人员ID.TabIndex = 6;
this.操作人员ID.Text = "操作人员ID:";
this.操作人员ID.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -476,7 +478,7 @@ namespace WindowsFormsApp1
this.linetype.Location = new System.Drawing.Point(719, 1);
this.linetype.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.linetype.Name = "linetype";
this.linetype.Size = new System.Drawing.Size(245, 75);
this.linetype.Size = new System.Drawing.Size(245, 79);
this.linetype.TabIndex = 5;
this.linetype.Text = "StationID";
this.linetype.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -490,7 +492,7 @@ namespace WindowsFormsApp1
this.linecode.Location = new System.Drawing.Point(463, 1);
this.linecode.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.linecode.Name = "linecode";
this.linecode.Size = new System.Drawing.Size(245, 75);
this.linecode.Size = new System.Drawing.Size(245, 79);
this.linecode.TabIndex = 4;
this.linecode.Text = "Line";
this.linecode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -503,7 +505,7 @@ namespace WindowsFormsApp1
this.linename.Location = new System.Drawing.Point(207, 1);
this.linename.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.linename.Name = "linename";
this.linename.Size = new System.Drawing.Size(245, 75);
this.linename.Size = new System.Drawing.Size(245, 79);
this.linename.TabIndex = 3;
this.linename.Text = "线别:";
this.linename.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -514,7 +516,7 @@ namespace WindowsFormsApp1
this.开始处理.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.开始处理.Location = new System.Drawing.Point(4, 4);
this.开始处理.Name = "开始处理";
this.开始处理.Size = new System.Drawing.Size(194, 69);
this.开始处理.Size = new System.Drawing.Size(194, 73);
this.开始处理.TabIndex = 17;
this.开始处理.Text = "开始处理";
this.开始处理.UseVisualStyleBackColor = true;
@@ -531,13 +533,13 @@ namespace WindowsFormsApp1
this.tableLayoutPanel4.Controls.Add(this.原料包装LOT号, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.tableLayoutPanel6, 0, 1);
this.tableLayoutPanel4.Controls.Add(this.tableLayoutPanel9, 1, 0);
this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 153);
this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 159);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 2;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(1754, 483);
this.tableLayoutPanel4.Size = new System.Drawing.Size(1754, 503);
this.tableLayoutPanel4.TabIndex = 8;
//
// 原料包装LOT号
@@ -549,7 +551,7 @@ namespace WindowsFormsApp1
this.原料包装LOT号.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.原料包装LOT号.Name = "原料包装LOT号";
this.原料包装LOT号.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.原料包装LOT号.Size = new System.Drawing.Size(1397, 185);
this.原料包装LOT号.Size = new System.Drawing.Size(1397, 193);
this.原料包装LOT号.TabIndex = 0;
this.原料包装LOT号.TabStop = false;
this.原料包装LOT号.Text = "产品信息:";
@@ -574,7 +576,7 @@ namespace WindowsFormsApp1
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(1391, 140);
this.tableLayoutPanel5.Size = new System.Drawing.Size(1391, 148);
this.tableLayoutPanel5.TabIndex = 0;
//
// 材料值
@@ -582,9 +584,9 @@ namespace WindowsFormsApp1
this.材料值.AutoSize = true;
this.材料值.Dock = System.Windows.Forms.DockStyle.Fill;
this.材料值.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.材料值.Location = new System.Drawing.Point(350, 46);
this.材料值.Location = new System.Drawing.Point(350, 49);
this.材料值.Name = "材料值";
this.材料值.Size = new System.Drawing.Size(1038, 46);
this.材料值.Size = new System.Drawing.Size(1038, 49);
this.材料值.TabIndex = 7;
this.材料值.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@@ -593,9 +595,9 @@ namespace WindowsFormsApp1
this.材料.AutoSize = true;
this.材料.Dock = System.Windows.Forms.DockStyle.Fill;
this.材料.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.材料.Location = new System.Drawing.Point(3, 46);
this.材料.Location = new System.Drawing.Point(3, 49);
this.材料.Name = "材料";
this.材料.Size = new System.Drawing.Size(341, 46);
this.材料.Size = new System.Drawing.Size(341, 49);
this.材料.TabIndex = 6;
this.材料.Text = "材 料:";
this.材料.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -607,7 +609,7 @@ namespace WindowsFormsApp1
this.LOT号显示.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LOT号显示.Location = new System.Drawing.Point(3, 0);
this.LOT号显示.Name = "LOT号显示";
this.LOT号显示.Size = new System.Drawing.Size(341, 46);
this.LOT号显示.Size = new System.Drawing.Size(341, 49);
this.LOT号显示.TabIndex = 2;
this.LOT号显示.Text = "产品 SN:";
this.LOT号显示.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -617,9 +619,9 @@ namespace WindowsFormsApp1
this.MES提示.AutoSize = true;
this.MES提示.Dock = System.Windows.Forms.DockStyle.Fill;
this.MES提示.Font = new System.Drawing.Font("宋体", 15F);
this.MES提示.Location = new System.Drawing.Point(3, 92);
this.MES提示.Location = new System.Drawing.Point(3, 98);
this.MES提示.Name = "MES提示";
this.MES提示.Size = new System.Drawing.Size(341, 48);
this.MES提示.Size = new System.Drawing.Size(341, 50);
this.MES提示.TabIndex = 4;
this.MES提示.Text = "托 盘 码:";
this.MES提示.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -629,9 +631,9 @@ namespace WindowsFormsApp1
this.Tray盘二维码.AutoSize = true;
this.Tray盘二维码.Dock = System.Windows.Forms.DockStyle.Fill;
this.Tray盘二维码.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold);
this.Tray盘二维码.Location = new System.Drawing.Point(350, 92);
this.Tray盘二维码.Location = new System.Drawing.Point(350, 98);
this.Tray盘二维码.Name = "Tray盘二维码";
this.Tray盘二维码.Size = new System.Drawing.Size(1038, 48);
this.Tray盘二维码.Size = new System.Drawing.Size(1038, 50);
this.Tray盘二维码.TabIndex = 2;
this.Tray盘二维码.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@@ -642,7 +644,7 @@ namespace WindowsFormsApp1
this.LOT号.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold);
this.LOT号.Location = new System.Drawing.Point(350, 0);
this.LOT号.Name = "LOT号";
this.LOT号.Size = new System.Drawing.Size(1038, 46);
this.LOT号.Size = new System.Drawing.Size(1038, 49);
this.LOT号.TabIndex = 0;
this.LOT号.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@@ -661,12 +663,12 @@ namespace WindowsFormsApp1
this.tableLayoutPanel6.Controls.Add(this.MES提示信息, 2, 1);
this.tableLayoutPanel6.Controls.Add(this.eventTableLayout, 0, 1);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 196);
this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 204);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 2;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel6.Size = new System.Drawing.Size(1748, 284);
this.tableLayoutPanel6.Size = new System.Drawing.Size(1748, 296);
this.tableLayoutPanel6.TabIndex = 3;
//
// label1
@@ -676,7 +678,7 @@ namespace WindowsFormsApp1
this.label1.Font = new System.Drawing.Font("宋体", 10.125F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(4, 1);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(430, 48);
this.label1.Size = new System.Drawing.Size(430, 50);
this.label1.TabIndex = 0;
this.label1.Text = "MES事件";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -688,7 +690,7 @@ namespace WindowsFormsApp1
this.label2.Font = new System.Drawing.Font("宋体", 10.125F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(441, 1);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(430, 48);
this.label2.Size = new System.Drawing.Size(430, 50);
this.label2.TabIndex = 1;
this.label2.Text = "MES事件结果";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -700,7 +702,7 @@ namespace WindowsFormsApp1
this.label3.Font = new System.Drawing.Font("宋体", 10.125F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(878, 1);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(866, 48);
this.label3.Size = new System.Drawing.Size(866, 50);
this.label3.TabIndex = 2;
this.label3.Text = "MES信息提示";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -710,9 +712,9 @@ namespace WindowsFormsApp1
this.事件结果.AutoSize = true;
this.事件结果.Dock = System.Windows.Forms.DockStyle.Fill;
this.事件结果.Font = new System.Drawing.Font("宋体", 25.875F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.事件结果.Location = new System.Drawing.Point(441, 50);
this.事件结果.Location = new System.Drawing.Point(441, 52);
this.事件结果.Name = "事件结果";
this.事件结果.Size = new System.Drawing.Size(430, 233);
this.事件结果.Size = new System.Drawing.Size(430, 243);
this.事件结果.TabIndex = 3;
this.事件结果.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@@ -721,9 +723,9 @@ namespace WindowsFormsApp1
this.MES提示信息.AutoSize = true;
this.MES提示信息.Dock = System.Windows.Forms.DockStyle.Fill;
this.MES提示信息.Font = new System.Drawing.Font("宋体", 22.125F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.MES提示信息.Location = new System.Drawing.Point(878, 50);
this.MES提示信息.Location = new System.Drawing.Point(878, 52);
this.MES提示信息.Name = "MES提示信息";
this.MES提示信息.Size = new System.Drawing.Size(866, 233);
this.MES提示信息.Size = new System.Drawing.Size(866, 243);
this.MES提示信息.TabIndex = 4;
this.MES提示信息.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@@ -743,7 +745,7 @@ namespace WindowsFormsApp1
this.eventTableLayout.Controls.Add(this.label8, 0, 3);
this.eventTableLayout.Controls.Add(this.label9, 0, 4);
this.eventTableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.eventTableLayout.Location = new System.Drawing.Point(4, 53);
this.eventTableLayout.Location = new System.Drawing.Point(4, 55);
this.eventTableLayout.Name = "eventTableLayout";
this.eventTableLayout.RowCount = 5;
this.eventTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
@@ -751,7 +753,7 @@ namespace WindowsFormsApp1
this.eventTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.eventTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.eventTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.eventTableLayout.Size = new System.Drawing.Size(430, 227);
this.eventTableLayout.Size = new System.Drawing.Size(430, 237);
this.eventTableLayout.TabIndex = 5;
//
// panel1
@@ -760,46 +762,46 @@ namespace WindowsFormsApp1
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(333, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(94, 39);
this.panel1.Size = new System.Drawing.Size(94, 41);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(38, 45);
this.panel2.Location = new System.Drawing.Point(38, 47);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 39);
this.panel2.Size = new System.Drawing.Size(200, 41);
this.panel2.TabIndex = 1;
//
// panel4
//
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(333, 48);
this.panel4.Location = new System.Drawing.Point(333, 50);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(94, 39);
this.panel4.Size = new System.Drawing.Size(94, 41);
this.panel4.TabIndex = 2;
//
// panel3
//
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(333, 93);
this.panel3.Location = new System.Drawing.Point(333, 97);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(94, 39);
this.panel3.Size = new System.Drawing.Size(94, 41);
this.panel3.TabIndex = 1;
//
// panel5
//
this.panel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel5.Location = new System.Drawing.Point(333, 138);
this.panel5.Location = new System.Drawing.Point(333, 144);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(94, 39);
this.panel5.Size = new System.Drawing.Size(94, 41);
this.panel5.TabIndex = 3;
//
// panel6
//
this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel6.Location = new System.Drawing.Point(333, 183);
this.panel6.Location = new System.Drawing.Point(333, 191);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(94, 41);
this.panel6.Size = new System.Drawing.Size(94, 43);
this.panel6.TabIndex = 4;
//
// label5
@@ -809,7 +811,7 @@ namespace WindowsFormsApp1
this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
this.label5.Location = new System.Drawing.Point(3, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(324, 45);
this.label5.Size = new System.Drawing.Size(324, 47);
this.label5.TabIndex = 5;
this.label5.Text = "label5";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -819,9 +821,9 @@ namespace WindowsFormsApp1
this.label6.AutoSize = true;
this.label6.Dock = System.Windows.Forms.DockStyle.Fill;
this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(3, 45);
this.label6.Location = new System.Drawing.Point(3, 47);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(324, 45);
this.label6.Size = new System.Drawing.Size(324, 47);
this.label6.TabIndex = 6;
this.label6.Text = "label6";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -831,9 +833,9 @@ namespace WindowsFormsApp1
this.label7.AutoSize = true;
this.label7.Dock = System.Windows.Forms.DockStyle.Fill;
this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(3, 90);
this.label7.Location = new System.Drawing.Point(3, 94);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(324, 45);
this.label7.Size = new System.Drawing.Size(324, 47);
this.label7.TabIndex = 7;
this.label7.Text = "label7";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -843,9 +845,9 @@ namespace WindowsFormsApp1
this.label8.AutoSize = true;
this.label8.Dock = System.Windows.Forms.DockStyle.Fill;
this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(3, 135);
this.label8.Location = new System.Drawing.Point(3, 141);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(324, 45);
this.label8.Size = new System.Drawing.Size(324, 47);
this.label8.TabIndex = 8;
this.label8.Text = "label8";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -855,9 +857,9 @@ namespace WindowsFormsApp1
this.label9.AutoSize = true;
this.label9.Dock = System.Windows.Forms.DockStyle.Fill;
this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(3, 180);
this.label9.Location = new System.Drawing.Point(3, 188);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(324, 47);
this.label9.Size = new System.Drawing.Size(324, 49);
this.label9.TabIndex = 9;
this.label9.Text = "label9";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -873,9 +875,9 @@ namespace WindowsFormsApp1
this.tableLayoutPanel9.Location = new System.Drawing.Point(1406, 3);
this.tableLayoutPanel9.Name = "tableLayoutPanel9";
this.tableLayoutPanel9.RowCount = 2;
this.tableLayoutPanel9.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F));
this.tableLayoutPanel9.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel9.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel9.Size = new System.Drawing.Size(345, 187);
this.tableLayoutPanel9.Size = new System.Drawing.Size(345, 195);
this.tableLayoutPanel9.TabIndex = 4;
//
// label4
@@ -885,7 +887,7 @@ namespace WindowsFormsApp1
this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(3, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(339, 48);
this.label4.Size = new System.Drawing.Size(339, 50);
this.label4.TabIndex = 0;
this.label4.Text = "胶水寿命";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -895,9 +897,9 @@ namespace WindowsFormsApp1
this.剩余寿命.AutoSize = true;
this.剩余寿命.Dock = System.Windows.Forms.DockStyle.Fill;
this.剩余寿命.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.剩余寿命.Location = new System.Drawing.Point(3, 48);
this.剩余寿命.Location = new System.Drawing.Point(3, 50);
this.剩余寿命.Name = "剩余寿命";
this.剩余寿命.Size = new System.Drawing.Size(339, 139);
this.剩余寿命.Size = new System.Drawing.Size(339, 145);
this.剩余寿命.TabIndex = 1;
this.剩余寿命.Text = "label5";
this.剩余寿命.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -910,7 +912,7 @@ namespace WindowsFormsApp1
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Size = new System.Drawing.Size(1752, 38);
this.groupBox1.Size = new System.Drawing.Size(1752, 40);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "处理界面";
@@ -936,12 +938,12 @@ namespace WindowsFormsApp1
this.tableLayoutPanel8.Controls.Add(this.btnToggleTestMode, 9, 0);
this.tableLayoutPanel8.Controls.Add(this.button1, 8, 0);
this.tableLayoutPanel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel8.Location = new System.Drawing.Point(3, 1028);
this.tableLayoutPanel8.Location = new System.Drawing.Point(3, 1070);
this.tableLayoutPanel8.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.tableLayoutPanel8.Name = "tableLayoutPanel8";
this.tableLayoutPanel8.RowCount = 1;
this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel8.Size = new System.Drawing.Size(1754, 36);
this.tableLayoutPanel8.Size = new System.Drawing.Size(1754, 38);
this.tableLayoutPanel8.TabIndex = 7;
//
// 底部注释1
@@ -950,7 +952,7 @@ namespace WindowsFormsApp1
this.底部注释1.AutoSize = true;
this.底部注释1.Location = new System.Drawing.Point(3, 6);
this.底部注释1.Name = "底部注释1";
this.底部注释1.Size = new System.Drawing.Size(118, 24);
this.底部注释1.Size = new System.Drawing.Size(108, 25);
this.底部注释1.TabIndex = 0;
this.底部注释1.Text = "底部注释1";
//
@@ -960,7 +962,7 @@ namespace WindowsFormsApp1
this.底部注释2.AutoSize = true;
this.底部注释2.Location = new System.Drawing.Point(178, 6);
this.底部注释2.Name = "底部注释2";
this.底部注释2.Size = new System.Drawing.Size(118, 24);
this.底部注释2.Size = new System.Drawing.Size(108, 25);
this.底部注释2.TabIndex = 1;
this.底部注释2.Text = "底部注释2";
//
@@ -970,7 +972,7 @@ namespace WindowsFormsApp1
this.底部注释3.AutoSize = true;
this.底部注释3.Location = new System.Drawing.Point(353, 6);
this.底部注释3.Name = "底部注释3";
this.底部注释3.Size = new System.Drawing.Size(118, 24);
this.底部注释3.Size = new System.Drawing.Size(108, 25);
this.底部注释3.TabIndex = 2;
this.底部注释3.Text = "底部注释3";
//
@@ -980,7 +982,7 @@ namespace WindowsFormsApp1
this.底部注释4.AutoSize = true;
this.底部注释4.Location = new System.Drawing.Point(528, 6);
this.底部注释4.Name = "底部注释4";
this.底部注释4.Size = new System.Drawing.Size(118, 24);
this.底部注释4.Size = new System.Drawing.Size(108, 25);
this.底部注释4.TabIndex = 3;
this.底部注释4.Text = "底部注释4";
//
@@ -990,7 +992,7 @@ namespace WindowsFormsApp1
this.底部注释5.AutoSize = true;
this.底部注释5.Location = new System.Drawing.Point(703, 6);
this.底部注释5.Name = "底部注释5";
this.底部注释5.Size = new System.Drawing.Size(118, 24);
this.底部注释5.Size = new System.Drawing.Size(108, 25);
this.底部注释5.TabIndex = 4;
this.底部注释5.Text = "底部注释5";
//
@@ -1000,7 +1002,7 @@ namespace WindowsFormsApp1
this.btnToggleTestMode.Dock = System.Windows.Forms.DockStyle.Fill;
this.btnToggleTestMode.Location = new System.Drawing.Point(1578, 3);
this.btnToggleTestMode.Name = "btnToggleTestMode";
this.btnToggleTestMode.Size = new System.Drawing.Size(173, 30);
this.btnToggleTestMode.Size = new System.Drawing.Size(173, 32);
this.btnToggleTestMode.TabIndex = 5;
this.btnToggleTestMode.Text = "调试模式";
this.btnToggleTestMode.UseVisualStyleBackColor = false;
@@ -1011,7 +1013,7 @@ namespace WindowsFormsApp1
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
this.button1.Location = new System.Drawing.Point(1403, 3);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(169, 30);
this.button1.Size = new System.Drawing.Size(169, 32);
this.button1.TabIndex = 6;
this.button1.Text = "螺丝开盖";
this.button1.UseVisualStyleBackColor = true;
@@ -1025,12 +1027,12 @@ namespace WindowsFormsApp1
this.tableLayoutPanel7.Controls.Add(this.richTextBox1, 0, 0);
this.tableLayoutPanel7.Controls.Add(this.richTextBox2, 1, 0);
this.tableLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel7.Location = new System.Drawing.Point(3, 643);
this.tableLayoutPanel7.Location = new System.Drawing.Point(3, 669);
this.tableLayoutPanel7.Name = "tableLayoutPanel7";
this.tableLayoutPanel7.RowCount = 1;
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 19F));
this.tableLayoutPanel7.Size = new System.Drawing.Size(1754, 282);
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel7.Size = new System.Drawing.Size(1754, 294);
this.tableLayoutPanel7.TabIndex = 10;
//
// richTextBox1
@@ -1038,7 +1040,7 @@ namespace WindowsFormsApp1
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(3, 3);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(871, 276);
this.richTextBox1.Size = new System.Drawing.Size(871, 288);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
@@ -1047,15 +1049,22 @@ namespace WindowsFormsApp1
this.richTextBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox2.Location = new System.Drawing.Point(880, 3);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(871, 276);
this.richTextBox2.Size = new System.Drawing.Size(871, 288);
this.richTextBox2.TabIndex = 1;
this.richTextBox2.Text = "";
//
// oEE地址管理ToolStripMenuItem
//
this.oEE地址管理ToolStripMenuItem.Name = "oEE地址管理ToolStripMenuItem";
this.oEE地址管理ToolStripMenuItem.Size = new System.Drawing.Size(379, 50);
this.oEE地址管理ToolStripMenuItem.Text = "OEE地址管理";
this.oEE地址管理ToolStripMenuItem.Click += new System.EventHandler(this.oEE地址管理ToolStripMenuItem_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1760, 1068);
this.ClientSize = new System.Drawing.Size(1760, 1112);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.tableLayoutPanel1);
this.MainMenuStrip = this.menuStrip1;
@@ -1173,6 +1182,7 @@ namespace WindowsFormsApp1
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Button btnToggleTestMode;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ToolStripMenuItem oEE地址管理ToolStripMenuItem;
}
}
+146 -82
View File
@@ -48,6 +48,8 @@ namespace WindowsFormsApp1
// 在MainForm类的成员变量部分添加一个定时器
private System.Windows.Forms.Timer statusReportTimer = new System.Windows.Forms.Timer();
private System.Windows.Forms.Timer screwReportTimer = new System.Windows.Forms.Timer();
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
private object curingLock = new object();
private Dictionary<int, int> OldPlcTrigger = new Dictionary<int, int>();
@@ -121,6 +123,9 @@ namespace WindowsFormsApp1
// 初始化状态上报定时器
statusReportTimer.Interval = int.Parse(Init.t_Keyvalues.First(x => x.key == "StatusTime").value) * 1000; // 15秒
statusReportTimer.Tick += StatusReportTimer_Tick;
screwReportTimer.Interval = 8000;
screwReportTimer.Tick += ScrewReportTimer_Tick;
}
public void build(t_plc Plc, CancellationToken token)
@@ -170,6 +175,7 @@ namespace WindowsFormsApp1
List<t_angleaddress> angleaddress = Init.t_Angleaddresses.FindAll(a => a.plcid == Plc.id);
List<t_torqueaddress> torqueaddress = Init.t_Torqueaddresses.FindAll(a => a.plcid == Plc.id);
List<t_pressurecurve> pressurecurveaddress = Init.t_Pressurecurves.FindAll(a => a.plcid == Plc.id);
List<t_oeeaddress> oeeaddresses = Init.t_Oeeaddresses.ToList();
plcdata PlcData = new plcdata();
@@ -289,91 +295,95 @@ namespace WindowsFormsApp1
ApiClient apiClient = new ApiClient();
otherdata otherdata = new otherdata();
//Init.SN = PlcData.Read_MaterialCode0;
#region 机台状态及报警
//机台状态
//机台状态.Text = "机台状态:" + Enum.GetName(typeof(plcstatus), Init.Plcstatus);
Init.Plcstatus = PlcData.Read_Status;
int oldstatus = Init.Plcstatus;
//if (PlcData.Read_Status != 0)
if (false)
//Init.Plcstatus = PlcData.Read_Status;
// 多个plc 只有一个报警
if (Plc.id == Init.t_Lineplcs.First().plcid)
{
//状态+报警
if (oldstatus != PlcData.Read_Status)
int oldstatus = Init.Plcstatus;
if (PlcData.Read_Status != 0)
{
//反馈状态
Init.Plcstatus = PlcData.Read_Status;
Init.Plcstatus_LastTime = DateTime.Now;
otherdata.Plc_Status = PlcData.Read_Status;
var statusresult = apiClient.CallFunctionByName("Status", PlcData, otherdata);
if (statusresult.Success)
//状态+报警
if (oldstatus != PlcData.Read_Status)
{
//MES链接状态.Text = "MES链接状态:OK";
//MES链接状态.BackColor = SystemColors.Control;
//MES通讯时间.Text = "MES通讯时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
MES_MsgfORM("Status", statusresult, statusresult.Requesttime);
if (statusresult.Mesresult != mesresult.PASS)
//反馈状态
Init.Plcstatus = PlcData.Read_Status;
Init.Plcstatus_LastTime = DateTime.Now;
otherdata.Plc_Status = PlcData.Read_Status.ToString();
if (PlcData.Read_Status == 2)
{
PlcData.Write_Status = 1001;
siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
else
{
//MES链接状态.Text = "MES链接状态:NG";
//MES链接状态.BackColor = Color.Red;
LogExecute.logNet.WriteError($"MES通讯异常!");
PlcData.Write_Status = 1002;
var errresult = siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
}
//机台报警
if (PlcData.Read_Status == (short)plcstatus.停机)
{
//机台状态.BackColor = Color.Red;
if (oldstatus != (short)plcstatus.停机)
{
//反馈报警
List<string> list = new List<string>();
///////////////////////////////测试用
list.Add("M03CVSO-01");
otherdata.Plc_ErrorMsgs = list;
Init.Plcstatus = PlcData.Read_Status;
Init.Plcstatus_LastTime = DateTime.Now;
var statusresult = apiClient.CallFunctionByName("Alarm", PlcData, otherdata);
if (statusresult.Success)
{
//MES链接状态.Text = "MES链接状态:OK";
//MES链接状态.BackColor = SystemColors.Control;
//MES通讯时间.Text = "MES通讯时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
MES_MsgfORM("Alarm", statusresult, statusresult.Requesttime);
if (statusresult.Mesresult != mesresult.PASS)
{
PlcData.Write_Status = 1001;
siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
else
{
//MES链接状态.Text = "MES链接状态:NG";
//MES链接状态.BackColor = Color.Red;
LogExecute.logNet.WriteError($"MES通讯异常!");
PlcData.Write_Status = 1002;
siemensHelp.WriteAddress(plcaddress, PlcData);
}
}
continue;
}
else
{
//机台状态.BackColor = SystemColors.Control;
}
// 报警的时候 赋值报警代码
var oeeresult1 = siemensHelp.ReadAddress(oeeaddresses);
Init.ErrorCode = oeeresult1.Data.FirstOrDefault(x => x.value.ToLower() == "true")?.code;
otherdata.Plc_Status = $"{PlcData.Read_Status}_{Init.ErrorCode}";
}
var statusresult = apiClient.CallFunctionByName("Status", PlcData, otherdata);
if (statusresult.Success)
{
LogExecute.OEElogNet.WriteDebug($"上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)} {Init.ErrorCode}");
MES_MsgfORM("Status", statusresult, statusresult.Requesttime);
if (statusresult.Mesresult != mesresult.PASS)
{
PlcData.Write_Status = 1001;
siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
else
{
LogExecute.logNet.WriteError($"MES通讯异常!");
PlcData.Write_Status = 1002;
var errresult = siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
}
//机台报警
if (PlcData.Read_Status == (short)plcstatus.停机)
{
//机台状态.BackColor = Color.Red;
if (oldstatus != (short)plcstatus.停机)
{
//反馈报警
Init.Plcstatus = PlcData.Read_Status;
Init.Plcstatus_LastTime = DateTime.Now;
var statusresult = apiClient.CallFunctionByName("Alarm", PlcData, otherdata);
if (statusresult.Success)
{
LogExecute.OEElogNet.WriteDebug($"上报机台报警成功: {Init.ErrorCode}");
MES_MsgfORM("Alarm", statusresult, statusresult.Requesttime);
if (statusresult.Mesresult != mesresult.PASS)
{
PlcData.Write_Status = 1001;
siemensHelp.WriteAddress(plcaddress, PlcData);
continue;
}
}
else
{
//MES链接状态.Text = "MES链接状态:NG";
//MES链接状态.BackColor = Color.Red;
LogExecute.logNet.WriteError($"MES通讯异常!");
PlcData.Write_Status = 1002;
siemensHelp.WriteAddress(plcaddress, PlcData);
}
}
continue;
}
else
{
//机台状态.BackColor = SystemColors.Control;
}
}
#endregion
#region 判断及查找流程
@@ -424,7 +434,7 @@ namespace WindowsFormsApp1
}
#endregion
#region 根据流程,判断是否需要扫码、气密、扭力等
if (nowflow.scan)
{
@@ -586,6 +596,9 @@ namespace WindowsFormsApp1
{
//文件上传
}
// oeedatacollection
var oeeresult = siemensHelp.ReadAddress(oeeaddresses);
otherdata.Oeeaddresses = oeeaddresses;
#endregion
#region 判断物料调用次数 固化站,抽真空
@@ -733,7 +746,8 @@ namespace WindowsFormsApp1
{
if (result.Mesresult != mesresult.PASS)
{
if (result.Msg.Contains("机台上料数量不够扣料"))
if (result.Msg.Contains("机台上料数量不够扣料")
|| result.Msg.Contains("没有上料"))
{
PlcData.Write_Status = 1003;
}
@@ -844,6 +858,14 @@ namespace WindowsFormsApp1
return;
}
SQLiteHelper<t_oeeaddress> sQLiteHelper_oee = new db.SQLiteHelper<t_oeeaddress>();
var oee_result = sQLiteHelper_oee.QueryAll();
if (!oee_result.Success)
{
MessageBox.Show("无法初始化报警信息,无法开始处理!");
return;
}
SQLiteHelper<t_interface> sQLiteHelper_interface = new db.SQLiteHelper<t_interface>();
var interface_result = sQLiteHelper_interface.QueryAll();
if (!interface_result.Success)
@@ -873,6 +895,7 @@ namespace WindowsFormsApp1
Init.t_Angleaddresses = angleaddress_result.Data;
Init.t_Torqueaddresses = torqueaddress_result.Data;
Init.t_Pressurecurves = pressurecurve_result.Data;
Init.t_Oeeaddresses = oee_result.Data;
Init.t_Interfaces = interface_result.Data;
Init.t_Keyvalues = key_sqlresult.Data;
Init.t_plcs = plc_result;
@@ -882,6 +905,7 @@ namespace WindowsFormsApp1
// 启动状态上报定时器
statusReportTimer.Start();
screwReportTimer.Start();
#endregion
@@ -1048,6 +1072,7 @@ namespace WindowsFormsApp1
{
// 停止状态上报定时器
statusReportTimer.Stop();
screwReportTimer.Stop();
// 停止所有线程
if (Init.threadHelps != null)
@@ -1115,6 +1140,12 @@ namespace WindowsFormsApp1
torqueaddress_Manage.ShowDialog();
}
private void oEE地址管理ToolStripMenuItem_Click(object sender, EventArgs e)
{
OEEaddress_Manage oeeManage = new OEEaddress_Manage();
oeeManage.ShowDialog();
}
private void 流程管理ToolStripMenuItem_Click(object sender, EventArgs e)
{
Flow_Manage fLOW_Mange = new Flow_Manage();
@@ -1747,10 +1778,14 @@ namespace WindowsFormsApp1
// 如果没有PLC数据或者状态为0,则不上报
if (Init.Plcstatus == 0 || Init.Plcstatus == -1)
return;
otherdata statusOtherData = new otherdata();
statusOtherData.Plc_Status = Init.Plcstatus;
statusOtherData.Plc_Status = Init.Plcstatus.ToString();
if (Init.Plcstatus == 2)
{
//报警
statusOtherData.Plc_Status = $"{Init.Plcstatus}_{Init.ErrorCode}";
}
var statusResult = statusApiClient.CallFunctionByName("Status", new plcdata(), statusOtherData);
if (statusResult.Success)
{
@@ -1759,7 +1794,7 @@ namespace WindowsFormsApp1
// 更新最后上报时间
Init.Plcstatus_LastTime = DateTime.Now;
LogExecute.OEElogNet.WriteDebug($"定时上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)}");
LogExecute.OEElogNet.WriteDebug($"定时上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)},{statusOtherData.Plc_Status}");
}
else
{
@@ -1772,6 +1807,35 @@ namespace WindowsFormsApp1
}
}
//螺丝扭力上传定时器
private void ScrewReportTimer_Tick(object sender, EventArgs e)
{
SQLiteHelper<t_materialupload> sQLiteHelper_upload = new db.SQLiteHelper<t_materialupload>();
var material_sqlresult = sQLiteHelper_upload
.Query(x => x.datacollectionUploaded == 1);
if (material_sqlresult.Success)
{
ApiClient apiClient = new ApiClient();
var materialList = material_sqlresult.Data.Take(5);
foreach(var material in materialList)
{
otherdata OtherData = new otherdata();
OtherData.material = material;
var result = apiClient.CallFunctionByName("Data_Collection", new plcdata(), OtherData);
if (result.Success)
{
MES_MsgfORM("Data_Collection", result, result.Requesttime);
if(result.Mesresult == mesresult.PASS)
{
//标记该物料已上传
material.datacollectionUploaded = 2;
sQLiteHelper_upload.Update(material);
LogExecute.OEElogNet.WriteDebug($"{material.sn} 扭力上报成功!");
}
}
}
}
}
// 定时扫描 周期扫描未上传 图片,视频等 sn,然后调用上传文件接口 todo
#endregion 定时器
+2
View File
@@ -48,6 +48,7 @@ namespace WindowsFormsApp1
public static List<t_angleaddress> t_Angleaddresses;
public static List<t_torqueaddress> t_Torqueaddresses;
public static List<t_pressurecurve> t_Pressurecurves;
public static List<t_oeeaddress> t_Oeeaddresses;
public static List<t_keyvalue> t_Keyvalues;
@@ -58,6 +59,7 @@ namespace WindowsFormsApp1
public static string DZString;
//PLC状态存储
public static short Plcstatus = -1;
public static string ErrorCode = "";
//PLC最后状态事件(用于计时15秒状态不变回传)
public static DateTime Plcstatus_LastTime = DateTime.Now;
+36
View File
@@ -45,6 +45,42 @@ namespace WindowsFormsApp1.db
}
/// <summary>
/// 数据插入
/// </summary>
/// <param name="item">要插入的数据项</param>
/// <returns></returns>
public BllResult InsertAll(List<T> item)
{
if (_connection.InsertAll(item) > 0)
{
return BllResult.Sucess();
}
else
{
return BllResult.Error();
}
}
/// <summary>
/// 数据删除
/// </summary>
/// <param name="item">要插入的数据项</param>
/// <returns></returns>
public BllResult DeleteAll()
{
if (_connection.DeleteAll<T>() > 0)
{
return BllResult.Sucess();
}
else
{
return BllResult.Error();
}
}
/// <summary>
/// 数据删除
/// </summary>
+218
View File
@@ -0,0 +1,218 @@
namespace WindowsFormsApp1.form
{
partial class OEEaddress_Manage
{
/// <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.dataGridView1 = new System.Windows.Forms.DataGridView();
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.plcid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.code = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.type = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.dbaddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addresstype = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addressdecimal = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
this.查询 = new System.Windows.Forms.Button();
this.清空 = new System.Windows.Forms.Button(); // 将保存改为清空
this.关闭 = new System.Windows.Forms.Button();
this.导入 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.id,
this.plcid,
this.code,
this.type,
this.dbaddress,
this.addresstype,
this.addresstypelegth,
this.addressoffset,
this.addressdecimal,
this.remark});
this.dataGridView1.Location = new System.Drawing.Point(12, 41);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(1200, 397);
this.dataGridView1.TabIndex = 0;
//
// id
//
this.id.DataPropertyName = "id";
this.id.HeaderText = "id";
this.id.Name = "id";
//
// plcid
//
this.plcid.DataPropertyName = "plcid";
this.plcid.HeaderText = "plcid";
this.plcid.Name = "plcid";
//
// code
//
this.code.DataPropertyName = "code";
this.code.HeaderText = "code";
this.code.Name = "code";
//
// type
//
this.type.DataPropertyName = "type";
this.type.HeaderText = "类型";
this.type.Name = "type";
//
// dbaddress
//
this.dbaddress.DataPropertyName = "dbaddress";
this.dbaddress.HeaderText = "地址";
this.dbaddress.Name = "dbaddress";
//
// addresstype
//
this.addresstype.DataPropertyName = "addresstype";
this.addresstype.HeaderText = "地址类型";
this.addresstype.Name = "addresstype";
//
// addresstypelegth
//
this.addresstypelegth.DataPropertyName = "addresstypelegth";
this.addresstypelegth.HeaderText = "地址长度";
this.addresstypelegth.Name = "addresstypelegth";
//
// addressoffset
//
this.addressoffset.DataPropertyName = "addressoffset";
this.addressoffset.HeaderText = "地址偏移";
this.addressoffset.Name = "addressoffset";
//
// addressdecimal
//
this.addressdecimal.DataPropertyName = "addressdecimal";
this.addressdecimal.HeaderText = "位地址";
this.addressdecimal.Name = "addressdecimal";
//
// remark
//
this.remark.DataPropertyName = "remark";
this.remark.HeaderText = "备注";
this.remark.Name = "remark";
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "新增";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 查询
//
this.查询.Location = new System.Drawing.Point(93, 12);
this.查询.Name = "查询";
this.查询.Size = new System.Drawing.Size(75, 23);
this.查询.TabIndex = 2;
this.查询.Text = "查询";
this.查询.UseVisualStyleBackColor = true;
this.查询.Click += new System.EventHandler(this.查询_Click);
//
// 清空
//
this.清空.Location = new System.Drawing.Point(174, 12);
this.清空.Name = "清空";
this.清空.Size = new System.Drawing.Size(75, 23);
this.清空.TabIndex = 3;
this.清空.Text = "清空";
this.清空.UseVisualStyleBackColor = true;
this.清空.Click += new System.EventHandler(this.清空_Click);
//
// 关闭
//
this.关闭.Location = new System.Drawing.Point(255, 12);
this.关闭.Name = "关闭";
this.关闭.Size = new System.Drawing.Size(75, 23);
this.关闭.TabIndex = 4;
this.关闭.Text = "关闭";
this.关闭.UseVisualStyleBackColor = true;
this.关闭.Click += new System.EventHandler(this.关闭_Click);
//
// 导入
//
this.导入.Location = new System.Drawing.Point(336, 12);
this.导入.Name = "导入";
this.导入.Size = new System.Drawing.Size(75, 23);
this.导入.TabIndex = 5;
this.导入.Text = "导入";
this.导入.UseVisualStyleBackColor = true;
this.导入.Click += new System.EventHandler(this.导入_Click);
//
// OEEaddress_Manage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1210, 450);
this.Controls.Add(this.导入);
this.Controls.Add(this.关闭);
this.Controls.Add(this.清空);
this.Controls.Add(this.查询);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView1);
this.Name = "OEEaddress_Manage";
this.Text = "OEE地址管理";
this.Load += new System.EventHandler(this.OEEaddress_Manage_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button 查询;
private System.Windows.Forms.Button 清空; // 将保存改为清空
private System.Windows.Forms.Button 关闭;
private System.Windows.Forms.Button 导入;
private System.Windows.Forms.DataGridViewTextBoxColumn id;
private System.Windows.Forms.DataGridViewTextBoxColumn plcid;
private System.Windows.Forms.DataGridViewTextBoxColumn code;
private System.Windows.Forms.DataGridViewComboBoxColumn type;
private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress;
private System.Windows.Forms.DataGridViewComboBoxColumn addresstype;
private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth;
private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset;
private System.Windows.Forms.DataGridViewTextBoxColumn addressdecimal;
private System.Windows.Forms.DataGridViewTextBoxColumn remark;
}
}
+396
View File
@@ -0,0 +1,396 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.db;
using WindowsFormsApp1.mod;
namespace WindowsFormsApp1.form
{
public partial class OEEaddress_Manage : Form
{
public OEEaddress_Manage()
{
InitializeComponent();
}
private void 查询_Click(object sender, EventArgs e)
{
GetInfo();
}
private void 关闭_Click(object sender, EventArgs e)
{
this.Close();
}
private void OEEaddress_Manage_Load(object sender, EventArgs e)
{
dataGridView1.AutoGenerateColumns = false;
SQLiteHelper<t_plc> sQLiteHelper1 = new db.SQLiteHelper<t_plc>();
var result_combox = sQLiteHelper1.QueryAll();
if (!result_combox.Success)
{
MessageBox.Show("查询失败");
return;
}
var result1 = new List<object>
{
new {name = "read",value = "read"},
new {name = "write",value = "write"}
};
var result2 = new List<object>
{
new {name = "real",value = "real"},
new {name = "string",value = "string"},
new {name = "uint",value = "uint"},
new {name = "bool",value = "bool"},
new {name = "int",value = "int"},
new {name = "dint",value = "dint"},
new {name = "byte",value = "byte"},
};
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3];
// 绑定数据源到 ComboBox
comboBoxColumn.DataSource = result1;
comboBoxColumn.DisplayMember = "name";
comboBoxColumn.ValueMember = "value";
comboBoxColumn.DataPropertyName = "type";
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
// 绑定数据源到 ComboBox
comboBoxColumn1.DataSource = result2;
comboBoxColumn1.DisplayMember = "name";
comboBoxColumn1.ValueMember = "value";
comboBoxColumn1.DataPropertyName = "addresstype";
DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn();
modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
modifyColumn.Name = "ModifyColumn";
modifyColumn.HeaderText = "修改";
modifyColumn.Text = "修改";
modifyColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(modifyColumn);
// 添加删除按钮列
DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn();
deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
deleteColumn.Name = "DeleteColumn";
deleteColumn.HeaderText = "删除";
deleteColumn.Text = "删除";
deleteColumn.UseColumnTextForButtonValue = true;
dataGridView1.CellContentClick += DataGridView1_CellContentClick;
dataGridView1.Columns.Add(deleteColumn);
GetInfo();
}
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// 检查点击的是否为按钮列
if (e.RowIndex >= 0)
{
DataGridView dataGridView = (DataGridView)sender;
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
int selectid = int.Parse(row.Cells[0].Value.ToString());
if (e.ColumnIndex == 10)
{
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
oeeInsert.dataid = selectid;
oeeInsert.Operation = OperationType.Edit;
oeeInsert.ShowDialog();
GetInfo();
}
else if (e.ColumnIndex == 11)
{
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var delresult = sQLiteHelper.Delete(selectid);
if (delresult.Success)
{
MessageBox.Show("删除成功");
}
else
{
MessageBox.Show("删除失败");
}
GetInfo();
}
}
}
}
public void GetInfo()
{
try
{
dataGridView1.DataSource = null;
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var result = sQLiteHelper.QueryAll();
if (result.Success)
{
List<object> list = new List<object>();
foreach (var plcaddress in result.Data)
{
list.Add(new
{
id = plcaddress.id,
plcid = plcaddress.plcid,
code = plcaddress.code,
type = plcaddress.type,
dbaddress = plcaddress.dbaddress,
addresstype = plcaddress.addresstype,
addresstypelegth = plcaddress.addresstypelegth,
addressoffset = plcaddress.addressoffset,
remark = plcaddress.remark,
value = plcaddress.value,
addressdecimal = plcaddress.addressdecimal
});
}
dataGridView1.DataSource = list;
dataGridView1.Refresh();
}
}
catch (Exception ex)
{
MessageBox.Show($"查询失败,错误原因:{ex.Message}");
}
}
private void button1_Click(object sender, EventArgs e)
{
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
oeeInsert.ShowDialog();
GetInfo();
}
// 添加导入按钮点击事件处理
private void 导入_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "CSV文件|*.csv";
openFileDialog.Title = "选择要导入的CSV文件";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
ImportFromCSV(filePath);
}
}
catch (Exception ex)
{
MessageBox.Show($"导入失败,错误原因:{ex.Message}");
}
}
private void ImportFromCSV(string filePath)
{
try
{
List<t_oeeaddress> addressList = new List<t_oeeaddress>();
// 读取CSV文件 - 修改编码方式
// 尝试使用UTF-8编码读取
string[] lines = System.IO.File.ReadAllLines(filePath, Encoding.UTF8);
// 如果检测到乱码,可以尝试其他编码
if (ContainsGarbledText(lines))
{
// 尝试使用GB2312编码
lines = System.IO.File.ReadAllLines(filePath, Encoding.GetEncoding("gb2312"));
// 如果仍然乱码,再尝试其他编码
if (ContainsGarbledText(lines))
{
// 尝试使用GBK编码
lines = System.IO.File.ReadAllLines(filePath, Encoding.GetEncoding("gbk"));
}
}
// 从第2行开始读取数据(假设第1行是标题)
for (int i = 1; i < lines.Length; i++)
{
string line = lines[i];
if (string.IsNullOrWhiteSpace(line))
continue;
// 分割CSV行并去除双引号
string[] values = SplitCsvLineAndRemoveQuotes(line);
if (values.Length < 10)
{
MessageBox.Show($"第{i + 1}行数据格式不正确,请检查CSV文件格式");
break;
}
var test = values[0];
try
{
t_oeeaddress address = new t_oeeaddress
{
plcid = Convert.ToInt32(values[0]),
code = values[1],
type = values[2],
dbaddress = values[3],
addresstype = values[4],
addresstypelegth = Convert.ToInt32(values[5]),
addressoffset = Convert.ToInt32(values[6]),
addressdecimal = Convert.ToInt32(values[7]),
remark = values[8] ?? "",
};
addressList.Add(address);
}
catch (FormatException)
{
MessageBox.Show($"第{i + 1}行数据格式转换错误,请检查数据类型是否正确");
break;
}
}
SaveImportedData(addressList);
}
catch (Exception ex)
{
MessageBox.Show($"CSV导入失败,错误原因:{ex.Message}");
}
}
// 添加一个方法来分割CSV行并去除双引号
private string[] SplitCsvLineAndRemoveQuotes(string line)
{
// 使用正则表达式处理CSV,考虑引号内的逗号
List<string> result = new List<string>();
bool inQuotes = false;
StringBuilder field = new StringBuilder();
for (int i = 0; i < line.Length; i++)
{
char c = line[i];
if (c == '"')
{
// 如果是引号,切换引号状态
inQuotes = !inQuotes;
// 不将引号添加到结果中
}
else if (c == ',' && !inQuotes)
{
// 如果是逗号且不在引号内,则添加当前字段并重置
result.Add(field.ToString().Trim());
field.Clear();
}
else
{
// 其他字符直接添加
field.Append(c);
}
}
// 添加最后一个字段
result.Add(field.ToString().Trim());
return result.ToArray();
}
// 添加一个辅助方法检测文本是否包含乱码
private bool ContainsGarbledText(string[] lines)
{
// 简单检测:如果包含特定的乱码字符,则认为是乱码
// 这里只是一个简单的示例,可能需要根据实际情况调整
string pattern = @"[\u0000-\u001F\u007F-\u009F]"; // 控制字符
foreach (string line in lines)
{
if (System.Text.RegularExpressions.Regex.IsMatch(line, pattern))
{
return true;
}
}
return false;
}
private void SaveImportedData(List<t_oeeaddress> addressList)
{
if (addressList.Count == 0)
{
MessageBox.Show("没有有效数据可导入");
return;
}
try
{
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var result = sQLiteHelper.InsertAll(addressList);
if (result.Success)
{
// 更新缓存
var allAddresses = sQLiteHelper.QueryAll();
if (allAddresses.Success)
{
Init.t_Oeeaddresses = allAddresses.Data;
}
MessageBox.Show($"成功导入{addressList.Count}条数据");
GetInfo(); // 刷新数据显示
}
else
{
MessageBox.Show($"导入失败:{result.Msg}");
}
}
catch (Exception ex)
{
MessageBox.Show($"保存导入数据失败,错误原因:{ex.Message}");
}
}
// 添加清空按钮点击事件处理
private void 清空_Click(object sender, EventArgs e)
{
try
{
DialogResult result = MessageBox.Show("确定要删除所有数据吗?此操作不可恢复!", "警告",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (result == DialogResult.OK)
{
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var deleteResult = sQLiteHelper.DeleteAll();
if (deleteResult.Success)
{
MessageBox.Show("所有数据已成功删除!");
GetInfo(); // 刷新数据显示
}
else
{
MessageBox.Show($"删除失败:{deleteResult.Msg}");
}
}
}
catch (Exception ex)
{
MessageBox.Show($"清空数据失败,错误原因:{ex.Message}");
}
}
}
}
@@ -0,0 +1,276 @@
namespace WindowsFormsApp1.form
{
partial class OEEaddress_Insert
{
/// <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.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.textBox6 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 0;
this.label1.Text = "PLC:";
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(47, 12);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 12);
this.label2.TabIndex = 2;
this.label2.Text = "编码:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(47, 38);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(121, 21);
this.textBox1.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 68);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 12);
this.label3.TabIndex = 4;
this.label3.Text = "类型:";
//
// comboBox2
//
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(47, 65);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(121, 20);
this.comboBox2.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 95);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 12);
this.label4.TabIndex = 6;
this.label4.Text = "地址:";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(47, 92);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(121, 21);
this.textBox2.TabIndex = 7;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 122);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(59, 12);
this.label5.TabIndex = 8;
this.label5.Text = "地址类型:";
//
// comboBox3
//
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(77, 119);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(91, 20);
this.comboBox3.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 149);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 12);
this.label6.TabIndex = 10;
this.label6.Text = "地址长度:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(77, 146);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(91, 21);
this.textBox3.TabIndex = 11;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 176);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(59, 12);
this.label7.TabIndex = 12;
this.label7.Text = "地址偏移:";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(77, 173);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(91, 21);
this.textBox4.TabIndex = 13;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 206);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(59, 12);
this.label8.TabIndex = 14;
this.label8.Text = "位地址值:";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(77, 203);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(91, 21);
this.textBox6.TabIndex = 15;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 236);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(59, 12);
this.label9.TabIndex = 16;
this.label9.Text = "备注:";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(77, 233);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(91, 21);
this.textBox5.TabIndex = 17;
//
// button1
//
this.button1.Location = new System.Drawing.Point(14, 264);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 18;
this.button1.Text = "确定";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(95, 264);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 19;
this.button2.Text = "取消";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// OEEaddress_Insert
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(184, 299);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.label9);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label8);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label6);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name = "OEEaddress_Insert";
this.Text = "OEE地址编辑";
this.Load += new System.EventHandler(this.OEEaddress_Insert_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.db;
using WindowsFormsApp1.mod;
namespace WindowsFormsApp1.form
{
public partial class OEEaddress_Insert : Form
{
public int dataid { get; set; }
public OperationType Operation { get; set; } = OperationType.Add;
public OEEaddress_Insert()
{
InitializeComponent();
}
private void OEEaddress_Insert_Load(object sender, EventArgs e)
{
SQLiteHelper<t_plc> sQLiteHelper = new db.SQLiteHelper<t_plc>();
var result = sQLiteHelper.QueryAll();
if (result.Success)
{
comboBox1.DataSource = result.Data;
comboBox1.DisplayMember = "plcname";
comboBox1.ValueMember = "id";
comboBox1.SelectedValue = Init.t_Line.plcid;
}
comboBox2.Items.Add("read");
comboBox2.Items.Add("write");
comboBox2.SelectedIndex = 0;
comboBox3.Items.Add("bool");
comboBox3.Items.Add("real");
comboBox3.Items.Add("string");
comboBox3.Items.Add("uint");
comboBox3.Items.Add("int");
comboBox3.Items.Add("dint");
comboBox3.Items.Add("byte");
comboBox3.SelectedIndex = 0;
if (Operation == OperationType.Edit)
{
SQLiteHelper<t_oeeaddress> sQLiteHelper1 = new db.SQLiteHelper<t_oeeaddress>();
var result1 = sQLiteHelper1.QuerySingle(x => x.id == dataid);
if (result1.Success)
{
comboBox1.SelectedValue = result1.Data.plcid;
textBox1.Text = result1.Data.code;
comboBox2.Text = result1.Data.type;
textBox2.Text = result1.Data.dbaddress;
comboBox3.Text = result1.Data.addresstype;
textBox3.Text = result1.Data.addresstypelegth.ToString();
textBox4.Text = result1.Data.addressoffset.ToString();
textBox6.Text = result1.Data.addressdecimal.ToString();
textBox5.Text = result1.Data.remark;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
t_oeeaddress t_Oeeaddress = new t_oeeaddress();
t_Oeeaddress.plcid = (int)comboBox1.SelectedValue;
t_Oeeaddress.code = textBox1.Text;
t_Oeeaddress.type = comboBox2.Text;
t_Oeeaddress.dbaddress = textBox2.Text;
t_Oeeaddress.addresstype = comboBox3.Text;
t_Oeeaddress.addresstypelegth = int.Parse(textBox3.Text);
t_Oeeaddress.addressoffset = int.Parse(textBox4.Text);
t_Oeeaddress.remark = textBox5.Text;
// 处理位地址
if (!string.IsNullOrEmpty(textBox6.Text) && int.TryParse(textBox6.Text, out int bitOffset))
{
t_Oeeaddress.addressdecimal = bitOffset;
}
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
if (Operation == OperationType.Add)
{
var result = sQLiteHelper.Insert(t_Oeeaddress);
if (result.Success)
{
MessageBox.Show("添加成功");
this.Close();
}
else
{
MessageBox.Show("添加失败");
}
}
else
{
t_Oeeaddress.id = dataid;
var result = sQLiteHelper.Update(t_Oeeaddress);
if (result.Success)
{
// 更新缓存
var cacheIndex = Init.t_Oeeaddresses.FindIndex(x => x.id == dataid);
if (cacheIndex != -1)
{
Init.t_Oeeaddresses[cacheIndex] = t_Oeeaddress;
}
MessageBox.Show("修改成功");
this.Close();
}
else
{
MessageBox.Show("修改失败");
}
}
}
catch (Exception ex)
{
MessageBox.Show($"操作失败,错误原因:{ex.Message}");
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SQLite;
namespace WindowsFormsApp1.mod
{
[Table("oeeaddress")]
public class t_oeeaddress
{
[PrimaryKey, AutoIncrement]
public int id { get; set; }
public int plcid { get; set; }
public string code { get; set; }
public string type { get; set; }
public string dbaddress { get; set; }
public string addresstype { get; set; }
public int addresstypelegth { get; set; }
public int addressoffset { get; set; }
// 添加位地址支持,用于存储布尔类型的位偏移
public int addressdecimal { get; set; }
public string remark { get; set; }
public string value { get; set; }
}
}
+6 -1
View File
@@ -11,7 +11,7 @@ namespace WindowsFormsApp1.mod.server
/// <summary>
/// PLC反馈的机台状态
/// </summary>
public int Plc_Status { get; set; }
public string Plc_Status { get; set; }
/// <summary>
/// PLC反馈的机台报警(默认获取0位)
@@ -80,6 +80,11 @@ namespace WindowsFormsApp1.mod.server
public int plcid { get; set; }
public t_materialupload material { get; set; }
/// <summary>
/// oee
/// </summary>
public List<t_oeeaddress> Oeeaddresses { get; set; }
}
+62 -67
View File
@@ -525,14 +525,14 @@ namespace WindowsFormsApp1.server
else if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM,ScrewTC".ToLower().Contains(station))
{
// 扭力 读马头服务器
var geturl = $"http://10.50.12.41/getdata/v2/tighteningresults?startTime={OtherData.material.date}&endTime={DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")}&vin={OtherData.material.sn}&controllerName={Init.t_Line.lineremark3}@{Init.t_Line.linecode}&includeCurve=true&includeSteps=false";
var geturl = $"http://10.50.12.41/getdata/v2/tighteningresults?startTime={OtherData.material.date}&endTime={DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")}&vin={OtherData.material.sn}&controllerName={Init.t_Line.lineremark2}@{Init.t_Line.linecode}&includeCurve=true&includeSteps=false";
//var geturl = "http://10.50.12.41/getdata/v2/tighteningresults?startTime=2025-04-11&endTime=2025-04-12&vin=ok&controllerName=OP1260%4010.50.247.110&includeCurve=true&includeSteps=false";
var res = _httpClient.GetAsync(geturl).Result;
if (res.StatusCode == System.Net.HttpStatusCode.OK)
{
//var getresult = JsonConvert.DeserializeObject(res.Content.ReadAsStringAsync().Result);
// 扭力 读马头服务器 todo
// 扭力 读马头服务器
try
{
// 反序列化 JSON 数据
@@ -579,7 +579,7 @@ namespace WindowsFormsApp1.server
}
catch (Exception ex)
{
Console.WriteLine($"发生错误: {ex.Message}");
LogExecute.logNet.WriteError($"解析马头数据,发生错误: {ex.Message}");
}
}
}
@@ -620,7 +620,7 @@ namespace WindowsFormsApp1.server
StationID = _stationID,
MachineID = _machineID,
OPID = _opID,
AlarmID = OtherData.Plc_ErrorMsgs[0],
AlarmID = Init.ErrorCode,
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
ResetTime = ""
};
@@ -890,7 +890,7 @@ namespace WindowsFormsApp1.server
material = new t_materialupload
{
sn = PlcData.Write_stSN,
CarrierID = PlcData.Write_stSN,
CarrierID = PlcData.Read_MaterialCode1,
datacollectionUploaded = 1,
result = logresult,
date = DateTime.Now.ToString("yyyy-MM-dd")
@@ -1082,6 +1082,63 @@ namespace WindowsFormsApp1.server
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
}
public ApiFormResult OEEDataCollection(string url, plcdata PlcData, otherdata OtherData)
{
var request = new
{
EventID = "OEEDataCollection",
Line = _line,
StationID = _stationID,
MachineID = _machineID,
OPID = _opID,
SN = PlcData.Write_stSN,
CarrierID = PlcData.Read_MaterialCode1,
DC_INFO = new List<DataDCInfoItem>(),
CompList = new List<CompListItem>(),
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
// 工位最长ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Cycle_Time",
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == "uiMAXCT")?.value //跟PLC定义好值从哪里获取
});
// 机台ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Takt_Time",
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == "uiNEWCT")?.value //跟PLC定义好值从哪里获取
});
var tossing = DataListManager.DataList.Any(x => x.Name == _stationID);
if (tossing)
{
var materialList = DataListManager.DataList.First(x => x.Name == _stationID).Components;
var num = 0;
foreach (var material in materialList)
{
request.DC_INFO.Add(
new DataDCInfoItem()
{
Item = $"Toss_Count_{material}",
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == $"uiUnloadingNG[{num}]")?.value //跟PLC定义好值从哪里获取
}
);
request.DC_INFO.Add(
new DataDCInfoItem()
{
Item = $"TossRate_{material}",
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == $"uiUnloadingNGX[{num}]")?.value //跟PLC定义好值从哪里获取
}
);
num++;
}
}
return CallApi(url, request, "OEEDataCollection", PlcData, PLC_Status.OEEDataCollection);
}
#region 暂时不用
public ApiFormResult Test(string url, plcdata PlcData, otherdata OtherData)
{
@@ -1098,68 +1155,6 @@ namespace WindowsFormsApp1.server
return CallApi(url, request, "Test", PlcData, PLC_Status.Test);
}
public ApiFormResult OEEDataCollection(string url, plcdata PlcData, otherdata OtherData)
{
//模穴 真空站两个穴位
var model = 1;
if (_stationID.ToLower() == "vacuum")
{
model = OtherData.plcid;
}
var request = new
{
EventID = "OEEDataCollection",
Line = _line,
StationID = _stationID,
MachineID = _machineID,
OPID = _opID,
SN = PlcData.Write_stSN,
CarrierID = PlcData.Read_MaterialCode1,
DC_INFO = new List<DataDCInfoItem>(),
CompList = new List<CompListItem>(),
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Eq_Active_Rate",
Value = "0"
});
// 工位最长ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Cycle_Time",
Value = "0" //跟PLC定义好值从哪里获取
});
// 机台ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Takt_Time",
Value = "0" //跟PLC定义好值从哪里获取
});
var tossing = DataListManager.DataList.Any(x => x.Name == _stationID);
if (tossing)
{
var materialList = DataListManager.DataList.First(x => x.Name == _stationID).Components;
foreach(var material in materialList)
{
request.DC_INFO.Add(
new DataDCInfoItem()
{
Item = $"Tossing_{material}",
Value = "1" //跟PLC定义好值从哪里获取
}
);
}
}
return CallApi(url, request, "OEEDataCollection", PlcData, PLC_Status.OEEDataCollection);
}
public ApiFormResult Get_Para(string url, plcdata PlcData, otherdata OtherData)
{
var request = new
+119 -1
View File
@@ -244,7 +244,7 @@ namespace WindowsFormsApp1.server
case "byte":
address[i].value = ByteTransform.TransByte(read.Content, index).ToString();
break;
case "real":
address[i].value = ByteTransform.TransSingle(read.Content, index).ToString();
break;
@@ -685,5 +685,123 @@ namespace WindowsFormsApp1.server
}
}
#endregion
#region 读取报警
private BllResult ReadOneDB(List<t_oeeaddress> address)
{
address = address.OrderBy(a => a.dbaddress)
.ThenBy(x => x.addressoffset)
.ToList();
OperateResult<byte[]> read;
if (address.Count == 1)
{
string startaddress = address[0].dbaddress + "." + address[0].addressoffset.ToString();
read = siemensS7Net.Read(startaddress, (ushort)address[0].addressdecimal);
}
else
{
double admax = address.Select(a => a.addressoffset).Max();
double admin = address.Select(a => a.addressoffset).Min();
ushort length = (ushort)(Math.Floor(admax - admin) + address.Last().addresstypelegth);
string startaddress = address[0].dbaddress + "." + admin.ToString();
read = siemensS7Net.Read(startaddress, length);
}
if (read.IsSuccess)
{
if (TransforWCSDataToAddressData(address, read).Success)
{
return BllResult.Sucess(address, "成功");
}
else
{
return BllResult.Sucess(address, "成功");
}
}
else
{
return BllResult.Error(read.Message);
}
}
public BllResult<List<t_oeeaddress>> ReadAddress(List<t_oeeaddress> address)
{
List<List<t_oeeaddress>> i_Device_s = new List<List<t_oeeaddress>>();
var ulist = address.GroupBy(a => a.dbaddress).ToList();
foreach (var u in ulist)
{
var readresult = ReadOneDB(u.ToList());
if (!readresult.Success)
{
return BllResult<List<t_oeeaddress>>.Error(readresult.Msg);
}
}
List<t_oeeaddress> list = new List<t_oeeaddress>();
foreach (var add in address.OrderBy(a => a.addressoffset))
{
list.Add(new t_oeeaddress {code = add.code, value = add.value});
}
return BllResult<List<t_oeeaddress>>.Sucess(list, "成功");
}
public BllResult TransforWCSDataToAddressData(List<t_oeeaddress> address, OperateResult<byte[]> read)
{
try
{
//按偏移量排序
address = address.OrderBy(a => a.dbaddress)
.ThenBy(x => x.addressoffset).ToList();
int startindex = address[0].addressoffset;
for (int i = 0; i < address.Count; i++)
{
int index = address[i].addressoffset - startindex;
switch (address[i].addresstype)
{
case "BYTE":
address[i].value = ByteTransform.TransByte(read.Content, index).ToString();
break;
case "real":
address[i].value = ByteTransform.TransSingle(read.Content, index).ToString();
break;
case "uint":
address[i].value = ByteTransform.TransInt16(read.Content, index).ToString();
break;
case "LWORD":
address[i].value = Convert.ToString(ByteTransform.TransInt64(read.Content, index), 16); ;
break;
case "bool":
address[i].value = ByteTransform.TransBool(read.Content, index, 1)[address[i].addressdecimal].ToString();
break;
case "INT":
address[i].value = ByteTransform.TransInt16(read.Content, index).ToString();
break;
case "DINT":
address[i].value = Convert.ToString(ByteTransform.TransInt32(read.Content, index), 10);
break;
case "CHAR":
address[i].value = Encoding.ASCII.GetString(read.Content, index, 20).Replace(" ", "").Replace("\0", "").Replace("\u0003", "");
break;
default:
return BllResult.Error("找不到未知的数据类型");
}
}
return BllResult.Sucess(address);
}
catch (Exception ex)
{
return BllResult.Error($"转换WCS数据失败{ex.Message}");
}
}
#endregion
}
}