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

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

@@ -9,19 +9,11 @@
<!--<add key="GlobalPaletteMode" value="Professionaloffice2003"/>-->
<add key="LanguageCode" value="zh-CN"/>
<!--<add key="LanguageCode" value="English"/>-->
<add key="sqlmapConfigPath" value="Config/sqlmap.config"/>
<!--MySql数据库连接字符串-->
<add key="LeadMySql" value="Data Source = localhost; Port=3306;Initial Catalog = testasrs; Persist Security Info=True;User ID = root; Password=sa1234567;"/>
<!--SqlServer数据库连接字符串-->
<add key="LeadSqlServer" value="Data Source =localhost;Initial Catalog =NX_CLEAR_MAC;User Id = sa;Password =syl.syl503601;"/>
<!--Oracle数据库连接字符串-->
<add key="LeadOracle" value="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=LEADASRS; Password=LEADASRS;"/>
<!--SQLite数据库连接字符串-->
<!--SQLite数据库连接字符串-->
<!--<add key="LeadSQLite" value="Data Source=|DataDirectory|\\clearMac.db;Pooling=true;FailIfMissing=false"/>-->
<add key="LeadSQLite" value="Data Source=DataBase/clearMac.db"/>
<!--串口名称-->
<add key="PortName" value="COM3"/>
<add key="PortName" value="COM2"/>
<!--串口波特率-->
<add key="BaudRate" value="9600"/>
<!--串口数据位-->

View File

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

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;

View File

@@ -890,7 +890,7 @@ namespace CleanMachineHMI
private void frmMainNew_Shown(object sender, EventArgs e)
{
InitControl();
// InitControl();
}
private void InitControl()
{