diff --git a/CleanMachineHMI/Program.cs b/CleanMachineHMI/Program.cs index 339c3d2..a7c6cdf 100644 --- a/CleanMachineHMI/Program.cs +++ b/CleanMachineHMI/Program.cs @@ -27,7 +27,9 @@ namespace CleanMachineHMI Application.EnableVisualStyles(); //frmUtil.DB2Json();//语言字典从数据库转json GlobalHelper.LoadTheme(); +#if DEBUG GlobalHelper.LoadzhCN(); +#endif Application.SetCompatibleTextRenderingDefault(false); GlobalHelper.LoadAllFormData(); Application.Run(GlobalHelper.LoginForm); diff --git a/CleanMachineHMI/Utils/PlcOperationHelper.cs b/CleanMachineHMI/Utils/PlcOperationHelper.cs index 5f6abc5..39932cd 100644 --- a/CleanMachineHMI/Utils/PlcOperationHelper.cs +++ b/CleanMachineHMI/Utils/PlcOperationHelper.cs @@ -1,8 +1,14 @@ //使用本地调式 -#define USE_LOCAL_TCP_DEBUG -//启用心跳检查 -// #define UseHeartbeat +#if DEBUG + +#define USE_LOCAL_TCP_DEBUG +#endif +//启用心跳检查 + +#if RELEASE + #define UseHeartbeat +#endif using CleanMachine.Model; using LeadDataBaseUtility; @@ -84,7 +90,7 @@ namespace CleanMachineHMI public bool PlcInit() { -#if !DEBUG +#if RELEASE try { #endif @@ -122,8 +128,8 @@ namespace CleanMachineHMI #endif return true; -#if !DEBUG - } +#if RELEASE + } catch (Exception ex) { LogHelper.WriteLog($"初始化PLC连接时发生异常:【{ex.Message}】", LogTypeEum.Err); @@ -147,7 +153,7 @@ namespace CleanMachineHMI } public void RefreshPlcItem_M() { -#if !DEBUG +#if RELEASE try { #endif @@ -184,7 +190,7 @@ namespace CleanMachineHMI } } } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -194,7 +200,7 @@ namespace CleanMachineHMI } public void RefreshPlcItem_D() { -#if !DEBUG +#if RELEASE try { #endif @@ -249,7 +255,7 @@ namespace CleanMachineHMI } HandleWaringLog(tmpReadAlarmBytArr_D); } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -261,7 +267,7 @@ namespace CleanMachineHMI //报警信息记录 private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D) { -#if !DEBUG +#if RELEASE try { #endif @@ -587,7 +593,7 @@ namespace CleanMachineHMI //frmMainNew.Show_ptb_Alarm(false); GlobalHelper.ShowMainFrmAlarmMsg(false, EventArgs.Empty); } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -598,7 +604,7 @@ namespace CleanMachineHMI public void RefreshPlcItem_X() { -#if !DEBUG +#if RELEASE try { #endif @@ -626,7 +632,7 @@ namespace CleanMachineHMI } } } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -637,7 +643,7 @@ namespace CleanMachineHMI public void RefreshPlcItem_Y() { -#if !DEBUG +#if RELEASE try { #endif @@ -665,7 +671,7 @@ namespace CleanMachineHMI } } } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -677,7 +683,7 @@ namespace CleanMachineHMI public object ReadPlcItem(string plcItemCode, PlcItemTypeDesc itemType) { -#if !DEBUG +#if RELEASE try { #endif @@ -750,7 +756,7 @@ namespace CleanMachineHMI break; } return retObj; -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -763,7 +769,7 @@ namespace CleanMachineHMI public bool WritePlcItem(string plcItemCode, string writeValue, PlcItemTypeDesc itemType) { -#if !DEBUG +#if RELEASE try { #endif @@ -798,7 +804,7 @@ namespace CleanMachineHMI default: return false; } -#if !DEBUG +#if RELEASE } catch (Exception ex) { @@ -809,13 +815,13 @@ namespace CleanMachineHMI } private int wcsToPlcHeartDataNew = 0; private DateTime HeartbeatTime = new DateTime(); - + private int ReConnNum = 1; /// /// 心跳处理 /// public void HeartbeatDetection() { -#if !DEBUG +#if RELEASE try { #endif @@ -889,7 +895,7 @@ namespace CleanMachineHMI } #endif -#if !DEBUG +#if RELEASE } catch (Exception ex) {