Compare commits

...
9 Commits
Author SHA1 Message Date
gf zhou eb64a3fc2f 写入冷却加热时间
测试模式切换时对应的定时器也要开启关闭
读到3触发字,关闭扫码页面
2025-06-02 16:43:09 +08:00
gf zhou 817b66ad53 5.12 OEE相关日志放到右侧
螺丝添加NG的统计
2025-05-12 14:01:46 +08:00
zhougf e8001a81bb PLC时间对接
定时器测试
s7通讯加辅助方法
4.21 测试
2025-04-21 15:29:57 +08:00
gf zhou 76cd069435 4.18 checkin不管成功失败都写sn
加上needwork的判定
datacollection 判断dcinfo为空,不传mes,事件不显示在事件列表,只记录日志
状态上传定时器重新修改上传逻辑
文件上传定时器
2025-04-20 18:15:30 +08:00
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
gf zhou 233737bc31 添加接口null值检查
打开螺丝引导页面逻辑修改
程序重复打开命名修改
添加心跳线程
2025-04-16 11:31:16 +08:00
zhougf 1a9f2a5bca 4.12
1.添加马头螺丝扭力角度的上传,后期使用定时器定时上传数据
2.抽真空 plc 触发90
3.螺丝开盖按钮添加 从 keyvalue获取值,对比扫码得到的值更新other4
2025-04-12 14:55:51 +08:00
zhougf 69c851c09e 4.11更新
1.添加是否调用mes接口按钮,并只有admin用户可以点击,2.修改螺丝引导页面
3.端子只有一个,端子扫码借用扫码页面
2025-04-11 15:47:10 +08:00
27 changed files with 3280 additions and 650 deletions

No files matched your search

