diff --git a/DyeingComputer.csproj b/DyeingComputer.csproj index 56ea0ad..6dd3a40 100644 --- a/DyeingComputer.csproj +++ b/DyeingComputer.csproj @@ -137,6 +137,7 @@ + diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index c39a6e8..2e911db 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -511,10 +511,10 @@ Jump - ProductCode + ProductCode - Grams + Grams Amount diff --git a/UserClass/ERRinf.cs b/UserClass/ERRinf.cs new file mode 100644 index 0000000..953d7dd --- /dev/null +++ b/UserClass/ERRinf.cs @@ -0,0 +1,42 @@ +using DyeingComputer.ViewModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using static DyeingComputer.UserClass.SqliteHelper; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock; + +namespace DyeingComputer.UserClass +{ + public class ERRinf + { + public static void ERRinf_i(DataTable dataTable) + { + dataTable.Columns.Add("ID", Type.GetType("System.String")); + dataTable.Columns.Add("INF", Type.GetType("System.String")); + dataTable.Columns.Add("Time", Type.GetType("System.String")); + } + public static void ERRinf_w(DataTable dataTable,string dat,string ID)//写入 + { + int i = dataTable.Select("INF='" + dat+ "'").Length; + if (i == 0) + { + dataTable.Rows.Add(ID,dat, DateTime.Now.ToString("yyMMddHHmmss")); + } + } + public static void ERRinf_d(DataTable dataTable, string dat)//删除 + { + int i = dataTable.Select("ID='" + dat + "'").Length; + if (i != 0) + { + dataTable.Rows.Remove(dataTable.Select("ID='" + dat + "'").First()); + } + } + public static string ERRinf_r(DataTable dataTable)//读取 + { + string index = dataTable.Rows[0].Field("INF"); + return index; + } + } +} diff --git a/View/TechnologicalProcessView.xaml.cs b/View/TechnologicalProcessView.xaml.cs index 098c417..22fa26d 100644 --- a/View/TechnologicalProcessView.xaml.cs +++ b/View/TechnologicalProcessView.xaml.cs @@ -321,7 +321,7 @@ namespace DyeingComputer.View private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控 { - if (string.IsNullOrEmpty(MainWindowViewModel.Name_err.ToString()))//无错误信息 + if (errTabler.Rows.Count == 0)//无错误信息 { if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始 { diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 9b872f4..9bc73d5 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -66,6 +66,7 @@ namespace DyeingComputer.ViewModel private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径 private IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini"); private PID pid = new PID(); + public static DataTable errTabler = new DataTable();//错误表 public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表 public static int RUN_STEPID;//当前步骤 public static int SYS_REDYE=0;//当前重燃步 @@ -75,6 +76,8 @@ namespace DyeingComputer.ViewModel public MainWindowViewModel() { SYSKEY = MD5check.MD5Encrypt16(HardwareSN.GetCPUSerialNumber()+HardwareSN.GetBIOSSerialNumber()); + ERRinf.ERRinf_i(errTabler); + Sys_workSTEPID = -1; WorkNumder = "----------"; SYS_SET(); //crbl @@ -353,23 +356,30 @@ namespace DyeingComputer.ViewModel IO_view(); TechnologicalProcess_view(); - if (!string.IsNullOrEmpty(Name_err.ToString())) - { - Status_Str = Name_err.ToString(); - if (Alert_red) { Alert_red = false; Alert_bell = false; }//关报警 + if (errTabler.Rows.Count!=0) + { + Status_Str = ERRinf.ERRinf_r(errTabler); + Alert_red = true; + Alert_bell = true; } else { - Alert_red = !Alert_red; - Alert_bell = !Alert_bell; + Alert_red = false; + Alert_bell = false; } } void Tick_Event_5S()//Tick_Event周期执行事件5S { if(WORK_RUN !=0) Chart();//写入记录 - if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160))) - { Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示 + if ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160)) + { + ERRinf.ERRinf_w(errTabler, Resources.Temperature + Resources.Sensor + Resources.Malfunction, "ERE101"); + } //温度故障提示 + else + { + ERRinf.ERRinf_d(errTabler, "ERR101"); + } } void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件200MS { @@ -381,16 +391,7 @@ namespace DyeingComputer.ViewModel if (LINK_OK) IO_data(); - if (!string.IsNullOrEmpty(Name_err.ToString()) && (!ERR_JOG)) //有故障信息,无故障保持 - { - ERR_JOG = true; - LogGing.LogGingDATA(Name_err.ToString());//输出故障信息 - } - if (string.IsNullOrEmpty(Name_err.ToString()) && (ERR_JOG)) //无故障信息,有故障保持 - { - ERR_JOG = false; - LogGing.LogGingDATA(Name_err.ToString() + "=>" + Resources.FailureRecovery);//解除故障信息 - } + } void Chart() @@ -663,7 +664,7 @@ namespace DyeingComputer.ViewModel TIME_H = STEP_TIME / 3600; TIME_M = (STEP_TIME - TIME_H * 3600) / 60; TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60; - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Heat_insulating + ":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); + if (errTabler.Rows.Count==0) Status_Str = Resources.Heat_insulating + ":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); if (STEP_TIME == 0) { STEP_finish = true; @@ -691,7 +692,7 @@ namespace DyeingComputer.ViewModel { TIME_M = Convert.ToInt16((STEP_P1 - T) / (STEP_P2 / 10)); } - if (string.IsNullOrEmpty(Name_err.ToString())) + if (errTabler.Rows.Count == 0) { Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C"; if ((TEMP_co - T) > 5) @@ -719,7 +720,7 @@ namespace DyeingComputer.ViewModel { TIME_M = Convert.ToInt16((T - STEP_P1) / (STEP_P2 / 10)); } - if (string.IsNullOrEmpty(Name_err.ToString())) + if (errTabler.Rows.Count == 0) { Status_Str = Resources.Cooling + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C"; if ((T - TEMP_co) > 5) @@ -770,7 +771,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; } else if (STEP_P1.ToString() == "2") { @@ -778,7 +779,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", true); Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; } else if (STEP_P1.ToString() == "3") { @@ -786,7 +787,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", true); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; } else if (STEP_P1.ToString() == "4") { @@ -794,7 +795,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", false); Updata_dtd("3015", true); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; } if (Selet_dtm("1015") >= STEP_P2) //到达水位 @@ -803,7 +804,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.Finish; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.Finish; STEP_finish = true; } break;//液位入水 @@ -815,7 +816,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; } else if (STEP_P1.ToString() == "2") { @@ -823,7 +824,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", true); Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; } else if (STEP_P1.ToString() == "3") { @@ -831,7 +832,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", true); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; } else if (STEP_P1.ToString() == "4") { @@ -839,7 +840,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", false); Updata_dtd("3015", true); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; } if (Selet_dtm("1016") >= STEP_P2) //到达水量 @@ -848,7 +849,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3013", false); Updata_dtd("3014", false); Updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.Finish; + if (errTabler.Rows.Count == 0) Status_Str = Resources.AddWater + ":" + Resources.Finish; STEP_finish = true; } break;//流量入水 @@ -867,7 +868,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3016", true); Updata_dtd("3017", false); Updata_dtd("3018", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; } else if (STEP_P1.ToString() == "2") @@ -875,14 +876,14 @@ namespace DyeingComputer.ViewModel Updata_dtd("3016", false); Updata_dtd("3017", true); Updata_dtd("3018", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "2"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "2"; } else if (STEP_P1.ToString() == "3") { Updata_dtd("3016", false); Updata_dtd("3017", false); Updata_dtd("3018", true); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; } if (Selet_dtm("1015") <= STEP_P2) //排水状态完成 @@ -892,13 +893,13 @@ namespace DyeingComputer.ViewModel Updata_dtd("3016", false); Updata_dtd("3017", false); Updata_dtd("3018", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Finish; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Finish; STEP_finish = true; } else { STEP_TIME--; //排水延时计时 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; } } break;//排水 @@ -908,7 +909,7 @@ namespace DyeingComputer.ViewModel Updata_dtd("3016", true); Updata_dtd("3017", false); Updata_dtd("3018", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; } else if (STEP_P1.ToString() == "2") @@ -916,14 +917,14 @@ namespace DyeingComputer.ViewModel Updata_dtd("3016", false); Updata_dtd("3017", true); Updata_dtd("3018", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "2"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "2"; } else if (STEP_P1.ToString() == "3") { Updata_dtd("3016", false); Updata_dtd("3017", false); Updata_dtd("3018", true); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; } Updata_dtd("3019", true);//开排水泵 @@ -935,13 +936,13 @@ namespace DyeingComputer.ViewModel Updata_dtd("3017", false); Updata_dtd("3018", false); Updata_dtd("3019", false);//开排水泵 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Finish; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Finish; STEP_finish = true; } else { STEP_TIME--; //排水延时计时 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; } } break;//动力排水 @@ -955,7 +956,7 @@ namespace DyeingComputer.ViewModel STEP_TIME--; TIME_M = STEP_TIME / 60; TIME_S = STEP_TIME - TIME_M * 60; - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.RunningTime + ":" + Resources.Time + string.Format(" {0:D3}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); + if (errTabler.Rows.Count == 0) Status_Str = Resources.RunningTime + ":" + Resources.Time + string.Format(" {0:D3}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); } break;//运转时间 case "035": @@ -977,7 +978,7 @@ namespace DyeingComputer.ViewModel Alert_bell = true; } } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.ClothIntake; + if (errTabler.Rows.Count == 0) Status_Str = Resources.ClothIntake; break;//准备入布 case "036": if (Selet_dtd("2003")) @@ -998,7 +999,7 @@ namespace DyeingComputer.ViewModel Alert_bell = true; } } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.OutTheCloth; + if (errTabler.Rows.Count == 0) Status_Str = Resources.OutTheCloth; break;//准备出布 case "039": if (Selet_dtd("2003")) @@ -1019,7 +1020,7 @@ namespace DyeingComputer.ViewModel Alert_bell = true; } } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.CallWorkers; + if (errTabler.Rows.Count == 0) Status_Str = Resources.CallWorkers; break;//呼叫人工 case "040": if (Selet_dtd("2003")) @@ -1040,11 +1041,11 @@ namespace DyeingComputer.ViewModel Alert_bell = true; } } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Sampling; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Sampling; break;//取样 case "041": STEP_finish = true; - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.End; + if (errTabler.Rows.Count == 0) Status_Str = Resources.End; break;//结束 case "049": if (Selet_dtd("2003")) @@ -1065,7 +1066,7 @@ namespace DyeingComputer.ViewModel Alert_bell = true; } } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Await; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Await; break;//等待 case "050": @@ -1089,20 +1090,20 @@ namespace DyeingComputer.ViewModel { STEP_finish = true; } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.PumpStart + "("+ STEP_TIME + "S)"; + if (errTabler.Rows.Count == 0) Status_Str = Resources.PumpStart + "("+ STEP_TIME + "S)"; } else { Updata_dtd("3011", false); Updata_dtd("3012", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.MasterCylinder + Resources.Low_waterlevel; + if (errTabler.Rows.Count == 0) Status_Str = Resources.MasterCylinder + Resources.Low_waterlevel; } break;//主泵启动 case "056": Updata_dtd("3011", false);//主泵 if (S16 == 1) Updata_dtd("3012", false);//风机 STEP_finish = true; - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.PumpStops; + if (errTabler.Rows.Count == 0) Status_Str = Resources.PumpStops; break;//主泵停止 case "064": if ((STEP_P1 == 1)||(STEP_P1==0)) @@ -1153,7 +1154,7 @@ namespace DyeingComputer.ViewModel else if(STEP_P2 == 1) Updata_dtd("3036", true); else if (STEP_P2 == 2) Updata_dtd("3037", true); } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank +" 1 :" + Resources.Ready; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank +" 1 :" + Resources.Ready; } //药缸1 else if (STEP_P1 == 2) { @@ -1203,7 +1204,7 @@ namespace DyeingComputer.ViewModel else if (STEP_P2 == 1) Updata_dtd("3046", true); else if (STEP_P2 == 2) Updata_dtd("3047", true); } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.Ready; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 2 :" + Resources.Ready; }//药缸2 else if (STEP_P1 == 3) { @@ -1253,7 +1254,7 @@ namespace DyeingComputer.ViewModel else if (STEP_P2 == 1) Updata_dtd("3056", true); else if (STEP_P2 == 2) Updata_dtd("3057", true); } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.Ready; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 3 :" + Resources.Ready; }//药缸3 break;//药缸备药 case "065": @@ -1262,21 +1263,21 @@ namespace DyeingComputer.ViewModel if ((TANK1_L - Selet_dtm("1017")) > TANK1_SL) { TANK1_Pc = TANK2_Pc - 3.3; }//计算比例 else { TANK1_Pc = TANK1_Pc + 3.3; } if (((TANK1_Pt - TANK1_Pc) > 5) || ((TANK1_Pt - TANK1_Pc) > -5)) TANK1_Pt = TANK1_Pc;//调整比例 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 1 :" + Resources.AddTheMedicine; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 1 :" + Resources.AddTheMedicine; } //药缸1 else if (STEP_P1 == 2) { if ((TANK2_L - Selet_dtm("1018")) > TANK2_SL) { TANK2_Pc = TANK2_Pc - 3.3; }//计算比例 else { TANK2_Pc = TANK2_Pc + 3.3; } if (((TANK2_Pt - TANK2_Pc) > 5) || ((TANK2_Pt - TANK2_Pc) > -5)) TANK2_Pt = TANK2_Pc;//调整比例 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.AddTheMedicine; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 2 :" + Resources.AddTheMedicine; }//药缸2 else if (STEP_P1 == 3) { if ((TANK3_L - Selet_dtm("1019")) > TANK3_SL) { TANK3_Pc = TANK3_Pc - 3.3; }//计算比例 else { TANK3_Pc = TANK3_Pc + 3.3; } if (((TANK3_Pt - TANK3_Pc) > 5) || ((TANK3_Pt - TANK3_Pc) > -5)) TANK3_Pt = TANK3_Pc;//调整比例 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.AddTheMedicine; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 3 :" + Resources.AddTheMedicine; }//药缸3 break;//药缸加药 case "066": @@ -1286,7 +1287,7 @@ namespace DyeingComputer.ViewModel if(string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString(); TANK1_STEP =Convert.ToInt16(STEP_P3); FeedingRecords(work_Numder,TANK1_DYELOT,Convert.ToInt16(STEP_P1),TANK1_STEP,Convert.ToInt16(STEP_P2));//调用呼叫 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 1 :" + Resources.CallDistribution; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 1 :" + Resources.CallDistribution; STEP_finish = true; } //药缸1 else if (STEP_P1 == 2) @@ -1295,7 +1296,7 @@ namespace DyeingComputer.ViewModel if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString(); TANK2_STEP = Convert.ToInt16(STEP_P3); FeedingRecords(work_Numder, TANK2_DYELOT, Convert.ToInt16(STEP_P1), TANK2_STEP, Convert.ToInt16(STEP_P2));//调用呼叫 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.CallDistribution; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 2 :" + Resources.CallDistribution; STEP_finish = true; }//药缸2 else if (STEP_P1 == 3) @@ -1304,7 +1305,7 @@ namespace DyeingComputer.ViewModel if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString(); TANK3_STEP = Convert.ToInt16(STEP_P3); FeedingRecords(work_Numder, TANK3_DYELOT, Convert.ToInt16(STEP_P1), TANK3_STEP, Convert.ToInt16(STEP_P2));//调用呼叫 - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.CallDistribution; + if (errTabler.Rows.Count == 0) Status_Str = Resources.Tank + " 3 :" + Resources.CallDistribution; STEP_finish = true; }//药缸3 //STEP_finish = true; @@ -1322,11 +1323,11 @@ namespace DyeingComputer.ViewModel PH_start= false; STEP_finish = true; } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = "PH" + Resources.PHControl + "(" + Selet_dtm("1009") + "pH)"; + if (errTabler.Rows.Count == 0) Status_Str = "PH" + Resources.PHControl + "(" + Selet_dtm("1009") + "pH)"; } else { - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = "PH" + Resources.PHControl + "(" + Resources.Await + Resources.Temperature +")"; + if (errTabler.Rows.Count == 0) Status_Str = "PH" + Resources.PHControl + "(" + Resources.Await + Resources.Temperature +")"; } break;//快速加酸 case "091": @@ -1367,7 +1368,7 @@ namespace DyeingComputer.ViewModel } } } - if (string.IsNullOrEmpty(Name_err.ToString())) + if (errTabler.Rows.Count == 0) { Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C"; if ((TEMP_co - T) > 5) @@ -1399,7 +1400,7 @@ namespace DyeingComputer.ViewModel { STEP_TIME--; } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = "PH" + Resources.PHDetection +"("+ STEP_TIME +")"; + if (errTabler.Rows.Count == 0) Status_Str = "PH" + Resources.PHDetection +"("+ STEP_TIME +")"; break;//PH检测 case "094": if (STEP_TIME <= 0)//控制时间到达结束 @@ -1412,7 +1413,7 @@ namespace DyeingComputer.ViewModel PH_start = true; STEP_TIME--; } - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = "PH" + Resources.PHControl + "(" + STEP_TIME + "S)"; + if (errTabler.Rows.Count == 0) Status_Str = "PH" + Resources.PHControl + "(" + STEP_TIME + "S)"; break;//PH控制(时间) default: break; @@ -1436,7 +1437,7 @@ namespace DyeingComputer.ViewModel if (ViewID == 1) { sys_workSTEPID = RUN_STEPID; } else { sys_workSTEPID = -1; } } - if (string.IsNullOrEmpty(Name_err.ToString())) + if (errTabler.Rows.Count == 0) { Status_Str = Resources.Await; } @@ -1464,7 +1465,7 @@ namespace DyeingComputer.ViewModel Updata_dtd((3000+i).ToString(), false); } }//清除输出状态 - if (string.IsNullOrEmpty(Name_err.ToString())) + if (errTabler.Rows.Count == 0) { //WorkNumder = "----------"; int TIMEH = DIDETime / 3600; @@ -1512,6 +1513,7 @@ namespace DyeingComputer.ViewModel string protocols_; // Create Modbus Master static IModbusMaster master = factory.CreateRtuMaster(port); + bool PORTOK = false; void UPort() { try @@ -1525,13 +1527,15 @@ namespace DyeingComputer.ViewModel port.ReadTimeout = 1000; port.WriteTimeout = 1000; port.Open();//打开串口 + PORTOK= true; Port_link(); } catch (Exception e) { LogGing.LogGingDATA("800_SerialPort_Not"); LogGing.LogGingDATA(e.Message); - Name_err = "800_SerialPort_Not"; + + ERRinf.ERRinf_w(errTabler, "800_SerialPort_Not", "ERR000"); } }//ck private bool LINK_OK = false; @@ -1550,7 +1554,7 @@ namespace DyeingComputer.ViewModel readonly byte slaveId = 1; private async void Port_link() { - if (Name_err.ToString() != "800_SerialPort_Not") + if (PORTOK) { await Task.Run(() => { @@ -1571,14 +1575,14 @@ namespace DyeingComputer.ViewModel master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器 }//SCMODBUSRTU LINK_OK = true; - Name_err = ""; + ERRinf.ERRinf_d(errTabler, "ERR001"); LINK_RUN++; } catch (Exception ex) { LINK_OK = false; LINK_ERR++; - Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")"; + ERRinf.ERRinf_w(errTabler, "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")", "ERR001"); } finally { @@ -1740,19 +1744,19 @@ namespace DyeingComputer.ViewModel { SYSData_M = ToObservableCollection(dt_m); } - catch (Exception ex) { Name_err = "IO_SYSData_M" + "(" + ex.Message + ")"; } + catch (Exception ) { } try { if ((bool)A_view) SYSData_A = ToObservableCollection(dt_a); } - catch (Exception ex) { Name_err = "IO_SYSData_A" + "(" + ex.Message + ")"; } + catch (Exception ) { } try { if ((bool)D_view) SYSData_D = ToObservableCollection(dt_d); } - catch (Exception ex) { Name_err = "IO_SYSData_D" + "(" + ex.Message + ")"; } + catch (Exception ) { } }); }