From adfcd624fa7d4a3679ac080bb94411f7aec7999f Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Fri, 22 Nov 2024 14:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=94=A8=E7=9A=84=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RfidWeb/FormMain.cs | 132 ++++---- RfidWeb/Frm/FrmBarCodeGridView.cs | 46 ++- RfidWeb/Frm/UserAlarmShow.Designer.cs | 108 +++---- RfidWeb/Frm/UserAlarmShow.cs | 48 +-- RfidWeb/RfidWeb.csproj | 1 - RfidWeb/Tool/TestFactory.cs | 39 --- Tool/CacheManager.cs | 4 +- Tool/ExcelHelp.cs | 244 +-------------- Tool/Model/HmiPoint.cs | Bin 14387 -> 0 bytes Tool/Model/HmiPointInfo.cs | 414 ++++++++++++++++++++++++++ Tool/PlcConnect.cs | 11 + Tool/RfidSetting.cs | Bin 1660 -> 0 bytes Tool/RfidSetting2.cs | 21 ++ Tool/Tool.csproj | 10 +- 14 files changed, 640 insertions(+), 438 deletions(-) delete mode 100644 RfidWeb/Tool/TestFactory.cs delete mode 100644 Tool/Model/HmiPoint.cs create mode 100644 Tool/Model/HmiPointInfo.cs delete mode 100644 Tool/RfidSetting.cs create mode 100644 Tool/RfidSetting2.cs diff --git a/RfidWeb/FormMain.cs b/RfidWeb/FormMain.cs index 4a3ae8d..efd2a18 100644 --- a/RfidWeb/FormMain.cs +++ b/RfidWeb/FormMain.cs @@ -34,10 +34,9 @@ namespace RfidWeb public FormMain() { cache=Cache.Default; - + var currentPlcIp = RfidSetting.Current.PlcIp; DbInfo.Init(typeof(UserInfo).Assembly); - var rfidSetting = RfidSetting.Current; InitializeComponent(); if (this.FormBorderStyle == FormBorderStyle.None) { @@ -67,12 +66,12 @@ namespace RfidWeb buttons.Clear(); buttons.Add(btnShow); - buttons.Add(btnArgument); buttons.Add(btnAlarm); buttons.Add(btnAccount); buttons.Add(btnMes); buttons.Add(buttonUpdateLog); + buttons.Add(btnBarCode); btnShow_Click(new object(), EventArgs.Empty); } @@ -82,32 +81,32 @@ namespace RfidWeb /// 移除过期的缓存项 void TimeState(Object state) { - - labTime.Text = DateTime.Now.ToFullString(); bool isExit = UserManager.IsExit(); this.Invoke(() => { - - - - - this.Invoke(() => + labTime.Text = DateTime.Now.ToFullString(); + //不存在 + if (!isExit) { - //不存在 - if (!isExit) - { - labUser.ForeColor= System.Drawing.SystemColors.Window; - labUser.Text = "未登录(未授权)"; - PlcConnect.Instance.Write(HmiPointInfo.Safety_level, int.Parse("0")); - } - else + labUser.ForeColor = System.Drawing.SystemColors.Window; + labUser.Text = "未登录(未授权)"; + + CacheManager.Act(CacheKeyManager.FormMain, () => { - var dto = UserManager.GetUser(); - labUser.Text = $"{dto.UserName}({dto.RoleName})"; - labUser.ForeColor = Color.FromArgb(21, 182, 173); - } + ThreadPoolX.QueueUserWorkItem(() => + { + PlcConnect.Instance.Write(HmiPointInfo.Safety_level, int.Parse("0")); + }); + }); - }); + + } + else + { + var dto = UserManager.GetUser(); + labUser.Text = $"{dto.UserName}({dto.RoleName})"; + labUser.ForeColor = Color.FromArgb(21, 182, 173); + } }); @@ -122,38 +121,40 @@ namespace RfidWeb private void ShowLed() { - if (cache.ContainsKey(CacheKeyManager.Home)) return; - cache.Set(CacheKeyManager.Home, DateTime.Now, TimeSpan.FromSeconds(10)); - bool result =PlcConnect.Instance.ReadPlcType().IsSuccess; - hslLanternSimplePlc.LanternBackground = result ? Color.LimeGreen : Color.Red; - cache.Remove(CacheKeyManager.Home); + CacheManager.Act(CacheKeyManager.Home, () => + { + + bool result = PlcConnect.IsSuccess; + hslLanternSimplePlc.LanternBackground = result ? Color.LimeGreen : Color.Red; + }); } private void ReadBufLog() { - if (cache.ContainsKey(CacheKeyManager.ReadBufLog)) return; - cache.Set(CacheKeyManager.ReadBufLog, DateTime.Now, TimeSpan.FromSeconds(10)); - - var barCodea = HmiPointInfo.GetBufA(); - if (barCodea.Item1) + CacheManager.Act(CacheKeyManager.ReadBufLog, () => { - readBufService.Insert("A",barCodea.Item2); - } - var barCodeb = HmiPointInfo.GetBufB(); - if (barCodeb.Item1) - { - readBufService.Insert("B", barCodeb.Item2); - } + var barCodea = HmiPointInfo.GetBufA(); + if (barCodea.Item1) + { + readBufService.Insert("A", barCodea.Item2); + } - var barCodec = HmiPointInfo.GetBufC(); - if (barCodec.Item1) - { - readBufService.Insert("C", barCodec.Item2); - } + var barCodeb = HmiPointInfo.GetBufB(); + if (barCodeb.Item1) + { + readBufService.Insert("B", barCodeb.Item2); + } + + var barCodec = HmiPointInfo.GetBufC(); + if (barCodec.Item1) + { + readBufService.Insert("C", barCodec.Item2); + } + + }); - cache.Remove(CacheKeyManager.ReadBufLog); } /// @@ -164,23 +165,26 @@ namespace RfidWeb if (UserManager.IsExit()) { - var dic = pointService.GetValueName(); - - if (cache.ContainsKey(CacheKeyManager.UpdateLog)) return; - cache.Set(CacheKeyManager.UpdateLog, DateTime.Now, TimeSpan.FromSeconds(5)); - var plc = PlcConnect.Instance; - var userDto = UserManager.GetUser(); - var strings = dic.Keys; - foreach (var se in strings) + + CacheManager.Act(CacheKeyManager.UpdateLog, () => { - var res = plc.ReadInt32(se); - if (res.IsSuccess) + var dic = pointService.GetValueName(); + var plc = PlcConnect.Instance; + var userDto = UserManager.GetUser(); + var strings = dic.Keys; + foreach (var se in strings) { - string name = dic[se]; - updateLogService.AddOrUpdateLog(userDto, name, res.Content); + var res = plc.ReadInt32(se); + if (res.IsSuccess) + { + string name = dic[se]; + updateLogService.AddOrUpdateLog(userDto, name, res.Content); + } } - } - cache.Remove(CacheKeyManager.UpdateLog); + }); + + + } @@ -339,14 +343,6 @@ namespace RfidWeb panContent.Controls.Clear(); panContent.Controls.Add(new FrmBarCodeGridView()); CheckButton(btnBarCode); - - // CheckLogin(); - - //var isLogin = UserManager.IsExit(); - //if (isLogin) - //{ - - //} } } } diff --git a/RfidWeb/Frm/FrmBarCodeGridView.cs b/RfidWeb/Frm/FrmBarCodeGridView.cs index b3cfd17..84a0973 100644 --- a/RfidWeb/Frm/FrmBarCodeGridView.cs +++ b/RfidWeb/Frm/FrmBarCodeGridView.cs @@ -1,4 +1,6 @@ -using DB.Service; +using ClosedXML.Excel; + +using DB.Service; using HZH_Controls.Controls; @@ -20,13 +22,14 @@ namespace RfidWeb.Frm public partial class FrmBarCodeGridView : UserControl { private ReadBufLogService readBufLogService = new ReadBufLogService(); + public FrmBarCodeGridView() { InitializeComponent(); this.dataGridView1.Columns["CreateTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; - var keyValue= new List>(); + var keyValue = new List>(); keyValue.Add(new KeyValuePair("A", "收料1")); keyValue.Add(new KeyValuePair("B", "收料2")); keyValue.Add(new KeyValuePair("C", "废料")); @@ -48,7 +51,8 @@ namespace RfidWeb.Frm this.ucPagerControl21.ShowSourceChanged += new HZH_Controls.Controls.PageControlEventHandler(this.ucPagerControl21_ShowSourceChanged); - this.ucHorizontalList1.SelectedItemEvent += new System.EventHandler(this.ucHorizontalList1_SelectedItemEvent); + this.ucHorizontalList1.SelectedItemEvent += + new System.EventHandler(this.ucHorizontalList1_SelectedItemEvent); ucPagerControl21_ShowSourceChanged(new object()); } @@ -70,7 +74,7 @@ namespace RfidWeb.Frm int index = ucPagerControl21.PageIndex; var page = readBufLogService.GetPagedList(ucPagerControl21.PageIndex, - ucPagerControl21.PageSize, key,beginTime,endTime); + ucPagerControl21.PageSize, key, beginTime, endTime); ucPagerControl21.PageCount = page.TotalPages; this.dataGridView1.DataSource = page.Items; } @@ -100,11 +104,41 @@ namespace RfidWeb.Frm Console.WriteLine("目录已创建。"); } - string file = directoryPath + "\\" + DateTime.Now.ToFullString(true) + "_" + val + ".xlsx"; + string suiji = Guid.NewGuid().ToString().Substring(0, 5); + + string file = directoryPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + suiji + "_" + val + ".xlsx"; var dt = readBufLogService.GetDtaTable(key, beginTime, endTime); - ExcelHelper.Export(dt,val,file); + ExportDataTableToExcel(dt, file); MessageBox.Show("OK"); } + + void ExportDataTableToExcel(DataTable table, string filePath) + { + using (var workbook = new XLWorkbook()) + { + table.TableName = "Shell1"; + var worksheet = workbook.Worksheets.Add(table.TableName); + + // 写入列头 + for (int col = 0; col < table.Columns.Count; col++) + { + worksheet.Cell(1, col + 1).Value = table.Columns[col].ColumnName; + } + + // 写入行数据 + for (int row = 0; row < table.Rows.Count; row++) + { + for (int col = 0; col < table.Columns.Count; col++) + { + worksheet.Cell(row + 2, col + 1).Value = table.Rows[row][col].ToString(); + } + } + + + // 保存为文件 + workbook.SaveAs(filePath); + } + } } } diff --git a/RfidWeb/Frm/UserAlarmShow.Designer.cs b/RfidWeb/Frm/UserAlarmShow.Designer.cs index 0e1439b..99fd757 100644 --- a/RfidWeb/Frm/UserAlarmShow.Designer.cs +++ b/RfidWeb/Frm/UserAlarmShow.Designer.cs @@ -28,11 +28,11 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -63,6 +63,7 @@ this.hslA3 = new HslControls.HslLanternSimple(); this.hslA2 = new HslControls.HslLanternSimple(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.btnStatus = new System.Windows.Forms.Button(); this.panel3 = new System.Windows.Forms.Panel(); this.hslLabelCombofeedingMotorSpeed = new HslControls.HslLabelCombo(); this.hslLabelComboReceiving = new HslControls.HslLabelCombo(); @@ -79,7 +80,6 @@ this.hslB9 = new HslControls.HslLanternSimple(); this.hslB10 = new HslControls.HslLanternSimple(); this.hslB11 = new HslControls.HslLanternSimple(); - this.btnStatus = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); @@ -110,37 +110,37 @@ this.dataGridView2.AllowUserToAddRows = false; this.dataGridView2.AllowUserToDeleteRows = false; this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2}); - dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle7.BackColor = System.Drawing.Color.Red; - dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.Red; - dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.Red; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.Red; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle2; this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView2.Location = new System.Drawing.Point(458, 3); this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.ReadOnly = true; - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle8.BackColor = System.Drawing.Color.Red; - dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 15F); - dataGridViewCellStyle8.ForeColor = System.Drawing.Color.White; - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Red; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView2.RowsDefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.Yellow; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 15F); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Yellow; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.Black; + this.dataGridView2.RowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView2.RowTemplate.Height = 23; this.dataGridView2.Size = new System.Drawing.Size(449, 270); this.dataGridView2.TabIndex = 1; @@ -165,14 +165,14 @@ // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; - dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.al, @@ -181,13 +181,13 @@ this.dataGridView1.Location = new System.Drawing.Point(3, 3); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; - dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle10.BackColor = System.Drawing.Color.Red; - dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White; - dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.Red; - dataGridViewCellStyle10.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.Red; + dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Red; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.Size = new System.Drawing.Size(449, 270); this.dataGridView1.TabIndex = 0; @@ -486,6 +486,16 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "料盘侧(收料2)"; // + // btnStatus + // + this.btnStatus.BackColor = System.Drawing.Color.Chartreuse; + this.btnStatus.Location = new System.Drawing.Point(252, 92); + this.btnStatus.Name = "btnStatus"; + this.btnStatus.Size = new System.Drawing.Size(112, 28); + this.btnStatus.TabIndex = 32; + this.btnStatus.Text = "状态"; + this.btnStatus.UseVisualStyleBackColor = false; + // // panel3 // this.panel3.BackColor = System.Drawing.SystemColors.ButtonFace; @@ -653,16 +663,6 @@ this.hslB11.TabIndex = 12; this.hslB11.Text = "hslLanternSimple1"; // - // btnStatus - // - this.btnStatus.BackColor = System.Drawing.Color.Chartreuse; - this.btnStatus.Location = new System.Drawing.Point(252, 92); - this.btnStatus.Name = "btnStatus"; - this.btnStatus.Size = new System.Drawing.Size(112, 28); - this.btnStatus.TabIndex = 32; - this.btnStatus.Text = "状态"; - this.btnStatus.UseVisualStyleBackColor = false; - // // UserAlarmShow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RfidWeb/Frm/UserAlarmShow.cs b/RfidWeb/Frm/UserAlarmShow.cs index e530c13..e9dcc3d 100644 --- a/RfidWeb/Frm/UserAlarmShow.cs +++ b/RfidWeb/Frm/UserAlarmShow.cs @@ -23,6 +23,7 @@ using Tool; using Tool.Model; using HslCommunication.LogNet; using Chloe; +using DocumentFormat.OpenXml.Wordprocessing; namespace RfidWeb.Frm { @@ -46,24 +47,31 @@ namespace RfidWeb.Frm void TimeState(Object state) { - - if(cache.ContainsKey("UserAlarmShow")) return; - - cache.Set("UserAlarmShow", DateTime.Now.ToString(), TimeSpan.FromSeconds(20)); - - stopwatc.Restart(); - var stateText = HmiPointInfo.GetStateText(); - this.Invoke(() => + + CacheManager.Act("UserAlarmShow", () => { - btnStatus.Text = stateText; + var isSuccess = PlcConnect.IsSuccess; + if (isSuccess) + { + + stopwatc.Restart(); + var stateText = HmiPointInfo.GetStateText(); + this.Invoke(() => { btnStatus.Text = stateText; }); + FillAlarmGrid(); + FillPromptGrid(); + FillAlartLed(); + FillhslLabelCombo(); + stopwatc.Stop(); + logNet.WriteInfo("首页运行时间:" + stopwatc.Elapsed.TotalMilliseconds); + } + else + { + this.Invoke(() => { btnStatus.Text = "plc连接失败"; }); + logNet.WriteWarn("plc连接失败"); + } }); - FillAlarmGrid(); - FillPromptGrid(); - FillAlartLed(); - FillhslLabelCombo(); - stopwatc.Stop(); - cache.Remove("UserAlarmShow"); - logNet.WriteInfo("运行时间:"+stopwatc.Elapsed.TotalMilliseconds); + + } /// @@ -334,9 +342,9 @@ namespace RfidWeb.Frm { foreach (var simple in simples) { - if (simple.LanternBackground != Color.Red) + if (simple.LanternBackground != System.Drawing.Color.Red) { - simple.LanternBackground = Color.Red; + simple.LanternBackground = System.Drawing.Color.Red; } } } @@ -344,9 +352,9 @@ namespace RfidWeb.Frm { foreach (var simple in simples) { - if (simple.LanternBackground != Color.Chartreuse) + if (simple.LanternBackground != System.Drawing.Color.Chartreuse) { - simple.LanternBackground = Color.Chartreuse; + simple.LanternBackground = System.Drawing.Color.Chartreuse; } } diff --git a/RfidWeb/RfidWeb.csproj b/RfidWeb/RfidWeb.csproj index eb59b1d..116db01 100644 --- a/RfidWeb/RfidWeb.csproj +++ b/RfidWeb/RfidWeb.csproj @@ -225,7 +225,6 @@ - FormLogin.cs diff --git a/RfidWeb/Tool/TestFactory.cs b/RfidWeb/Tool/TestFactory.cs deleted file mode 100644 index adde399..0000000 --- a/RfidWeb/Tool/TestFactory.cs +++ /dev/null @@ -1,39 +0,0 @@ -using DB.Dto; -using DB.Service; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.VisualBasic.ApplicationServices; - -namespace RfidWeb -{ - public class TestFactory - { - public static UserDto dto; - public static UserDto TestUser() - { - if (dto != null) - { - return dto; - } - long id = 7254397083167133696; - var userInfo = new UserService().Query(id); - - - UserDto user = new UserDto - { - Id = userInfo.ID, - UserName = userInfo.UserName, - RoleId = userInfo.RoleId, - RoleName ="管理员", - RoleLevel =1 - }; - dto = user; - return user; - - } - } -} diff --git a/Tool/CacheManager.cs b/Tool/CacheManager.cs index 9eb02d9..8bd3006 100644 --- a/Tool/CacheManager.cs +++ b/Tool/CacheManager.cs @@ -5,14 +5,14 @@ namespace Tool { public class CacheManager { - + public static void Act(string key,Action action) { ICache _cache=Cache.Default; if(_cache.ContainsKey(key)) return; try { - _cache.Set(key, TimeSpan.FromSeconds(300)); + _cache.Set(key, TimeSpan.FromSeconds(3000)); action(); } finally diff --git a/Tool/ExcelHelp.cs b/Tool/ExcelHelp.cs index a5fbfc3..5f28270 100644 --- a/Tool/ExcelHelp.cs +++ b/Tool/ExcelHelp.cs @@ -1,243 +1 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using NPOI.SS.UserModel; -using NPOI.XSSF.UserModel; - - -namespace Tool -{ - public class ExcelHelper - { - /// - /// Excel行高,Height的单位是1/20个点。例:设置高度为25个点 - /// - private static short rowHeight = 25 * 20; - - #region 导出Excel - - #region 导出 - - /// - /// 导出 - /// - /// 数据源 - /// 列名 - /// 绝对路径 - /// sheet页名 - public static void Export(DataTable dt, string strHeader, string fileName, string sheetName = "Sheet1") - { - // 使用 NPOI 组件导出 Excel 文件 - - //XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx - XSSFWorkbook workbook = new XSSFWorkbook(); - - //HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls - //HSSFWorkbook workbook = new HSSFWorkbook(); - - //创建Sheet - ISheet sheet = workbook.CreateSheet(sheetName); - - //对列名拆分 - string[] strArry = strHeader.Split(','); - - //设置单元格样式 - ICellStyle style = SetCellStyle(workbook); - - //创建表格 - NPOICreateTable(dt, strArry, sheet, style, 0); - - // 将 Excel 文件保存到磁盘 - NPOISaveFile(workbook, fileName); - - // 释放资源 - //workbook.Dispose(); - } - #endregion - - #region 自定义框架,导出 - - /// - /// 自定义顶部,导出 - /// - /// 数据源 - /// 拆分后列名 - /// 绝对路径,路径+文件名+后缀 - /// 新一行索引,开始 - /// - /// - public static void Export(DataTable dt, string[] strArry, string fileName, int num, XSSFWorkbook workbook, ISheet sheet) - { - //设置单元格样式 - ICellStyle style = SetCellStyle(workbook); - - //创建表格 - NPOICreateTable(dt, strArry, sheet, style, num); - - // 将 Excel 文件保存到磁盘 - NPOISaveFile(workbook, fileName); - - // 释放资源 - //workbook.Dispose(); - } - #endregion - - #endregion - - - - #region 保存文件 - - private static string NPOISaveFile(XSSFWorkbook workbook, string fileName) - { - try - { - // 将 Excel 文件保存到磁盘 - using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - workbook.Write(fs); - } - - return ""; - } - catch (Exception err) - { - return err.Message; - } - } - - #endregion - - #region 创建表格 - - /// - /// 创建表格 - /// - /// 数据源 - /// 拆分后的列名 - /// Sheet页 - /// 样式 - /// 行索引 - private static void NPOICreateTable(DataTable dt, string[] strArry, ISheet sheet, ICellStyle style, int num) - { - IRow row = null;//声明行 - - #region 创建列名 - - //在索引 num 的位置 创建一行 - row = sheet.CreateRow(num); - row.Height = rowHeight;//设置行高 - - //循环列名数组,创建单元格并赋值、样式 - for (int i = 0; i < strArry.Length; i++) - { - row.CreateCell(i).SetCellValue(strArry[i]); - row.GetCell(i).CellStyle = style; - } - - #endregion - - #region 创建行 - - //循环数据源 创建行 - for (int i = 0; i < dt.Rows.Count; i++) - { - //创建行 - row = sheet.CreateRow(num + 1); - row.Height = rowHeight;//设置行高 - num++;//行索引自增 - - //循环数据源列集合,创建单元格 - for (int j = 0; j < dt.Columns.Count; j++) - { - string ValueType = "";//值类型 - string Value = "";//值 - //类型 和 值,赋值 - if (dt.Rows[i][j].ToString() != null) - { - ValueType = dt.Rows[i][j].GetType().ToString(); - Value = dt.Rows[i][j].ToString(); - } - //根据不同数据类型,对数据处理。处理后创建单元格并赋值 和 样式 - switch (ValueType) - { - case "System.String"://字符串类型 - row.CreateCell(j).SetCellValue(Value); - break; - case "System.DateTime"://日期类型 - System.DateTime dateV; - System.DateTime.TryParse(Value, out dateV); - row.CreateCell(j).SetCellValue(dateV.ToString("yyyy-MM-dd")); - break; - case "System.Boolean"://布尔型 - bool boolV = false; - bool.TryParse(Value, out boolV); - row.CreateCell(j).SetCellValue(boolV); - break; - case "System.Int16"://整型 - case "System.Int32": - case "System.Int64": - case "System.Byte": - int intV = 0; - int.TryParse(Value, out intV); - row.CreateCell(j).SetCellValue(intV); - break; - case "System.Decimal"://浮点型 - case "System.Double": - double doubV = 0; - double.TryParse(Value, out doubV); - row.CreateCell(j).SetCellValue(doubV); - break; - case "System.DBNull"://空值处理 - row.CreateCell(j).SetCellValue(""); - break; - default: - row.CreateCell(j).SetCellValue(""); - break; - } - row.GetCell(j).CellStyle = style; - //设置宽度 - //sheet.SetColumnWidth(j, (Value.Length + 10) * 256); - } - } - - #endregion - - //循环列名数组,多所有列 设置 自动列宽 - for (int i = 0; i < strArry.Length; i++) - { - sheet.AutoSizeColumn(i); - } - } - - #endregion - - #region 设置单元格样式 - - public static ICellStyle SetCellStyle(XSSFWorkbook workbook) - { - #region 单元格样式 - - //创建一个样式 - ICellStyle style = workbook.CreateCellStyle(); - style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;//水平对齐 - style.VerticalAlignment = VerticalAlignment.Center;//垂直对齐 - - style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;//下边框为细线边框 - style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;//左边框 - style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;//上边框 - style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;//右边框 - - #endregion - - return style; - } - - #endregion - } -} + \ No newline at end of file diff --git a/Tool/Model/HmiPoint.cs b/Tool/Model/HmiPoint.cs deleted file mode 100644 index 9381bd8921520f2c3fcbdc5ff3ef5eb3137c8fbe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14387 zcmYk?gN`T&fGp6qZQHhO+qZ4ow(Z-tZQHhO+k7*-v&s92N>wTceM2t~jd?mF+Dbc) zB!dpv)wILZ7rLsyZ?rx?mr2KflA4PsJ2Y30Zx#F{EaKE@U^T~*cgHvMHQulpC-{5^ zSgncpHjnV+T$z$Lx(zII%65QhblNxq69BlelG=GNpL6vSpU4gd%h8%`k-DDl0)~BZ z6>%)6uLXVq`v&9sHcE{*unP>}Ed!{%6h3^$h9JXlS20C#o?$(8>)I@A)uI)=OrE^P z_r7fLEI>_>-l@c_PZa)@8s@f<6+~-I zoU^|OpyoxaSF-`htU&;t2e0wnjVDF|bMOndwIjQcX_8XgB8_T!Wk)b5avvzK2!72^ z_z<`VnF0!700!k~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ZGn4a$4OI?n5Lu#OOM}4$68e*}W9KrDvpzEvOd@Vw#irZ&7%l!rZF6{sMzpo3< zLsjST+YcLDIdGSrNHUzx#$mgaXVRinwFLa~p;^+EUP|{F`u-xul?%-egc!q{1)u-? z->6?K`z876Mx&^KsVLrt@gyTbfxh_TUp(>P0^FY*K_03)B|TvisuCp`yfn>-HLv-xA@!{;w#|VCM)vS>lEZR};3T=8NmusDIy2>0FRxs+9eDHQMJa zb|x)SP6t?Z`5*tsJN2LcGj~+s{h?MRrQJZ;(WkOA=UXU$O#b?{ktKY&c+lI(EC0k} p#{0+reO&+J|7df)oWq_+t3T9`V9tIJCR79kO%Xm4CDxdw{~t6n60raP diff --git a/Tool/Model/HmiPointInfo.cs b/Tool/Model/HmiPointInfo.cs new file mode 100644 index 0000000..fc6af8a --- /dev/null +++ b/Tool/Model/HmiPointInfo.cs @@ -0,0 +1,414 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +using HslCommunication; + +namespace Tool.Model +{ + public class HmiPointInfo + { + /// + /// DInt 供料电机速度 + /// + public static readonly string feeding_motor_speed = "feeding_motor_speed"; + + public static Int32 GetFeedingMotorSpeed => GetValue(feeding_motor_speed); + + + /// + /// DInt 层合电机速度 + /// + public static readonly string Laminated_motor_speed = "Laminated_motor_speed"; + + + public static Int32 GetLaminatedMotorSpeed => GetValue(Laminated_motor_speed); + + + /// + /// DInt 毛毡带电机速度 + /// + public static readonly string Felt_belt_motor_speed = "Felt_belt_motor_speed"; + + + public static Int32 GetFeltBeltMotorSpeed => GetValue(Felt_belt_motor_speed); + + + /// + /// DInt 收料电机1速度 + /// + public static readonly string Receiving_Electric_motor_speed = "Receiving_Electric_motor_speed"; + + public static Int32 GeReceivingMotorSpeed => GetValue(Receiving_Electric_motor_speed); + + + /// + /// 层合生产数量 + /// + public static readonly string Product_counter2 = "Product_counter2"; + + public static Int32 GetProduct_counter2 => GetValue(Product_counter2); + /// + /// 裁切1生产数量 + /// + public static readonly string CQ_Chip1_counter = "CQ_Chip1_counter"; + + public static Int32 GetCQ_Chip1_counter => GetValue(CQ_Chip1_counter); + + /// + /// 裁切2生产数量 + /// + public static readonly string CQ_Chip2_counter = "CQ_Chip2_counter"; + + public static Int32 GetCQ_Chip2_counter => GetValue(CQ_Chip2_counter); + + + /// + /// 裁刀1温度 + /// + public static readonly string QDWD1SS = "QDWD1SS"; + + public static Int32 GetQDWD1SS => GetValue(QDWD1SS); + + /// + /// 裁刀1温度 + /// + public static readonly string QDWD2SS = "QDWD2SS"; + + public static Int32 GetQDWD2SS => GetValue(QDWD2SS); + + /// + /// 设备内部温度 + /// + public static readonly string SWSS = "SWSS"; + + public static Int32 GetSWSS => GetValue(SWSS); + + + private static Int32 GetValue(string key) + { + var plc = PlcConnect.Instance; + var result = plc.ReadInt32(key); + + return result.IsSuccess ? result.Content : 0; + } + + + private static Boolean GetBoolValue(string key) + { + var plc = PlcConnect.Instance; + var result = plc.ReadBool(key); + + return result.Content; + } + + public static readonly string CUTTING_SET_TEMPERATURE1_1 = "CUTTING_SET_TEMPERATURE1_1"; + + public static Int32 GetCUTTING_SET_TEMPERATURE1_1 => GetValue(CUTTING_SET_TEMPERATURE1_1); + + public static readonly string CUTTING_SET_TEMPERATURE1_2 = "CUTTING_SET_TEMPERATURE1_2"; + public static Int32 GetCUTTING_SET_TEMPERATURE1_2 => GetValue(CUTTING_SET_TEMPERATURE1_2); + + + public static readonly string CUTTING_SET_TEMPERATURE1_3 = "CUTTING_SET_TEMPERATURE1_3"; + + public static Int32 GetCUTTING_SET_TEMPERATURE1_3 => GetValue(CUTTING_SET_TEMPERATURE1_3); + + public static readonly string CUTTING_SET_TEMPERATURE1_4 = "CUTTING_SET_TEMPERATURE1_4"; + + public static Int32 GetCUTTING_SET_TEMPERATURE1_4 => GetValue(CUTTING_SET_TEMPERATURE1_4); + + + + + public static readonly string CUTTING_SET_TEMPERATURE2_1 = "CUTTING_SET_TEMPERATURE2_1"; + + public static Int32 GetCUTTING_SET_TEMPERATURE2_1 => GetValue(CUTTING_SET_TEMPERATURE2_1); + + public static readonly string CUTTING_SET_TEMPERATURE2_2 = "CUTTING_SET_TEMPERATURE2_2"; + public static Int32 GetCUTTING_SET_TEMPERATURE2_2 => GetValue(CUTTING_SET_TEMPERATURE2_2); + + public static readonly string CUTTING_SET_TEMPERATURE2_3 = "CUTTING_SET_TEMPERATURE2_3"; + + public static Int32 GetCUTTING_SET_TEMPERATURE2_3 => GetValue(CUTTING_SET_TEMPERATURE2_3); + + public static readonly string CUTTING_SET_TEMPERATURE2_4 = "CUTTING_SET_TEMPERATURE2_4"; + + public static Int32 GetCUTTING_SET_TEMPERATURE2_4 => GetValue(CUTTING_SET_TEMPERATURE2_4); + + + public static readonly string CUTTING_SET_TIME1_1 = "CUTTING_SET_TIME1_1"; + + public static Int32 GetCUTTING_SET_TIME1_1 => GetValue(CUTTING_SET_TIME1_1); + + public static readonly string CUTTING_SET_TIME1_2 = "CUTTING_SET_TIME1_2"; + + public static Int32 GetCUTTING_SET_TIME1_2 => GetValue(CUTTING_SET_TIME1_2); + + + public static readonly string CUTTING_SET_TIME1_3 = "CUTTING_SET_TIME1_3"; + + public static Int32 GetCUTTING_SET_TIME1_3 => GetValue(CUTTING_SET_TIME1_3); + + public static readonly string CUTTING_SET_TIME1_4 = "CUTTING_SET_TIME1_4"; + + public static Int32 GetCUTTING_SET_TIME1_4 => GetValue(CUTTING_SET_TIME1_4); + + + public static readonly string CUTTING_SET_TIME2_1 = "CUTTING_SET_TIME2_1"; + + public static Int32 GetCUTTING_SET_TIME2_1 => GetValue(CUTTING_SET_TIME2_1); + + public static readonly string CUTTING_SET_TIME2_2 = "CUTTING_SET_TIME2_2"; + + public static Int32 GetCUTTING_SET_TIME2_2 => GetValue(CUTTING_SET_TIME2_2); + + public static readonly string CUTTING_SET_TIME2_3 = "CUTTING_SET_TIME2_3"; + + public static Int32 GetCUTTING_SET_TIME2_3 => GetValue(CUTTING_SET_TIME2_3); + + public static readonly string CUTTING_SET_TIME2_4 = "CUTTING_SET_TIME2_4"; + + public static Int32 GetCUTTING_SET_TIME2_4 => GetValue(CUTTING_SET_TIME2_4); + + + + + /// + /// 计划的数量 + /// + public static readonly string Product_counter_CH = "Product_counter_CH"; + + + /// + /// 安全级别 + /// + public static readonly string Safety_level = "Safety_level"; + + + + /// + /// 1盘料选择,0卷料选择 + /// + public static readonly string CH_Mode_selection = "CH_Mode_selection"; + + /// + /// 裁刀1屏蔽 + /// + public static readonly string HMI_Cutting1_pass = "HMI_Cutting1_pass"; + + + /// + /// 裁刀2屏蔽 + /// + public static readonly string HMI_Cutting2_pass = "HMI_Cutting2_pass"; + + + /// + /// 裁刀1屏蔽 + /// + public static readonly string Cutting1_passad = "Cutting1_passad"; + + + /// + /// 裁刀2屏蔽 + /// + public static readonly string Cutting2_passad = "Cutting2_passad"; + + + + /// + /// 切刀1到达使用上限清除计数按钮 + /// + public static readonly string CQ_QD1_counter_reset = "CQ_QD1_counter_reset"; + + + /// + /// 切刀2到达使用上限清除计数按钮 + /// + public static readonly string CQ_QD2_counter_reset = "CQ_QD2_counter_reset"; + + + + /// + /// 毛毡带到达使用上限清除计数按钮 + /// + public static readonly string CQ_MZD_counter_reset = "CQ_MZD_counter_reset"; + + + public static String GetStateText() + { + + string text = ""; + var plc = PlcConnect.Instance; + var result = plc.ReadInt32("status_indicator"); + if (result.IsSuccess) + { + var context = result.Content; + switch (context) + { + case 0: + text = "异常停机"; + break; + + case 1: + text = "手动模式"; + break; + case 2: + text = "自动模式"; + break; + case 3: + text = "自动运行中"; + break; + case 4: + text = "停止"; + break; + case 5: + text = "安全回路异常"; + break; + } + + } + + return text; + } + + + public static Dictionary BufDictionary = new Dictionary(); + + + public static (bool, string) GetBufA() + { + string key = "CHIP0_OK_For_SWJ"; + string kye = "READ_CHIP0.BUF"; + var plc = PlcConnect.Instance; + var result =plc.ReadInt32(key); + if (result.IsSuccess && result.Content==1) + { + OperateResult read = plc.ReadTag(kye, ushort.Parse("23")); + if (read.IsSuccess) + { + var stringBuilder = read.Content2.ToHexString(); + if (stringBuilder.Length > 22) + { + stringBuilder = stringBuilder.Substring(22); + plc.Write(key, Int32.Parse("0")); + return (true,stringBuilder); + } + } + } + + return (false, ""); + } + + + public static (bool, string) GetBufB() + { + string key = "CHIP1_OK_For_SWJ"; + string kye = "READ_CHIP1.BUF"; + var plc = PlcConnect.Instance; + var result = plc.ReadInt32(key); + if (result.IsSuccess && result.Content == 1) + { + OperateResult read = plc.ReadTag(kye, ushort.Parse("23")); + if (read.IsSuccess) + { + var stringBuilder = read.Content2.ToHexString(); + if (stringBuilder.Length > 22) + { + stringBuilder = stringBuilder.Substring(22); + plc.Write(key, Int32.Parse("0")); + return (true, stringBuilder); + } + } + } + + return (false, ""); + + } + + public static (bool, string) GetBufC() + { + var plc = PlcConnect.Instance; + string kye = "READ_CHIP2.BUF"; + string stringBuilder = ""; + + OperateResult read = plc.ReadTag(kye, ushort.Parse("25")); + if (read.IsSuccess) + { + stringBuilder = read.Content2.ToHexString(); + if (stringBuilder.StartsWith("024E6F52", StringComparison.OrdinalIgnoreCase)) + { + return (false, ""); + } + + if (stringBuilder.Length > 2) + { + stringBuilder = stringBuilder.Substring(2); + return (true, stringBuilder); + } + } + + + return (false, ""); + } + + public static (bool, string) GetBufABC(string key2) + { + string[] str = new string[] { "READ_CHIP0.BUF", "READ_CHIP1.BUF", "READ_CHIP2.BUF" }; + string kye = ""; + switch (key2) + { + case "A": + kye = str[0]; + break; + case "B": + kye = str[1]; + break; + + case "C": + kye = str[2]; + break; + } + + var plc = PlcConnect.Instance; + string stringBuilder = ""; + + OperateResult read = plc.ReadTag(kye, ushort.Parse("25")); + if (read.IsSuccess) + { + stringBuilder = read.Content2.ToHexString(); + } + + if (stringBuilder.Trim().Length == 0) + { + return (false, stringBuilder); + } + + if (stringBuilder.StartsWith("000000000") || stringBuilder.StartsWith("024E6F52".ToLower())) + { + return (false, stringBuilder); + } + if (BufDictionary.TryGetValue(key2, out var val)) + { + if (val == stringBuilder) + { + return (false, stringBuilder); + } + else + { + BufDictionary[key2] = stringBuilder; + return (true, stringBuilder); + } + } + else + { + BufDictionary[key2] = stringBuilder; + return (true, stringBuilder); + } + } + } +} diff --git a/Tool/PlcConnect.cs b/Tool/PlcConnect.cs index ed133cf..86e5649 100644 --- a/Tool/PlcConnect.cs +++ b/Tool/PlcConnect.cs @@ -21,6 +21,9 @@ namespace Tool } + + + private AllenBradleyNet CreateAb() { var rfidSetting = RfidSetting.Current; @@ -101,6 +104,14 @@ namespace Tool } + public static bool IsSuccess + { + get + { + bool result = PlcConnect.Instance.ReadPlcType().IsSuccess; + return result; + } + } public static OperateResult WriteTag(string address, UInt32 num) diff --git a/Tool/RfidSetting.cs b/Tool/RfidSetting.cs deleted file mode 100644 index 6ebb269a7cd559b5f99ac0c9701c10b679278de4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1660 zcmV-?27~z*+Fzg+GtHWeYg~^cnl1x&X1Zp63#`Gw$FZTGGF@RQD>@><(923WfCu&0 z-sOD8g3oF;+k4fgmNl?QiMi8PU$Y?ZpdsezQz<=+xCWcdZo)Fh&18ug00XnDD|Ex5 zIoJCiB5w>Da%?u!E3q!>3^&Wy5y*qUwhz)9?ilUwi&i~?yaoXHngY3^Slr5Lcg=Xx zQJz|kJ>13Fy*!81J+n~z8z%iJ{r!gMfl>@Wq~{=`IZhfS=4$V#j!D%dq8GM$Vl8ER zl$`dlbEap&MGyBY4DYiw1X|cfIl-g=uJ%U1S+WvmvOo_!9<%v(JdH>h!~7k$x}CE! z%PCxGmnzlP-a&(k;R2wf57>W0;{&74(aVJVa)4D9+X4TpL&CI_)rP)zv! zhy~cM2s=k-^=xsxdp5T&W?hX3T!n>yqtXuEwg!`NYL5($Nt_&xh5d9|>&M>$&+%t9 z7ii>4Bwb(RMvhAx+GIhvmrQECHEm)JWTPJQ<7xkwo0yR#o72AhD~l1?FQ^&S-H#Iy z=f=FUoX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v|~gFLd10h%#93| z^Vi$9lKJZ{ZeT}l9>7H$A6f$TyOZB1F~Sdv-bU%mIic*ksvaZ5NzJJFFuwCYzNjo? zh|bTw?XYC5Uw*%2Z3q;P2Nz!K$jL$5fj_dkTV+9Z%}dOs@?6yoGp*cPK0`$_qwi5= za;|KLmuMw2gvDx$?Tu|fV0O$b{B+s- + { + public string Db { get; set; } = "server=127.0.0.1;database=gaosu;uid=postgres;pwd=123456"; + public string PlcIp { get; set; } = "192.168.1.100"; + public int Port { get; set; } = 44818; + public string HslKey { get; set; } = "4b133324-fea4-4766-b066-857279c92f5d"; + } +} diff --git a/Tool/Tool.csproj b/Tool/Tool.csproj index fcbd6b1..6fe6c42 100644 --- a/Tool/Tool.csproj +++ b/Tool/Tool.csproj @@ -36,6 +36,9 @@ ..\Src\HslCommunication.dll + + 0.104.2 + 11.0.2024.1101 @@ -46,9 +49,6 @@ - - 2.7.2 - 112.1.0 @@ -81,14 +81,14 @@ - + - +