diff --git a/CleanMachineHMI/App.config b/CleanMachineHMI/App.config index df37e0a..d63f34e 100644 --- a/CleanMachineHMI/App.config +++ b/CleanMachineHMI/App.config @@ -9,19 +9,11 @@ - - - - - - - - - + - + diff --git a/CleanMachineHMI/FrmUserControl/frmMainDetailNew.cs b/CleanMachineHMI/FrmUserControl/frmMainDetailNew.cs index dcba3e9..b99e75e 100644 --- a/CleanMachineHMI/FrmUserControl/frmMainDetailNew.cs +++ b/CleanMachineHMI/FrmUserControl/frmMainDetailNew.cs @@ -108,8 +108,16 @@ namespace CleanMachineHMI.FrmUserControl frmMainNew.SwitchFrmMenu(EnumFormType.Base, false); } + private bool isInit = false; + + private void frmMainDetail_Load(object sender, EventArgs e) { + + if (isInit) return; + isInit = true; + + this.SetFormControlText(); try { @@ -325,6 +333,7 @@ namespace CleanMachineHMI.FrmUserControl { Console.WriteLine("数据变化"); + cbt_RunStatusTran.BackColor = _device.CleanMacRunStatusNew ? Color.Lime : Color.Gray; cbt_Brush1StatusTran.BackColor = _device.Hairbrush1Selection ? Color.Lime : Color.Gray; diff --git a/CleanMachineHMI/Utils/PlcOperationHelper.cs b/CleanMachineHMI/Utils/PlcOperationHelper.cs index bb68d48..435200d 100644 --- a/CleanMachineHMI/Utils/PlcOperationHelper.cs +++ b/CleanMachineHMI/Utils/PlcOperationHelper.cs @@ -2,7 +2,7 @@ #if DEBUG -#define USE_LOCAL_TCP_DEBUG +//#define USE_LOCAL_TCP_DEBUG #endif //启用心跳检查 @@ -156,9 +156,9 @@ namespace CleanMachineHMI } - public bool readIO { get;set; }= false; + public bool readIO { get; set; } = false; + - // public System.Threading.AutoResetEvent thEvent = new System.Threading.AutoResetEvent(false); @@ -183,19 +183,19 @@ namespace CleanMachineHMI TimeSpan ts = stopWatch.Elapsed; Console.WriteLine($"读取PLC时间:{ts.Milliseconds}", LogTypeEum.Run); - + if (haschange) { if (_synchronization != null) { - _synchronization.Post(this.DoOnReadFinish, null); + _synchronization.Send(this.DoOnReadFinish, null); } } HeartbeatDetection(); // thEvent.Set(); // ShowWarningMsg(); - int sleeptime = 100 - ts.Milliseconds; + int sleeptime = 500 - ts.Milliseconds; if (sleeptime < 0) { sleeptime = 0; @@ -365,6 +365,7 @@ namespace CleanMachineHMI if (item.PlcItemValue != value) { haschange = true; + Console.WriteLine(item.PlcItemCode + "数据变化"); } item.PlcItemValue = value; Global.ShowSensorStatus(item, new EventArgs()); @@ -447,9 +448,10 @@ namespace CleanMachineHMI { if (item.PlcItemValue != value) { - if (item.PlcItemCode != "PlcHeartbeatWriteData") + if (item.PlcItemCode != "PlcHeartbeatWriteData" && item.PlcItemCode != "PlcHeartbeatReadData") { haschange = true; + Console.WriteLine(item.PlcItemCode + "数据变化"); } item.PlcItemValue = value; diff --git a/CleanMachineHMI/frmMainNew.cs b/CleanMachineHMI/frmMainNew.cs index 7355fc4..8885e4f 100644 --- a/CleanMachineHMI/frmMainNew.cs +++ b/CleanMachineHMI/frmMainNew.cs @@ -890,7 +890,7 @@ namespace CleanMachineHMI private void frmMainNew_Shown(object sender, EventArgs e) { - InitControl(); + // InitControl(); } private void InitControl() {