diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index e10a650..5691b15 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -339,6 +339,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 FailureRecovery 的本地化字符串。 + /// + public static string FailureRecovery { + get { + return ResourceManager.GetString("FailureRecovery", resourceCulture); + } + } + /// /// 查找类似 Finish 的本地化字符串。 /// diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index 3225f4c..9c7fd38 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -439,4 +439,7 @@ Sensor + + FailureRecovery + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 988388b..5eeba91 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -435,4 +435,7 @@ Sensor + + FailureRecovery + \ No newline at end of file diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 39a48c6..0ebd378 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -439,4 +439,7 @@ 故障 + + 异常恢复 + \ No newline at end of file diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index 57acecc..f8059d6 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -435,4 +435,7 @@ 傳感器 + + 異常恢復 + \ No newline at end of file diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 7d04931..7bb4341 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -70,6 +70,7 @@ namespace DyeingComputer.ViewModel private static double MT05;//主缸排水延时 private static double MT06;//主缸排水延时 private static double MT33;//主缸温度偏差 + private static double MT90;//呼叫操作员 void SYS_SET() { SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 @@ -87,7 +88,7 @@ namespace DyeingComputer.ViewModel MT05 = Convert.ToDouble(Selet_sys("MT05"));//主缸排水延时 MT06 = Convert.ToDouble(Selet_sys("MT06"));//动力排水延时 MT33 = Convert.ToDouble(Selet_sys("MT33"));//温度偏差参数 - + MT90 = Convert.ToDouble(Selet_sys("MT90"));//呼叫操作员 } @@ -167,7 +168,7 @@ namespace DyeingComputer.ViewModel Work_Numder = WorkNumder.ToString(); if (LINK_OK) Modbus_link(); - DIDETime++; + if(!SETP_runtime) DIDETime++; STEP_RUN(); IO_data(); @@ -181,9 +182,20 @@ namespace DyeingComputer.ViewModel if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 10) || (Selet_dtm("1010") > 160))) { Status_Str = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示 } + + bool ERR_JOG; void DisTimer_100MS(object sender, EventArgs e)//Tick_Event周期执行事件100MS { - + 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);//解除故障信息 + } } public static int WORK_RUN = 0; //运行状态0停止1暂停2运行 @@ -198,13 +210,15 @@ namespace DyeingComputer.ViewModel private static int STEP_TIME = 0; //步骤计时S private static int THL_mode = 0; //温控模式 0保温 1加热 2降 private static double TEMP_co = 0; //计算温度 - + private bool Alert_yellow = false; //警报黄灯 + private bool Alert_red = false; //警报红灯 + private bool Alert_bell = false; //警报铃声 public static void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5) //启动模块 { - switch (STEP_ID) + STEP_ID = ID; + switch (ID) { case "001": - STEP_ID = "001"; STEP_P1 = Convert.ToDouble(P1); STEP_P2 = Convert.ToDouble(P2); STEP_P3 = Convert.ToDouble(P3); @@ -218,7 +232,7 @@ namespace DyeingComputer.ViewModel WORK_RUN = 2; SETP_runtime = true; STEP_finish = false; - break; + break;//功能模块001温度控制开始 case "007": STEP_P1 = Convert.ToDouble(P1); STEP_P2 = Convert.ToDouble(P2); @@ -259,21 +273,83 @@ namespace DyeingComputer.ViewModel STEP_finish = false; break; case "031": - + STEP_TIME = Convert.ToInt16(P1)*60; + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; break; case "035": - + STEP_TIME = Convert.ToInt32(MT90); + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; break; case "036": - + STEP_TIME = Convert.ToInt32(MT90); + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; break; case "039": - + STEP_TIME = Convert.ToInt32(MT90); + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; break; case "040": - + STEP_TIME = Convert.ToInt32(MT90); + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; break; case "041": + WORK_RUN = 2; + SETP_runtime = false; + STEP_finish = false; + break; + case "049": + STEP_TIME = Convert.ToInt32(MT90); + WORK_RUN = 2; + SETP_runtime = true; + STEP_finish = false; + break; + case "050": + + break; + case "051": + + break; + case "054": + + break; + case "055": + + break; + case "056": + + break; + case "064": + + break; + case "065": + + break; + case "066": + + break; + case "067": + + break; + case "090": + + break; + case "091": + + break; + case "093": + + break; + case "094": break; default: @@ -298,15 +374,21 @@ namespace DyeingComputer.ViewModel double T = Selet_dtm("1010"); //实际温度 if (THL_mode == 0) //保温 { - if (STEP_TIME == 0) { STEP_finish = true; } - else { STEP_TIME--; } + if (STEP_TIME == 0) + { + STEP_finish = true; + } + else + { + STEP_TIME--; + } TO = pid.PID_iterate(STEP_P1, T, ts); if (TO < 0) TO = 0; TIME_H = STEP_TIME / 3600; TIME_M = (STEP_TIME - TIME_H * 3600) / 60; TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60; - 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 (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); } else if (THL_mode == 1)//升温 { @@ -322,7 +404,7 @@ namespace DyeingComputer.ViewModel { TIME_M = Convert.ToInt16((STEP_P1 - T) / (STEP_P2 / 10)); } - Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min; } else if (THL_mode == 2)//降温 { @@ -339,7 +421,7 @@ namespace DyeingComputer.ViewModel { TIME_M = Convert.ToInt16((T - STEP_P1) / (STEP_P2 / 10)); } - Status_Str = Resources.Cooling + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Cooling + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min; } updata_dtm("1004", TO); updata_dtm("1005", TEMP_co); @@ -351,7 +433,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; } else if (STEP_P1.ToString() == "2") { @@ -359,7 +441,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", true); updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; } else if (STEP_P1.ToString() == "3") { @@ -367,7 +449,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", false); updata_dtd("3014", true); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; } else if (STEP_P1.ToString() == "4") { @@ -375,17 +457,17 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", true); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; } if (Selet_dtm("1015") >= STEP_P2) //到达水位 { - STEP_finish = true; updata_dtd("3012", false); updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.Finish; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.Finish; + STEP_finish = true; } break;//液位入水 case "008": @@ -396,7 +478,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources. AddWater + ":" + Resources.AddWater + "1"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources. AddWater + ":" + Resources.AddWater + "1"; } else if (STEP_P1.ToString() == "2") { @@ -404,7 +486,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", true); updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; } else if (STEP_P1.ToString() == "3") { @@ -412,7 +494,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", false); updata_dtd("3014", true); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; } else if (STEP_P1.ToString() == "4") { @@ -420,17 +502,17 @@ namespace DyeingComputer.ViewModel updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", true); - Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "4"; } if (Selet_dtm("1016") >= STEP_P2) //到达水量 { - STEP_finish = true; updata_dtd("3012", false); updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", false); - Status_Str = Resources.AddWater + ":" + Resources.Finish; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.Finish; + STEP_finish = true; } break;//流量入水 case "013": @@ -448,7 +530,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3016", true); updata_dtd("3017", false); updata_dtd("3018", false); - Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "1"; } else if (STEP_P1.ToString() == "2") @@ -456,54 +538,238 @@ namespace DyeingComputer.ViewModel updata_dtd("3016", false); updata_dtd("3017", true); updata_dtd("3018", false); - Status_Str = Resources.Drainage + ":" + Resources.Drainage + "2"; + if (string.IsNullOrEmpty(Name_err.ToString())) 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); - Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Drainage + "3"; } if (Selet_dtm("1015") <= STEP_P2) //排水状态完成 { if (STEP_TIME == 0)//排水延时 { - STEP_finish = true; updata_dtd("3016", false); updata_dtd("3017", false); updata_dtd("3018", false); - Status_Str = Resources.Drainage + ":" + Resources.Finish; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Finish; + STEP_finish = true; } else { STEP_TIME--; //排水延时计时 - Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; } } break;//排水 case "022": + if (STEP_P1.ToString() == "1") + { + 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"; - break; - case "031": + } + else if (STEP_P1.ToString() == "2") + { + 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"; + } + 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"; + } - break; + updata_dtd("3019", true);//开排水泵 + if (Selet_dtm("1015") <= STEP_P2) //排水状态完成 + { + if (STEP_TIME == 0)//排水延时 + { + updata_dtd("3016", false); + updata_dtd("3017", false); + updata_dtd("3018", false); + updata_dtd("3019", false);//开排水泵 + if (string.IsNullOrEmpty(Name_err.ToString())) 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; + } + } + break;//动力排水 + case "031": + if (STEP_TIME == 0) + { + STEP_finish = true; + } + else + { + 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); + } + break;//运转时间 case "035": - - break; + if (Selet_dtd("2003")) + { + STEP_finish = true; + Alert_yellow = false; + } + else + { + Alert_yellow = true; + STEP_TIME--; + if (STEP_TIME == 0) + { + Alert_bell = false; + } + else + { + Alert_bell = true; + } + } + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.ClothIntake; + break;//准备入布 case "036": - - break; + if (Selet_dtd("2003")) + { + STEP_finish = true; + Alert_yellow = false; + } + else + { + Alert_yellow = true; + STEP_TIME--; + if (STEP_TIME == 0) + { + Alert_bell = false; + } + else + { + Alert_bell = true; + } + } + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.OutTheCloth; + break;//准备出布 case "039": - - break; + if (Selet_dtd("2003")) + { + STEP_finish = true; + Alert_yellow = false; + } + else + { + Alert_yellow = true; + STEP_TIME--; + if (STEP_TIME == 0) + { + Alert_bell = false; + } + else + { + Alert_bell = true; + } + } + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.CallWorkers; + break;//呼叫人工 case "040": - - break; + if (Selet_dtd("2003")) + { + STEP_finish = true; + Alert_yellow = false; + } + else + { + Alert_yellow = true; + STEP_TIME--; + if (STEP_TIME == 0) + { + Alert_bell = false; + } + else + { + Alert_bell = true; + } + } + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Sampling; + break;//取样 case "041": + + STEP_finish = true; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.End; + break;//结束 + case "049": + if (Selet_dtd("2003")) + { + STEP_finish = true; + Alert_yellow = false; + } + else + { + Alert_yellow = true; + STEP_TIME--; + if (STEP_TIME == 0) + { + Alert_bell = false; + } + else + { + Alert_bell = true; + } + } + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Await; + break;//等待 + case "050": - break; + break;//主缸加压 + case "051": + + break;//主缸减压 + case "054": + + break;//主泵/风机速度 + case "055": + + break;//主泵启动 + case "056": + + break;//主泵停止 + case "064": + + break;//药缸备药 + case "065": + + break;//药缸加药 + case "066": + + break;//呼叫输送 + case "067": + + break;//呼叫输送 + case "090": + + break;//快速加酸 + case "091": + + break;//PH温度控制 + case "093": + + break;//PH检测 + case "094": + + break;//PH控制 default: break; } @@ -585,6 +851,7 @@ namespace DyeingComputer.ViewModel DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈 RW = master.ReadHoldingRegisters(slaveId,06000, RW_L); //读取寄存器 LINK_OK =true; + Name_err = ""; } catch (Exception ex) { diff --git a/Windows/ViewStep.xaml.cs b/Windows/ViewStep.xaml.cs index a371179..d387626 100644 --- a/Windows/ViewStep.xaml.cs +++ b/Windows/ViewStep.xaml.cs @@ -428,7 +428,7 @@ namespace DyeingComputer.Windows case 23: P1N.Text = Properties.Resources.Medicine + Properties.Resources.Tank; P2N.Text = Properties.Resources.Type; - P3N.Text = Properties.Resources.Flowmeter; + P3N.Text = Properties.Resources.Function; P1.Visibility = Visibility.Visible; P1N.Visibility = Visibility.Visible; P2.Visibility = Visibility.Visible;