修正主界面重复加载的错误

This commit is contained in:
gongxh
2022-05-17 16:26:35 +08:00
parent 47c68facc3
commit 099335e6b3
4 changed files with 21 additions and 18 deletions

View File

@@ -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;