From b5421e8f8a6df6b26eaa4ebc3c05344b0fdaba7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 5 Apr 2024 16:41:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?change=20-=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeForm.cs | 5 +- .../Forms/SystemSetting/ParaSettingForm.cs | 8 +- ProductionSystem_Model/Enum/ModeTypeEnum.cs | 28 +++++ .../ProductionSystem_Model.csproj | 3 +- .../ViewModel/Response/Para/EditionType.cs | 43 ++++++++ .../Response/Para/ParaTargetValVM.cs | 19 ---- ProductionSystem_Service/ParaConfigService.cs | 103 ++++++++++++++---- .../ExtendedControls/MyParaControl.cs | 6 + 8 files changed, 171 insertions(+), 44 deletions(-) create mode 100644 ProductionSystem_Model/Enum/ModeTypeEnum.cs create mode 100644 ProductionSystem_Model/ViewModel/Response/Para/EditionType.cs delete mode 100644 ProductionSystem_Model/ViewModel/Response/Para/ParaTargetValVM.cs diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index ff9643e..c87b005 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -65,8 +65,11 @@ namespace ProductionSystem.Forms cmbProductType.SelectedItem = new ListItem { Value = Program.ProductType, Text = Program.ProductType }; + //var temp = _paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB); + //string str1 = temp.PZF1.TargetVal; + //string str2 = temp.PZF1.Lin; + //string str3 = temp.PZF1.Com; - } private void HomeForm_Load(object sender, EventArgs e) diff --git a/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs b/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs index e50f30c..e785c09 100644 --- a/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs +++ b/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs @@ -165,7 +165,7 @@ namespace ProductionSystem.Forms.SystemSetting Name = $"layoutControlItem{j}", TextVisible = false }; - if (currentParaConfigs[j].ParaCode.Contains("protocol")) + if (currentParaConfigs[j].ParaCode.Contains("_DB")) { TextEdit textEdit = new TextEdit { @@ -175,13 +175,14 @@ namespace ProductionSystem.Forms.SystemSetting textEdit.Properties.Appearance.Font = new Font("Tahoma", 10.5F); textEdit.Properties.Appearance.Options.UseFont = true; textEdit.Properties.AutoHeight = false; - textEdit.Properties.NullValuePrompt = "请输入压缩机协议编码"; + textEdit.Properties.NullValuePrompt = "请输入"+ currentParaConfigs[j].ParaName; layoutControlItem.Control = textEdit; } else { MyParaControl myParaControl = new MyParaControl { + Name = $"myParaControl{j}", MaximumSize = new Size(700, 50), LblItemCode = currentParaConfigs[j].ParaCode, @@ -195,6 +196,9 @@ namespace ProductionSystem.Forms.SystemSetting CheckEditVisible = !currentParaConfigs[j].IsMust, TabIndex = j }; + + + layoutControlItem.Control = myParaControl; } layoutItemArr[j] = layoutControlItem; diff --git a/ProductionSystem_Model/Enum/ModeTypeEnum.cs b/ProductionSystem_Model/Enum/ModeTypeEnum.cs new file mode 100644 index 0000000..eaa65b2 --- /dev/null +++ b/ProductionSystem_Model/Enum/ModeTypeEnum.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProductionSystem_Model.Enum +{ + /// + /// 模式枚举 + /// + public enum ModeTypeEnum + { + [Description("步骤(模式)1")] + BZ1_DB = 1, + [Description("步骤(模式)2")] + BZ2_DB = 2, + [Description("步骤(模式)3")] + BZ3_DB = 3, + [Description("步骤(模式)4")] + BZ4_DB = 4, + [Description("步骤(模式)5")] + BZ5_DB = 5, + [Description("步骤(模式)6")] + BZ6_DB = 6, + } +} diff --git a/ProductionSystem_Model/ProductionSystem_Model.csproj b/ProductionSystem_Model/ProductionSystem_Model.csproj index 206989e..9cb7b85 100644 --- a/ProductionSystem_Model/ProductionSystem_Model.csproj +++ b/ProductionSystem_Model/ProductionSystem_Model.csproj @@ -115,6 +115,7 @@ + @@ -133,7 +134,7 @@ - + diff --git a/ProductionSystem_Model/ViewModel/Response/Para/EditionType.cs b/ProductionSystem_Model/ViewModel/Response/Para/EditionType.cs new file mode 100644 index 0000000..0549097 --- /dev/null +++ b/ProductionSystem_Model/ViewModel/Response/Para/EditionType.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProductionSystem_Model.ViewModel.Response.Para +{ + public class EditionPara + { + //目标值 + public string TargetVal { get; set; } + //通讯方式 + public string Lin { get; set; } + //端口号 + public string Com { get; set; } + //错误信息 + public string Err { get; set; } + } + + public class EditonType + { + + public EditonType() + { + STF1 = new EditionPara(); + STF2 = new EditionPara(); + PZF1 = new EditionPara(); + PZF2 = new EditionPara(); + SB1 = new EditionPara(); + SB2 = new EditionPara(); + SB3 = new EditionPara(); + } + public EditionPara STF1 { get; set; } + public EditionPara STF2 { get; set; } + public EditionPara PZF1 { get; set; } + public EditionPara PZF2 { get; set; } + public EditionPara SB1 { get; set; } + public EditionPara SB2 { get; set; } + public EditionPara SB3{ get; set; } + } + +} diff --git a/ProductionSystem_Model/ViewModel/Response/Para/ParaTargetValVM.cs b/ProductionSystem_Model/ViewModel/Response/Para/ParaTargetValVM.cs deleted file mode 100644 index 0fe6d18..0000000 --- a/ProductionSystem_Model/ViewModel/Response/Para/ParaTargetValVM.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProductionSystem_Model.ViewModel.Response.Para -{ - public class ParaTargetValVM - { - public string STF1TargetVal { get; set; } - public string STF2TargetVal { get; set; } - public string PZF1TargetVal { get; set; } - public string PZF2TargetVal { get; set; } - public string SB1TargetVal { get; set; } - public string SB2TargetVal { get; set; } - public string SB3TargetVal { get; set; } - } -} diff --git a/ProductionSystem_Service/ParaConfigService.cs b/ProductionSystem_Service/ParaConfigService.cs index 0c3fbd3..b1f6210 100644 --- a/ProductionSystem_Service/ParaConfigService.cs +++ b/ProductionSystem_Service/ParaConfigService.cs @@ -1,9 +1,12 @@ using ProductionSystem_Log; using ProductionSystem_Model.DbModel.Para; +using ProductionSystem_Model.DbModel.Protocol; +using ProductionSystem_Model.Enum; using ProductionSystem_Model.ViewModel.Response.Para; using SqlSugar; using System; using System.Collections.Generic; +using System.Linq; namespace ProductionSystem_Service { @@ -95,63 +98,121 @@ namespace ProductionSystem_Service { try { - var temp = db.Queryable().Where(m => m.ParaCategory == paraCategory && m.IsActive); - return temp; + var temp1 = db.Queryable().Where(m => m.ParaCategory == paraCategory && m.IsActive); + return temp1; }catch (Exception ex) { LogHelper.Error(ex, "执行ParaConfigService下QueryTargetValWithParaCodeByParaCategery时异常"); return null; } } + private T_ParaColumnConfig QueryLinByParaCategeryAndParaCode(string paraCategory,string paraCode) + { + + T_ParaColumnConfig temp1 = db.Queryable(). + Where(m => m.ParaCategory == paraCategory && m.ParaCode == paraCode && m.IsActive). + First(); + if (temp1 == null) + { + throw new Exception("未维护数据!请先维护!"); + } + else + { + var temp2 = db.Queryable(). + Where(m => m.ParaCategory == paraCategory && m.ParaCode == paraCode && m.IsActive). + First().ProtocolType; + if (temp2 == null) + { + temp2 = "未配置通讯方式"; + } + return db.Queryable().Where(m => m.ParaCategory == paraCategory && m.ParaCode == paraCode && m.IsActive).First(); + } + } + private T_Protocol_Config QueryComByLin(string lin) + { + T_Protocol_Config temp1 = db.Queryable().Where(m => m.ProtocolCode == lin && m.IsActive).First(); + if (temp1 == null) + { + throw new Exception("未维护数据!请先维护!"); + } + string temp3 = db.Queryable().Where(m => m.ProtocolCode == lin && m.IsActive).First().ProtocolType; + if (temp3 == null) + { + temp3 = "未配置串口"; + } + return db.Queryable().Where(m => m.ProtocolCode == lin && m.IsActive).First(); + } /// - /// 根据参数种类查询有效参数配置项,例如传“BZ1”、“BZ2” + /// 根据参数种类查询有效参数配置项,例如传“BZ1_DB”、“BZ2_DB” /// /// /// - public ParaTargetValVM GetParaTargetVal(string paraCategory) + public EditonType GetParaTargetVal(ModeTypeEnum modeTypeEnum) { - ParaTargetValVM paraTargetVal = new ParaTargetValVM(); - var paraConfig = QueryTargetValWithParaCodeByParaCategery(paraCategory).ToList(); + EditonType editonType = new EditonType(); + var paraConfig = QueryTargetValWithParaCodeByParaCategery(modeTypeEnum.ToString()).ToList(); for (int i = 0; i < paraConfig.Count; i++) { - if(paraConfig[i].ParaCode == "STF1MS") + if(paraConfig[i].ParaCode == modeTypeEnum.ToString()) { - paraTargetVal.STF1TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.STF1.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.STF1.TargetVal = "空值"; } + editonType.STF1.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.STF1.Com = QueryComByLin(editonType.STF1.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "STF2MS") + else if (paraConfig[i].ParaCode == "FKSTF2ZT_DB") { - paraTargetVal.STF2TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.STF2.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.STF2.TargetVal = "空值"; } + editonType.STF2.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.STF2.Com = QueryComByLin(editonType.STF2.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "DZPZF1") + else if (paraConfig[i].ParaCode == "DZPZF1_DB") { - paraTargetVal.PZF1TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.PZF1.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.PZF1.TargetVal = "空值"; } + editonType.PZF1.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.PZF1.Com = QueryComByLin(editonType.PZF1.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "DZPZF2") + else if (paraConfig[i].ParaCode == "DZPZF2_DB") { - paraTargetVal.PZF2TargetVal = paraConfig[i].TargetVal.ToString(); + + if (paraConfig[i].TargetVal != null) { editonType.PZF2.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.PZF2.TargetVal = "空值"; } + editonType.PZF2.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.PZF2.Com = QueryComByLin(editonType.PZF2.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "SB1ZS") + else if (paraConfig[i].ParaCode == "SB1ZS_DB") { - paraTargetVal.SB1TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.SB1.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.SB1.TargetVal = "空值"; } + editonType.SB1.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.SB1.Com = QueryComByLin(editonType.SB1.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "SB2ZS") + else if (paraConfig[i].ParaCode == "SB2ZS_DB") { - paraTargetVal.SB2TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.SB2.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.SB2.TargetVal = "空值"; } + editonType.SB2.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.SB2.Com = QueryComByLin(editonType.SB2.Lin).Port; continue; } - else if (paraConfig[i].ParaCode == "SB3ZS") + else if (paraConfig[i].ParaCode == "SB3ZS_DB") { - paraTargetVal.SB3TargetVal = paraConfig[i].TargetVal.ToString(); + if (paraConfig[i].TargetVal != null) { editonType.SB3.TargetVal = paraConfig[i].TargetVal.ToString(); } + else { editonType.SB3.TargetVal = "空值"; } + editonType.SB3.Lin = QueryLinByParaCategeryAndParaCode(modeTypeEnum.ToString(), paraConfig[i].ParaCode).ProtocolType; + editonType.SB3.Com = QueryComByLin(editonType.SB3.Lin).Port; continue; } } - return paraTargetVal; + return editonType; } /// diff --git a/ProductionSystem_UserControl/ExtendedControls/MyParaControl.cs b/ProductionSystem_UserControl/ExtendedControls/MyParaControl.cs index 07ea74f..04a8563 100644 --- a/ProductionSystem_UserControl/ExtendedControls/MyParaControl.cs +++ b/ProductionSystem_UserControl/ExtendedControls/MyParaControl.cs @@ -15,6 +15,12 @@ namespace ProductionSystem_UserControl.ExtendedControls MaximumSize = new Size(480, 50); } + + public void HiderTargetVal() + { + txtTargetVal.ReadOnly = true; + } + #region 自定义属性 /// From accd635b0a28ab1fa378f131a9a45741f33c472e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sun, 7 Apr 2024 08:20:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 7 +++ .../Forms/SystemSetting/ParaSettingForm.cs | 4 +- ProductionSystem_Service/ExvService.cs | 49 +++++++++++++++++++ .../ProductionSystem_Service.csproj | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 ProductionSystem_Service/ExvService.cs diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f980ab9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs b/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs index 5021b10..a8f04e2 100644 --- a/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs +++ b/ProductionSystem/Forms/SystemSetting/ParaSettingForm.cs @@ -420,12 +420,14 @@ namespace ProductionSystem.Forms.SystemSetting if (textEditControl != null) { var protocolConfigCode = textEditControl.TargetText.Trim(); + T_ParaConfig t_ParaConfig = new T_ParaConfig { ProductType = productType, ParaCategory = paraCategory, ParaCode = textEditControl.LblItemCode, - Remark = protocolConfigCode, + TargetVal = protocolConfigCode.ToDecimal(), + Remark= protocolConfigCode, CreatedTime = DateTime.Now, CreatedBy = CurrentUser.Id }; diff --git a/ProductionSystem_Service/ExvService.cs b/ProductionSystem_Service/ExvService.cs new file mode 100644 index 0000000..d92e66c --- /dev/null +++ b/ProductionSystem_Service/ExvService.cs @@ -0,0 +1,49 @@ +using ProductionSystem_Log; + +using ProductionSystem_Model; +using ProductionSystem_Model.DbModel; +using ProductionSystem_Model.DbModel.Para; +using ProductionSystem_Model.ViewModel.Response.Para; +using SqlSugar; +using System; +using System.Collections.Generic; + +namespace ProductionSystem_Service +{ + public class ExvService : DbContext + { + + public void Add(Exv ex) + { + db.Insertable(ex).ExecuteCommand(); + } + + + } + + public class UxService : DbContext + { + public void Add(Ux entity) + { + db.Insertable(entity).ExecuteCommand(); + } + } + + public class UYService : DbContext + { + public void Add(Uy entity) + { + db.Insertable(entity).ExecuteCommand(); + } + } + + public class StoneService : DbContext + { + public void Add(Stone entity) + { + db.Insertable(entity).ExecuteCommand(); + } + + } + +} diff --git a/ProductionSystem_Service/ProductionSystem_Service.csproj b/ProductionSystem_Service/ProductionSystem_Service.csproj index 5533a5b..3ee7d6c 100644 --- a/ProductionSystem_Service/ProductionSystem_Service.csproj +++ b/ProductionSystem_Service/ProductionSystem_Service.csproj @@ -105,6 +105,7 @@ + From 91bb746da12c3cf7a6c45f46d10cb0acdc8be55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sun, 7 Apr 2024 08:44:24 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E9=A2=9C=E8=89=B2=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeForm.cs | 15 +++++++--- .../ExtendedControls/MyResultControl.cs | 30 +++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 97acd50..fbe3f9e 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -171,9 +171,7 @@ namespace ProductionSystem.Forms ShowMiddleData2(); - ShowMiddleData2(); - ShowMiddleData2(); - ShowMiddleData2(); + } @@ -573,15 +571,18 @@ namespace ProductionSystem.Forms testValPoint.Val = val; this.Invoke(new Action(() => { + topMyResultControls[i].SetForeColor(Color.Black); topMyResultControls[i].TestValText = testValPoint.Val; if (testValPoint.Val == "0.000") { topMyResultControls[i].TestValText = "停止"; + topMyResultControls[i].SetForeColor(Color.Red); } else if (testValPoint.Val == "1.000") { topMyResultControls[i].TestValText = "启动"; + topMyResultControls[i].SetForeColor(Color.Green); } })); //if (M249.Val != "0.000" && M249.Val != "10.000") @@ -803,7 +804,7 @@ namespace ProductionSystem.Forms private void ShowMiddleData2() { - Thread.Sleep(Program.ReadPlcRate); + GetPlc(Program.BZ1, "BZ1"); GetPlc(Program.BZ2, "BZ2"); @@ -812,6 +813,7 @@ namespace ProductionSystem.Forms GetPlc(Program.BZ5, "BZ5"); GetPlc(Program.BZ6, "BZ6"); + Thread.Sleep(Program.ReadPlcRate); } @@ -1223,6 +1225,11 @@ namespace ProductionSystem.Forms + + /// + /// 显示Db块的数据 + /// + /// private void SetMiddleData(string paraCategory) { try diff --git a/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs b/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs index e17cf4d..4b85262 100644 --- a/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs +++ b/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs @@ -33,23 +33,29 @@ namespace ProductionSystem_UserControl.ExtendedControls get { return txtTestVal.Text; } set { - if (txtTestVal.Text == "停止") - { - txtTestVal.ForeColor = Color.Red; - } - else if(txtTestVal.Text == "启动") - { - txtTestVal.ForeColor = Color.Green; - } - else - { - txtTestVal.ForeColor = Color.Black; - } + //if (txtTestVal.Text == "停止") + //{ + // txtTestVal.ForeColor = Color.Red; + //} + //else if(txtTestVal.Text == "启动") + //{ + // txtTestVal.ForeColor = Color.Green; + //} + //else + //{ + // txtTestVal.ForeColor = Color.Black; + //} _testValText = value; txtTestVal.Text = _testValText; } } + + public void SetForeColor(Color color) + { + this.txtTestVal.ForeColor = color; + } + //添加背景颜色 /// From 591e1c1e0013d14530a9be7d7918b53e91fced7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sun, 7 Apr 2024 10:29:46 +0800 Subject: [PATCH 4/4] home --- ProductionSystem/Forms/HomeForm.cs | 80 ++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index fbe3f9e..d8aaef8 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -42,6 +42,7 @@ namespace ProductionSystem.Forms private static string iniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemConfig.ini"); private bool topIsCanRound = true;//展示PLC采集数据时,是否可以进入下一次循环 private bool middleIsCanRound = true;//展示PLC采集数据时,是否可以进入下一次循环 + private bool middleIsCanRound2 = true;//展示PLC采集数据时,是否可以进入下一次循环 private static List _curveKes = new List();//曲线名称 CancellationToken cureCancellationToken; @@ -69,23 +70,26 @@ namespace ProductionSystem.Forms } - private void HomeForm_Load(object sender, EventArgs e) - { - - #region 各工序的采集点位 - Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); + private void Init() + { + Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ2").ToList(); - - - Program.BZ3 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ3").ToList(); Program.BZ4 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ4").ToList(); Program.BZ5 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ5").ToList(); Program.BZ6 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ6").ToList(); Program.BZ7 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ7").ToList(); Program.BZ8 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ8").ToList(); + } + + private void HomeForm_Load(object sender, EventArgs e) + { + + #region 各工序的采集点位 + + Init(); @@ -164,13 +168,24 @@ namespace ProductionSystem.Forms Task.Run(() => { ShowMiddleData(); - + }, cancellationTokenSource.Token); + + Task.Run(() => + { + + ShowMiddleData2(); + + + }, cancellationTokenSource.Token); + + + hslCurveHistory.RemoveAllCurve(); - ShowMiddleData2(); + } @@ -571,19 +586,27 @@ namespace ProductionSystem.Forms testValPoint.Val = val; this.Invoke(new Action(() => { + + var LblItemText = topMyResultControls[i].LblItemText; + topMyResultControls[i].SetForeColor(Color.Black); topMyResultControls[i].TestValText = testValPoint.Val; - if (testValPoint.Val == "0.000") - { - topMyResultControls[i].TestValText = "停止"; - topMyResultControls[i].SetForeColor(Color.Red); - } - else - if (testValPoint.Val == "1.000") + + if (LblItemText.Contains("模式") || LblItemText.Contains("状态")) { - topMyResultControls[i].TestValText = "启动"; - topMyResultControls[i].SetForeColor(Color.Green); + if (testValPoint.Val == "0.000") + { + topMyResultControls[i].TestValText = "关闭"; + topMyResultControls[i].SetForeColor(Color.Red); + } + else + if (testValPoint.Val == "1.000") + { + topMyResultControls[i].TestValText = "启动"; + topMyResultControls[i].SetForeColor(Color.Green); + } } + })); //if (M249.Val != "0.000" && M249.Val != "10.000") //{ @@ -804,16 +827,19 @@ namespace ProductionSystem.Forms private void ShowMiddleData2() { - + while (!cancellationTokenSource.IsCancellationRequested) + { + GetPlc(Program.BZ1, "BZ1"); + GetPlc(Program.BZ2, "BZ2"); + GetPlc(Program.BZ3, "BZ3"); + GetPlc(Program.BZ4, "BZ4"); + GetPlc(Program.BZ5, "BZ5"); + GetPlc(Program.BZ6, "BZ6"); - GetPlc(Program.BZ1, "BZ1"); - GetPlc(Program.BZ2, "BZ2"); - GetPlc(Program.BZ3, "BZ3"); - GetPlc(Program.BZ4, "BZ4"); - GetPlc(Program.BZ5, "BZ5"); - GetPlc(Program.BZ6, "BZ6"); + Thread.Sleep(Program.ReadPlcRate); + } - Thread.Sleep(Program.ReadPlcRate); + }