+23 -5
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,12 @@
<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">
<DependentUpon>OEEaddress_Manage.cs</DependentUpon>
</Compile>
<Compile Include="form\ScanForm_DZ.cs">
<SubType>Form</SubType>
</Compile>
@@ -244,16 +254,18 @@
<Compile Include="form\MESUrl.Designer.cs">
<DependentUpon>MESUrl.cs</DependentUpon>
</Compile>
<Compile Include="MaterialScanForm.cs">
<Compile Include="form\MaterialScanForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MaterialScanForm.Designer.cs">
<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" />
<Compile Include="mod\database\t_materialscan.cs" />
<Compile Include="mod\database\t_materialupload.cs" />
<Compile Include="mod\database\t_pressurecurve.cs" />
<Compile Include="mod\database\t_flow.cs" />
<Compile Include="mod\database\t_interface.cs" />
@@ -264,6 +276,7 @@
<Compile Include="mod\database\t_plcaddress.cs" />
<Compile Include="mod\database\t_plc.cs" />
<Compile Include="mod\database\t_serialport.cs" />
<Compile Include="mod\database\t_sn.cs" />
<Compile Include="mod\database\t_user.cs" />
<Compile Include="mod\enum\plc_emum.cs" />
<Compile Include="mod\server\otherdata.cs" />
@@ -331,6 +344,11 @@
<EmbeddedResource Include="form\Angleaddress_Manage.resx">
<DependentUpon>Angleaddress_Manage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="form\OEEaddress_Manage.resx">
<DependentUpon>OEEaddress_Manage.cs</DependentUpon>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>OEEaddress_Manage1.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="form\ScanForm_DZ.resx">
<DependentUpon>ScanForm_DZ.cs</DependentUpon>
</EmbeddedResource>
@@ -370,7 +388,7 @@
<EmbeddedResource Include="form\MESUrl.resx">
<DependentUpon>MESUrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MaterialScanForm.resx">
<EmbeddedResource Include="form\MaterialScanForm.resx">
<DependentUpon>MaterialScanForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
+80 -39
View File
@@ -77,9 +77,9 @@ namespace WindowsFormsApp1
this.材料值 = new System.Windows.Forms.Label();
this.材料 = new System.Windows.Forms.Label();
this.LOT号显示 = new System.Windows.Forms.Label();
this.LOT号 = new System.Windows.Forms.Label();
this.MES提示 = new System.Windows.Forms.Label();
this.Tray盘二维码 = new System.Windows.Forms.Label();
this.LOT号 = new System.Windows.Forms.Label();
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@@ -108,10 +108,13 @@ namespace WindowsFormsApp1
this.底部注释3 = new System.Windows.Forms.Label();
this.底部注释4 = new System.Windows.Forms.Label();
this.底部注释5 = new System.Windows.Forms.Label();
this.btnToggleTestMode = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel();
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();
@@ -277,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);
@@ -427,9 +431,10 @@ namespace WindowsFormsApp1
//
// linemode
//
this.linemode.AutoEllipsis = true;
this.linemode.AutoSize = true;
this.linemode.Dock = System.Windows.Forms.DockStyle.Fill;
this.linemode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linemode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
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";
@@ -442,7 +447,7 @@ namespace WindowsFormsApp1
//
this.当前时间.AutoSize = true;
this.当前时间.Dock = System.Windows.Forms.DockStyle.Fill;
this.当前时间.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.当前时间.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.当前时间.Location = new System.Drawing.Point(1487, 1);
this.当前时间.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.当前时间.Name = "当前时间";
@@ -455,7 +460,7 @@ namespace WindowsFormsApp1
//
this.操作人员ID.AutoSize = true;
this.操作人员ID.Dock = System.Windows.Forms.DockStyle.Fill;
this.操作人员ID.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.操作人员ID.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
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";
@@ -466,9 +471,10 @@ namespace WindowsFormsApp1
//
// linetype
//
this.linetype.AutoEllipsis = true;
this.linetype.AutoSize = true;
this.linetype.Dock = System.Windows.Forms.DockStyle.Fill;
this.linetype.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linetype.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
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";
@@ -479,9 +485,10 @@ namespace WindowsFormsApp1
//
// linecode
//
this.linecode.AutoEllipsis = true;
this.linecode.AutoSize = true;
this.linecode.Dock = System.Windows.Forms.DockStyle.Fill;
this.linecode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linecode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
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";
@@ -494,7 +501,7 @@ namespace WindowsFormsApp1
//
this.linename.AutoSize = true;
this.linename.Dock = System.Windows.Forms.DockStyle.Fill;
this.linename.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linename.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
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";
@@ -553,15 +560,14 @@ namespace WindowsFormsApp1
//
this.tableLayoutPanel5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.tableLayoutPanel5.ColumnCount = 2;
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 24.49411F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 75.50589F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 75F));
this.tableLayoutPanel5.Controls.Add(this.材料值, 1, 1);
this.tableLayoutPanel5.Controls.Add(this.材料, 0, 1);
this.tableLayoutPanel5.Controls.Add(this.LOT号显示, 0, 0);
this.tableLayoutPanel5.Controls.Add(this.LOT号, 1, 0);
this.tableLayoutPanel5.Controls.Add(this.MES提示, 0, 2);
this.tableLayoutPanel5.Controls.Add(this.Tray盘二维码, 1, 2);
this.tableLayoutPanel5.Controls.Add(this.LOT号, 1, 0);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel5.Location = new System.Drawing.Point(3, 41);
this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
@@ -578,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(343, 49);
this.材料值.Location = new System.Drawing.Point(350, 49);
this.材料值.Name = "材料值";
this.材料值.Size = new System.Drawing.Size(1045, 49);
this.材料值.Size = new System.Drawing.Size(1038, 49);
this.材料值.TabIndex = 7;
this.材料值.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@@ -591,7 +597,7 @@ namespace WindowsFormsApp1
this.材料.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.材料.Location = new System.Drawing.Point(3, 49);
this.材料.Name = "材料";
this.材料.Size = new System.Drawing.Size(334, 49);
this.材料.Size = new System.Drawing.Size(341, 49);
this.材料.TabIndex = 6;
this.材料.Text = "材 料:";
this.材料.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -603,22 +609,11 @@ 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(334, 49);
this.LOT号显示.Size = new System.Drawing.Size(341, 49);
this.LOT号显示.TabIndex = 2;
this.LOT号显示.Text = "产品 SN:";
this.LOT号显示.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// LOT号
//
this.LOT号.AutoSize = true;
this.LOT号.Dock = System.Windows.Forms.DockStyle.Fill;
this.LOT号.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold);
this.LOT号.Location = new System.Drawing.Point(343, 0);
this.LOT号.Name = "LOT号";
this.LOT号.Size = new System.Drawing.Size(1045, 49);
this.LOT号.TabIndex = 0;
this.LOT号.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// MES提示
//
this.MES提示.AutoSize = true;
@@ -626,7 +621,7 @@ namespace WindowsFormsApp1
this.MES提示.Font = new System.Drawing.Font("宋体", 15F);
this.MES提示.Location = new System.Drawing.Point(3, 98);
this.MES提示.Name = "MES提示";
this.MES提示.Size = new System.Drawing.Size(334, 50);
this.MES提示.Size = new System.Drawing.Size(341, 50);
this.MES提示.TabIndex = 4;
this.MES提示.Text = "托 盘 码:";
this.MES提示.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -636,20 +631,31 @@ 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(343, 98);
this.Tray盘二维码.Location = new System.Drawing.Point(350, 98);
this.Tray盘二维码.Name = "Tray盘二维码";
this.Tray盘二维码.Size = new System.Drawing.Size(1045, 50);
this.Tray盘二维码.Size = new System.Drawing.Size(1038, 50);
this.Tray盘二维码.TabIndex = 2;
this.Tray盘二维码.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// LOT号
//
this.LOT号.AutoSize = true;
this.LOT号.Dock = System.Windows.Forms.DockStyle.Fill;
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, 49);
this.LOT号.TabIndex = 0;
this.LOT号.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tableLayoutPanel6
//
this.tableLayoutPanel6.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
this.tableLayoutPanel6.ColumnCount = 3;
this.tableLayoutPanel4.SetColumnSpan(this.tableLayoutPanel6, 2);
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel6.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel6.Controls.Add(this.label2, 1, 0);
this.tableLayoutPanel6.Controls.Add(this.label3, 2, 0);
@@ -684,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(255, 50);
this.label2.Size = new System.Drawing.Size(430, 50);
this.label2.TabIndex = 1;
this.label2.Text = "MES事件结果";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -694,9 +700,9 @@ namespace WindowsFormsApp1
this.label3.AutoSize = true;
this.label3.Dock = System.Windows.Forms.DockStyle.Fill;
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(703, 1);
this.label3.Location = new System.Drawing.Point(878, 1);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(1041, 50);
this.label3.Size = new System.Drawing.Size(866, 50);
this.label3.TabIndex = 2;
this.label3.Text = "MES信息提示";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -708,7 +714,7 @@ namespace WindowsFormsApp1
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, 52);
this.事件结果.Name = "事件结果";
this.事件结果.Size = new System.Drawing.Size(255, 243);
this.事件结果.Size = new System.Drawing.Size(430, 243);
this.事件结果.TabIndex = 3;
this.事件结果.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@@ -716,10 +722,10 @@ namespace WindowsFormsApp1
//
this.MES提示信息.AutoSize = true;
this.MES提示信息.Dock = System.Windows.Forms.DockStyle.Fill;
this.MES提示信息.Font = new System.Drawing.Font("宋体", 16.125F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.MES提示信息.Location = new System.Drawing.Point(703, 52);
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, 52);
this.MES提示信息.Name = "MES提示信息";
this.MES提示信息.Size = new System.Drawing.Size(1041, 243);
this.MES提示信息.Size = new System.Drawing.Size(866, 243);
this.MES提示信息.TabIndex = 4;
this.MES提示信息.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@@ -929,6 +935,8 @@ namespace WindowsFormsApp1
this.tableLayoutPanel8.Controls.Add(this.底部注释3, 2, 0);
this.tableLayoutPanel8.Controls.Add(this.底部注释4, 3, 0);
this.tableLayoutPanel8.Controls.Add(this.底部注释5, 4, 0);
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, 1070);
this.tableLayoutPanel8.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
@@ -988,6 +996,29 @@ namespace WindowsFormsApp1
this.底部注释5.TabIndex = 4;
this.底部注释5.Text = "底部注释5";
//
// btnToggleTestMode
//
this.btnToggleTestMode.BackColor = System.Drawing.Color.Gray;
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, 32);
this.btnToggleTestMode.TabIndex = 5;
this.btnToggleTestMode.Text = "调试模式";
this.btnToggleTestMode.UseVisualStyleBackColor = false;
this.btnToggleTestMode.Click += new System.EventHandler(this.BtnToggleTestMode_Click);
//
// button1
//
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, 32);
this.button1.TabIndex = 6;
this.button1.Text = "螺丝开盖";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// tableLayoutPanel7
//
this.tableLayoutPanel7.ColumnCount = 2;
@@ -1022,6 +1053,13 @@ namespace WindowsFormsApp1
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, 25F);
@@ -1142,6 +1180,9 @@ namespace WindowsFormsApp1
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
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;
}
}
File diff suppressed because it is too large. Load diff
+5
View File
@@ -41,12 +41,14 @@ namespace WindowsFormsApp1
public static List<t_flow> t_Flows;
public static List<t_lineplc> t_Lineplcs;
public static List<t_plc> t_plcs;
public static List<t_interface> t_Interfaces;
public static List<t_plcaddress> t_Plcaddresses;
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;
@@ -54,8 +56,10 @@ namespace WindowsFormsApp1
public static List<ThreadHelp> threadHelps;
public static string ScanString;
public static string DZString;
//PLC状态存储
public static short Plcstatus = -1;
public static string ErrorCode = "";
//PLC最后状态事件(用于计时15秒状态不变回传)
public static DateTime Plcstatus_LastTime = DateTime.Now;
@@ -73,6 +77,7 @@ namespace WindowsFormsApp1
public static string ImageName { get; set; }
public static int ImageLocation { get; set; }
public static short ScrewBegin { get; set; }
public static int PlcTrigger { get; set; }
+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>
+300 -51
View File
@@ -5,6 +5,8 @@ using System.ComponentModel;
using System.IO;
using WindowsFormsApp1.mod;
using WindowsFormsApp1.db;
using System.Collections.Generic;
using System.Linq;
namespace WindowsFormsApp1
{
@@ -23,13 +25,33 @@ namespace WindowsFormsApp1
private string currentName = "";
private string currentPosition = "";
private bool isBlinking = false;
// 圆形标记相关参数
private float currentRadius = 20f;
private const float MIN_RADIUS = 20f;
private const float MAX_RADIUS = 50f;
private const float MIN_RADIUS = 30f;
private const float MAX_RADIUS = 55f;
private bool isExpanding = true;
private const float RADIUS_CHANGE_SPEED = 2f;
// 添加上一个位置的坐标
private int previousX = -1;
private int previousY = -1;
private bool hasPreviousPosition = false;
// 添加所有点位的列表
private List<t_imageposition> allPositions = new List<t_imageposition>();
private bool showAllPositions = true;
// 添加历史位置列表
private List<PositionHistory> previousPositions = new List<PositionHistory>();
// 定义历史位置类
private class PositionHistory
{
public int X { get; set; }
public int Y { get; set; }
public string Position { get; set; }
}
#endregion
#region 构造函数和初始化
@@ -43,6 +65,25 @@ namespace WindowsFormsApp1
autoUpdateTimer.Interval = 1000;
autoUpdateTimer.Tick += new EventHandler(AutoUpdateTimer_Tick);
autoUpdateTimer.Start();
// 添加窗体加载事件
this.Load += ImageDisplayForm_Load;
}
private void ImageDisplayForm_Load(object sender, EventArgs e)
{
// 设置窗体大小为屏幕工作区的80%
Screen screen = Screen.FromControl(this);
this.Size = new Size(
(int)(screen.WorkingArea.Width * 0.8),
(int)(screen.WorkingArea.Height * 0.8)
);
this.CenterToScreen();
// 或者使用以下代码设置为全屏但非最大化
// this.WindowState = FormWindowState.Normal;
// this.FormBorderStyle = FormBorderStyle.None;
// this.Bounds = Screen.FromControl(this).Bounds;
}
#endregion
@@ -98,6 +139,9 @@ namespace WindowsFormsApp1
originalImage = new Bitmap(imagePath);
markedImage = new Bitmap(originalImage);
pictureBox.Image = markedImage;
// 加载所有点位并标注
LoadAllPositions(name);
}
catch (Exception ex)
{
@@ -110,65 +154,157 @@ namespace WindowsFormsApp1
}
}
// 在图像上绘制标记
private void DrawMark(int x, int y)
// 加载所有点位并标注
private void LoadAllPositions(string name)
{
try
{
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
allPositions = sQLiteHelper_position.Query(x => x.name == name).Data;
if (allPositions != null && allPositions.Count > 0)
{
// 重新绘制图像,标注所有点位
RedrawImage();
}
}
catch (Exception ex)
{
Console.WriteLine($"加载所有点位失败:{ex.Message}");
}
}
// 重新绘制图像,包括所有标记
private void RedrawImage()
{
if (originalImage == null)
return;
// 创建新的标记图像
if (markedImage != null)
markedImage.Dispose();
markedImage = new Bitmap(originalImage);
using (Graphics g = Graphics.FromImage(markedImage))
{
if (isBlinking)
// 设置高质量绘图模式
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// 绘制所有点位(白色实心圆和序号)
if (showAllPositions && allPositions != null)
{
// 设置高质量绘图模式
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// 只绘制白色圆
using (Brush whiteBrush = new SolidBrush(Color.White))
for (int i = 0; i < allPositions.Count; i++)
{
g.FillEllipse(whiteBrush,
x - currentRadius,
y - currentRadius,
currentRadius * 2,
currentRadius * 2);
}
var pos = allPositions[i];
// 更新半径
if (isExpanding)
{
currentRadius += RADIUS_CHANGE_SPEED;
if (currentRadius >= MAX_RADIUS)
// 绘制白色实心圆
using (Brush whiteBrush = new SolidBrush(Color.White))
{
currentRadius = MAX_RADIUS;
isExpanding = false;
g.FillEllipse(whiteBrush,
pos.x - MIN_RADIUS,
pos.y - MIN_RADIUS,
MIN_RADIUS * 2,
MIN_RADIUS * 2);
}
}
else
{
currentRadius -= RADIUS_CHANGE_SPEED;
if (currentRadius <= MIN_RADIUS)
// 绘制白色序号
using (Font font = new Font("Arial", 16, FontStyle.Bold))
using (Brush textBrush = new SolidBrush(Color.Black))
{
currentRadius = MIN_RADIUS;
isExpanding = true;
string text = pos.position; // 使用position属性
SizeF textSize = g.MeasureString(text, font);
g.DrawString(text, font, textBrush,
pos.x - textSize.Width / 2,
pos.y - textSize.Height / 2);
}
}
}
// 绘制所有历史位置的绿色标记
foreach (var history in previousPositions)
{
using (Brush greenBrush = new SolidBrush(Color.Green))
{
g.FillEllipse(greenBrush,
history.X - MIN_RADIUS,
history.Y - MIN_RADIUS,
MIN_RADIUS * 2,
MIN_RADIUS * 2);
}
// 绘制绿色标记上的文字
using (Font font = new Font("Arial", 16, FontStyle.Bold))
using (Brush textBrush = new SolidBrush(Color.White))
{
string text = history.Position;
SizeF textSize = g.MeasureString(text, font);
g.DrawString(text, font, textBrush,
history.X - textSize.Width / 2,
history.Y - textSize.Height / 2);
}
}
}
pictureBox.Image = markedImage;
}
#endregion
#region 数据查询和更新
// 自动更新定时器事件
private void AutoUpdateTimer_Tick(object sender, EventArgs e)
{
if(Init.ScrewBegin != 1)
{
this.Close();
return;
}
// 获取当前位置变量
//string newPosition = GetCurrentPosition();
string newPosition = Init.ImageLocation.ToString();
if (newPosition != currentPosition || (string.IsNullOrEmpty(currentPosition) && !string.IsNullOrEmpty(newPosition)))
{
// 保存上一个位置
if (!string.IsNullOrEmpty(currentPosition))
{
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
var positions = sQLiteHelper_position.Query(x => x.name == currentName
&& x.position == currentPosition).Data;
if (positions != null && positions.Count > 0)
{
var pos = positions[0];
// 检查是否已经存在相同位置的历史记录
bool exists = false;
foreach (var history in previousPositions)
{
if (history.X == pos.x && history.Y == pos.y)
{
// 更新位置文本
history.Position = currentPosition;
exists = true;
break;
}
}
// 如果不存在,添加到历史记录
if (!exists)
{
previousPositions.Add(new PositionHistory
{
X = pos.x,
Y = pos.y,
Position = currentPosition
});
}
// 设置最近的历史位置
previousX = pos.x;
previousY = pos.y;
hasPreviousPosition = true;
}
}
currentPosition = newPosition;
// 如果名称和位置都有值,则查询坐标并标注
@@ -193,49 +329,162 @@ namespace WindowsFormsApp1
{
try
{
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
var positions = sQLiteHelper_position.Query(x => x.name == name
&& x.position == position).Data;
// 从已加载的点位列表中查找,避免重复查询数据库
var pos = allPositions?.FirstOrDefault(x => x.name == name && x.position == position);
if (positions != null && positions.Count > 0)
if (pos != null)
{
var pos = positions[0];
// 标记位置
if (originalImage != null)
{
isBlinking = true; // 设置为 true 后不再切换
currentRadius = MIN_RADIUS; // 重置半径
blinkTimer.Start();
// 确保闪烁定时器已启动
if (blinkTimer != null && !blinkTimer.Enabled)
blinkTimer.Start();
// 在图像上绘制标记
DrawMark(pos.x, pos.y);
}
}
else
{
// 如果在内存中没有找到,尝试从数据库查询
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
var positions = sQLiteHelper_position.Query(x => x.name == name && x.position == position).Data;
if (positions != null && positions.Count > 0)
{
pos = positions[0];
// 添加到内存中的列表
if (!allPositions.Any(x => x.name == name && x.position == position))
{
allPositions.Add(pos);
}
// 标记位置
if (originalImage != null)
{
isBlinking = true;
currentRadius = MIN_RADIUS;
if (blinkTimer != null && !blinkTimer.Enabled)
blinkTimer.Start();
DrawMark(pos.x, pos.y);
}
}
else
{
// 如果没有找到对应的位置,停止闪烁
isBlinking = false;
blinkTimer?.Stop();
// 仍然重绘图像以显示所有点位和之前的绿色标记
RedrawImage();
Console.WriteLine($"未找到名称为 {name} 位置为 {position} 的坐标");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"查询坐标失败:{ex.Message}");
// 发生异常时也重绘图像
RedrawImage();
}
}
#endregion
#region 事件处理
// 在图像上绘制标记
private void DrawMark(int x, int y)
{
if (originalImage == null)
return;
// 先重新绘制基础图像(包含所有点位标记)
RedrawImage();
using (Graphics g = Graphics.FromImage(markedImage))
{
// 设置高质量绘图模式
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
if (isBlinking)
{
// 绘制当前位置的黄色实心圆
using (Brush brush = new SolidBrush(Color.Yellow))
{
g.FillEllipse(brush,
x - MIN_RADIUS,
y - MIN_RADIUS,
MIN_RADIUS * 2,
MIN_RADIUS * 2);
}
// 绘制白色数字标记
using (Font font = new Font("Arial", 16, FontStyle.Bold))
using (Brush textBrush = new SolidBrush(Color.Black))
{
string text = currentPosition;
SizeF textSize = g.MeasureString(text, font);
g.DrawString(text, font, textBrush,
x - textSize.Width / 2,
y - textSize.Height / 2);
}
// 绘制黄色虚线空心圆闪烁效果
using (Pen yellowPen = new Pen(Color.Yellow, 2))
{
yellowPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
g.DrawEllipse(yellowPen,
x - currentRadius,
y - currentRadius,
currentRadius * 2,
currentRadius * 2);
}
}
}
pictureBox.Image = markedImage;
}
// 闪烁定时器事件
private void BlinkTimer_Tick(object sender, EventArgs e)
{
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
var positions = sQLiteHelper_position.Query(x => x.name == currentName
&& x.position == currentPosition).Data;
// 从已加载的点位列表中查找当前位置
var pos = allPositions?.FirstOrDefault(x => x.name == currentName && x.position == currentPosition);
if (positions != null && positions.Count > 0)
if (pos != null)
{
var pos = positions[0];
// 直接调用DrawMark方法绘制标记
DrawMark(pos.x, pos.y);
// 更新半径
if (isExpanding)
{
currentRadius += RADIUS_CHANGE_SPEED;
if (currentRadius >= MAX_RADIUS)
{
currentRadius = MAX_RADIUS;
isExpanding = false;
}
}
else
{
currentRadius -= RADIUS_CHANGE_SPEED;
if (currentRadius <= MIN_RADIUS)
{
currentRadius = MIN_RADIUS;
isExpanding = true;
}
}
}
}
// 移除了 BtnLoadImage_Click 事件处理程序
#endregion
#region 资源释放
protected override void Dispose(bool disposing)
{
@@ -297,4 +546,4 @@ namespace WindowsFormsApp1
#endregion
}
}
}
@@ -42,6 +42,7 @@ namespace WindowsFormsApp1
else
{
MessageBox.Show("扫码枪串口未配置,请检查系统设置", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
_dbHelper = new SQLiteHelper<t_materialscan>();
_apiClient = new ApiClient();
+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,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
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">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</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.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:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+11 -2
View File
@@ -104,8 +104,17 @@ namespace WindowsFormsApp1
{
端子1校验.Text = "校验OK";
}));
// 写数据到 主页的barcode 数据库改,缓存改
var txt = Init.t_Keyvalues.FirstOrDefault(a => a.key == "Barcode1");
txt.value = 端子1.Text;
var code = key_sqlresult.Data.First(x => x.key == txt.key);
code.value = 端子1.Text;
sQLiteHelper_key.Update(code);
//继续调用接口
var result2 = ApiClient.CallFunctionByName("Link_Comp", PlcData, new otherdata() { JS_SN = barcode });
/*var result2 = ApiClient.CallFunctionByName("Link_Comp", PlcData, new otherdata() { JS_SN = barcode });
if (result2.Success && result2.Mesresult == mesresult.PASS)
{
this.Invoke(new Action(() =>
@@ -127,7 +136,7 @@ namespace WindowsFormsApp1
{
端子1结果.Text = "绑定NG";
}));
}
}*/
}
else
{
@@ -34,7 +34,7 @@ namespace WindowsFormsApp1
// 圆形标记相关参数
private float currentRadius = 20f;
private const float MIN_RADIUS = 20f;
private const float MIN_RADIUS = 25f;
private const float MAX_RADIUS = 50f;
private bool isExpanding = true;
private const float RADIUS_CHANGE_SPEED = 2f;
@@ -44,6 +44,24 @@ namespace WindowsFormsApp1
public SimpleImageDisplayForm()
{
InitializeComponent();
// 添加窗体加载事件
this.Load += ImageDisplayForm_Load;
}
private void ImageDisplayForm_Load(object sender, EventArgs e)
{
// 设置窗体大小为屏幕工作区的80%
Screen screen = Screen.FromControl(this);
this.Size = new Size(
(int)(screen.WorkingArea.Width * 0.8),
(int)(screen.WorkingArea.Height * 0.8)
);
this.CenterToScreen();
// 或者使用以下代码设置为全屏但非最大化
// this.WindowState = FormWindowState.Normal;
// this.FormBorderStyle = FormBorderStyle.None;
// this.Bounds = Screen.FromControl(this).Bounds;
}
#endregion
@@ -53,7 +71,7 @@ namespace WindowsFormsApp1
{
if (originalImage == null)
return;
markedImage.Dispose();
markedImage = new Bitmap(originalImage);
using (Graphics g = Graphics.FromImage(markedImage))
{
@@ -63,9 +81,9 @@ namespace WindowsFormsApp1
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// 只绘制白色圆
using (Brush whiteBrush = new SolidBrush(Color.White))
using (var brush = new Pen(Color.Yellow))
{
g.FillEllipse(whiteBrush,
g.DrawEllipse(brush,
x - currentRadius,
y - currentRadius,
currentRadius * 2,
@@ -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();
}
}
}
@@ -7,6 +7,7 @@ using SQLite;
namespace WindowsFormsApp1.mod
{
[Table("t_imageposition")]
public class t_imageposition
{
[PrimaryKey, AutoIncrement]
@@ -9,6 +9,8 @@ namespace WindowsFormsApp1.mod
[PrimaryKey, AutoIncrement]
public int id { get; set; }
public string materialid { get; set; }
public string sn { get; set; }
public bool isout { get; set; }
public DateTime? checkin1 { get; set; }
public DateTime? checkin2 { get; set; }
public DateTime? checkin3 { get; set; }
@@ -0,0 +1,21 @@
using SQLite;
using System;
namespace WindowsFormsApp1.mod
{
[Table("material_upload")]
public class t_materialupload
{
[PrimaryKey, AutoIncrement]
public int id { get; set; }
public string sn { get; set; }
public string CarrierID { get; set; }
// plc·´À¡µÄ½á¹û£¬ok/ng
public string result { get; set; }
public int imageUploaded { get; set; }
public int vedioUploaded { get; set; }
public int datacollectionUploaded { get; set; }
public string date { get; set; }
public DateTime outtime { get; set; }
}
}
@@ -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; }
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SQLite;
namespace WindowsFormsApp1.mod
{
[Table("sn")]
public class t_sn
{
public int id { get; set; }
public string sn { get; set; }
}
}
+11 -2
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位)
@@ -51,7 +51,7 @@ namespace WindowsFormsApp1.mod.server
/// <summary>
/// 螺丝枪角度
/// </summary>
public List<float> FinalAngleValue { get; set; }
public List<List<dynamic>> FinalAngleValue { get; set; }
/// <summary>
/// 螺丝枪扭力曲线
@@ -76,6 +76,15 @@ namespace WindowsFormsApp1.mod.server
/// 上下料操作 上料:1;下料 2
/// </summary>
public int opindex { get; set; }
public int plcid { get; set; }
public t_materialupload material { get; set; }
/// <summary>
/// oee
/// </summary>
public List<t_oeeaddress> Oeeaddresses { get; set; }
}
+1
View File
@@ -187,5 +187,6 @@ namespace WindowsFormsApp1.mod.server
/// 写入PLC的时间
/// </summary>
public DateTime Write_Time2 { get; set; }
public DateTime NowDateTime { get; set; }
}
}
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -13,7 +13,7 @@ namespace WindowsFormsApp1.server
public static ILogNet PlclogNet = new LogNetDateTime("C:\\Log\\PlcLogs", GenerateMode.ByEveryDay);
public static ILogNet ApilogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryHour);
public static ILogNet SNlogNet = new LogNetDateTime("C:\\Log\\SNlogs", GenerateMode.ByEveryDay);
public static ILogNet OEElogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryDay);
public static ILogNet OEElogNet = new LogNetDateTime("C:\\Log\\OEElogs", GenerateMode.ByEveryDay);
public static HslCommunication.BasicFramework.SoftNumericalOrder softNumericalOrder = new HslCommunication.BasicFramework.SoftNumericalOrder("", "yyyyMMdd", 4, @"\numericalOrder.txt");
+172 -6
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;
@@ -280,6 +280,10 @@ namespace WindowsFormsApp1.server
.ToArray());
break;
case "dtl":
address[i].value = GetDTLTime(read.Content, index).ToString();
break;
default:
return BllResult.Error("找不到未知的数据类型");
}
@@ -359,6 +363,12 @@ namespace WindowsFormsApp1.server
stringBytes.CopyTo(writebyte, index);
break;
case "dtl":
DateTime totime = Convert.ToDateTime(value);
byte[] totime_byte = GetBytesFromDTLTime(totime);
totime_byte.CopyTo(writebyte, index);
break;
default:
return BllResult.Error("找不到未知的数据类型");
}
@@ -477,7 +487,7 @@ namespace WindowsFormsApp1.server
#endregion
#region 读取角度
public BllResult<List<float>> ReadAddress(List<t_angleaddress> address)
public BllResult<List<dynamic>> ReadAddress(List<t_angleaddress> address)
{
var ulist = address.GroupBy(a => a.dbaddress).ToList();
foreach (var u in ulist)
@@ -485,15 +495,18 @@ namespace WindowsFormsApp1.server
var readresult = ReadOneDB(u.ToList());
if (!readresult.Success)
{
return BllResult<List<float>>.Error(readresult.Msg);
return BllResult<List<dynamic>>.Error(readresult.Msg);
}
}
List<float> list = new List<float>();
List<dynamic> list = new List<dynamic>();
foreach (var add in address.OrderBy(a => a.addressoffset))
{
list.Add(float.Parse(add.value));
if(add.addresstype == "real")
list.Add(float.Parse(add.value));
else
list.Add(short.Parse(add.value));
}
return BllResult<List<float>>.Sucess(list, "成功");
return BllResult<List<dynamic>>.Sucess(list, "成功");
}
private BllResult ReadOneDB(List<t_angleaddress> address)
{
@@ -685,5 +698,158 @@ 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
#region
public byte[] GetBytesFromDTLTime(DateTime dateTime)
{
byte[] array = new byte[12];
ByteTransform.TransByte((short)dateTime.Year).CopyTo(array, 0);
array[2] = (byte)dateTime.Month;
array[3] = (byte)dateTime.Day;
array[4] = 5;
array[5] = (byte)dateTime.Hour;
array[6] = (byte)dateTime.Minute;
array[7] = (byte)dateTime.Second;
ByteTransform.TransByte(dateTime.Millisecond * 1000 * 1000).CopyTo(array, 8);
return array;
}
public DateTime GetDTLTime(byte[] buffer, int index)
{
int year = (int)ByteTransform.TransInt16(buffer, index);
int month = (int)buffer[index + 2];
int day = (int)buffer[index + 3];
int hour = (int)buffer[index + 5];
int minute = (int)buffer[index + 6];
int second = (int)buffer[index + 7];
int millisecond = ByteTransform.TransInt32(buffer, index + 8) / 1000 / 1000;
if (year == 0 && month == 0 && day == 0)
{
year = 1900;
month = 1;
day = 1;
}
return new DateTime(year, month, day, hour, minute, second, millisecond);
}
#endregion
}
}
+9 -3
View File
@@ -7,10 +7,16 @@ using System.Threading.Tasks;
namespace WindowsFormsApp1.server
{
public class ThreadHelp
public class ThreadHelp :IDisposable
{
public Thread Thread { get; set; }
public bool isrunning1 = false;
public CancellationTokenSource cancellationTokenSource1;
public bool isrunning1 {get;set;}= false;
public CancellationTokenSource cancellationTokenSource1{get;set;}
public void Dispose()
{
cancellationTokenSource1?.Cancel();
cancellationTokenSource1?.Dispose();
Thread = null;
}
}
}